babylon.module.d.ts 5.2 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/arrayTools" {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module "babylonjs/Maths/math.scalar" {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module "babylonjs/Maths/math" {
  256. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  257. /**
  258. * Constant used to convert a value to gamma space
  259. * @ignorenaming
  260. */
  261. export const ToGammaSpace: number;
  262. /**
  263. * Constant used to convert a value to linear space
  264. * @ignorenaming
  265. */
  266. export const ToLinearSpace = 2.2;
  267. /**
  268. * Constant used to define the minimal number value in Babylon.js
  269. * @ignorenaming
  270. */
  271. let Epsilon: number;
  272. export { Epsilon };
  273. /**
  274. * Class used to hold a RBG color
  275. */
  276. export class Color3 {
  277. /**
  278. * Defines the red component (between 0 and 1, default is 0)
  279. */
  280. r: number;
  281. /**
  282. * Defines the green component (between 0 and 1, default is 0)
  283. */
  284. g: number;
  285. /**
  286. * Defines the blue component (between 0 and 1, default is 0)
  287. */
  288. b: number;
  289. /**
  290. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  291. * @param r defines the red component (between 0 and 1, default is 0)
  292. * @param g defines the green component (between 0 and 1, default is 0)
  293. * @param b defines the blue component (between 0 and 1, default is 0)
  294. */
  295. constructor(
  296. /**
  297. * Defines the red component (between 0 and 1, default is 0)
  298. */
  299. r?: number,
  300. /**
  301. * Defines the green component (between 0 and 1, default is 0)
  302. */
  303. g?: number,
  304. /**
  305. * Defines the blue component (between 0 and 1, default is 0)
  306. */
  307. b?: number);
  308. /**
  309. * Creates a string with the Color3 current values
  310. * @returns the string representation of the Color3 object
  311. */
  312. toString(): string;
  313. /**
  314. * Returns the string "Color3"
  315. * @returns "Color3"
  316. */
  317. getClassName(): string;
  318. /**
  319. * Compute the Color3 hash code
  320. * @returns an unique number that can be used to hash Color3 objects
  321. */
  322. getHashCode(): number;
  323. /**
  324. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  325. * @param array defines the array where to store the r,g,b components
  326. * @param index defines an optional index in the target array to define where to start storing values
  327. * @returns the current Color3 object
  328. */
  329. toArray(array: FloatArray, index?: number): Color3;
  330. /**
  331. * Returns a new Color4 object from the current Color3 and the given alpha
  332. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  333. * @returns a new Color4 object
  334. */
  335. toColor4(alpha?: number): Color4;
  336. /**
  337. * Returns a new array populated with 3 numeric elements : red, green and blue values
  338. * @returns the new array
  339. */
  340. asArray(): number[];
  341. /**
  342. * Returns the luminance value
  343. * @returns a float value
  344. */
  345. toLuminance(): number;
  346. /**
  347. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  348. * @param otherColor defines the second operand
  349. * @returns the new Color3 object
  350. */
  351. multiply(otherColor: DeepImmutable<Color3>): Color3;
  352. /**
  353. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  354. * @param otherColor defines the second operand
  355. * @param result defines the Color3 object where to store the result
  356. * @returns the current Color3
  357. */
  358. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  359. /**
  360. * Determines equality between Color3 objects
  361. * @param otherColor defines the second operand
  362. * @returns true if the rgb values are equal to the given ones
  363. */
  364. equals(otherColor: DeepImmutable<Color3>): boolean;
  365. /**
  366. * Determines equality between the current Color3 object and a set of r,b,g values
  367. * @param r defines the red component to check
  368. * @param g defines the green component to check
  369. * @param b defines the blue component to check
  370. * @returns true if the rgb values are equal to the given ones
  371. */
  372. equalsFloats(r: number, g: number, b: number): boolean;
  373. /**
  374. * Multiplies in place each rgb value by scale
  375. * @param scale defines the scaling factor
  376. * @returns the updated Color3
  377. */
  378. scale(scale: number): Color3;
  379. /**
  380. * Multiplies the rgb values by scale and stores the result into "result"
  381. * @param scale defines the scaling factor
  382. * @param result defines the Color3 object where to store the result
  383. * @returns the unmodified current Color3
  384. */
  385. scaleToRef(scale: number, result: Color3): Color3;
  386. /**
  387. * Scale the current Color3 values by a factor and add the result to a given Color3
  388. * @param scale defines the scale factor
  389. * @param result defines color to store the result into
  390. * @returns the unmodified current Color3
  391. */
  392. scaleAndAddToRef(scale: number, result: Color3): Color3;
  393. /**
  394. * Clamps the rgb values by the min and max values and stores the result into "result"
  395. * @param min defines minimum clamping value (default is 0)
  396. * @param max defines maximum clamping value (default is 1)
  397. * @param result defines color to store the result into
  398. * @returns the original Color3
  399. */
  400. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  401. /**
  402. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  403. * @param otherColor defines the second operand
  404. * @returns the new Color3
  405. */
  406. add(otherColor: DeepImmutable<Color3>): Color3;
  407. /**
  408. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  409. * @param otherColor defines the second operand
  410. * @param result defines Color3 object to store the result into
  411. * @returns the unmodified current Color3
  412. */
  413. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  414. /**
  415. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  416. * @param otherColor defines the second operand
  417. * @returns the new Color3
  418. */
  419. subtract(otherColor: DeepImmutable<Color3>): Color3;
  420. /**
  421. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  422. * @param otherColor defines the second operand
  423. * @param result defines Color3 object to store the result into
  424. * @returns the unmodified current Color3
  425. */
  426. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  427. /**
  428. * Copy the current object
  429. * @returns a new Color3 copied the current one
  430. */
  431. clone(): Color3;
  432. /**
  433. * Copies the rgb values from the source in the current Color3
  434. * @param source defines the source Color3 object
  435. * @returns the updated Color3 object
  436. */
  437. copyFrom(source: DeepImmutable<Color3>): Color3;
  438. /**
  439. * Updates the Color3 rgb values from the given floats
  440. * @param r defines the red component to read from
  441. * @param g defines the green component to read from
  442. * @param b defines the blue component to read from
  443. * @returns the current Color3 object
  444. */
  445. copyFromFloats(r: number, g: number, b: number): Color3;
  446. /**
  447. * Updates the Color3 rgb values from the given floats
  448. * @param r defines the red component to read from
  449. * @param g defines the green component to read from
  450. * @param b defines the blue component to read from
  451. * @returns the current Color3 object
  452. */
  453. set(r: number, g: number, b: number): Color3;
  454. /**
  455. * Compute the Color3 hexadecimal code as a string
  456. * @returns a string containing the hexadecimal representation of the Color3 object
  457. */
  458. toHexString(): string;
  459. /**
  460. * Computes a new Color3 converted from the current one to linear space
  461. * @returns a new Color3 object
  462. */
  463. toLinearSpace(): Color3;
  464. /**
  465. * Converts current color in rgb space to HSV values
  466. * @returns a new color3 representing the HSV values
  467. */
  468. toHSV(): Color3;
  469. /**
  470. * Converts current color in rgb space to HSV values
  471. * @param result defines the Color3 where to store the HSV values
  472. */
  473. toHSVToRef(result: Color3): void;
  474. /**
  475. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  476. * @param convertedColor defines the Color3 object where to store the linear space version
  477. * @returns the unmodified Color3
  478. */
  479. toLinearSpaceToRef(convertedColor: Color3): Color3;
  480. /**
  481. * Computes a new Color3 converted from the current one to gamma space
  482. * @returns a new Color3 object
  483. */
  484. toGammaSpace(): Color3;
  485. /**
  486. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  487. * @param convertedColor defines the Color3 object where to store the gamma space version
  488. * @returns the unmodified Color3
  489. */
  490. toGammaSpaceToRef(convertedColor: Color3): Color3;
  491. private static _BlackReadOnly;
  492. /**
  493. * Convert Hue, saturation and value to a Color3 (RGB)
  494. * @param hue defines the hue
  495. * @param saturation defines the saturation
  496. * @param value defines the value
  497. * @param result defines the Color3 where to store the RGB values
  498. */
  499. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  500. /**
  501. * Creates a new Color3 from the string containing valid hexadecimal values
  502. * @param hex defines a string containing valid hexadecimal values
  503. * @returns a new Color3 object
  504. */
  505. static FromHexString(hex: string): Color3;
  506. /**
  507. * Creates a new Color3 from the starting index of the given array
  508. * @param array defines the source array
  509. * @param offset defines an offset in the source array
  510. * @returns a new Color3 object
  511. */
  512. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  513. /**
  514. * Creates a new Color3 from integer values (< 256)
  515. * @param r defines the red component to read from (value between 0 and 255)
  516. * @param g defines the green component to read from (value between 0 and 255)
  517. * @param b defines the blue component to read from (value between 0 and 255)
  518. * @returns a new Color3 object
  519. */
  520. static FromInts(r: number, g: number, b: number): Color3;
  521. /**
  522. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  523. * @param start defines the start Color3 value
  524. * @param end defines the end Color3 value
  525. * @param amount defines the gradient value between start and end
  526. * @returns a new Color3 object
  527. */
  528. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  529. /**
  530. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  531. * @param left defines the start value
  532. * @param right defines the end value
  533. * @param amount defines the gradient factor
  534. * @param result defines the Color3 object where to store the result
  535. */
  536. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  537. /**
  538. * Returns a Color3 value containing a red color
  539. * @returns a new Color3 object
  540. */
  541. static Red(): Color3;
  542. /**
  543. * Returns a Color3 value containing a green color
  544. * @returns a new Color3 object
  545. */
  546. static Green(): Color3;
  547. /**
  548. * Returns a Color3 value containing a blue color
  549. * @returns a new Color3 object
  550. */
  551. static Blue(): Color3;
  552. /**
  553. * Returns a Color3 value containing a black color
  554. * @returns a new Color3 object
  555. */
  556. static Black(): Color3;
  557. /**
  558. * Gets a Color3 value containing a black color that must not be updated
  559. */
  560. static readonly BlackReadOnly: DeepImmutable<Color3>;
  561. /**
  562. * Returns a Color3 value containing a white color
  563. * @returns a new Color3 object
  564. */
  565. static White(): Color3;
  566. /**
  567. * Returns a Color3 value containing a purple color
  568. * @returns a new Color3 object
  569. */
  570. static Purple(): Color3;
  571. /**
  572. * Returns a Color3 value containing a magenta color
  573. * @returns a new Color3 object
  574. */
  575. static Magenta(): Color3;
  576. /**
  577. * Returns a Color3 value containing a yellow color
  578. * @returns a new Color3 object
  579. */
  580. static Yellow(): Color3;
  581. /**
  582. * Returns a Color3 value containing a gray color
  583. * @returns a new Color3 object
  584. */
  585. static Gray(): Color3;
  586. /**
  587. * Returns a Color3 value containing a teal color
  588. * @returns a new Color3 object
  589. */
  590. static Teal(): Color3;
  591. /**
  592. * Returns a Color3 value containing a random color
  593. * @returns a new Color3 object
  594. */
  595. static Random(): Color3;
  596. }
  597. /**
  598. * Class used to hold a RBGA color
  599. */
  600. export class Color4 {
  601. /**
  602. * Defines the red component (between 0 and 1, default is 0)
  603. */
  604. r: number;
  605. /**
  606. * Defines the green component (between 0 and 1, default is 0)
  607. */
  608. g: number;
  609. /**
  610. * Defines the blue component (between 0 and 1, default is 0)
  611. */
  612. b: number;
  613. /**
  614. * Defines the alpha component (between 0 and 1, default is 1)
  615. */
  616. a: number;
  617. /**
  618. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  619. * @param r defines the red component (between 0 and 1, default is 0)
  620. * @param g defines the green component (between 0 and 1, default is 0)
  621. * @param b defines the blue component (between 0 and 1, default is 0)
  622. * @param a defines the alpha component (between 0 and 1, default is 1)
  623. */
  624. constructor(
  625. /**
  626. * Defines the red component (between 0 and 1, default is 0)
  627. */
  628. r?: number,
  629. /**
  630. * Defines the green component (between 0 and 1, default is 0)
  631. */
  632. g?: number,
  633. /**
  634. * Defines the blue component (between 0 and 1, default is 0)
  635. */
  636. b?: number,
  637. /**
  638. * Defines the alpha component (between 0 and 1, default is 1)
  639. */
  640. a?: number);
  641. /**
  642. * Adds in place the given Color4 values to the current Color4 object
  643. * @param right defines the second operand
  644. * @returns the current updated Color4 object
  645. */
  646. addInPlace(right: DeepImmutable<Color4>): Color4;
  647. /**
  648. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  649. * @returns the new array
  650. */
  651. asArray(): number[];
  652. /**
  653. * Stores from the starting index in the given array the Color4 successive values
  654. * @param array defines the array where to store the r,g,b components
  655. * @param index defines an optional index in the target array to define where to start storing values
  656. * @returns the current Color4 object
  657. */
  658. toArray(array: number[], index?: number): Color4;
  659. /**
  660. * Determines equality between Color4 objects
  661. * @param otherColor defines the second operand
  662. * @returns true if the rgba values are equal to the given ones
  663. */
  664. equals(otherColor: DeepImmutable<Color4>): boolean;
  665. /**
  666. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  667. * @param right defines the second operand
  668. * @returns a new Color4 object
  669. */
  670. add(right: DeepImmutable<Color4>): Color4;
  671. /**
  672. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  673. * @param right defines the second operand
  674. * @returns a new Color4 object
  675. */
  676. subtract(right: DeepImmutable<Color4>): Color4;
  677. /**
  678. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  679. * @param right defines the second operand
  680. * @param result defines the Color4 object where to store the result
  681. * @returns the current Color4 object
  682. */
  683. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  684. /**
  685. * Creates a new Color4 with the current Color4 values multiplied by scale
  686. * @param scale defines the scaling factor to apply
  687. * @returns a new Color4 object
  688. */
  689. scale(scale: number): Color4;
  690. /**
  691. * Multiplies the current Color4 values by scale and stores the result in "result"
  692. * @param scale defines the scaling factor to apply
  693. * @param result defines the Color4 object where to store the result
  694. * @returns the current unmodified Color4
  695. */
  696. scaleToRef(scale: number, result: Color4): Color4;
  697. /**
  698. * Scale the current Color4 values by a factor and add the result to a given Color4
  699. * @param scale defines the scale factor
  700. * @param result defines the Color4 object where to store the result
  701. * @returns the unmodified current Color4
  702. */
  703. scaleAndAddToRef(scale: number, result: Color4): Color4;
  704. /**
  705. * Clamps the rgb values by the min and max values and stores the result into "result"
  706. * @param min defines minimum clamping value (default is 0)
  707. * @param max defines maximum clamping value (default is 1)
  708. * @param result defines color to store the result into.
  709. * @returns the cuurent Color4
  710. */
  711. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  712. /**
  713. * Multipy an Color4 value by another and return a new Color4 object
  714. * @param color defines the Color4 value to multiply by
  715. * @returns a new Color4 object
  716. */
  717. multiply(color: Color4): Color4;
  718. /**
  719. * Multipy a Color4 value by another and push the result in a reference value
  720. * @param color defines the Color4 value to multiply by
  721. * @param result defines the Color4 to fill the result in
  722. * @returns the result Color4
  723. */
  724. multiplyToRef(color: Color4, result: Color4): Color4;
  725. /**
  726. * Creates a string with the Color4 current values
  727. * @returns the string representation of the Color4 object
  728. */
  729. toString(): string;
  730. /**
  731. * Returns the string "Color4"
  732. * @returns "Color4"
  733. */
  734. getClassName(): string;
  735. /**
  736. * Compute the Color4 hash code
  737. * @returns an unique number that can be used to hash Color4 objects
  738. */
  739. getHashCode(): number;
  740. /**
  741. * Creates a new Color4 copied from the current one
  742. * @returns a new Color4 object
  743. */
  744. clone(): Color4;
  745. /**
  746. * Copies the given Color4 values into the current one
  747. * @param source defines the source Color4 object
  748. * @returns the current updated Color4 object
  749. */
  750. copyFrom(source: Color4): Color4;
  751. /**
  752. * Copies the given float values into the current one
  753. * @param r defines the red component to read from
  754. * @param g defines the green component to read from
  755. * @param b defines the blue component to read from
  756. * @param a defines the alpha component to read from
  757. * @returns the current updated Color4 object
  758. */
  759. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  760. /**
  761. * Copies the given float values into the current one
  762. * @param r defines the red component to read from
  763. * @param g defines the green component to read from
  764. * @param b defines the blue component to read from
  765. * @param a defines the alpha component to read from
  766. * @returns the current updated Color4 object
  767. */
  768. set(r: number, g: number, b: number, a: number): Color4;
  769. /**
  770. * Compute the Color4 hexadecimal code as a string
  771. * @returns a string containing the hexadecimal representation of the Color4 object
  772. */
  773. toHexString(): string;
  774. /**
  775. * Computes a new Color4 converted from the current one to linear space
  776. * @returns a new Color4 object
  777. */
  778. toLinearSpace(): Color4;
  779. /**
  780. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  781. * @param convertedColor defines the Color4 object where to store the linear space version
  782. * @returns the unmodified Color4
  783. */
  784. toLinearSpaceToRef(convertedColor: Color4): Color4;
  785. /**
  786. * Computes a new Color4 converted from the current one to gamma space
  787. * @returns a new Color4 object
  788. */
  789. toGammaSpace(): Color4;
  790. /**
  791. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  792. * @param convertedColor defines the Color4 object where to store the gamma space version
  793. * @returns the unmodified Color4
  794. */
  795. toGammaSpaceToRef(convertedColor: Color4): Color4;
  796. /**
  797. * Creates a new Color4 from the string containing valid hexadecimal values
  798. * @param hex defines a string containing valid hexadecimal values
  799. * @returns a new Color4 object
  800. */
  801. static FromHexString(hex: string): Color4;
  802. /**
  803. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  804. * @param left defines the start value
  805. * @param right defines the end value
  806. * @param amount defines the gradient factor
  807. * @returns a new Color4 object
  808. */
  809. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  810. /**
  811. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  812. * @param left defines the start value
  813. * @param right defines the end value
  814. * @param amount defines the gradient factor
  815. * @param result defines the Color4 object where to store data
  816. */
  817. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  818. /**
  819. * Creates a new Color4 from a Color3 and an alpha value
  820. * @param color3 defines the source Color3 to read from
  821. * @param alpha defines the alpha component (1.0 by default)
  822. * @returns a new Color4 object
  823. */
  824. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  825. /**
  826. * Creates a new Color4 from the starting index element of the given array
  827. * @param array defines the source array to read from
  828. * @param offset defines the offset in the source array
  829. * @returns a new Color4 object
  830. */
  831. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  832. /**
  833. * Creates a new Color3 from integer values (< 256)
  834. * @param r defines the red component to read from (value between 0 and 255)
  835. * @param g defines the green component to read from (value between 0 and 255)
  836. * @param b defines the blue component to read from (value between 0 and 255)
  837. * @param a defines the alpha component to read from (value between 0 and 255)
  838. * @returns a new Color3 object
  839. */
  840. static FromInts(r: number, g: number, b: number, a: number): Color4;
  841. /**
  842. * Check the content of a given array and convert it to an array containing RGBA data
  843. * If the original array was already containing count * 4 values then it is returned directly
  844. * @param colors defines the array to check
  845. * @param count defines the number of RGBA data to expect
  846. * @returns an array containing count * 4 values (RGBA)
  847. */
  848. static CheckColors4(colors: number[], count: number): number[];
  849. }
  850. /**
  851. * Class representing a vector containing 2 coordinates
  852. */
  853. export class Vector2 {
  854. /** defines the first coordinate */
  855. x: number;
  856. /** defines the second coordinate */
  857. y: number;
  858. /**
  859. * Creates a new Vector2 from the given x and y coordinates
  860. * @param x defines the first coordinate
  861. * @param y defines the second coordinate
  862. */
  863. constructor(
  864. /** defines the first coordinate */
  865. x?: number,
  866. /** defines the second coordinate */
  867. y?: number);
  868. /**
  869. * Gets a string with the Vector2 coordinates
  870. * @returns a string with the Vector2 coordinates
  871. */
  872. toString(): string;
  873. /**
  874. * Gets class name
  875. * @returns the string "Vector2"
  876. */
  877. getClassName(): string;
  878. /**
  879. * Gets current vector hash code
  880. * @returns the Vector2 hash code as a number
  881. */
  882. getHashCode(): number;
  883. /**
  884. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  885. * @param array defines the source array
  886. * @param index defines the offset in source array
  887. * @returns the current Vector2
  888. */
  889. toArray(array: FloatArray, index?: number): Vector2;
  890. /**
  891. * Copy the current vector to an array
  892. * @returns a new array with 2 elements: the Vector2 coordinates.
  893. */
  894. asArray(): number[];
  895. /**
  896. * Sets the Vector2 coordinates with the given Vector2 coordinates
  897. * @param source defines the source Vector2
  898. * @returns the current updated Vector2
  899. */
  900. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  901. /**
  902. * Sets the Vector2 coordinates with the given floats
  903. * @param x defines the first coordinate
  904. * @param y defines the second coordinate
  905. * @returns the current updated Vector2
  906. */
  907. copyFromFloats(x: number, y: number): Vector2;
  908. /**
  909. * Sets the Vector2 coordinates with the given floats
  910. * @param x defines the first coordinate
  911. * @param y defines the second coordinate
  912. * @returns the current updated Vector2
  913. */
  914. set(x: number, y: number): Vector2;
  915. /**
  916. * Add another vector with the current one
  917. * @param otherVector defines the other vector
  918. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  919. */
  920. add(otherVector: DeepImmutable<Vector2>): Vector2;
  921. /**
  922. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  923. * @param otherVector defines the other vector
  924. * @param result defines the target vector
  925. * @returns the unmodified current Vector2
  926. */
  927. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  928. /**
  929. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  930. * @param otherVector defines the other vector
  931. * @returns the current updated Vector2
  932. */
  933. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  934. /**
  935. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  936. * @param otherVector defines the other vector
  937. * @returns a new Vector2
  938. */
  939. addVector3(otherVector: Vector3): Vector2;
  940. /**
  941. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  942. * @param otherVector defines the other vector
  943. * @returns a new Vector2
  944. */
  945. subtract(otherVector: Vector2): Vector2;
  946. /**
  947. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  948. * @param otherVector defines the other vector
  949. * @param result defines the target vector
  950. * @returns the unmodified current Vector2
  951. */
  952. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  953. /**
  954. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  955. * @param otherVector defines the other vector
  956. * @returns the current updated Vector2
  957. */
  958. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  959. /**
  960. * Multiplies in place the current Vector2 coordinates by the given ones
  961. * @param otherVector defines the other vector
  962. * @returns the current updated Vector2
  963. */
  964. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  965. /**
  966. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  967. * @param otherVector defines the other vector
  968. * @returns a new Vector2
  969. */
  970. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  971. /**
  972. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  973. * @param otherVector defines the other vector
  974. * @param result defines the target vector
  975. * @returns the unmodified current Vector2
  976. */
  977. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  978. /**
  979. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  980. * @param x defines the first coordinate
  981. * @param y defines the second coordinate
  982. * @returns a new Vector2
  983. */
  984. multiplyByFloats(x: number, y: number): Vector2;
  985. /**
  986. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  987. * @param otherVector defines the other vector
  988. * @returns a new Vector2
  989. */
  990. divide(otherVector: Vector2): Vector2;
  991. /**
  992. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  993. * @param otherVector defines the other vector
  994. * @param result defines the target vector
  995. * @returns the unmodified current Vector2
  996. */
  997. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  998. /**
  999. * Divides the current Vector2 coordinates by the given ones
  1000. * @param otherVector defines the other vector
  1001. * @returns the current updated Vector2
  1002. */
  1003. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1004. /**
  1005. * Gets a new Vector2 with current Vector2 negated coordinates
  1006. * @returns a new Vector2
  1007. */
  1008. negate(): Vector2;
  1009. /**
  1010. * Multiply the Vector2 coordinates by scale
  1011. * @param scale defines the scaling factor
  1012. * @returns the current updated Vector2
  1013. */
  1014. scaleInPlace(scale: number): Vector2;
  1015. /**
  1016. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1017. * @param scale defines the scaling factor
  1018. * @returns a new Vector2
  1019. */
  1020. scale(scale: number): Vector2;
  1021. /**
  1022. * Scale the current Vector2 values by a factor to a given Vector2
  1023. * @param scale defines the scale factor
  1024. * @param result defines the Vector2 object where to store the result
  1025. * @returns the unmodified current Vector2
  1026. */
  1027. scaleToRef(scale: number, result: Vector2): Vector2;
  1028. /**
  1029. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1030. * @param scale defines the scale factor
  1031. * @param result defines the Vector2 object where to store the result
  1032. * @returns the unmodified current Vector2
  1033. */
  1034. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1035. /**
  1036. * Gets a boolean if two vectors are equals
  1037. * @param otherVector defines the other vector
  1038. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1039. */
  1040. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1041. /**
  1042. * Gets a boolean if two vectors are equals (using an epsilon value)
  1043. * @param otherVector defines the other vector
  1044. * @param epsilon defines the minimal distance to consider equality
  1045. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1046. */
  1047. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1048. /**
  1049. * Gets a new Vector2 from current Vector2 floored values
  1050. * @returns a new Vector2
  1051. */
  1052. floor(): Vector2;
  1053. /**
  1054. * Gets a new Vector2 from current Vector2 floored values
  1055. * @returns a new Vector2
  1056. */
  1057. fract(): Vector2;
  1058. /**
  1059. * Gets the length of the vector
  1060. * @returns the vector length (float)
  1061. */
  1062. length(): number;
  1063. /**
  1064. * Gets the vector squared length
  1065. * @returns the vector squared length (float)
  1066. */
  1067. lengthSquared(): number;
  1068. /**
  1069. * Normalize the vector
  1070. * @returns the current updated Vector2
  1071. */
  1072. normalize(): Vector2;
  1073. /**
  1074. * Gets a new Vector2 copied from the Vector2
  1075. * @returns a new Vector2
  1076. */
  1077. clone(): Vector2;
  1078. /**
  1079. * Gets a new Vector2(0, 0)
  1080. * @returns a new Vector2
  1081. */
  1082. static Zero(): Vector2;
  1083. /**
  1084. * Gets a new Vector2(1, 1)
  1085. * @returns a new Vector2
  1086. */
  1087. static One(): Vector2;
  1088. /**
  1089. * Gets a new Vector2 set from the given index element of the given array
  1090. * @param array defines the data source
  1091. * @param offset defines the offset in the data source
  1092. * @returns a new Vector2
  1093. */
  1094. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1095. /**
  1096. * Sets "result" from the given index element of the given array
  1097. * @param array defines the data source
  1098. * @param offset defines the offset in the data source
  1099. * @param result defines the target vector
  1100. */
  1101. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1102. /**
  1103. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1104. * @param value1 defines 1st point of control
  1105. * @param value2 defines 2nd point of control
  1106. * @param value3 defines 3rd point of control
  1107. * @param value4 defines 4th point of control
  1108. * @param amount defines the interpolation factor
  1109. * @returns a new Vector2
  1110. */
  1111. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1112. /**
  1113. * 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".
  1114. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1115. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1116. * @param value defines the value to clamp
  1117. * @param min defines the lower limit
  1118. * @param max defines the upper limit
  1119. * @returns a new Vector2
  1120. */
  1121. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1122. /**
  1123. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1124. * @param value1 defines the 1st control point
  1125. * @param tangent1 defines the outgoing tangent
  1126. * @param value2 defines the 2nd control point
  1127. * @param tangent2 defines the incoming tangent
  1128. * @param amount defines the interpolation factor
  1129. * @returns a new Vector2
  1130. */
  1131. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1132. /**
  1133. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1134. * @param start defines the start vector
  1135. * @param end defines the end vector
  1136. * @param amount defines the interpolation factor
  1137. * @returns a new Vector2
  1138. */
  1139. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1140. /**
  1141. * Gets the dot product of the vector "left" and the vector "right"
  1142. * @param left defines first vector
  1143. * @param right defines second vector
  1144. * @returns the dot product (float)
  1145. */
  1146. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1147. /**
  1148. * Returns a new Vector2 equal to the normalized given vector
  1149. * @param vector defines the vector to normalize
  1150. * @returns a new Vector2
  1151. */
  1152. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1153. /**
  1154. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1155. * @param left defines 1st vector
  1156. * @param right defines 2nd vector
  1157. * @returns a new Vector2
  1158. */
  1159. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1160. /**
  1161. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1162. * @param left defines 1st vector
  1163. * @param right defines 2nd vector
  1164. * @returns a new Vector2
  1165. */
  1166. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1167. /**
  1168. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1169. * @param vector defines the vector to transform
  1170. * @param transformation defines the matrix to apply
  1171. * @returns a new Vector2
  1172. */
  1173. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1174. /**
  1175. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1176. * @param vector defines the vector to transform
  1177. * @param transformation defines the matrix to apply
  1178. * @param result defines the target vector
  1179. */
  1180. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1181. /**
  1182. * Determines if a given vector is included in a triangle
  1183. * @param p defines the vector to test
  1184. * @param p0 defines 1st triangle point
  1185. * @param p1 defines 2nd triangle point
  1186. * @param p2 defines 3rd triangle point
  1187. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1188. */
  1189. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1190. /**
  1191. * Gets the distance between the vectors "value1" and "value2"
  1192. * @param value1 defines first vector
  1193. * @param value2 defines second vector
  1194. * @returns the distance between vectors
  1195. */
  1196. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1197. /**
  1198. * Returns the squared distance between the vectors "value1" and "value2"
  1199. * @param value1 defines first vector
  1200. * @param value2 defines second vector
  1201. * @returns the squared distance between vectors
  1202. */
  1203. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1204. /**
  1205. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1206. * @param value1 defines first vector
  1207. * @param value2 defines second vector
  1208. * @returns a new Vector2
  1209. */
  1210. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1211. /**
  1212. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1213. * @param p defines the middle point
  1214. * @param segA defines one point of the segment
  1215. * @param segB defines the other point of the segment
  1216. * @returns the shortest distance
  1217. */
  1218. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1219. }
  1220. /**
  1221. * Classed used to store (x,y,z) vector representation
  1222. * A Vector3 is the main object used in 3D geometry
  1223. * It can represent etiher the coordinates of a point the space, either a direction
  1224. * Reminder: js uses a left handed forward facing system
  1225. */
  1226. export class Vector3 {
  1227. /**
  1228. * Defines the first coordinates (on X axis)
  1229. */
  1230. x: number;
  1231. /**
  1232. * Defines the second coordinates (on Y axis)
  1233. */
  1234. y: number;
  1235. /**
  1236. * Defines the third coordinates (on Z axis)
  1237. */
  1238. z: number;
  1239. private static _UpReadOnly;
  1240. private static _ZeroReadOnly;
  1241. /**
  1242. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1243. * @param x defines the first coordinates (on X axis)
  1244. * @param y defines the second coordinates (on Y axis)
  1245. * @param z defines the third coordinates (on Z axis)
  1246. */
  1247. constructor(
  1248. /**
  1249. * Defines the first coordinates (on X axis)
  1250. */
  1251. x?: number,
  1252. /**
  1253. * Defines the second coordinates (on Y axis)
  1254. */
  1255. y?: number,
  1256. /**
  1257. * Defines the third coordinates (on Z axis)
  1258. */
  1259. z?: number);
  1260. /**
  1261. * Creates a string representation of the Vector3
  1262. * @returns a string with the Vector3 coordinates.
  1263. */
  1264. toString(): string;
  1265. /**
  1266. * Gets the class name
  1267. * @returns the string "Vector3"
  1268. */
  1269. getClassName(): string;
  1270. /**
  1271. * Creates the Vector3 hash code
  1272. * @returns a number which tends to be unique between Vector3 instances
  1273. */
  1274. getHashCode(): number;
  1275. /**
  1276. * Creates an array containing three elements : the coordinates of the Vector3
  1277. * @returns a new array of numbers
  1278. */
  1279. asArray(): number[];
  1280. /**
  1281. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1282. * @param array defines the destination array
  1283. * @param index defines the offset in the destination array
  1284. * @returns the current Vector3
  1285. */
  1286. toArray(array: FloatArray, index?: number): Vector3;
  1287. /**
  1288. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1289. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1290. */
  1291. toQuaternion(): Quaternion;
  1292. /**
  1293. * Adds the given vector to the current Vector3
  1294. * @param otherVector defines the second operand
  1295. * @returns the current updated Vector3
  1296. */
  1297. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1298. /**
  1299. * Adds the given coordinates to the current Vector3
  1300. * @param x defines the x coordinate of the operand
  1301. * @param y defines the y coordinate of the operand
  1302. * @param z defines the z coordinate of the operand
  1303. * @returns the current updated Vector3
  1304. */
  1305. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1306. /**
  1307. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1308. * @param otherVector defines the second operand
  1309. * @returns the resulting Vector3
  1310. */
  1311. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1312. /**
  1313. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1314. * @param otherVector defines the second operand
  1315. * @param result defines the Vector3 object where to store the result
  1316. * @returns the current Vector3
  1317. */
  1318. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1319. /**
  1320. * Subtract the given vector from the current Vector3
  1321. * @param otherVector defines the second operand
  1322. * @returns the current updated Vector3
  1323. */
  1324. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1325. /**
  1326. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1327. * @param otherVector defines the second operand
  1328. * @returns the resulting Vector3
  1329. */
  1330. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1331. /**
  1332. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1333. * @param otherVector defines the second operand
  1334. * @param result defines the Vector3 object where to store the result
  1335. * @returns the current Vector3
  1336. */
  1337. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1338. /**
  1339. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1340. * @param x defines the x coordinate of the operand
  1341. * @param y defines the y coordinate of the operand
  1342. * @param z defines the z coordinate of the operand
  1343. * @returns the resulting Vector3
  1344. */
  1345. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1346. /**
  1347. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1348. * @param x defines the x coordinate of the operand
  1349. * @param y defines the y coordinate of the operand
  1350. * @param z defines the z coordinate of the operand
  1351. * @param result defines the Vector3 object where to store the result
  1352. * @returns the current Vector3
  1353. */
  1354. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1355. /**
  1356. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1357. * @returns a new Vector3
  1358. */
  1359. negate(): Vector3;
  1360. /**
  1361. * Multiplies the Vector3 coordinates by the float "scale"
  1362. * @param scale defines the multiplier factor
  1363. * @returns the current updated Vector3
  1364. */
  1365. scaleInPlace(scale: number): Vector3;
  1366. /**
  1367. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1368. * @param scale defines the multiplier factor
  1369. * @returns a new Vector3
  1370. */
  1371. scale(scale: number): Vector3;
  1372. /**
  1373. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1374. * @param scale defines the multiplier factor
  1375. * @param result defines the Vector3 object where to store the result
  1376. * @returns the current Vector3
  1377. */
  1378. scaleToRef(scale: number, result: Vector3): Vector3;
  1379. /**
  1380. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1381. * @param scale defines the scale factor
  1382. * @param result defines the Vector3 object where to store the result
  1383. * @returns the unmodified current Vector3
  1384. */
  1385. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1386. /**
  1387. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1388. * @param otherVector defines the second operand
  1389. * @returns true if both vectors are equals
  1390. */
  1391. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1392. /**
  1393. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1394. * @param otherVector defines the second operand
  1395. * @param epsilon defines the minimal distance to define values as equals
  1396. * @returns true if both vectors are distant less than epsilon
  1397. */
  1398. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1399. /**
  1400. * Returns true if the current Vector3 coordinates equals the given floats
  1401. * @param x defines the x coordinate of the operand
  1402. * @param y defines the y coordinate of the operand
  1403. * @param z defines the z coordinate of the operand
  1404. * @returns true if both vectors are equals
  1405. */
  1406. equalsToFloats(x: number, y: number, z: number): boolean;
  1407. /**
  1408. * Multiplies the current Vector3 coordinates by the given ones
  1409. * @param otherVector defines the second operand
  1410. * @returns the current updated Vector3
  1411. */
  1412. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1413. /**
  1414. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1415. * @param otherVector defines the second operand
  1416. * @returns the new Vector3
  1417. */
  1418. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1419. /**
  1420. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1421. * @param otherVector defines the second operand
  1422. * @param result defines the Vector3 object where to store the result
  1423. * @returns the current Vector3
  1424. */
  1425. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1426. /**
  1427. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1428. * @param x defines the x coordinate of the operand
  1429. * @param y defines the y coordinate of the operand
  1430. * @param z defines the z coordinate of the operand
  1431. * @returns the new Vector3
  1432. */
  1433. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1434. /**
  1435. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1436. * @param otherVector defines the second operand
  1437. * @returns the new Vector3
  1438. */
  1439. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1440. /**
  1441. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1442. * @param otherVector defines the second operand
  1443. * @param result defines the Vector3 object where to store the result
  1444. * @returns the current Vector3
  1445. */
  1446. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1447. /**
  1448. * Divides the current Vector3 coordinates by the given ones.
  1449. * @param otherVector defines the second operand
  1450. * @returns the current updated Vector3
  1451. */
  1452. divideInPlace(otherVector: Vector3): Vector3;
  1453. /**
  1454. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1455. * @param other defines the second operand
  1456. * @returns the current updated Vector3
  1457. */
  1458. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1459. /**
  1460. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1461. * @param other defines the second operand
  1462. * @returns the current updated Vector3
  1463. */
  1464. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1465. /**
  1466. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1467. * @param x defines the x coordinate of the operand
  1468. * @param y defines the y coordinate of the operand
  1469. * @param z defines the z coordinate of the operand
  1470. * @returns the current updated Vector3
  1471. */
  1472. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1473. /**
  1474. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1475. * @param x defines the x coordinate of the operand
  1476. * @param y defines the y coordinate of the operand
  1477. * @param z defines the z coordinate of the operand
  1478. * @returns the current updated Vector3
  1479. */
  1480. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1481. /**
  1482. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1483. * Check if is non uniform within a certain amount of decimal places to account for this
  1484. * @param epsilon the amount the values can differ
  1485. * @returns if the the vector is non uniform to a certain number of decimal places
  1486. */
  1487. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1488. /**
  1489. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1490. */
  1491. readonly isNonUniform: boolean;
  1492. /**
  1493. * Gets a new Vector3 from current Vector3 floored values
  1494. * @returns a new Vector3
  1495. */
  1496. floor(): Vector3;
  1497. /**
  1498. * Gets a new Vector3 from current Vector3 floored values
  1499. * @returns a new Vector3
  1500. */
  1501. fract(): Vector3;
  1502. /**
  1503. * Gets the length of the Vector3
  1504. * @returns the length of the Vecto3
  1505. */
  1506. length(): number;
  1507. /**
  1508. * Gets the squared length of the Vector3
  1509. * @returns squared length of the Vector3
  1510. */
  1511. lengthSquared(): number;
  1512. /**
  1513. * Normalize the current Vector3.
  1514. * Please note that this is an in place operation.
  1515. * @returns the current updated Vector3
  1516. */
  1517. normalize(): Vector3;
  1518. /**
  1519. * Reorders the x y z properties of the vector in place
  1520. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1521. * @returns the current updated vector
  1522. */
  1523. reorderInPlace(order: string): this;
  1524. /**
  1525. * Rotates the vector around 0,0,0 by a quaternion
  1526. * @param quaternion the rotation quaternion
  1527. * @param result vector to store the result
  1528. * @returns the resulting vector
  1529. */
  1530. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1531. /**
  1532. * Rotates a vector around a given point
  1533. * @param quaternion the rotation quaternion
  1534. * @param point the point to rotate around
  1535. * @param result vector to store the result
  1536. * @returns the resulting vector
  1537. */
  1538. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1539. /**
  1540. * Normalize the current Vector3 with the given input length.
  1541. * Please note that this is an in place operation.
  1542. * @param len the length of the vector
  1543. * @returns the current updated Vector3
  1544. */
  1545. normalizeFromLength(len: number): Vector3;
  1546. /**
  1547. * Normalize the current Vector3 to a new vector
  1548. * @returns the new Vector3
  1549. */
  1550. normalizeToNew(): Vector3;
  1551. /**
  1552. * Normalize the current Vector3 to the reference
  1553. * @param reference define the Vector3 to update
  1554. * @returns the updated Vector3
  1555. */
  1556. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1557. /**
  1558. * Creates a new Vector3 copied from the current Vector3
  1559. * @returns the new Vector3
  1560. */
  1561. clone(): Vector3;
  1562. /**
  1563. * Copies the given vector coordinates to the current Vector3 ones
  1564. * @param source defines the source Vector3
  1565. * @returns the current updated Vector3
  1566. */
  1567. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1568. /**
  1569. * Copies the given floats to the current Vector3 coordinates
  1570. * @param x defines the x coordinate of the operand
  1571. * @param y defines the y coordinate of the operand
  1572. * @param z defines the z coordinate of the operand
  1573. * @returns the current updated Vector3
  1574. */
  1575. copyFromFloats(x: number, y: number, z: number): Vector3;
  1576. /**
  1577. * Copies the given floats to the current Vector3 coordinates
  1578. * @param x defines the x coordinate of the operand
  1579. * @param y defines the y coordinate of the operand
  1580. * @param z defines the z coordinate of the operand
  1581. * @returns the current updated Vector3
  1582. */
  1583. set(x: number, y: number, z: number): Vector3;
  1584. /**
  1585. * Copies the given float to the current Vector3 coordinates
  1586. * @param v defines the x, y and z coordinates of the operand
  1587. * @returns the current updated Vector3
  1588. */
  1589. setAll(v: number): Vector3;
  1590. /**
  1591. * Get the clip factor between two vectors
  1592. * @param vector0 defines the first operand
  1593. * @param vector1 defines the second operand
  1594. * @param axis defines the axis to use
  1595. * @param size defines the size along the axis
  1596. * @returns the clip factor
  1597. */
  1598. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1599. /**
  1600. * Get angle between two vectors
  1601. * @param vector0 angle between vector0 and vector1
  1602. * @param vector1 angle between vector0 and vector1
  1603. * @param normal direction of the normal
  1604. * @return the angle between vector0 and vector1
  1605. */
  1606. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1607. /**
  1608. * Returns a new Vector3 set from the index "offset" of the given array
  1609. * @param array defines the source array
  1610. * @param offset defines the offset in the source array
  1611. * @returns the new Vector3
  1612. */
  1613. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1614. /**
  1615. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1616. * This function is deprecated. Use FromArray instead
  1617. * @param array defines the source array
  1618. * @param offset defines the offset in the source array
  1619. * @returns the new Vector3
  1620. */
  1621. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1622. /**
  1623. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1624. * @param array defines the source array
  1625. * @param offset defines the offset in the source array
  1626. * @param result defines the Vector3 where to store the result
  1627. */
  1628. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1629. /**
  1630. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1631. * This function is deprecated. Use FromArrayToRef instead.
  1632. * @param array defines the source array
  1633. * @param offset defines the offset in the source array
  1634. * @param result defines the Vector3 where to store the result
  1635. */
  1636. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1637. /**
  1638. * Sets the given vector "result" with the given floats.
  1639. * @param x defines the x coordinate of the source
  1640. * @param y defines the y coordinate of the source
  1641. * @param z defines the z coordinate of the source
  1642. * @param result defines the Vector3 where to store the result
  1643. */
  1644. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1645. /**
  1646. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1647. * @returns a new empty Vector3
  1648. */
  1649. static Zero(): Vector3;
  1650. /**
  1651. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1652. * @returns a new unit Vector3
  1653. */
  1654. static One(): Vector3;
  1655. /**
  1656. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1657. * @returns a new up Vector3
  1658. */
  1659. static Up(): Vector3;
  1660. /**
  1661. * Gets a up Vector3 that must not be updated
  1662. */
  1663. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1664. /**
  1665. * Gets a zero Vector3 that must not be updated
  1666. */
  1667. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1668. /**
  1669. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1670. * @returns a new down Vector3
  1671. */
  1672. static Down(): Vector3;
  1673. /**
  1674. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1675. * @returns a new forward Vector3
  1676. */
  1677. static Forward(): Vector3;
  1678. /**
  1679. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1680. * @returns a new forward Vector3
  1681. */
  1682. static Backward(): Vector3;
  1683. /**
  1684. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1685. * @returns a new right Vector3
  1686. */
  1687. static Right(): Vector3;
  1688. /**
  1689. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1690. * @returns a new left Vector3
  1691. */
  1692. static Left(): Vector3;
  1693. /**
  1694. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1695. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1696. * @param vector defines the Vector3 to transform
  1697. * @param transformation defines the transformation matrix
  1698. * @returns the transformed Vector3
  1699. */
  1700. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1701. /**
  1702. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1703. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1704. * @param vector defines the Vector3 to transform
  1705. * @param transformation defines the transformation matrix
  1706. * @param result defines the Vector3 where to store the result
  1707. */
  1708. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1709. /**
  1710. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1711. * This method computes tranformed coordinates only, not transformed direction vectors
  1712. * @param x define the x coordinate of the source vector
  1713. * @param y define the y coordinate of the source vector
  1714. * @param z define the z coordinate of the source vector
  1715. * @param transformation defines the transformation matrix
  1716. * @param result defines the Vector3 where to store the result
  1717. */
  1718. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1719. /**
  1720. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1721. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1722. * @param vector defines the Vector3 to transform
  1723. * @param transformation defines the transformation matrix
  1724. * @returns the new Vector3
  1725. */
  1726. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1727. /**
  1728. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1729. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1730. * @param vector defines the Vector3 to transform
  1731. * @param transformation defines the transformation matrix
  1732. * @param result defines the Vector3 where to store the result
  1733. */
  1734. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1735. /**
  1736. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1737. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1738. * @param x define the x coordinate of the source vector
  1739. * @param y define the y coordinate of the source vector
  1740. * @param z define the z coordinate of the source vector
  1741. * @param transformation defines the transformation matrix
  1742. * @param result defines the Vector3 where to store the result
  1743. */
  1744. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1745. /**
  1746. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1747. * @param value1 defines the first control point
  1748. * @param value2 defines the second control point
  1749. * @param value3 defines the third control point
  1750. * @param value4 defines the fourth control point
  1751. * @param amount defines the amount on the spline to use
  1752. * @returns the new Vector3
  1753. */
  1754. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1755. /**
  1756. * 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"
  1757. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1758. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1759. * @param value defines the current value
  1760. * @param min defines the lower range value
  1761. * @param max defines the upper range value
  1762. * @returns the new Vector3
  1763. */
  1764. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1765. /**
  1766. * 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"
  1767. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1768. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1769. * @param value defines the current value
  1770. * @param min defines the lower range value
  1771. * @param max defines the upper range value
  1772. * @param result defines the Vector3 where to store the result
  1773. */
  1774. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1775. /**
  1776. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1777. * @param value1 defines the first control point
  1778. * @param tangent1 defines the first tangent vector
  1779. * @param value2 defines the second control point
  1780. * @param tangent2 defines the second tangent vector
  1781. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1782. * @returns the new Vector3
  1783. */
  1784. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1785. /**
  1786. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1787. * @param start defines the start value
  1788. * @param end defines the end value
  1789. * @param amount max defines amount between both (between 0 and 1)
  1790. * @returns the new Vector3
  1791. */
  1792. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1793. /**
  1794. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1795. * @param start defines the start value
  1796. * @param end defines the end value
  1797. * @param amount max defines amount between both (between 0 and 1)
  1798. * @param result defines the Vector3 where to store the result
  1799. */
  1800. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1801. /**
  1802. * Returns the dot product (float) between the vectors "left" and "right"
  1803. * @param left defines the left operand
  1804. * @param right defines the right operand
  1805. * @returns the dot product
  1806. */
  1807. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1808. /**
  1809. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1810. * The cross product is then orthogonal to both "left" and "right"
  1811. * @param left defines the left operand
  1812. * @param right defines the right operand
  1813. * @returns the cross product
  1814. */
  1815. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1816. /**
  1817. * Sets the given vector "result" with the cross product of "left" and "right"
  1818. * The cross product is then orthogonal to both "left" and "right"
  1819. * @param left defines the left operand
  1820. * @param right defines the right operand
  1821. * @param result defines the Vector3 where to store the result
  1822. */
  1823. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1824. /**
  1825. * Returns a new Vector3 as the normalization of the given vector
  1826. * @param vector defines the Vector3 to normalize
  1827. * @returns the new Vector3
  1828. */
  1829. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1830. /**
  1831. * Sets the given vector "result" with the normalization of the given first vector
  1832. * @param vector defines the Vector3 to normalize
  1833. * @param result defines the Vector3 where to store the result
  1834. */
  1835. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1836. /**
  1837. * Project a Vector3 onto screen space
  1838. * @param vector defines the Vector3 to project
  1839. * @param world defines the world matrix to use
  1840. * @param transform defines the transform (view x projection) matrix to use
  1841. * @param viewport defines the screen viewport to use
  1842. * @returns the new Vector3
  1843. */
  1844. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1845. /** @hidden */
  1846. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1847. /**
  1848. * Unproject from screen space to object space
  1849. * @param source defines the screen space Vector3 to use
  1850. * @param viewportWidth defines the current width of the viewport
  1851. * @param viewportHeight defines the current height of the viewport
  1852. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1853. * @param transform defines the transform (view x projection) matrix to use
  1854. * @returns the new Vector3
  1855. */
  1856. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1857. /**
  1858. * Unproject from screen space to object space
  1859. * @param source defines the screen space Vector3 to use
  1860. * @param viewportWidth defines the current width of the viewport
  1861. * @param viewportHeight defines the current height of the viewport
  1862. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1863. * @param view defines the view matrix to use
  1864. * @param projection defines the projection matrix to use
  1865. * @returns the new Vector3
  1866. */
  1867. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1868. /**
  1869. * Unproject from screen space to object space
  1870. * @param source defines the screen space Vector3 to use
  1871. * @param viewportWidth defines the current width of the viewport
  1872. * @param viewportHeight defines the current height of the viewport
  1873. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1874. * @param view defines the view matrix to use
  1875. * @param projection defines the projection matrix to use
  1876. * @param result defines the Vector3 where to store the result
  1877. */
  1878. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1879. /**
  1880. * Unproject from screen space to object space
  1881. * @param sourceX defines the screen space x coordinate to use
  1882. * @param sourceY defines the screen space y coordinate to use
  1883. * @param sourceZ defines the screen space z coordinate to use
  1884. * @param viewportWidth defines the current width of the viewport
  1885. * @param viewportHeight defines the current height of the viewport
  1886. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1887. * @param view defines the view matrix to use
  1888. * @param projection defines the projection matrix to use
  1889. * @param result defines the Vector3 where to store the result
  1890. */
  1891. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1892. /**
  1893. * Gets the minimal coordinate values between two Vector3
  1894. * @param left defines the first operand
  1895. * @param right defines the second operand
  1896. * @returns the new Vector3
  1897. */
  1898. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1899. /**
  1900. * Gets the maximal coordinate values between two Vector3
  1901. * @param left defines the first operand
  1902. * @param right defines the second operand
  1903. * @returns the new Vector3
  1904. */
  1905. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1906. /**
  1907. * Returns the distance between the vectors "value1" and "value2"
  1908. * @param value1 defines the first operand
  1909. * @param value2 defines the second operand
  1910. * @returns the distance
  1911. */
  1912. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1913. /**
  1914. * Returns the squared distance between the vectors "value1" and "value2"
  1915. * @param value1 defines the first operand
  1916. * @param value2 defines the second operand
  1917. * @returns the squared distance
  1918. */
  1919. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1920. /**
  1921. * Returns a new Vector3 located at the center between "value1" and "value2"
  1922. * @param value1 defines the first operand
  1923. * @param value2 defines the second operand
  1924. * @returns the new Vector3
  1925. */
  1926. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1927. /**
  1928. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1929. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1930. * to something in order to rotate it from its local system to the given target system
  1931. * Note: axis1, axis2 and axis3 are normalized during this operation
  1932. * @param axis1 defines the first axis
  1933. * @param axis2 defines the second axis
  1934. * @param axis3 defines the third axis
  1935. * @returns a new Vector3
  1936. */
  1937. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1938. /**
  1939. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1940. * @param axis1 defines the first axis
  1941. * @param axis2 defines the second axis
  1942. * @param axis3 defines the third axis
  1943. * @param ref defines the Vector3 where to store the result
  1944. */
  1945. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1946. }
  1947. /**
  1948. * Vector4 class created for EulerAngle class conversion to Quaternion
  1949. */
  1950. export class Vector4 {
  1951. /** x value of the vector */
  1952. x: number;
  1953. /** y value of the vector */
  1954. y: number;
  1955. /** z value of the vector */
  1956. z: number;
  1957. /** w value of the vector */
  1958. w: number;
  1959. /**
  1960. * Creates a Vector4 object from the given floats.
  1961. * @param x x value of the vector
  1962. * @param y y value of the vector
  1963. * @param z z value of the vector
  1964. * @param w w value of the vector
  1965. */
  1966. constructor(
  1967. /** x value of the vector */
  1968. x: number,
  1969. /** y value of the vector */
  1970. y: number,
  1971. /** z value of the vector */
  1972. z: number,
  1973. /** w value of the vector */
  1974. w: number);
  1975. /**
  1976. * Returns the string with the Vector4 coordinates.
  1977. * @returns a string containing all the vector values
  1978. */
  1979. toString(): string;
  1980. /**
  1981. * Returns the string "Vector4".
  1982. * @returns "Vector4"
  1983. */
  1984. getClassName(): string;
  1985. /**
  1986. * Returns the Vector4 hash code.
  1987. * @returns a unique hash code
  1988. */
  1989. getHashCode(): number;
  1990. /**
  1991. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1992. * @returns the resulting array
  1993. */
  1994. asArray(): number[];
  1995. /**
  1996. * Populates the given array from the given index with the Vector4 coordinates.
  1997. * @param array array to populate
  1998. * @param index index of the array to start at (default: 0)
  1999. * @returns the Vector4.
  2000. */
  2001. toArray(array: FloatArray, index?: number): Vector4;
  2002. /**
  2003. * Adds the given vector to the current Vector4.
  2004. * @param otherVector the vector to add
  2005. * @returns the updated Vector4.
  2006. */
  2007. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2008. /**
  2009. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2010. * @param otherVector the vector to add
  2011. * @returns the resulting vector
  2012. */
  2013. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2014. /**
  2015. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2016. * @param otherVector the vector to add
  2017. * @param result the vector to store the result
  2018. * @returns the current Vector4.
  2019. */
  2020. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2021. /**
  2022. * Subtract in place the given vector from the current Vector4.
  2023. * @param otherVector the vector to subtract
  2024. * @returns the updated Vector4.
  2025. */
  2026. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2027. /**
  2028. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2029. * @param otherVector the vector to add
  2030. * @returns the new vector with the result
  2031. */
  2032. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2033. /**
  2034. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2035. * @param otherVector the vector to subtract
  2036. * @param result the vector to store the result
  2037. * @returns the current Vector4.
  2038. */
  2039. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2040. /**
  2041. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2042. */
  2043. /**
  2044. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2045. * @param x value to subtract
  2046. * @param y value to subtract
  2047. * @param z value to subtract
  2048. * @param w value to subtract
  2049. * @returns new vector containing the result
  2050. */
  2051. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2052. /**
  2053. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2054. * @param x value to subtract
  2055. * @param y value to subtract
  2056. * @param z value to subtract
  2057. * @param w value to subtract
  2058. * @param result the vector to store the result in
  2059. * @returns the current Vector4.
  2060. */
  2061. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2062. /**
  2063. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2064. * @returns a new vector with the negated values
  2065. */
  2066. negate(): Vector4;
  2067. /**
  2068. * Multiplies the current Vector4 coordinates by scale (float).
  2069. * @param scale the number to scale with
  2070. * @returns the updated Vector4.
  2071. */
  2072. scaleInPlace(scale: number): Vector4;
  2073. /**
  2074. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2075. * @param scale the number to scale with
  2076. * @returns a new vector with the result
  2077. */
  2078. scale(scale: number): Vector4;
  2079. /**
  2080. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2081. * @param scale the number to scale with
  2082. * @param result a vector to store the result in
  2083. * @returns the current Vector4.
  2084. */
  2085. scaleToRef(scale: number, result: Vector4): Vector4;
  2086. /**
  2087. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2088. * @param scale defines the scale factor
  2089. * @param result defines the Vector4 object where to store the result
  2090. * @returns the unmodified current Vector4
  2091. */
  2092. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2093. /**
  2094. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2095. * @param otherVector the vector to compare against
  2096. * @returns true if they are equal
  2097. */
  2098. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2099. /**
  2100. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2101. * @param otherVector vector to compare against
  2102. * @param epsilon (Default: very small number)
  2103. * @returns true if they are equal
  2104. */
  2105. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2106. /**
  2107. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2108. * @param x x value to compare against
  2109. * @param y y value to compare against
  2110. * @param z z value to compare against
  2111. * @param w w value to compare against
  2112. * @returns true if equal
  2113. */
  2114. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2115. /**
  2116. * Multiplies in place the current Vector4 by the given one.
  2117. * @param otherVector vector to multiple with
  2118. * @returns the updated Vector4.
  2119. */
  2120. multiplyInPlace(otherVector: Vector4): Vector4;
  2121. /**
  2122. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2123. * @param otherVector vector to multiple with
  2124. * @returns resulting new vector
  2125. */
  2126. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2127. /**
  2128. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2129. * @param otherVector vector to multiple with
  2130. * @param result vector to store the result
  2131. * @returns the current Vector4.
  2132. */
  2133. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2134. /**
  2135. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2136. * @param x x value multiply with
  2137. * @param y y value multiply with
  2138. * @param z z value multiply with
  2139. * @param w w value multiply with
  2140. * @returns resulting new vector
  2141. */
  2142. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2143. /**
  2144. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2145. * @param otherVector vector to devide with
  2146. * @returns resulting new vector
  2147. */
  2148. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2149. /**
  2150. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2151. * @param otherVector vector to devide with
  2152. * @param result vector to store the result
  2153. * @returns the current Vector4.
  2154. */
  2155. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2156. /**
  2157. * Divides the current Vector3 coordinates by the given ones.
  2158. * @param otherVector vector to devide with
  2159. * @returns the updated Vector3.
  2160. */
  2161. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2162. /**
  2163. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2164. * @param other defines the second operand
  2165. * @returns the current updated Vector4
  2166. */
  2167. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2168. /**
  2169. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2170. * @param other defines the second operand
  2171. * @returns the current updated Vector4
  2172. */
  2173. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2174. /**
  2175. * Gets a new Vector4 from current Vector4 floored values
  2176. * @returns a new Vector4
  2177. */
  2178. floor(): Vector4;
  2179. /**
  2180. * Gets a new Vector4 from current Vector3 floored values
  2181. * @returns a new Vector4
  2182. */
  2183. fract(): Vector4;
  2184. /**
  2185. * Returns the Vector4 length (float).
  2186. * @returns the length
  2187. */
  2188. length(): number;
  2189. /**
  2190. * Returns the Vector4 squared length (float).
  2191. * @returns the length squared
  2192. */
  2193. lengthSquared(): number;
  2194. /**
  2195. * Normalizes in place the Vector4.
  2196. * @returns the updated Vector4.
  2197. */
  2198. normalize(): Vector4;
  2199. /**
  2200. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2201. * @returns this converted to a new vector3
  2202. */
  2203. toVector3(): Vector3;
  2204. /**
  2205. * Returns a new Vector4 copied from the current one.
  2206. * @returns the new cloned vector
  2207. */
  2208. clone(): Vector4;
  2209. /**
  2210. * Updates the current Vector4 with the given one coordinates.
  2211. * @param source the source vector to copy from
  2212. * @returns the updated Vector4.
  2213. */
  2214. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2215. /**
  2216. * Updates the current Vector4 coordinates with the given floats.
  2217. * @param x float to copy from
  2218. * @param y float to copy from
  2219. * @param z float to copy from
  2220. * @param w float to copy from
  2221. * @returns the updated Vector4.
  2222. */
  2223. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2224. /**
  2225. * Updates the current Vector4 coordinates with the given floats.
  2226. * @param x float to set from
  2227. * @param y float to set from
  2228. * @param z float to set from
  2229. * @param w float to set from
  2230. * @returns the updated Vector4.
  2231. */
  2232. set(x: number, y: number, z: number, w: number): Vector4;
  2233. /**
  2234. * Copies the given float to the current Vector3 coordinates
  2235. * @param v defines the x, y, z and w coordinates of the operand
  2236. * @returns the current updated Vector3
  2237. */
  2238. setAll(v: number): Vector4;
  2239. /**
  2240. * Returns a new Vector4 set from the starting index of the given array.
  2241. * @param array the array to pull values from
  2242. * @param offset the offset into the array to start at
  2243. * @returns the new vector
  2244. */
  2245. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2246. /**
  2247. * Updates the given vector "result" from the starting index of the given array.
  2248. * @param array the array to pull values from
  2249. * @param offset the offset into the array to start at
  2250. * @param result the vector to store the result in
  2251. */
  2252. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2253. /**
  2254. * Updates the given vector "result" from the starting index of the given Float32Array.
  2255. * @param array the array to pull values from
  2256. * @param offset the offset into the array to start at
  2257. * @param result the vector to store the result in
  2258. */
  2259. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2260. /**
  2261. * Updates the given vector "result" coordinates from the given floats.
  2262. * @param x float to set from
  2263. * @param y float to set from
  2264. * @param z float to set from
  2265. * @param w float to set from
  2266. * @param result the vector to the floats in
  2267. */
  2268. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2269. /**
  2270. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2271. * @returns the new vector
  2272. */
  2273. static Zero(): Vector4;
  2274. /**
  2275. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2276. * @returns the new vector
  2277. */
  2278. static One(): Vector4;
  2279. /**
  2280. * Returns a new normalized Vector4 from the given one.
  2281. * @param vector the vector to normalize
  2282. * @returns the vector
  2283. */
  2284. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2285. /**
  2286. * Updates the given vector "result" from the normalization of the given one.
  2287. * @param vector the vector to normalize
  2288. * @param result the vector to store the result in
  2289. */
  2290. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2291. /**
  2292. * Returns a vector with the minimum values from the left and right vectors
  2293. * @param left left vector to minimize
  2294. * @param right right vector to minimize
  2295. * @returns a new vector with the minimum of the left and right vector values
  2296. */
  2297. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2298. /**
  2299. * Returns a vector with the maximum values from the left and right vectors
  2300. * @param left left vector to maximize
  2301. * @param right right vector to maximize
  2302. * @returns a new vector with the maximum of the left and right vector values
  2303. */
  2304. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2305. /**
  2306. * Returns the distance (float) between the vectors "value1" and "value2".
  2307. * @param value1 value to calulate the distance between
  2308. * @param value2 value to calulate the distance between
  2309. * @return the distance between the two vectors
  2310. */
  2311. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2312. /**
  2313. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2314. * @param value1 value to calulate the distance between
  2315. * @param value2 value to calulate the distance between
  2316. * @return the distance between the two vectors squared
  2317. */
  2318. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2319. /**
  2320. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2321. * @param value1 value to calulate the center between
  2322. * @param value2 value to calulate the center between
  2323. * @return the center between the two vectors
  2324. */
  2325. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2326. /**
  2327. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2328. * This methods computes transformed normalized direction vectors only.
  2329. * @param vector the vector to transform
  2330. * @param transformation the transformation matrix to apply
  2331. * @returns the new vector
  2332. */
  2333. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2334. /**
  2335. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2336. * This methods computes transformed normalized direction vectors only.
  2337. * @param vector the vector to transform
  2338. * @param transformation the transformation matrix to apply
  2339. * @param result the vector to store the result in
  2340. */
  2341. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2342. /**
  2343. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2344. * This methods computes transformed normalized direction vectors only.
  2345. * @param x value to transform
  2346. * @param y value to transform
  2347. * @param z value to transform
  2348. * @param w value to transform
  2349. * @param transformation the transformation matrix to apply
  2350. * @param result the vector to store the results in
  2351. */
  2352. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2353. /**
  2354. * Creates a new Vector4 from a Vector3
  2355. * @param source defines the source data
  2356. * @param w defines the 4th component (default is 0)
  2357. * @returns a new Vector4
  2358. */
  2359. static FromVector3(source: Vector3, w?: number): Vector4;
  2360. }
  2361. /**
  2362. * Interface for the size containing width and height
  2363. */
  2364. export interface ISize {
  2365. /**
  2366. * Width
  2367. */
  2368. width: number;
  2369. /**
  2370. * Heighht
  2371. */
  2372. height: number;
  2373. }
  2374. /**
  2375. * Size containing widht and height
  2376. */
  2377. export class Size implements ISize {
  2378. /**
  2379. * Width
  2380. */
  2381. width: number;
  2382. /**
  2383. * Height
  2384. */
  2385. height: number;
  2386. /**
  2387. * Creates a Size object from the given width and height (floats).
  2388. * @param width width of the new size
  2389. * @param height height of the new size
  2390. */
  2391. constructor(width: number, height: number);
  2392. /**
  2393. * Returns a string with the Size width and height
  2394. * @returns a string with the Size width and height
  2395. */
  2396. toString(): string;
  2397. /**
  2398. * "Size"
  2399. * @returns the string "Size"
  2400. */
  2401. getClassName(): string;
  2402. /**
  2403. * Returns the Size hash code.
  2404. * @returns a hash code for a unique width and height
  2405. */
  2406. getHashCode(): number;
  2407. /**
  2408. * Updates the current size from the given one.
  2409. * @param src the given size
  2410. */
  2411. copyFrom(src: Size): void;
  2412. /**
  2413. * Updates in place the current Size from the given floats.
  2414. * @param width width of the new size
  2415. * @param height height of the new size
  2416. * @returns the updated Size.
  2417. */
  2418. copyFromFloats(width: number, height: number): Size;
  2419. /**
  2420. * Updates in place the current Size from the given floats.
  2421. * @param width width to set
  2422. * @param height height to set
  2423. * @returns the updated Size.
  2424. */
  2425. set(width: number, height: number): Size;
  2426. /**
  2427. * Multiplies the width and height by numbers
  2428. * @param w factor to multiple the width by
  2429. * @param h factor to multiple the height by
  2430. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2431. */
  2432. multiplyByFloats(w: number, h: number): Size;
  2433. /**
  2434. * Clones the size
  2435. * @returns a new Size copied from the given one.
  2436. */
  2437. clone(): Size;
  2438. /**
  2439. * True if the current Size and the given one width and height are strictly equal.
  2440. * @param other the other size to compare against
  2441. * @returns True if the current Size and the given one width and height are strictly equal.
  2442. */
  2443. equals(other: Size): boolean;
  2444. /**
  2445. * The surface of the Size : width * height (float).
  2446. */
  2447. readonly surface: number;
  2448. /**
  2449. * Create a new size of zero
  2450. * @returns a new Size set to (0.0, 0.0)
  2451. */
  2452. static Zero(): Size;
  2453. /**
  2454. * Sums the width and height of two sizes
  2455. * @param otherSize size to add to this size
  2456. * @returns a new Size set as the addition result of the current Size and the given one.
  2457. */
  2458. add(otherSize: Size): Size;
  2459. /**
  2460. * Subtracts the width and height of two
  2461. * @param otherSize size to subtract to this size
  2462. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2463. */
  2464. subtract(otherSize: Size): Size;
  2465. /**
  2466. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2467. * @param start starting size to lerp between
  2468. * @param end end size to lerp between
  2469. * @param amount amount to lerp between the start and end values
  2470. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2471. */
  2472. static Lerp(start: Size, end: Size, amount: number): Size;
  2473. }
  2474. /**
  2475. * Class used to store quaternion data
  2476. * @see https://en.wikipedia.org/wiki/Quaternion
  2477. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2478. */
  2479. export class Quaternion {
  2480. /** defines the first component (0 by default) */
  2481. x: number;
  2482. /** defines the second component (0 by default) */
  2483. y: number;
  2484. /** defines the third component (0 by default) */
  2485. z: number;
  2486. /** defines the fourth component (1.0 by default) */
  2487. w: number;
  2488. /**
  2489. * Creates a new Quaternion from the given floats
  2490. * @param x defines the first component (0 by default)
  2491. * @param y defines the second component (0 by default)
  2492. * @param z defines the third component (0 by default)
  2493. * @param w defines the fourth component (1.0 by default)
  2494. */
  2495. constructor(
  2496. /** defines the first component (0 by default) */
  2497. x?: number,
  2498. /** defines the second component (0 by default) */
  2499. y?: number,
  2500. /** defines the third component (0 by default) */
  2501. z?: number,
  2502. /** defines the fourth component (1.0 by default) */
  2503. w?: number);
  2504. /**
  2505. * Gets a string representation for the current quaternion
  2506. * @returns a string with the Quaternion coordinates
  2507. */
  2508. toString(): string;
  2509. /**
  2510. * Gets the class name of the quaternion
  2511. * @returns the string "Quaternion"
  2512. */
  2513. getClassName(): string;
  2514. /**
  2515. * Gets a hash code for this quaternion
  2516. * @returns the quaternion hash code
  2517. */
  2518. getHashCode(): number;
  2519. /**
  2520. * Copy the quaternion to an array
  2521. * @returns a new array populated with 4 elements from the quaternion coordinates
  2522. */
  2523. asArray(): number[];
  2524. /**
  2525. * Check if two quaternions are equals
  2526. * @param otherQuaternion defines the second operand
  2527. * @return true if the current quaternion and the given one coordinates are strictly equals
  2528. */
  2529. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2530. /**
  2531. * Clone the current quaternion
  2532. * @returns a new quaternion copied from the current one
  2533. */
  2534. clone(): Quaternion;
  2535. /**
  2536. * Copy a quaternion to the current one
  2537. * @param other defines the other quaternion
  2538. * @returns the updated current quaternion
  2539. */
  2540. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2541. /**
  2542. * Updates the current quaternion with the given float coordinates
  2543. * @param x defines the x coordinate
  2544. * @param y defines the y coordinate
  2545. * @param z defines the z coordinate
  2546. * @param w defines the w coordinate
  2547. * @returns the updated current quaternion
  2548. */
  2549. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2550. /**
  2551. * Updates the current quaternion from the given float coordinates
  2552. * @param x defines the x coordinate
  2553. * @param y defines the y coordinate
  2554. * @param z defines the z coordinate
  2555. * @param w defines the w coordinate
  2556. * @returns the updated current quaternion
  2557. */
  2558. set(x: number, y: number, z: number, w: number): Quaternion;
  2559. /**
  2560. * Adds two quaternions
  2561. * @param other defines the second operand
  2562. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2563. */
  2564. add(other: DeepImmutable<Quaternion>): Quaternion;
  2565. /**
  2566. * Add a quaternion to the current one
  2567. * @param other defines the quaternion to add
  2568. * @returns the current quaternion
  2569. */
  2570. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2571. /**
  2572. * Subtract two quaternions
  2573. * @param other defines the second operand
  2574. * @returns a new quaternion as the subtraction result of the given one from the current one
  2575. */
  2576. subtract(other: Quaternion): Quaternion;
  2577. /**
  2578. * Multiplies the current quaternion by a scale factor
  2579. * @param value defines the scale factor
  2580. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2581. */
  2582. scale(value: number): Quaternion;
  2583. /**
  2584. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2585. * @param scale defines the scale factor
  2586. * @param result defines the Quaternion object where to store the result
  2587. * @returns the unmodified current quaternion
  2588. */
  2589. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2590. /**
  2591. * Multiplies in place the current quaternion by a scale factor
  2592. * @param value defines the scale factor
  2593. * @returns the current modified quaternion
  2594. */
  2595. scaleInPlace(value: number): Quaternion;
  2596. /**
  2597. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2598. * @param scale defines the scale factor
  2599. * @param result defines the Quaternion object where to store the result
  2600. * @returns the unmodified current quaternion
  2601. */
  2602. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2603. /**
  2604. * Multiplies two quaternions
  2605. * @param q1 defines the second operand
  2606. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2607. */
  2608. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2609. /**
  2610. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2611. * @param q1 defines the second operand
  2612. * @param result defines the target quaternion
  2613. * @returns the current quaternion
  2614. */
  2615. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2616. /**
  2617. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2618. * @param q1 defines the second operand
  2619. * @returns the currentupdated quaternion
  2620. */
  2621. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2622. /**
  2623. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2624. * @param ref defines the target quaternion
  2625. * @returns the current quaternion
  2626. */
  2627. conjugateToRef(ref: Quaternion): Quaternion;
  2628. /**
  2629. * Conjugates in place (1-q) the current quaternion
  2630. * @returns the current updated quaternion
  2631. */
  2632. conjugateInPlace(): Quaternion;
  2633. /**
  2634. * Conjugates in place (1-q) the current quaternion
  2635. * @returns a new quaternion
  2636. */
  2637. conjugate(): Quaternion;
  2638. /**
  2639. * Gets length of current quaternion
  2640. * @returns the quaternion length (float)
  2641. */
  2642. length(): number;
  2643. /**
  2644. * Normalize in place the current quaternion
  2645. * @returns the current updated quaternion
  2646. */
  2647. normalize(): Quaternion;
  2648. /**
  2649. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2650. * @param order is a reserved parameter and is ignore for now
  2651. * @returns a new Vector3 containing the Euler angles
  2652. */
  2653. toEulerAngles(order?: string): Vector3;
  2654. /**
  2655. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2656. * @param result defines the vector which will be filled with the Euler angles
  2657. * @param order is a reserved parameter and is ignore for now
  2658. * @returns the current unchanged quaternion
  2659. */
  2660. toEulerAnglesToRef(result: Vector3): Quaternion;
  2661. /**
  2662. * Updates the given rotation matrix with the current quaternion values
  2663. * @param result defines the target matrix
  2664. * @returns the current unchanged quaternion
  2665. */
  2666. toRotationMatrix(result: Matrix): Quaternion;
  2667. /**
  2668. * Updates the current quaternion from the given rotation matrix values
  2669. * @param matrix defines the source matrix
  2670. * @returns the current updated quaternion
  2671. */
  2672. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2673. /**
  2674. * Creates a new quaternion from a rotation matrix
  2675. * @param matrix defines the source matrix
  2676. * @returns a new quaternion created from the given rotation matrix values
  2677. */
  2678. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2679. /**
  2680. * Updates the given quaternion with the given rotation matrix values
  2681. * @param matrix defines the source matrix
  2682. * @param result defines the target quaternion
  2683. */
  2684. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2685. /**
  2686. * Returns the dot product (float) between the quaternions "left" and "right"
  2687. * @param left defines the left operand
  2688. * @param right defines the right operand
  2689. * @returns the dot product
  2690. */
  2691. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2692. /**
  2693. * Checks if the two quaternions are close to each other
  2694. * @param quat0 defines the first quaternion to check
  2695. * @param quat1 defines the second quaternion to check
  2696. * @returns true if the two quaternions are close to each other
  2697. */
  2698. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2699. /**
  2700. * Creates an empty quaternion
  2701. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2702. */
  2703. static Zero(): Quaternion;
  2704. /**
  2705. * Inverse a given quaternion
  2706. * @param q defines the source quaternion
  2707. * @returns a new quaternion as the inverted current quaternion
  2708. */
  2709. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2710. /**
  2711. * Inverse a given quaternion
  2712. * @param q defines the source quaternion
  2713. * @param result the quaternion the result will be stored in
  2714. * @returns the result quaternion
  2715. */
  2716. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2717. /**
  2718. * Creates an identity quaternion
  2719. * @returns the identity quaternion
  2720. */
  2721. static Identity(): Quaternion;
  2722. /**
  2723. * Gets a boolean indicating if the given quaternion is identity
  2724. * @param quaternion defines the quaternion to check
  2725. * @returns true if the quaternion is identity
  2726. */
  2727. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2728. /**
  2729. * Creates a quaternion from a rotation around an axis
  2730. * @param axis defines the axis to use
  2731. * @param angle defines the angle to use
  2732. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2733. */
  2734. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2735. /**
  2736. * Creates a rotation around an axis and stores it into the given quaternion
  2737. * @param axis defines the axis to use
  2738. * @param angle defines the angle to use
  2739. * @param result defines the target quaternion
  2740. * @returns the target quaternion
  2741. */
  2742. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2743. /**
  2744. * Creates a new quaternion from data stored into an array
  2745. * @param array defines the data source
  2746. * @param offset defines the offset in the source array where the data starts
  2747. * @returns a new quaternion
  2748. */
  2749. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2750. /**
  2751. * Create a quaternion from Euler rotation angles
  2752. * @param x Pitch
  2753. * @param y Yaw
  2754. * @param z Roll
  2755. * @returns the new Quaternion
  2756. */
  2757. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2758. /**
  2759. * Updates a quaternion from Euler rotation angles
  2760. * @param x Pitch
  2761. * @param y Yaw
  2762. * @param z Roll
  2763. * @param result the quaternion to store the result
  2764. * @returns the updated quaternion
  2765. */
  2766. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2767. /**
  2768. * Create a quaternion from Euler rotation vector
  2769. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2770. * @returns the new Quaternion
  2771. */
  2772. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2773. /**
  2774. * Updates a quaternion from Euler rotation vector
  2775. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2776. * @param result the quaternion to store the result
  2777. * @returns the updated quaternion
  2778. */
  2779. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2780. /**
  2781. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2782. * @param yaw defines the rotation around Y axis
  2783. * @param pitch defines the rotation around X axis
  2784. * @param roll defines the rotation around Z axis
  2785. * @returns the new quaternion
  2786. */
  2787. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2788. /**
  2789. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2790. * @param yaw defines the rotation around Y axis
  2791. * @param pitch defines the rotation around X axis
  2792. * @param roll defines the rotation around Z axis
  2793. * @param result defines the target quaternion
  2794. */
  2795. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2796. /**
  2797. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2798. * @param alpha defines the rotation around first axis
  2799. * @param beta defines the rotation around second axis
  2800. * @param gamma defines the rotation around third axis
  2801. * @returns the new quaternion
  2802. */
  2803. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2804. /**
  2805. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2806. * @param alpha defines the rotation around first axis
  2807. * @param beta defines the rotation around second axis
  2808. * @param gamma defines the rotation around third axis
  2809. * @param result defines the target quaternion
  2810. */
  2811. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2812. /**
  2813. * 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)
  2814. * @param axis1 defines the first axis
  2815. * @param axis2 defines the second axis
  2816. * @param axis3 defines the third axis
  2817. * @returns the new quaternion
  2818. */
  2819. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2820. /**
  2821. * 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
  2822. * @param axis1 defines the first axis
  2823. * @param axis2 defines the second axis
  2824. * @param axis3 defines the third axis
  2825. * @param ref defines the target quaternion
  2826. */
  2827. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2828. /**
  2829. * Interpolates between two quaternions
  2830. * @param left defines first quaternion
  2831. * @param right defines second quaternion
  2832. * @param amount defines the gradient to use
  2833. * @returns the new interpolated quaternion
  2834. */
  2835. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2836. /**
  2837. * Interpolates between two quaternions and stores it into a target quaternion
  2838. * @param left defines first quaternion
  2839. * @param right defines second quaternion
  2840. * @param amount defines the gradient to use
  2841. * @param result defines the target quaternion
  2842. */
  2843. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2844. /**
  2845. * Interpolate between two quaternions using Hermite interpolation
  2846. * @param value1 defines first quaternion
  2847. * @param tangent1 defines the incoming tangent
  2848. * @param value2 defines second quaternion
  2849. * @param tangent2 defines the outgoing tangent
  2850. * @param amount defines the target quaternion
  2851. * @returns the new interpolated quaternion
  2852. */
  2853. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2854. }
  2855. /**
  2856. * Class used to store matrix data (4x4)
  2857. */
  2858. export class Matrix {
  2859. private static _updateFlagSeed;
  2860. private static _identityReadOnly;
  2861. private _isIdentity;
  2862. private _isIdentityDirty;
  2863. private _isIdentity3x2;
  2864. private _isIdentity3x2Dirty;
  2865. /**
  2866. * Gets the update flag of the matrix which is an unique number for the matrix.
  2867. * It will be incremented every time the matrix data change.
  2868. * You can use it to speed the comparison between two versions of the same matrix.
  2869. */
  2870. updateFlag: number;
  2871. private readonly _m;
  2872. /**
  2873. * Gets the internal data of the matrix
  2874. */
  2875. readonly m: DeepImmutable<Float32Array>;
  2876. /** @hidden */
  2877. _markAsUpdated(): void;
  2878. /** @hidden */
  2879. private _updateIdentityStatus;
  2880. /**
  2881. * Creates an empty matrix (filled with zeros)
  2882. */
  2883. constructor();
  2884. /**
  2885. * Check if the current matrix is identity
  2886. * @returns true is the matrix is the identity matrix
  2887. */
  2888. isIdentity(): boolean;
  2889. /**
  2890. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2891. * @returns true is the matrix is the identity matrix
  2892. */
  2893. isIdentityAs3x2(): boolean;
  2894. /**
  2895. * Gets the determinant of the matrix
  2896. * @returns the matrix determinant
  2897. */
  2898. determinant(): number;
  2899. /**
  2900. * Returns the matrix as a Float32Array
  2901. * @returns the matrix underlying array
  2902. */
  2903. toArray(): DeepImmutable<Float32Array>;
  2904. /**
  2905. * Returns the matrix as a Float32Array
  2906. * @returns the matrix underlying array.
  2907. */
  2908. asArray(): DeepImmutable<Float32Array>;
  2909. /**
  2910. * Inverts the current matrix in place
  2911. * @returns the current inverted matrix
  2912. */
  2913. invert(): Matrix;
  2914. /**
  2915. * Sets all the matrix elements to zero
  2916. * @returns the current matrix
  2917. */
  2918. reset(): Matrix;
  2919. /**
  2920. * Adds the current matrix with a second one
  2921. * @param other defines the matrix to add
  2922. * @returns a new matrix as the addition of the current matrix and the given one
  2923. */
  2924. add(other: DeepImmutable<Matrix>): Matrix;
  2925. /**
  2926. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2927. * @param other defines the matrix to add
  2928. * @param result defines the target matrix
  2929. * @returns the current matrix
  2930. */
  2931. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2932. /**
  2933. * Adds in place the given matrix to the current matrix
  2934. * @param other defines the second operand
  2935. * @returns the current updated matrix
  2936. */
  2937. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2938. /**
  2939. * Sets the given matrix to the current inverted Matrix
  2940. * @param other defines the target matrix
  2941. * @returns the unmodified current matrix
  2942. */
  2943. invertToRef(other: Matrix): Matrix;
  2944. /**
  2945. * add a value at the specified position in the current Matrix
  2946. * @param index the index of the value within the matrix. between 0 and 15.
  2947. * @param value the value to be added
  2948. * @returns the current updated matrix
  2949. */
  2950. addAtIndex(index: number, value: number): Matrix;
  2951. /**
  2952. * mutiply the specified position in the current Matrix by a value
  2953. * @param index the index of the value within the matrix. between 0 and 15.
  2954. * @param value the value to be added
  2955. * @returns the current updated matrix
  2956. */
  2957. multiplyAtIndex(index: number, value: number): Matrix;
  2958. /**
  2959. * Inserts the translation vector (using 3 floats) in the current matrix
  2960. * @param x defines the 1st component of the translation
  2961. * @param y defines the 2nd component of the translation
  2962. * @param z defines the 3rd component of the translation
  2963. * @returns the current updated matrix
  2964. */
  2965. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2966. /**
  2967. * Adds the translation vector (using 3 floats) in the current matrix
  2968. * @param x defines the 1st component of the translation
  2969. * @param y defines the 2nd component of the translation
  2970. * @param z defines the 3rd component of the translation
  2971. * @returns the current updated matrix
  2972. */
  2973. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2974. /**
  2975. * Inserts the translation vector in the current matrix
  2976. * @param vector3 defines the translation to insert
  2977. * @returns the current updated matrix
  2978. */
  2979. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2980. /**
  2981. * Gets the translation value of the current matrix
  2982. * @returns a new Vector3 as the extracted translation from the matrix
  2983. */
  2984. getTranslation(): Vector3;
  2985. /**
  2986. * Fill a Vector3 with the extracted translation from the matrix
  2987. * @param result defines the Vector3 where to store the translation
  2988. * @returns the current matrix
  2989. */
  2990. getTranslationToRef(result: Vector3): Matrix;
  2991. /**
  2992. * Remove rotation and scaling part from the matrix
  2993. * @returns the updated matrix
  2994. */
  2995. removeRotationAndScaling(): Matrix;
  2996. /**
  2997. * Multiply two matrices
  2998. * @param other defines the second operand
  2999. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3000. */
  3001. multiply(other: DeepImmutable<Matrix>): Matrix;
  3002. /**
  3003. * Copy the current matrix from the given one
  3004. * @param other defines the source matrix
  3005. * @returns the current updated matrix
  3006. */
  3007. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3008. /**
  3009. * Populates the given array from the starting index with the current matrix values
  3010. * @param array defines the target array
  3011. * @param offset defines the offset in the target array where to start storing values
  3012. * @returns the current matrix
  3013. */
  3014. copyToArray(array: Float32Array, offset?: number): Matrix;
  3015. /**
  3016. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3017. * @param other defines the second operand
  3018. * @param result defines the matrix where to store the multiplication
  3019. * @returns the current matrix
  3020. */
  3021. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3022. /**
  3023. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3024. * @param other defines the second operand
  3025. * @param result defines the array where to store the multiplication
  3026. * @param offset defines the offset in the target array where to start storing values
  3027. * @returns the current matrix
  3028. */
  3029. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3030. /**
  3031. * Check equality between this matrix and a second one
  3032. * @param value defines the second matrix to compare
  3033. * @returns true is the current matrix and the given one values are strictly equal
  3034. */
  3035. equals(value: DeepImmutable<Matrix>): boolean;
  3036. /**
  3037. * Clone the current matrix
  3038. * @returns a new matrix from the current matrix
  3039. */
  3040. clone(): Matrix;
  3041. /**
  3042. * Returns the name of the current matrix class
  3043. * @returns the string "Matrix"
  3044. */
  3045. getClassName(): string;
  3046. /**
  3047. * Gets the hash code of the current matrix
  3048. * @returns the hash code
  3049. */
  3050. getHashCode(): number;
  3051. /**
  3052. * Decomposes the current Matrix into a translation, rotation and scaling components
  3053. * @param scale defines the scale vector3 given as a reference to update
  3054. * @param rotation defines the rotation quaternion given as a reference to update
  3055. * @param translation defines the translation vector3 given as a reference to update
  3056. * @returns true if operation was successful
  3057. */
  3058. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3059. /**
  3060. * Gets specific row of the matrix
  3061. * @param index defines the number of the row to get
  3062. * @returns the index-th row of the current matrix as a new Vector4
  3063. */
  3064. getRow(index: number): Nullable<Vector4>;
  3065. /**
  3066. * Sets the index-th row of the current matrix to the vector4 values
  3067. * @param index defines the number of the row to set
  3068. * @param row defines the target vector4
  3069. * @returns the updated current matrix
  3070. */
  3071. setRow(index: number, row: Vector4): Matrix;
  3072. /**
  3073. * Compute the transpose of the matrix
  3074. * @returns the new transposed matrix
  3075. */
  3076. transpose(): Matrix;
  3077. /**
  3078. * Compute the transpose of the matrix and store it in a given matrix
  3079. * @param result defines the target matrix
  3080. * @returns the current matrix
  3081. */
  3082. transposeToRef(result: Matrix): Matrix;
  3083. /**
  3084. * Sets the index-th row of the current matrix with the given 4 x float values
  3085. * @param index defines the row index
  3086. * @param x defines the x component to set
  3087. * @param y defines the y component to set
  3088. * @param z defines the z component to set
  3089. * @param w defines the w component to set
  3090. * @returns the updated current matrix
  3091. */
  3092. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3093. /**
  3094. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3095. * @param scale defines the scale factor
  3096. * @returns a new matrix
  3097. */
  3098. scale(scale: number): Matrix;
  3099. /**
  3100. * Scale the current matrix values by a factor to a given result matrix
  3101. * @param scale defines the scale factor
  3102. * @param result defines the matrix to store the result
  3103. * @returns the current matrix
  3104. */
  3105. scaleToRef(scale: number, result: Matrix): Matrix;
  3106. /**
  3107. * Scale the current matrix values by a factor and add the result to a given matrix
  3108. * @param scale defines the scale factor
  3109. * @param result defines the Matrix to store the result
  3110. * @returns the current matrix
  3111. */
  3112. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3113. /**
  3114. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3115. * @param ref matrix to store the result
  3116. */
  3117. toNormalMatrix(ref: Matrix): void;
  3118. /**
  3119. * Gets only rotation part of the current matrix
  3120. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3121. */
  3122. getRotationMatrix(): Matrix;
  3123. /**
  3124. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3125. * @param result defines the target matrix to store data to
  3126. * @returns the current matrix
  3127. */
  3128. getRotationMatrixToRef(result: Matrix): Matrix;
  3129. /**
  3130. * Toggles model matrix from being right handed to left handed in place and vice versa
  3131. */
  3132. toggleModelMatrixHandInPlace(): void;
  3133. /**
  3134. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3135. */
  3136. toggleProjectionMatrixHandInPlace(): void;
  3137. /**
  3138. * Creates a matrix from an array
  3139. * @param array defines the source array
  3140. * @param offset defines an offset in the source array
  3141. * @returns a new Matrix set from the starting index of the given array
  3142. */
  3143. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3144. /**
  3145. * Copy the content of an array into a given matrix
  3146. * @param array defines the source array
  3147. * @param offset defines an offset in the source array
  3148. * @param result defines the target matrix
  3149. */
  3150. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3151. /**
  3152. * Stores an array into a matrix after having multiplied each component by a given factor
  3153. * @param array defines the source array
  3154. * @param offset defines the offset in the source array
  3155. * @param scale defines the scaling factor
  3156. * @param result defines the target matrix
  3157. */
  3158. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3159. /**
  3160. * Gets an identity matrix that must not be updated
  3161. */
  3162. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3163. /**
  3164. * Stores a list of values (16) inside a given matrix
  3165. * @param initialM11 defines 1st value of 1st row
  3166. * @param initialM12 defines 2nd value of 1st row
  3167. * @param initialM13 defines 3rd value of 1st row
  3168. * @param initialM14 defines 4th value of 1st row
  3169. * @param initialM21 defines 1st value of 2nd row
  3170. * @param initialM22 defines 2nd value of 2nd row
  3171. * @param initialM23 defines 3rd value of 2nd row
  3172. * @param initialM24 defines 4th value of 2nd row
  3173. * @param initialM31 defines 1st value of 3rd row
  3174. * @param initialM32 defines 2nd value of 3rd row
  3175. * @param initialM33 defines 3rd value of 3rd row
  3176. * @param initialM34 defines 4th value of 3rd row
  3177. * @param initialM41 defines 1st value of 4th row
  3178. * @param initialM42 defines 2nd value of 4th row
  3179. * @param initialM43 defines 3rd value of 4th row
  3180. * @param initialM44 defines 4th value of 4th row
  3181. * @param result defines the target matrix
  3182. */
  3183. 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;
  3184. /**
  3185. * Creates new matrix from a list of values (16)
  3186. * @param initialM11 defines 1st value of 1st row
  3187. * @param initialM12 defines 2nd value of 1st row
  3188. * @param initialM13 defines 3rd value of 1st row
  3189. * @param initialM14 defines 4th value of 1st row
  3190. * @param initialM21 defines 1st value of 2nd row
  3191. * @param initialM22 defines 2nd value of 2nd row
  3192. * @param initialM23 defines 3rd value of 2nd row
  3193. * @param initialM24 defines 4th value of 2nd row
  3194. * @param initialM31 defines 1st value of 3rd row
  3195. * @param initialM32 defines 2nd value of 3rd row
  3196. * @param initialM33 defines 3rd value of 3rd row
  3197. * @param initialM34 defines 4th value of 3rd row
  3198. * @param initialM41 defines 1st value of 4th row
  3199. * @param initialM42 defines 2nd value of 4th row
  3200. * @param initialM43 defines 3rd value of 4th row
  3201. * @param initialM44 defines 4th value of 4th row
  3202. * @returns the new matrix
  3203. */
  3204. 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;
  3205. /**
  3206. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3207. * @param scale defines the scale vector3
  3208. * @param rotation defines the rotation quaternion
  3209. * @param translation defines the translation vector3
  3210. * @returns a new matrix
  3211. */
  3212. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3213. /**
  3214. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3215. * @param scale defines the scale vector3
  3216. * @param rotation defines the rotation quaternion
  3217. * @param translation defines the translation vector3
  3218. * @param result defines the target matrix
  3219. */
  3220. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3221. /**
  3222. * Creates a new identity matrix
  3223. * @returns a new identity matrix
  3224. */
  3225. static Identity(): Matrix;
  3226. /**
  3227. * Creates a new identity matrix and stores the result in a given matrix
  3228. * @param result defines the target matrix
  3229. */
  3230. static IdentityToRef(result: Matrix): void;
  3231. /**
  3232. * Creates a new zero matrix
  3233. * @returns a new zero matrix
  3234. */
  3235. static Zero(): Matrix;
  3236. /**
  3237. * Creates a new rotation matrix for "angle" radians around the X axis
  3238. * @param angle defines the angle (in radians) to use
  3239. * @return the new matrix
  3240. */
  3241. static RotationX(angle: number): Matrix;
  3242. /**
  3243. * Creates a new matrix as the invert of a given matrix
  3244. * @param source defines the source matrix
  3245. * @returns the new matrix
  3246. */
  3247. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3248. /**
  3249. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3250. * @param angle defines the angle (in radians) to use
  3251. * @param result defines the target matrix
  3252. */
  3253. static RotationXToRef(angle: number, result: Matrix): void;
  3254. /**
  3255. * Creates a new rotation matrix for "angle" radians around the Y axis
  3256. * @param angle defines the angle (in radians) to use
  3257. * @return the new matrix
  3258. */
  3259. static RotationY(angle: number): Matrix;
  3260. /**
  3261. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3262. * @param angle defines the angle (in radians) to use
  3263. * @param result defines the target matrix
  3264. */
  3265. static RotationYToRef(angle: number, result: Matrix): void;
  3266. /**
  3267. * Creates a new rotation matrix for "angle" radians around the Z axis
  3268. * @param angle defines the angle (in radians) to use
  3269. * @return the new matrix
  3270. */
  3271. static RotationZ(angle: number): Matrix;
  3272. /**
  3273. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3274. * @param angle defines the angle (in radians) to use
  3275. * @param result defines the target matrix
  3276. */
  3277. static RotationZToRef(angle: number, result: Matrix): void;
  3278. /**
  3279. * Creates a new rotation matrix for "angle" radians around the given axis
  3280. * @param axis defines the axis to use
  3281. * @param angle defines the angle (in radians) to use
  3282. * @return the new matrix
  3283. */
  3284. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3285. /**
  3286. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3287. * @param axis defines the axis to use
  3288. * @param angle defines the angle (in radians) to use
  3289. * @param result defines the target matrix
  3290. */
  3291. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3292. /**
  3293. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3294. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3295. * @param from defines the vector to align
  3296. * @param to defines the vector to align to
  3297. * @param result defines the target matrix
  3298. */
  3299. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3300. /**
  3301. * Creates a rotation matrix
  3302. * @param yaw defines the yaw angle in radians (Y axis)
  3303. * @param pitch defines the pitch angle in radians (X axis)
  3304. * @param roll defines the roll angle in radians (X axis)
  3305. * @returns the new rotation matrix
  3306. */
  3307. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3308. /**
  3309. * Creates a rotation matrix and stores it in a given matrix
  3310. * @param yaw defines the yaw angle in radians (Y axis)
  3311. * @param pitch defines the pitch angle in radians (X axis)
  3312. * @param roll defines the roll angle in radians (X axis)
  3313. * @param result defines the target matrix
  3314. */
  3315. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3316. /**
  3317. * Creates a scaling matrix
  3318. * @param x defines the scale factor on X axis
  3319. * @param y defines the scale factor on Y axis
  3320. * @param z defines the scale factor on Z axis
  3321. * @returns the new matrix
  3322. */
  3323. static Scaling(x: number, y: number, z: number): Matrix;
  3324. /**
  3325. * Creates a scaling matrix and stores it in a given matrix
  3326. * @param x defines the scale factor on X axis
  3327. * @param y defines the scale factor on Y axis
  3328. * @param z defines the scale factor on Z axis
  3329. * @param result defines the target matrix
  3330. */
  3331. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3332. /**
  3333. * Creates a translation matrix
  3334. * @param x defines the translation on X axis
  3335. * @param y defines the translation on Y axis
  3336. * @param z defines the translationon Z axis
  3337. * @returns the new matrix
  3338. */
  3339. static Translation(x: number, y: number, z: number): Matrix;
  3340. /**
  3341. * Creates a translation matrix and stores it in a given matrix
  3342. * @param x defines the translation on X axis
  3343. * @param y defines the translation on Y axis
  3344. * @param z defines the translationon Z axis
  3345. * @param result defines the target matrix
  3346. */
  3347. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3348. /**
  3349. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3350. * @param startValue defines the start value
  3351. * @param endValue defines the end value
  3352. * @param gradient defines the gradient factor
  3353. * @returns the new matrix
  3354. */
  3355. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3356. /**
  3357. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3358. * @param startValue defines the start value
  3359. * @param endValue defines the end value
  3360. * @param gradient defines the gradient factor
  3361. * @param result defines the Matrix object where to store data
  3362. */
  3363. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3364. /**
  3365. * Builds a new matrix whose values are computed by:
  3366. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3367. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3368. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3369. * @param startValue defines the first matrix
  3370. * @param endValue defines the second matrix
  3371. * @param gradient defines the gradient between the two matrices
  3372. * @returns the new matrix
  3373. */
  3374. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3375. /**
  3376. * Update a matrix to values which are computed by:
  3377. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3378. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3379. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3380. * @param startValue defines the first matrix
  3381. * @param endValue defines the second matrix
  3382. * @param gradient defines the gradient between the two matrices
  3383. * @param result defines the target matrix
  3384. */
  3385. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3386. /**
  3387. * 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"
  3388. * This function works in left handed mode
  3389. * @param eye defines the final position of the entity
  3390. * @param target defines where the entity should look at
  3391. * @param up defines the up vector for the entity
  3392. * @returns the new matrix
  3393. */
  3394. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3395. /**
  3396. * 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".
  3397. * This function works in left handed mode
  3398. * @param eye defines the final position of the entity
  3399. * @param target defines where the entity should look at
  3400. * @param up defines the up vector for the entity
  3401. * @param result defines the target matrix
  3402. */
  3403. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3404. /**
  3405. * 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"
  3406. * This function works in right handed mode
  3407. * @param eye defines the final position of the entity
  3408. * @param target defines where the entity should look at
  3409. * @param up defines the up vector for the entity
  3410. * @returns the new matrix
  3411. */
  3412. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3413. /**
  3414. * 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".
  3415. * This function works in right handed mode
  3416. * @param eye defines the final position of the entity
  3417. * @param target defines where the entity should look at
  3418. * @param up defines the up vector for the entity
  3419. * @param result defines the target matrix
  3420. */
  3421. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3422. /**
  3423. * Create a left-handed orthographic projection matrix
  3424. * @param width defines the viewport width
  3425. * @param height defines the viewport height
  3426. * @param znear defines the near clip plane
  3427. * @param zfar defines the far clip plane
  3428. * @returns a new matrix as a left-handed orthographic projection matrix
  3429. */
  3430. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3431. /**
  3432. * Store a left-handed orthographic projection to a given matrix
  3433. * @param width defines the viewport width
  3434. * @param height defines the viewport height
  3435. * @param znear defines the near clip plane
  3436. * @param zfar defines the far clip plane
  3437. * @param result defines the target matrix
  3438. */
  3439. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3440. /**
  3441. * Create a left-handed orthographic projection matrix
  3442. * @param left defines the viewport left coordinate
  3443. * @param right defines the viewport right coordinate
  3444. * @param bottom defines the viewport bottom coordinate
  3445. * @param top defines the viewport top coordinate
  3446. * @param znear defines the near clip plane
  3447. * @param zfar defines the far clip plane
  3448. * @returns a new matrix as a left-handed orthographic projection matrix
  3449. */
  3450. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3451. /**
  3452. * Stores a left-handed orthographic projection into a given matrix
  3453. * @param left defines the viewport left coordinate
  3454. * @param right defines the viewport right coordinate
  3455. * @param bottom defines the viewport bottom coordinate
  3456. * @param top defines the viewport top coordinate
  3457. * @param znear defines the near clip plane
  3458. * @param zfar defines the far clip plane
  3459. * @param result defines the target matrix
  3460. */
  3461. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3462. /**
  3463. * Creates a right-handed orthographic projection matrix
  3464. * @param left defines the viewport left coordinate
  3465. * @param right defines the viewport right coordinate
  3466. * @param bottom defines the viewport bottom coordinate
  3467. * @param top defines the viewport top coordinate
  3468. * @param znear defines the near clip plane
  3469. * @param zfar defines the far clip plane
  3470. * @returns a new matrix as a right-handed orthographic projection matrix
  3471. */
  3472. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3473. /**
  3474. * Stores a right-handed orthographic projection into a given matrix
  3475. * @param left defines the viewport left coordinate
  3476. * @param right defines the viewport right coordinate
  3477. * @param bottom defines the viewport bottom coordinate
  3478. * @param top defines the viewport top coordinate
  3479. * @param znear defines the near clip plane
  3480. * @param zfar defines the far clip plane
  3481. * @param result defines the target matrix
  3482. */
  3483. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3484. /**
  3485. * Creates a left-handed perspective projection matrix
  3486. * @param width defines the viewport width
  3487. * @param height defines the viewport height
  3488. * @param znear defines the near clip plane
  3489. * @param zfar defines the far clip plane
  3490. * @returns a new matrix as a left-handed perspective projection matrix
  3491. */
  3492. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3493. /**
  3494. * Creates a left-handed perspective projection matrix
  3495. * @param fov defines the horizontal field of view
  3496. * @param aspect defines the aspect ratio
  3497. * @param znear defines the near clip plane
  3498. * @param zfar defines the far clip plane
  3499. * @returns a new matrix as a left-handed perspective projection matrix
  3500. */
  3501. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3502. /**
  3503. * Stores a left-handed perspective projection into a given matrix
  3504. * @param fov defines the horizontal field of view
  3505. * @param aspect defines the aspect ratio
  3506. * @param znear defines the near clip plane
  3507. * @param zfar defines the far clip plane
  3508. * @param result defines the target matrix
  3509. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3510. */
  3511. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3512. /**
  3513. * Creates a right-handed perspective projection matrix
  3514. * @param fov defines the horizontal field of view
  3515. * @param aspect defines the aspect ratio
  3516. * @param znear defines the near clip plane
  3517. * @param zfar defines the far clip plane
  3518. * @returns a new matrix as a right-handed perspective projection matrix
  3519. */
  3520. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3521. /**
  3522. * Stores a right-handed perspective projection into a given matrix
  3523. * @param fov defines the horizontal field of view
  3524. * @param aspect defines the aspect ratio
  3525. * @param znear defines the near clip plane
  3526. * @param zfar defines the far clip plane
  3527. * @param result defines the target matrix
  3528. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3529. */
  3530. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3531. /**
  3532. * Stores a perspective projection for WebVR info a given matrix
  3533. * @param fov defines the field of view
  3534. * @param znear defines the near clip plane
  3535. * @param zfar defines the far clip plane
  3536. * @param result defines the target matrix
  3537. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3538. */
  3539. static PerspectiveFovWebVRToRef(fov: {
  3540. upDegrees: number;
  3541. downDegrees: number;
  3542. leftDegrees: number;
  3543. rightDegrees: number;
  3544. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3545. /**
  3546. * Computes a complete transformation matrix
  3547. * @param viewport defines the viewport to use
  3548. * @param world defines the world matrix
  3549. * @param view defines the view matrix
  3550. * @param projection defines the projection matrix
  3551. * @param zmin defines the near clip plane
  3552. * @param zmax defines the far clip plane
  3553. * @returns the transformation matrix
  3554. */
  3555. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3556. /**
  3557. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3558. * @param matrix defines the matrix to use
  3559. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3560. */
  3561. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3562. /**
  3563. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3564. * @param matrix defines the matrix to use
  3565. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3566. */
  3567. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3568. /**
  3569. * Compute the transpose of a given matrix
  3570. * @param matrix defines the matrix to transpose
  3571. * @returns the new matrix
  3572. */
  3573. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3574. /**
  3575. * Compute the transpose of a matrix and store it in a target matrix
  3576. * @param matrix defines the matrix to transpose
  3577. * @param result defines the target matrix
  3578. */
  3579. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3580. /**
  3581. * Computes a reflection matrix from a plane
  3582. * @param plane defines the reflection plane
  3583. * @returns a new matrix
  3584. */
  3585. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3586. /**
  3587. * Computes a reflection matrix from a plane
  3588. * @param plane defines the reflection plane
  3589. * @param result defines the target matrix
  3590. */
  3591. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3592. /**
  3593. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3594. * @param xaxis defines the value of the 1st axis
  3595. * @param yaxis defines the value of the 2nd axis
  3596. * @param zaxis defines the value of the 3rd axis
  3597. * @param result defines the target matrix
  3598. */
  3599. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3600. /**
  3601. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3602. * @param quat defines the quaternion to use
  3603. * @param result defines the target matrix
  3604. */
  3605. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3606. }
  3607. /**
  3608. * Represens a plane by the equation ax + by + cz + d = 0
  3609. */
  3610. export class Plane {
  3611. /**
  3612. * Normal of the plane (a,b,c)
  3613. */
  3614. normal: Vector3;
  3615. /**
  3616. * d component of the plane
  3617. */
  3618. d: number;
  3619. /**
  3620. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3621. * @param a a component of the plane
  3622. * @param b b component of the plane
  3623. * @param c c component of the plane
  3624. * @param d d component of the plane
  3625. */
  3626. constructor(a: number, b: number, c: number, d: number);
  3627. /**
  3628. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3629. */
  3630. asArray(): number[];
  3631. /**
  3632. * @returns a new plane copied from the current Plane.
  3633. */
  3634. clone(): Plane;
  3635. /**
  3636. * @returns the string "Plane".
  3637. */
  3638. getClassName(): string;
  3639. /**
  3640. * @returns the Plane hash code.
  3641. */
  3642. getHashCode(): number;
  3643. /**
  3644. * Normalize the current Plane in place.
  3645. * @returns the updated Plane.
  3646. */
  3647. normalize(): Plane;
  3648. /**
  3649. * Applies a transformation the plane and returns the result
  3650. * @param transformation the transformation matrix to be applied to the plane
  3651. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3652. */
  3653. transform(transformation: DeepImmutable<Matrix>): Plane;
  3654. /**
  3655. * Calcualtte the dot product between the point and the plane normal
  3656. * @param point point to calculate the dot product with
  3657. * @returns the dot product (float) of the point coordinates and the plane normal.
  3658. */
  3659. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3660. /**
  3661. * Updates the current Plane from the plane defined by the three given points.
  3662. * @param point1 one of the points used to contruct the plane
  3663. * @param point2 one of the points used to contruct the plane
  3664. * @param point3 one of the points used to contruct the plane
  3665. * @returns the updated Plane.
  3666. */
  3667. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3668. /**
  3669. * Checks if the plane is facing a given direction
  3670. * @param direction the direction to check if the plane is facing
  3671. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3672. * @returns True is the vector "direction" is the same side than the plane normal.
  3673. */
  3674. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3675. /**
  3676. * Calculates the distance to a point
  3677. * @param point point to calculate distance to
  3678. * @returns the signed distance (float) from the given point to the Plane.
  3679. */
  3680. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3681. /**
  3682. * Creates a plane from an array
  3683. * @param array the array to create a plane from
  3684. * @returns a new Plane from the given array.
  3685. */
  3686. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3687. /**
  3688. * Creates a plane from three points
  3689. * @param point1 point used to create the plane
  3690. * @param point2 point used to create the plane
  3691. * @param point3 point used to create the plane
  3692. * @returns a new Plane defined by the three given points.
  3693. */
  3694. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3695. /**
  3696. * Creates a plane from an origin point and a normal
  3697. * @param origin origin of the plane to be constructed
  3698. * @param normal normal of the plane to be constructed
  3699. * @returns a new Plane the normal vector to this plane at the given origin point.
  3700. * Note : the vector "normal" is updated because normalized.
  3701. */
  3702. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3703. /**
  3704. * Calculates the distance from a plane and a point
  3705. * @param origin origin of the plane to be constructed
  3706. * @param normal normal of the plane to be constructed
  3707. * @param point point to calculate distance to
  3708. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3709. */
  3710. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3711. }
  3712. /**
  3713. * Class used to represent a viewport on screen
  3714. */
  3715. export class Viewport {
  3716. /** viewport left coordinate */
  3717. x: number;
  3718. /** viewport top coordinate */
  3719. y: number;
  3720. /**viewport width */
  3721. width: number;
  3722. /** viewport height */
  3723. height: number;
  3724. /**
  3725. * Creates a Viewport object located at (x, y) and sized (width, height)
  3726. * @param x defines viewport left coordinate
  3727. * @param y defines viewport top coordinate
  3728. * @param width defines the viewport width
  3729. * @param height defines the viewport height
  3730. */
  3731. constructor(
  3732. /** viewport left coordinate */
  3733. x: number,
  3734. /** viewport top coordinate */
  3735. y: number,
  3736. /**viewport width */
  3737. width: number,
  3738. /** viewport height */
  3739. height: number);
  3740. /**
  3741. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3742. * @param renderWidth defines the rendering width
  3743. * @param renderHeight defines the rendering height
  3744. * @returns a new Viewport
  3745. */
  3746. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3747. /**
  3748. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3749. * @param renderWidth defines the rendering width
  3750. * @param renderHeight defines the rendering height
  3751. * @param ref defines the target viewport
  3752. * @returns the current viewport
  3753. */
  3754. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3755. /**
  3756. * Returns a new Viewport copied from the current one
  3757. * @returns a new Viewport
  3758. */
  3759. clone(): Viewport;
  3760. }
  3761. /**
  3762. * Reprasents a camera frustum
  3763. */
  3764. export class Frustum {
  3765. /**
  3766. * Gets the planes representing the frustum
  3767. * @param transform matrix to be applied to the returned planes
  3768. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3769. */
  3770. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3771. /**
  3772. * Gets the near frustum plane transformed by the transform matrix
  3773. * @param transform transformation matrix to be applied to the resulting frustum plane
  3774. * @param frustumPlane the resuling frustum plane
  3775. */
  3776. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3777. /**
  3778. * Gets the far frustum plane transformed by the transform matrix
  3779. * @param transform transformation matrix to be applied to the resulting frustum plane
  3780. * @param frustumPlane the resuling frustum plane
  3781. */
  3782. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3783. /**
  3784. * Gets the left frustum plane transformed by the transform matrix
  3785. * @param transform transformation matrix to be applied to the resulting frustum plane
  3786. * @param frustumPlane the resuling frustum plane
  3787. */
  3788. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3789. /**
  3790. * Gets the right frustum plane transformed by the transform matrix
  3791. * @param transform transformation matrix to be applied to the resulting frustum plane
  3792. * @param frustumPlane the resuling frustum plane
  3793. */
  3794. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3795. /**
  3796. * Gets the top frustum plane transformed by the transform matrix
  3797. * @param transform transformation matrix to be applied to the resulting frustum plane
  3798. * @param frustumPlane the resuling frustum plane
  3799. */
  3800. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3801. /**
  3802. * Gets the bottom frustum plane transformed by the transform matrix
  3803. * @param transform transformation matrix to be applied to the resulting frustum plane
  3804. * @param frustumPlane the resuling frustum plane
  3805. */
  3806. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3807. /**
  3808. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3809. * @param transform transformation matrix to be applied to the resulting frustum planes
  3810. * @param frustumPlanes the resuling frustum planes
  3811. */
  3812. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3813. }
  3814. /** Defines supported spaces */
  3815. export enum Space {
  3816. /** Local (object) space */
  3817. LOCAL = 0,
  3818. /** World space */
  3819. WORLD = 1,
  3820. /** Bone space */
  3821. BONE = 2
  3822. }
  3823. /** Defines the 3 main axes */
  3824. export class Axis {
  3825. /** X axis */
  3826. static X: Vector3;
  3827. /** Y axis */
  3828. static Y: Vector3;
  3829. /** Z axis */
  3830. static Z: Vector3;
  3831. }
  3832. /** Class used to represent a Bezier curve */
  3833. export class BezierCurve {
  3834. /**
  3835. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3836. * @param t defines the time
  3837. * @param x1 defines the left coordinate on X axis
  3838. * @param y1 defines the left coordinate on Y axis
  3839. * @param x2 defines the right coordinate on X axis
  3840. * @param y2 defines the right coordinate on Y axis
  3841. * @returns the interpolated value
  3842. */
  3843. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3844. }
  3845. /**
  3846. * Defines potential orientation for back face culling
  3847. */
  3848. export enum Orientation {
  3849. /**
  3850. * Clockwise
  3851. */
  3852. CW = 0,
  3853. /** Counter clockwise */
  3854. CCW = 1
  3855. }
  3856. /**
  3857. * Defines angle representation
  3858. */
  3859. export class Angle {
  3860. private _radians;
  3861. /**
  3862. * Creates an Angle object of "radians" radians (float).
  3863. * @param radians the angle in radians
  3864. */
  3865. constructor(radians: number);
  3866. /**
  3867. * Get value in degrees
  3868. * @returns the Angle value in degrees (float)
  3869. */
  3870. degrees(): number;
  3871. /**
  3872. * Get value in radians
  3873. * @returns the Angle value in radians (float)
  3874. */
  3875. radians(): number;
  3876. /**
  3877. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3878. * @param a defines first vector
  3879. * @param b defines second vector
  3880. * @returns a new Angle
  3881. */
  3882. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3883. /**
  3884. * Gets a new Angle object from the given float in radians
  3885. * @param radians defines the angle value in radians
  3886. * @returns a new Angle
  3887. */
  3888. static FromRadians(radians: number): Angle;
  3889. /**
  3890. * Gets a new Angle object from the given float in degrees
  3891. * @param degrees defines the angle value in degrees
  3892. * @returns a new Angle
  3893. */
  3894. static FromDegrees(degrees: number): Angle;
  3895. }
  3896. /**
  3897. * This represents an arc in a 2d space.
  3898. */
  3899. export class Arc2 {
  3900. /** Defines the start point of the arc */
  3901. startPoint: Vector2;
  3902. /** Defines the mid point of the arc */
  3903. midPoint: Vector2;
  3904. /** Defines the end point of the arc */
  3905. endPoint: Vector2;
  3906. /**
  3907. * Defines the center point of the arc.
  3908. */
  3909. centerPoint: Vector2;
  3910. /**
  3911. * Defines the radius of the arc.
  3912. */
  3913. radius: number;
  3914. /**
  3915. * Defines the angle of the arc (from mid point to end point).
  3916. */
  3917. angle: Angle;
  3918. /**
  3919. * Defines the start angle of the arc (from start point to middle point).
  3920. */
  3921. startAngle: Angle;
  3922. /**
  3923. * Defines the orientation of the arc (clock wise/counter clock wise).
  3924. */
  3925. orientation: Orientation;
  3926. /**
  3927. * Creates an Arc object from the three given points : start, middle and end.
  3928. * @param startPoint Defines the start point of the arc
  3929. * @param midPoint Defines the midlle point of the arc
  3930. * @param endPoint Defines the end point of the arc
  3931. */
  3932. constructor(
  3933. /** Defines the start point of the arc */
  3934. startPoint: Vector2,
  3935. /** Defines the mid point of the arc */
  3936. midPoint: Vector2,
  3937. /** Defines the end point of the arc */
  3938. endPoint: Vector2);
  3939. }
  3940. /**
  3941. * Represents a 2D path made up of multiple 2D points
  3942. */
  3943. export class Path2 {
  3944. private _points;
  3945. private _length;
  3946. /**
  3947. * If the path start and end point are the same
  3948. */
  3949. closed: boolean;
  3950. /**
  3951. * Creates a Path2 object from the starting 2D coordinates x and y.
  3952. * @param x the starting points x value
  3953. * @param y the starting points y value
  3954. */
  3955. constructor(x: number, y: number);
  3956. /**
  3957. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3958. * @param x the added points x value
  3959. * @param y the added points y value
  3960. * @returns the updated Path2.
  3961. */
  3962. addLineTo(x: number, y: number): Path2;
  3963. /**
  3964. * 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.
  3965. * @param midX middle point x value
  3966. * @param midY middle point y value
  3967. * @param endX end point x value
  3968. * @param endY end point y value
  3969. * @param numberOfSegments (default: 36)
  3970. * @returns the updated Path2.
  3971. */
  3972. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3973. /**
  3974. * Closes the Path2.
  3975. * @returns the Path2.
  3976. */
  3977. close(): Path2;
  3978. /**
  3979. * Gets the sum of the distance between each sequential point in the path
  3980. * @returns the Path2 total length (float).
  3981. */
  3982. length(): number;
  3983. /**
  3984. * Gets the points which construct the path
  3985. * @returns the Path2 internal array of points.
  3986. */
  3987. getPoints(): Vector2[];
  3988. /**
  3989. * Retreives the point at the distance aways from the starting point
  3990. * @param normalizedLengthPosition the length along the path to retreive the point from
  3991. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3992. */
  3993. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3994. /**
  3995. * Creates a new path starting from an x and y position
  3996. * @param x starting x value
  3997. * @param y starting y value
  3998. * @returns a new Path2 starting at the coordinates (x, y).
  3999. */
  4000. static StartingAt(x: number, y: number): Path2;
  4001. }
  4002. /**
  4003. * Represents a 3D path made up of multiple 3D points
  4004. */
  4005. export class Path3D {
  4006. /**
  4007. * an array of Vector3, the curve axis of the Path3D
  4008. */
  4009. path: Vector3[];
  4010. private _curve;
  4011. private _distances;
  4012. private _tangents;
  4013. private _normals;
  4014. private _binormals;
  4015. private _raw;
  4016. /**
  4017. * new Path3D(path, normal, raw)
  4018. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4019. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4020. * @param path an array of Vector3, the curve axis of the Path3D
  4021. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4022. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4023. */
  4024. constructor(
  4025. /**
  4026. * an array of Vector3, the curve axis of the Path3D
  4027. */
  4028. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4029. /**
  4030. * Returns the Path3D array of successive Vector3 designing its curve.
  4031. * @returns the Path3D array of successive Vector3 designing its curve.
  4032. */
  4033. getCurve(): Vector3[];
  4034. /**
  4035. * Returns an array populated with tangent vectors on each Path3D curve point.
  4036. * @returns an array populated with tangent vectors on each Path3D curve point.
  4037. */
  4038. getTangents(): Vector3[];
  4039. /**
  4040. * Returns an array populated with normal vectors on each Path3D curve point.
  4041. * @returns an array populated with normal vectors on each Path3D curve point.
  4042. */
  4043. getNormals(): Vector3[];
  4044. /**
  4045. * Returns an array populated with binormal vectors on each Path3D curve point.
  4046. * @returns an array populated with binormal vectors on each Path3D curve point.
  4047. */
  4048. getBinormals(): Vector3[];
  4049. /**
  4050. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4051. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4052. */
  4053. getDistances(): number[];
  4054. /**
  4055. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4056. * @param path path which all values are copied into the curves points
  4057. * @param firstNormal which should be projected onto the curve
  4058. * @returns the same object updated.
  4059. */
  4060. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4061. private _compute;
  4062. private _getFirstNonNullVector;
  4063. private _getLastNonNullVector;
  4064. private _normalVector;
  4065. }
  4066. /**
  4067. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4068. * A Curve3 is designed from a series of successive Vector3.
  4069. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4070. */
  4071. export class Curve3 {
  4072. private _points;
  4073. private _length;
  4074. /**
  4075. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4076. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4077. * @param v1 (Vector3) the control point
  4078. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4079. * @param nbPoints (integer) the wanted number of points in the curve
  4080. * @returns the created Curve3
  4081. */
  4082. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4083. /**
  4084. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4085. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4086. * @param v1 (Vector3) the first control point
  4087. * @param v2 (Vector3) the second control point
  4088. * @param v3 (Vector3) the end point of the Cubic Bezier
  4089. * @param nbPoints (integer) the wanted number of points in the curve
  4090. * @returns the created Curve3
  4091. */
  4092. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4093. /**
  4094. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4095. * @param p1 (Vector3) the origin point of the Hermite Spline
  4096. * @param t1 (Vector3) the tangent vector at the origin point
  4097. * @param p2 (Vector3) the end point of the Hermite Spline
  4098. * @param t2 (Vector3) the tangent vector at the end point
  4099. * @param nbPoints (integer) the wanted number of points in the curve
  4100. * @returns the created Curve3
  4101. */
  4102. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4103. /**
  4104. * Returns a Curve3 object along a CatmullRom Spline curve :
  4105. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4106. * @param nbPoints (integer) the wanted number of points between each curve control points
  4107. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4108. * @returns the created Curve3
  4109. */
  4110. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4111. /**
  4112. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4113. * A Curve3 is designed from a series of successive Vector3.
  4114. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4115. * @param points points which make up the curve
  4116. */
  4117. constructor(points: Vector3[]);
  4118. /**
  4119. * @returns the Curve3 stored array of successive Vector3
  4120. */
  4121. getPoints(): Vector3[];
  4122. /**
  4123. * @returns the computed length (float) of the curve.
  4124. */
  4125. length(): number;
  4126. /**
  4127. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4128. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4129. * curveA and curveB keep unchanged.
  4130. * @param curve the curve to continue from this curve
  4131. * @returns the newly constructed curve
  4132. */
  4133. continue(curve: DeepImmutable<Curve3>): Curve3;
  4134. private _computeLength;
  4135. }
  4136. /**
  4137. * Contains position and normal vectors for a vertex
  4138. */
  4139. export class PositionNormalVertex {
  4140. /** the position of the vertex (defaut: 0,0,0) */
  4141. position: Vector3;
  4142. /** the normal of the vertex (defaut: 0,1,0) */
  4143. normal: Vector3;
  4144. /**
  4145. * Creates a PositionNormalVertex
  4146. * @param position the position of the vertex (defaut: 0,0,0)
  4147. * @param normal the normal of the vertex (defaut: 0,1,0)
  4148. */
  4149. constructor(
  4150. /** the position of the vertex (defaut: 0,0,0) */
  4151. position?: Vector3,
  4152. /** the normal of the vertex (defaut: 0,1,0) */
  4153. normal?: Vector3);
  4154. /**
  4155. * Clones the PositionNormalVertex
  4156. * @returns the cloned PositionNormalVertex
  4157. */
  4158. clone(): PositionNormalVertex;
  4159. }
  4160. /**
  4161. * Contains position, normal and uv vectors for a vertex
  4162. */
  4163. export class PositionNormalTextureVertex {
  4164. /** the position of the vertex (defaut: 0,0,0) */
  4165. position: Vector3;
  4166. /** the normal of the vertex (defaut: 0,1,0) */
  4167. normal: Vector3;
  4168. /** the uv of the vertex (default: 0,0) */
  4169. uv: Vector2;
  4170. /**
  4171. * Creates a PositionNormalTextureVertex
  4172. * @param position the position of the vertex (defaut: 0,0,0)
  4173. * @param normal the normal of the vertex (defaut: 0,1,0)
  4174. * @param uv the uv of the vertex (default: 0,0)
  4175. */
  4176. constructor(
  4177. /** the position of the vertex (defaut: 0,0,0) */
  4178. position?: Vector3,
  4179. /** the normal of the vertex (defaut: 0,1,0) */
  4180. normal?: Vector3,
  4181. /** the uv of the vertex (default: 0,0) */
  4182. uv?: Vector2);
  4183. /**
  4184. * Clones the PositionNormalTextureVertex
  4185. * @returns the cloned PositionNormalTextureVertex
  4186. */
  4187. clone(): PositionNormalTextureVertex;
  4188. }
  4189. /**
  4190. * @hidden
  4191. */
  4192. export class Tmp {
  4193. static Color3: Color3[];
  4194. static Color4: Color4[];
  4195. static Vector2: Vector2[];
  4196. static Vector3: Vector3[];
  4197. static Vector4: Vector4[];
  4198. static Quaternion: Quaternion[];
  4199. static Matrix: Matrix[];
  4200. }
  4201. }
  4202. declare module "babylonjs/Offline/IOfflineProvider" {
  4203. /**
  4204. * Class used to enable access to offline support
  4205. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4206. */
  4207. export interface IOfflineProvider {
  4208. /**
  4209. * Gets a boolean indicating if scene must be saved in the database
  4210. */
  4211. enableSceneOffline: boolean;
  4212. /**
  4213. * Gets a boolean indicating if textures must be saved in the database
  4214. */
  4215. enableTexturesOffline: boolean;
  4216. /**
  4217. * Open the offline support and make it available
  4218. * @param successCallback defines the callback to call on success
  4219. * @param errorCallback defines the callback to call on error
  4220. */
  4221. open(successCallback: () => void, errorCallback: () => void): void;
  4222. /**
  4223. * Loads an image from the offline support
  4224. * @param url defines the url to load from
  4225. * @param image defines the target DOM image
  4226. */
  4227. loadImage(url: string, image: HTMLImageElement): void;
  4228. /**
  4229. * Loads a file from offline support
  4230. * @param url defines the URL to load from
  4231. * @param sceneLoaded defines a callback to call on success
  4232. * @param progressCallBack defines a callback to call when progress changed
  4233. * @param errorCallback defines a callback to call on error
  4234. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4235. */
  4236. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4237. }
  4238. }
  4239. declare module "babylonjs/Misc/observable" {
  4240. import { Nullable } from "babylonjs/types";
  4241. /**
  4242. * A class serves as a medium between the observable and its observers
  4243. */
  4244. export class EventState {
  4245. /**
  4246. * Create a new EventState
  4247. * @param mask defines the mask associated with this state
  4248. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4249. * @param target defines the original target of the state
  4250. * @param currentTarget defines the current target of the state
  4251. */
  4252. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4253. /**
  4254. * Initialize the current event state
  4255. * @param mask defines the mask associated with this state
  4256. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4257. * @param target defines the original target of the state
  4258. * @param currentTarget defines the current target of the state
  4259. * @returns the current event state
  4260. */
  4261. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4262. /**
  4263. * An Observer can set this property to true to prevent subsequent observers of being notified
  4264. */
  4265. skipNextObservers: boolean;
  4266. /**
  4267. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4268. */
  4269. mask: number;
  4270. /**
  4271. * The object that originally notified the event
  4272. */
  4273. target?: any;
  4274. /**
  4275. * The current object in the bubbling phase
  4276. */
  4277. currentTarget?: any;
  4278. /**
  4279. * This will be populated with the return value of the last function that was executed.
  4280. * If it is the first function in the callback chain it will be the event data.
  4281. */
  4282. lastReturnValue?: any;
  4283. }
  4284. /**
  4285. * Represent an Observer registered to a given Observable object.
  4286. */
  4287. export class Observer<T> {
  4288. /**
  4289. * Defines the callback to call when the observer is notified
  4290. */
  4291. callback: (eventData: T, eventState: EventState) => void;
  4292. /**
  4293. * Defines the mask of the observer (used to filter notifications)
  4294. */
  4295. mask: number;
  4296. /**
  4297. * Defines the current scope used to restore the JS context
  4298. */
  4299. scope: any;
  4300. /** @hidden */
  4301. _willBeUnregistered: boolean;
  4302. /**
  4303. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4304. */
  4305. unregisterOnNextCall: boolean;
  4306. /**
  4307. * Creates a new observer
  4308. * @param callback defines the callback to call when the observer is notified
  4309. * @param mask defines the mask of the observer (used to filter notifications)
  4310. * @param scope defines the current scope used to restore the JS context
  4311. */
  4312. constructor(
  4313. /**
  4314. * Defines the callback to call when the observer is notified
  4315. */
  4316. callback: (eventData: T, eventState: EventState) => void,
  4317. /**
  4318. * Defines the mask of the observer (used to filter notifications)
  4319. */
  4320. mask: number,
  4321. /**
  4322. * Defines the current scope used to restore the JS context
  4323. */
  4324. scope?: any);
  4325. }
  4326. /**
  4327. * Represent a list of observers registered to multiple Observables object.
  4328. */
  4329. export class MultiObserver<T> {
  4330. private _observers;
  4331. private _observables;
  4332. /**
  4333. * Release associated resources
  4334. */
  4335. dispose(): void;
  4336. /**
  4337. * Raise a callback when one of the observable will notify
  4338. * @param observables defines a list of observables to watch
  4339. * @param callback defines the callback to call on notification
  4340. * @param mask defines the mask used to filter notifications
  4341. * @param scope defines the current scope used to restore the JS context
  4342. * @returns the new MultiObserver
  4343. */
  4344. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4345. }
  4346. /**
  4347. * The Observable class is a simple implementation of the Observable pattern.
  4348. *
  4349. * 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.
  4350. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4351. * 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).
  4352. * 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.
  4353. */
  4354. export class Observable<T> {
  4355. private _observers;
  4356. private _eventState;
  4357. private _onObserverAdded;
  4358. /**
  4359. * Creates a new observable
  4360. * @param onObserverAdded defines a callback to call when a new observer is added
  4361. */
  4362. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4363. /**
  4364. * Create a new Observer with the specified callback
  4365. * @param callback the callback that will be executed for that Observer
  4366. * @param mask the mask used to filter observers
  4367. * @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.
  4368. * @param scope optional scope for the callback to be called from
  4369. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4370. * @returns the new observer created for the callback
  4371. */
  4372. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4373. /**
  4374. * Create a new Observer with the specified callback and unregisters after the next notification
  4375. * @param callback the callback that will be executed for that Observer
  4376. * @returns the new observer created for the callback
  4377. */
  4378. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4379. /**
  4380. * Remove an Observer from the Observable object
  4381. * @param observer the instance of the Observer to remove
  4382. * @returns false if it doesn't belong to this Observable
  4383. */
  4384. remove(observer: Nullable<Observer<T>>): boolean;
  4385. /**
  4386. * Remove a callback from the Observable object
  4387. * @param callback the callback to remove
  4388. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4389. * @returns false if it doesn't belong to this Observable
  4390. */
  4391. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4392. private _deferUnregister;
  4393. private _remove;
  4394. /**
  4395. * Moves the observable to the top of the observer list making it get called first when notified
  4396. * @param observer the observer to move
  4397. */
  4398. makeObserverTopPriority(observer: Observer<T>): void;
  4399. /**
  4400. * Moves the observable to the bottom of the observer list making it get called last when notified
  4401. * @param observer the observer to move
  4402. */
  4403. makeObserverBottomPriority(observer: Observer<T>): void;
  4404. /**
  4405. * Notify all Observers by calling their respective callback with the given data
  4406. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4407. * @param eventData defines the data to send to all observers
  4408. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4409. * @param target defines the original target of the state
  4410. * @param currentTarget defines the current target of the state
  4411. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4412. */
  4413. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4414. /**
  4415. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4416. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4417. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4418. * and it is crucial that all callbacks will be executed.
  4419. * The order of the callbacks is kept, callbacks are not executed parallel.
  4420. *
  4421. * @param eventData The data to be sent to each callback
  4422. * @param mask is used to filter observers defaults to -1
  4423. * @param target defines the callback target (see EventState)
  4424. * @param currentTarget defines he current object in the bubbling phase
  4425. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4426. */
  4427. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4428. /**
  4429. * Notify a specific observer
  4430. * @param observer defines the observer to notify
  4431. * @param eventData defines the data to be sent to each callback
  4432. * @param mask is used to filter observers defaults to -1
  4433. */
  4434. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4435. /**
  4436. * Gets a boolean indicating if the observable has at least one observer
  4437. * @returns true is the Observable has at least one Observer registered
  4438. */
  4439. hasObservers(): boolean;
  4440. /**
  4441. * Clear the list of observers
  4442. */
  4443. clear(): void;
  4444. /**
  4445. * Clone the current observable
  4446. * @returns a new observable
  4447. */
  4448. clone(): Observable<T>;
  4449. /**
  4450. * Does this observable handles observer registered with a given mask
  4451. * @param mask defines the mask to be tested
  4452. * @return whether or not one observer registered with the given mask is handeled
  4453. **/
  4454. hasSpecificMask(mask?: number): boolean;
  4455. }
  4456. }
  4457. declare module "babylonjs/Misc/filesInputStore" {
  4458. /**
  4459. * Class used to help managing file picking and drag'n'drop
  4460. * File Storage
  4461. */
  4462. export class FilesInputStore {
  4463. /**
  4464. * List of files ready to be loaded
  4465. */
  4466. static FilesToLoad: {
  4467. [key: string]: File;
  4468. };
  4469. }
  4470. }
  4471. declare module "babylonjs/Engines/constants" {
  4472. /** Defines the cross module used constants to avoid circular dependncies */
  4473. export class Constants {
  4474. /** Defines that alpha blending is disabled */
  4475. static readonly ALPHA_DISABLE: number;
  4476. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4477. static readonly ALPHA_ADD: number;
  4478. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4479. static readonly ALPHA_COMBINE: number;
  4480. /** Defines that alpha blending to DEST - SRC * DEST */
  4481. static readonly ALPHA_SUBTRACT: number;
  4482. /** Defines that alpha blending to SRC * DEST */
  4483. static readonly ALPHA_MULTIPLY: number;
  4484. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4485. static readonly ALPHA_MAXIMIZED: number;
  4486. /** Defines that alpha blending to SRC + DEST */
  4487. static readonly ALPHA_ONEONE: number;
  4488. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4489. static readonly ALPHA_PREMULTIPLIED: number;
  4490. /**
  4491. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4492. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4493. */
  4494. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4495. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4496. static readonly ALPHA_INTERPOLATE: number;
  4497. /**
  4498. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4499. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4500. */
  4501. static readonly ALPHA_SCREENMODE: number;
  4502. /** Defines that the ressource is not delayed*/
  4503. static readonly DELAYLOADSTATE_NONE: number;
  4504. /** Defines that the ressource was successfully delay loaded */
  4505. static readonly DELAYLOADSTATE_LOADED: number;
  4506. /** Defines that the ressource is currently delay loading */
  4507. static readonly DELAYLOADSTATE_LOADING: number;
  4508. /** Defines that the ressource is delayed and has not started loading */
  4509. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4510. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4511. static readonly NEVER: number;
  4512. /** 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 */
  4513. static readonly ALWAYS: number;
  4514. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4515. static readonly LESS: number;
  4516. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4517. static readonly EQUAL: number;
  4518. /** 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 */
  4519. static readonly LEQUAL: number;
  4520. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4521. static readonly GREATER: number;
  4522. /** 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 */
  4523. static readonly GEQUAL: number;
  4524. /** 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 */
  4525. static readonly NOTEQUAL: number;
  4526. /** Passed to stencilOperation to specify that stencil value must be kept */
  4527. static readonly KEEP: number;
  4528. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4529. static readonly REPLACE: number;
  4530. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4531. static readonly INCR: number;
  4532. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4533. static readonly DECR: number;
  4534. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4535. static readonly INVERT: number;
  4536. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4537. static readonly INCR_WRAP: number;
  4538. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4539. static readonly DECR_WRAP: number;
  4540. /** Texture is not repeating outside of 0..1 UVs */
  4541. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4542. /** Texture is repeating outside of 0..1 UVs */
  4543. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4544. /** Texture is repeating and mirrored */
  4545. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4546. /** ALPHA */
  4547. static readonly TEXTUREFORMAT_ALPHA: number;
  4548. /** LUMINANCE */
  4549. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4550. /** LUMINANCE_ALPHA */
  4551. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4552. /** RGB */
  4553. static readonly TEXTUREFORMAT_RGB: number;
  4554. /** RGBA */
  4555. static readonly TEXTUREFORMAT_RGBA: number;
  4556. /** RED */
  4557. static readonly TEXTUREFORMAT_RED: number;
  4558. /** RED (2nd reference) */
  4559. static readonly TEXTUREFORMAT_R: number;
  4560. /** RG */
  4561. static readonly TEXTUREFORMAT_RG: number;
  4562. /** RED_INTEGER */
  4563. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4564. /** RED_INTEGER (2nd reference) */
  4565. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4566. /** RG_INTEGER */
  4567. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4568. /** RGB_INTEGER */
  4569. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4570. /** RGBA_INTEGER */
  4571. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4572. /** UNSIGNED_BYTE */
  4573. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4574. /** UNSIGNED_BYTE (2nd reference) */
  4575. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4576. /** FLOAT */
  4577. static readonly TEXTURETYPE_FLOAT: number;
  4578. /** HALF_FLOAT */
  4579. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4580. /** BYTE */
  4581. static readonly TEXTURETYPE_BYTE: number;
  4582. /** SHORT */
  4583. static readonly TEXTURETYPE_SHORT: number;
  4584. /** UNSIGNED_SHORT */
  4585. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4586. /** INT */
  4587. static readonly TEXTURETYPE_INT: number;
  4588. /** UNSIGNED_INT */
  4589. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4590. /** UNSIGNED_SHORT_4_4_4_4 */
  4591. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4592. /** UNSIGNED_SHORT_5_5_5_1 */
  4593. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4594. /** UNSIGNED_SHORT_5_6_5 */
  4595. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4596. /** UNSIGNED_INT_2_10_10_10_REV */
  4597. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4598. /** UNSIGNED_INT_24_8 */
  4599. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4600. /** UNSIGNED_INT_10F_11F_11F_REV */
  4601. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4602. /** UNSIGNED_INT_5_9_9_9_REV */
  4603. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4604. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4605. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4606. /** nearest is mag = nearest and min = nearest and mip = linear */
  4607. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4608. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4609. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4610. /** Trilinear is mag = linear and min = linear and mip = linear */
  4611. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4612. /** nearest is mag = nearest and min = nearest and mip = linear */
  4613. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4614. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4615. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4616. /** Trilinear is mag = linear and min = linear and mip = linear */
  4617. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4618. /** mag = nearest and min = nearest and mip = nearest */
  4619. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4620. /** mag = nearest and min = linear and mip = nearest */
  4621. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4622. /** mag = nearest and min = linear and mip = linear */
  4623. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4624. /** mag = nearest and min = linear and mip = none */
  4625. static readonly TEXTURE_NEAREST_LINEAR: number;
  4626. /** mag = nearest and min = nearest and mip = none */
  4627. static readonly TEXTURE_NEAREST_NEAREST: number;
  4628. /** mag = linear and min = nearest and mip = nearest */
  4629. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4630. /** mag = linear and min = nearest and mip = linear */
  4631. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4632. /** mag = linear and min = linear and mip = none */
  4633. static readonly TEXTURE_LINEAR_LINEAR: number;
  4634. /** mag = linear and min = nearest and mip = none */
  4635. static readonly TEXTURE_LINEAR_NEAREST: number;
  4636. /** Explicit coordinates mode */
  4637. static readonly TEXTURE_EXPLICIT_MODE: number;
  4638. /** Spherical coordinates mode */
  4639. static readonly TEXTURE_SPHERICAL_MODE: number;
  4640. /** Planar coordinates mode */
  4641. static readonly TEXTURE_PLANAR_MODE: number;
  4642. /** Cubic coordinates mode */
  4643. static readonly TEXTURE_CUBIC_MODE: number;
  4644. /** Projection coordinates mode */
  4645. static readonly TEXTURE_PROJECTION_MODE: number;
  4646. /** Skybox coordinates mode */
  4647. static readonly TEXTURE_SKYBOX_MODE: number;
  4648. /** Inverse Cubic coordinates mode */
  4649. static readonly TEXTURE_INVCUBIC_MODE: number;
  4650. /** Equirectangular coordinates mode */
  4651. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4652. /** Equirectangular Fixed coordinates mode */
  4653. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4654. /** Equirectangular Fixed Mirrored coordinates mode */
  4655. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4656. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4657. static readonly SCALEMODE_FLOOR: number;
  4658. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4659. static readonly SCALEMODE_NEAREST: number;
  4660. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4661. static readonly SCALEMODE_CEILING: number;
  4662. /**
  4663. * The dirty texture flag value
  4664. */
  4665. static readonly MATERIAL_TextureDirtyFlag: number;
  4666. /**
  4667. * The dirty light flag value
  4668. */
  4669. static readonly MATERIAL_LightDirtyFlag: number;
  4670. /**
  4671. * The dirty fresnel flag value
  4672. */
  4673. static readonly MATERIAL_FresnelDirtyFlag: number;
  4674. /**
  4675. * The dirty attribute flag value
  4676. */
  4677. static readonly MATERIAL_AttributesDirtyFlag: number;
  4678. /**
  4679. * The dirty misc flag value
  4680. */
  4681. static readonly MATERIAL_MiscDirtyFlag: number;
  4682. /**
  4683. * The all dirty flag value
  4684. */
  4685. static readonly MATERIAL_AllDirtyFlag: number;
  4686. /**
  4687. * Returns the triangle fill mode
  4688. */
  4689. static readonly MATERIAL_TriangleFillMode: number;
  4690. /**
  4691. * Returns the wireframe mode
  4692. */
  4693. static readonly MATERIAL_WireFrameFillMode: number;
  4694. /**
  4695. * Returns the point fill mode
  4696. */
  4697. static readonly MATERIAL_PointFillMode: number;
  4698. /**
  4699. * Returns the point list draw mode
  4700. */
  4701. static readonly MATERIAL_PointListDrawMode: number;
  4702. /**
  4703. * Returns the line list draw mode
  4704. */
  4705. static readonly MATERIAL_LineListDrawMode: number;
  4706. /**
  4707. * Returns the line loop draw mode
  4708. */
  4709. static readonly MATERIAL_LineLoopDrawMode: number;
  4710. /**
  4711. * Returns the line strip draw mode
  4712. */
  4713. static readonly MATERIAL_LineStripDrawMode: number;
  4714. /**
  4715. * Returns the triangle strip draw mode
  4716. */
  4717. static readonly MATERIAL_TriangleStripDrawMode: number;
  4718. /**
  4719. * Returns the triangle fan draw mode
  4720. */
  4721. static readonly MATERIAL_TriangleFanDrawMode: number;
  4722. /**
  4723. * Stores the clock-wise side orientation
  4724. */
  4725. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4726. /**
  4727. * Stores the counter clock-wise side orientation
  4728. */
  4729. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4730. /**
  4731. * Nothing
  4732. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4733. */
  4734. static readonly ACTION_NothingTrigger: number;
  4735. /**
  4736. * On pick
  4737. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4738. */
  4739. static readonly ACTION_OnPickTrigger: number;
  4740. /**
  4741. * On left pick
  4742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4743. */
  4744. static readonly ACTION_OnLeftPickTrigger: number;
  4745. /**
  4746. * On right pick
  4747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4748. */
  4749. static readonly ACTION_OnRightPickTrigger: number;
  4750. /**
  4751. * On center pick
  4752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4753. */
  4754. static readonly ACTION_OnCenterPickTrigger: number;
  4755. /**
  4756. * On pick down
  4757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4758. */
  4759. static readonly ACTION_OnPickDownTrigger: number;
  4760. /**
  4761. * On double pick
  4762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4763. */
  4764. static readonly ACTION_OnDoublePickTrigger: number;
  4765. /**
  4766. * On pick up
  4767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4768. */
  4769. static readonly ACTION_OnPickUpTrigger: number;
  4770. /**
  4771. * On pick out.
  4772. * This trigger will only be raised if you also declared a OnPickDown
  4773. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4774. */
  4775. static readonly ACTION_OnPickOutTrigger: number;
  4776. /**
  4777. * On long press
  4778. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4779. */
  4780. static readonly ACTION_OnLongPressTrigger: number;
  4781. /**
  4782. * On pointer over
  4783. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4784. */
  4785. static readonly ACTION_OnPointerOverTrigger: number;
  4786. /**
  4787. * On pointer out
  4788. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4789. */
  4790. static readonly ACTION_OnPointerOutTrigger: number;
  4791. /**
  4792. * On every frame
  4793. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4794. */
  4795. static readonly ACTION_OnEveryFrameTrigger: number;
  4796. /**
  4797. * On intersection enter
  4798. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4799. */
  4800. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4801. /**
  4802. * On intersection exit
  4803. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4804. */
  4805. static readonly ACTION_OnIntersectionExitTrigger: number;
  4806. /**
  4807. * On key down
  4808. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4809. */
  4810. static readonly ACTION_OnKeyDownTrigger: number;
  4811. /**
  4812. * On key up
  4813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4814. */
  4815. static readonly ACTION_OnKeyUpTrigger: number;
  4816. /**
  4817. * Billboard mode will only apply to Y axis
  4818. */
  4819. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4820. /**
  4821. * Billboard mode will apply to all axes
  4822. */
  4823. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4824. /**
  4825. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4826. */
  4827. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4828. /**
  4829. * Gets or sets base Assets URL
  4830. */
  4831. static PARTICLES_BaseAssetsUrl: string;
  4832. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4833. * Test order :
  4834. * Is the bounding sphere outside the frustum ?
  4835. * If not, are the bounding box vertices outside the frustum ?
  4836. * It not, then the cullable object is in the frustum.
  4837. */
  4838. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4839. /** Culling strategy : Bounding Sphere Only.
  4840. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4841. * It's also less accurate than the standard because some not visible objects can still be selected.
  4842. * Test : is the bounding sphere outside the frustum ?
  4843. * If not, then the cullable object is in the frustum.
  4844. */
  4845. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4846. /** Culling strategy : Optimistic Inclusion.
  4847. * This in an inclusion test first, then the standard exclusion test.
  4848. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4849. * 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.
  4850. * Anyway, it's as accurate as the standard strategy.
  4851. * Test :
  4852. * Is the cullable object bounding sphere center in the frustum ?
  4853. * If not, apply the default culling strategy.
  4854. */
  4855. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4856. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4857. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4858. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4859. * 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.
  4860. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4861. * Test :
  4862. * Is the cullable object bounding sphere center in the frustum ?
  4863. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4864. */
  4865. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4866. /**
  4867. * No logging while loading
  4868. */
  4869. static readonly SCENELOADER_NO_LOGGING: number;
  4870. /**
  4871. * Minimal logging while loading
  4872. */
  4873. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4874. /**
  4875. * Summary logging while loading
  4876. */
  4877. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4878. /**
  4879. * Detailled logging while loading
  4880. */
  4881. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4882. }
  4883. }
  4884. declare module "babylonjs/Misc/domManagement" {
  4885. /**
  4886. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4887. * Babylon.js
  4888. */
  4889. export class DomManagement {
  4890. /**
  4891. * Checks if the window object exists
  4892. * @returns true if the window object exists
  4893. */
  4894. static IsWindowObjectExist(): boolean;
  4895. /**
  4896. * Extracts text content from a DOM element hierarchy
  4897. * @param element defines the root element
  4898. * @returns a string
  4899. */
  4900. static GetDOMTextContent(element: HTMLElement): string;
  4901. }
  4902. }
  4903. declare module "babylonjs/Misc/logger" {
  4904. /**
  4905. * Logger used througouht the application to allow configuration of
  4906. * the log level required for the messages.
  4907. */
  4908. export class Logger {
  4909. /**
  4910. * No log
  4911. */
  4912. static readonly NoneLogLevel: number;
  4913. /**
  4914. * Only message logs
  4915. */
  4916. static readonly MessageLogLevel: number;
  4917. /**
  4918. * Only warning logs
  4919. */
  4920. static readonly WarningLogLevel: number;
  4921. /**
  4922. * Only error logs
  4923. */
  4924. static readonly ErrorLogLevel: number;
  4925. /**
  4926. * All logs
  4927. */
  4928. static readonly AllLogLevel: number;
  4929. private static _LogCache;
  4930. /**
  4931. * Gets a value indicating the number of loading errors
  4932. * @ignorenaming
  4933. */
  4934. static errorsCount: number;
  4935. /**
  4936. * Callback called when a new log is added
  4937. */
  4938. static OnNewCacheEntry: (entry: string) => void;
  4939. private static _AddLogEntry;
  4940. private static _FormatMessage;
  4941. private static _LogDisabled;
  4942. private static _LogEnabled;
  4943. private static _WarnDisabled;
  4944. private static _WarnEnabled;
  4945. private static _ErrorDisabled;
  4946. private static _ErrorEnabled;
  4947. /**
  4948. * Log a message to the console
  4949. */
  4950. static Log: (message: string) => void;
  4951. /**
  4952. * Write a warning message to the console
  4953. */
  4954. static Warn: (message: string) => void;
  4955. /**
  4956. * Write an error message to the console
  4957. */
  4958. static Error: (message: string) => void;
  4959. /**
  4960. * Gets current log cache (list of logs)
  4961. */
  4962. static readonly LogCache: string;
  4963. /**
  4964. * Clears the log cache
  4965. */
  4966. static ClearLogCache(): void;
  4967. /**
  4968. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4969. */
  4970. static LogLevels: number;
  4971. }
  4972. }
  4973. declare module "babylonjs/Misc/typeStore" {
  4974. /** @hidden */
  4975. export class _TypeStore {
  4976. /** @hidden */
  4977. static RegisteredTypes: {
  4978. [key: string]: Object;
  4979. };
  4980. /** @hidden */
  4981. static GetClass(fqdn: string): any;
  4982. }
  4983. }
  4984. declare module "babylonjs/Misc/deepCopier" {
  4985. /**
  4986. * Class containing a set of static utilities functions for deep copy.
  4987. */
  4988. export class DeepCopier {
  4989. /**
  4990. * Tries to copy an object by duplicating every property
  4991. * @param source defines the source object
  4992. * @param destination defines the target object
  4993. * @param doNotCopyList defines a list of properties to avoid
  4994. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4995. */
  4996. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4997. }
  4998. }
  4999. declare module "babylonjs/Misc/precisionDate" {
  5000. /**
  5001. * Class containing a set of static utilities functions for precision date
  5002. */
  5003. export class PrecisionDate {
  5004. /**
  5005. * Gets either window.performance.now() if supported or Date.now() else
  5006. */
  5007. static readonly Now: number;
  5008. }
  5009. }
  5010. declare module "babylonjs/Misc/devTools" {
  5011. /** @hidden */
  5012. export class _DevTools {
  5013. static WarnImport(name: string): string;
  5014. }
  5015. }
  5016. declare module "babylonjs/Misc/webRequest" {
  5017. /**
  5018. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  5019. */
  5020. export class WebRequest {
  5021. private _xhr;
  5022. /**
  5023. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5024. * i.e. when loading files, where the server/service expects an Authorization header
  5025. */
  5026. static CustomRequestHeaders: {
  5027. [key: string]: string;
  5028. };
  5029. /**
  5030. * Add callback functions in this array to update all the requests before they get sent to the network
  5031. */
  5032. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5033. private _injectCustomRequestHeaders;
  5034. /**
  5035. * Gets or sets a function to be called when loading progress changes
  5036. */
  5037. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5038. /**
  5039. * Returns client's state
  5040. */
  5041. readonly readyState: number;
  5042. /**
  5043. * Returns client's status
  5044. */
  5045. readonly status: number;
  5046. /**
  5047. * Returns client's status as a text
  5048. */
  5049. readonly statusText: string;
  5050. /**
  5051. * Returns client's response
  5052. */
  5053. readonly response: any;
  5054. /**
  5055. * Returns client's response url
  5056. */
  5057. readonly responseURL: string;
  5058. /**
  5059. * Returns client's response as text
  5060. */
  5061. readonly responseText: string;
  5062. /**
  5063. * Gets or sets the expected response type
  5064. */
  5065. responseType: XMLHttpRequestResponseType;
  5066. /** @hidden */
  5067. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5068. /** @hidden */
  5069. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5070. /**
  5071. * Cancels any network activity
  5072. */
  5073. abort(): void;
  5074. /**
  5075. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5076. * @param body defines an optional request body
  5077. */
  5078. send(body?: Document | BodyInit | null): void;
  5079. /**
  5080. * Sets the request method, request URL
  5081. * @param method defines the method to use (GET, POST, etc..)
  5082. * @param url defines the url to connect with
  5083. */
  5084. open(method: string, url: string): void;
  5085. }
  5086. }
  5087. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5088. /**
  5089. * Class used to evalaute queries containing `and` and `or` operators
  5090. */
  5091. export class AndOrNotEvaluator {
  5092. /**
  5093. * Evaluate a query
  5094. * @param query defines the query to evaluate
  5095. * @param evaluateCallback defines the callback used to filter result
  5096. * @returns true if the query matches
  5097. */
  5098. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5099. private static _HandleParenthesisContent;
  5100. private static _SimplifyNegation;
  5101. }
  5102. }
  5103. declare module "babylonjs/Misc/tags" {
  5104. /**
  5105. * Class used to store custom tags
  5106. */
  5107. export class Tags {
  5108. /**
  5109. * Adds support for tags on the given object
  5110. * @param obj defines the object to use
  5111. */
  5112. static EnableFor(obj: any): void;
  5113. /**
  5114. * Removes tags support
  5115. * @param obj defines the object to use
  5116. */
  5117. static DisableFor(obj: any): void;
  5118. /**
  5119. * Gets a boolean indicating if the given object has tags
  5120. * @param obj defines the object to use
  5121. * @returns a boolean
  5122. */
  5123. static HasTags(obj: any): boolean;
  5124. /**
  5125. * Gets the tags available on a given object
  5126. * @param obj defines the object to use
  5127. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5128. * @returns the tags
  5129. */
  5130. static GetTags(obj: any, asString?: boolean): any;
  5131. /**
  5132. * Adds tags to an object
  5133. * @param obj defines the object to use
  5134. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5135. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5136. */
  5137. static AddTagsTo(obj: any, tagsString: string): void;
  5138. /**
  5139. * @hidden
  5140. */
  5141. static _AddTagTo(obj: any, tag: string): void;
  5142. /**
  5143. * Removes specific tags from a specific object
  5144. * @param obj defines the object to use
  5145. * @param tagsString defines the tags to remove
  5146. */
  5147. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5148. /**
  5149. * @hidden
  5150. */
  5151. static _RemoveTagFrom(obj: any, tag: string): void;
  5152. /**
  5153. * Defines if tags hosted on an object match a given query
  5154. * @param obj defines the object to use
  5155. * @param tagsQuery defines the tag query
  5156. * @returns a boolean
  5157. */
  5158. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5159. }
  5160. }
  5161. declare module "babylonjs/Materials/materialDefines" {
  5162. /**
  5163. * Manages the defines for the Material
  5164. */
  5165. export class MaterialDefines {
  5166. /** @hidden */
  5167. protected _keys: string[];
  5168. private _isDirty;
  5169. /** @hidden */
  5170. _renderId: number;
  5171. /** @hidden */
  5172. _areLightsDirty: boolean;
  5173. /** @hidden */
  5174. _areAttributesDirty: boolean;
  5175. /** @hidden */
  5176. _areTexturesDirty: boolean;
  5177. /** @hidden */
  5178. _areFresnelDirty: boolean;
  5179. /** @hidden */
  5180. _areMiscDirty: boolean;
  5181. /** @hidden */
  5182. _areImageProcessingDirty: boolean;
  5183. /** @hidden */
  5184. _normals: boolean;
  5185. /** @hidden */
  5186. _uvs: boolean;
  5187. /** @hidden */
  5188. _needNormals: boolean;
  5189. /** @hidden */
  5190. _needUVs: boolean;
  5191. [id: string]: any;
  5192. /**
  5193. * Specifies if the material needs to be re-calculated
  5194. */
  5195. readonly isDirty: boolean;
  5196. /**
  5197. * Marks the material to indicate that it has been re-calculated
  5198. */
  5199. markAsProcessed(): void;
  5200. /**
  5201. * Marks the material to indicate that it needs to be re-calculated
  5202. */
  5203. markAsUnprocessed(): void;
  5204. /**
  5205. * Marks the material to indicate all of its defines need to be re-calculated
  5206. */
  5207. markAllAsDirty(): void;
  5208. /**
  5209. * Marks the material to indicate that image processing needs to be re-calculated
  5210. */
  5211. markAsImageProcessingDirty(): void;
  5212. /**
  5213. * Marks the material to indicate the lights need to be re-calculated
  5214. */
  5215. markAsLightDirty(): void;
  5216. /**
  5217. * Marks the attribute state as changed
  5218. */
  5219. markAsAttributesDirty(): void;
  5220. /**
  5221. * Marks the texture state as changed
  5222. */
  5223. markAsTexturesDirty(): void;
  5224. /**
  5225. * Marks the fresnel state as changed
  5226. */
  5227. markAsFresnelDirty(): void;
  5228. /**
  5229. * Marks the misc state as changed
  5230. */
  5231. markAsMiscDirty(): void;
  5232. /**
  5233. * Rebuilds the material defines
  5234. */
  5235. rebuild(): void;
  5236. /**
  5237. * Specifies if two material defines are equal
  5238. * @param other - A material define instance to compare to
  5239. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5240. */
  5241. isEqual(other: MaterialDefines): boolean;
  5242. /**
  5243. * Clones this instance's defines to another instance
  5244. * @param other - material defines to clone values to
  5245. */
  5246. cloneTo(other: MaterialDefines): void;
  5247. /**
  5248. * Resets the material define values
  5249. */
  5250. reset(): void;
  5251. /**
  5252. * Converts the material define values to a string
  5253. * @returns - String of material define information
  5254. */
  5255. toString(): string;
  5256. }
  5257. }
  5258. declare module "babylonjs/Engines/IPipelineContext" {
  5259. /**
  5260. * Class used to store and describe the pipeline context associated with an effect
  5261. */
  5262. export interface IPipelineContext {
  5263. /**
  5264. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5265. */
  5266. isAsync: boolean;
  5267. /**
  5268. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5269. */
  5270. isReady: boolean;
  5271. /** @hidden */
  5272. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5273. }
  5274. }
  5275. declare module "babylonjs/Meshes/dataBuffer" {
  5276. /**
  5277. * Class used to store gfx data (like WebGLBuffer)
  5278. */
  5279. export class DataBuffer {
  5280. /**
  5281. * Gets or sets the number of objects referencing this buffer
  5282. */
  5283. references: number;
  5284. /** Gets or sets the size of the underlying buffer */
  5285. capacity: number;
  5286. /**
  5287. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5288. */
  5289. is32Bits: boolean;
  5290. /**
  5291. * Gets the underlying buffer
  5292. */
  5293. readonly underlyingResource: any;
  5294. }
  5295. }
  5296. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  5297. /** @hidden */
  5298. export interface IShaderProcessor {
  5299. attributeProcessor?: (attribute: string) => string;
  5300. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  5301. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5302. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5303. }
  5304. }
  5305. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  5306. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  5307. /** @hidden */
  5308. export interface ProcessingOptions {
  5309. defines: string[];
  5310. indexParameters: any;
  5311. isFragment: boolean;
  5312. shouldUseHighPrecisionShader: boolean;
  5313. supportsUniformBuffers: boolean;
  5314. shadersRepository: string;
  5315. includesShadersStore: {
  5316. [key: string]: string;
  5317. };
  5318. processor?: IShaderProcessor;
  5319. version: string;
  5320. }
  5321. }
  5322. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  5323. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5324. /** @hidden */
  5325. export class ShaderCodeNode {
  5326. line: string;
  5327. children: ShaderCodeNode[];
  5328. additionalDefineKey?: string;
  5329. additionalDefineValue?: string;
  5330. isValid(preprocessors: {
  5331. [key: string]: string;
  5332. }): boolean;
  5333. process(preprocessors: {
  5334. [key: string]: string;
  5335. }, options: ProcessingOptions): string;
  5336. private _lineStartsWith;
  5337. }
  5338. }
  5339. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  5340. /** @hidden */
  5341. export class ShaderCodeCursor {
  5342. private _lines;
  5343. lineIndex: number;
  5344. readonly currentLine: string;
  5345. readonly canRead: boolean;
  5346. lines: string[];
  5347. }
  5348. }
  5349. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  5350. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  5351. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5352. /** @hidden */
  5353. export class ShaderCodeConditionNode extends ShaderCodeNode {
  5354. process(preprocessors: {
  5355. [key: string]: string;
  5356. }, options: ProcessingOptions): string;
  5357. }
  5358. }
  5359. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  5360. /** @hidden */
  5361. export class ShaderDefineExpression {
  5362. isTrue(preprocessors: {
  5363. [key: string]: string;
  5364. }): boolean;
  5365. }
  5366. }
  5367. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  5368. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  5369. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5370. /** @hidden */
  5371. export class ShaderCodeTestNode extends ShaderCodeNode {
  5372. testExpression: ShaderDefineExpression;
  5373. isValid(preprocessors: {
  5374. [key: string]: string;
  5375. }): boolean;
  5376. }
  5377. }
  5378. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  5379. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5380. /** @hidden */
  5381. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  5382. define: string;
  5383. not: boolean;
  5384. constructor(define: string, not?: boolean);
  5385. isTrue(preprocessors: {
  5386. [key: string]: string;
  5387. }): boolean;
  5388. }
  5389. }
  5390. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  5391. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5392. /** @hidden */
  5393. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  5394. leftOperand: ShaderDefineExpression;
  5395. rightOperand: ShaderDefineExpression;
  5396. isTrue(preprocessors: {
  5397. [key: string]: string;
  5398. }): boolean;
  5399. }
  5400. }
  5401. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  5402. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5403. /** @hidden */
  5404. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  5405. leftOperand: ShaderDefineExpression;
  5406. rightOperand: ShaderDefineExpression;
  5407. isTrue(preprocessors: {
  5408. [key: string]: string;
  5409. }): boolean;
  5410. }
  5411. }
  5412. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  5413. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5414. /** @hidden */
  5415. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  5416. define: string;
  5417. operand: string;
  5418. testValue: string;
  5419. constructor(define: string, operand: string, testValue: string);
  5420. isTrue(preprocessors: {
  5421. [key: string]: string;
  5422. }): boolean;
  5423. }
  5424. }
  5425. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  5426. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5427. /** @hidden */
  5428. export class ShaderProcessor {
  5429. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5430. private static _ProcessPrecision;
  5431. private static _ExtractOperation;
  5432. private static _BuildSubExpression;
  5433. private static _BuildExpression;
  5434. private static _MoveCursorWithinIf;
  5435. private static _MoveCursor;
  5436. private static _EvaluatePreProcessors;
  5437. private static _PreparePreProcessors;
  5438. private static _ProcessShaderConversion;
  5439. private static _ProcessIncludes;
  5440. }
  5441. }
  5442. declare module "babylonjs/Misc/performanceMonitor" {
  5443. /**
  5444. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5445. */
  5446. export class PerformanceMonitor {
  5447. private _enabled;
  5448. private _rollingFrameTime;
  5449. private _lastFrameTimeMs;
  5450. /**
  5451. * constructor
  5452. * @param frameSampleSize The number of samples required to saturate the sliding window
  5453. */
  5454. constructor(frameSampleSize?: number);
  5455. /**
  5456. * Samples current frame
  5457. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5458. */
  5459. sampleFrame(timeMs?: number): void;
  5460. /**
  5461. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5462. */
  5463. readonly averageFrameTime: number;
  5464. /**
  5465. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5466. */
  5467. readonly averageFrameTimeVariance: number;
  5468. /**
  5469. * Returns the frame time of the most recent frame
  5470. */
  5471. readonly instantaneousFrameTime: number;
  5472. /**
  5473. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5474. */
  5475. readonly averageFPS: number;
  5476. /**
  5477. * Returns the average framerate in frames per second using the most recent frame time
  5478. */
  5479. readonly instantaneousFPS: number;
  5480. /**
  5481. * Returns true if enough samples have been taken to completely fill the sliding window
  5482. */
  5483. readonly isSaturated: boolean;
  5484. /**
  5485. * Enables contributions to the sliding window sample set
  5486. */
  5487. enable(): void;
  5488. /**
  5489. * Disables contributions to the sliding window sample set
  5490. * Samples will not be interpolated over the disabled period
  5491. */
  5492. disable(): void;
  5493. /**
  5494. * Returns true if sampling is enabled
  5495. */
  5496. readonly isEnabled: boolean;
  5497. /**
  5498. * Resets performance monitor
  5499. */
  5500. reset(): void;
  5501. }
  5502. /**
  5503. * RollingAverage
  5504. *
  5505. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5506. */
  5507. export class RollingAverage {
  5508. /**
  5509. * Current average
  5510. */
  5511. average: number;
  5512. /**
  5513. * Current variance
  5514. */
  5515. variance: number;
  5516. protected _samples: Array<number>;
  5517. protected _sampleCount: number;
  5518. protected _pos: number;
  5519. protected _m2: number;
  5520. /**
  5521. * constructor
  5522. * @param length The number of samples required to saturate the sliding window
  5523. */
  5524. constructor(length: number);
  5525. /**
  5526. * Adds a sample to the sample set
  5527. * @param v The sample value
  5528. */
  5529. add(v: number): void;
  5530. /**
  5531. * Returns previously added values or null if outside of history or outside the sliding window domain
  5532. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5533. * @return Value previously recorded with add() or null if outside of range
  5534. */
  5535. history(i: number): number;
  5536. /**
  5537. * Returns true if enough samples have been taken to completely fill the sliding window
  5538. * @return true if sample-set saturated
  5539. */
  5540. isSaturated(): boolean;
  5541. /**
  5542. * Resets the rolling average (equivalent to 0 samples taken so far)
  5543. */
  5544. reset(): void;
  5545. /**
  5546. * Wraps a value around the sample range boundaries
  5547. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5548. * @return Wrapped position in sample range
  5549. */
  5550. protected _wrapPosition(i: number): number;
  5551. }
  5552. }
  5553. declare module "babylonjs/Misc/stringDictionary" {
  5554. import { Nullable } from "babylonjs/types";
  5555. /**
  5556. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5557. * The underlying implementation relies on an associative array to ensure the best performances.
  5558. * The value can be anything including 'null' but except 'undefined'
  5559. */
  5560. export class StringDictionary<T> {
  5561. /**
  5562. * This will clear this dictionary and copy the content from the 'source' one.
  5563. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5564. * @param source the dictionary to take the content from and copy to this dictionary
  5565. */
  5566. copyFrom(source: StringDictionary<T>): void;
  5567. /**
  5568. * Get a value based from its key
  5569. * @param key the given key to get the matching value from
  5570. * @return the value if found, otherwise undefined is returned
  5571. */
  5572. get(key: string): T | undefined;
  5573. /**
  5574. * Get a value from its key or add it if it doesn't exist.
  5575. * This method will ensure you that a given key/data will be present in the dictionary.
  5576. * @param key the given key to get the matching value from
  5577. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5578. * The factory will only be invoked if there's no data for the given key.
  5579. * @return the value corresponding to the key.
  5580. */
  5581. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5582. /**
  5583. * Get a value from its key if present in the dictionary otherwise add it
  5584. * @param key the key to get the value from
  5585. * @param val if there's no such key/value pair in the dictionary add it with this value
  5586. * @return the value corresponding to the key
  5587. */
  5588. getOrAdd(key: string, val: T): T;
  5589. /**
  5590. * Check if there's a given key in the dictionary
  5591. * @param key the key to check for
  5592. * @return true if the key is present, false otherwise
  5593. */
  5594. contains(key: string): boolean;
  5595. /**
  5596. * Add a new key and its corresponding value
  5597. * @param key the key to add
  5598. * @param value the value corresponding to the key
  5599. * @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
  5600. */
  5601. add(key: string, value: T): boolean;
  5602. /**
  5603. * Update a specific value associated to a key
  5604. * @param key defines the key to use
  5605. * @param value defines the value to store
  5606. * @returns true if the value was updated (or false if the key was not found)
  5607. */
  5608. set(key: string, value: T): boolean;
  5609. /**
  5610. * Get the element of the given key and remove it from the dictionary
  5611. * @param key defines the key to search
  5612. * @returns the value associated with the key or null if not found
  5613. */
  5614. getAndRemove(key: string): Nullable<T>;
  5615. /**
  5616. * Remove a key/value from the dictionary.
  5617. * @param key the key to remove
  5618. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5619. */
  5620. remove(key: string): boolean;
  5621. /**
  5622. * Clear the whole content of the dictionary
  5623. */
  5624. clear(): void;
  5625. /**
  5626. * Gets the current count
  5627. */
  5628. readonly count: number;
  5629. /**
  5630. * Execute a callback on each key/val of the dictionary.
  5631. * Note that you can remove any element in this dictionary in the callback implementation
  5632. * @param callback the callback to execute on a given key/value pair
  5633. */
  5634. forEach(callback: (key: string, val: T) => void): void;
  5635. /**
  5636. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5637. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5638. * Note that you can remove any element in this dictionary in the callback implementation
  5639. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5640. * @returns the first item
  5641. */
  5642. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5643. private _count;
  5644. private _data;
  5645. }
  5646. }
  5647. declare module "babylonjs/Misc/promise" {
  5648. /**
  5649. * Helper class that provides a small promise polyfill
  5650. */
  5651. export class PromisePolyfill {
  5652. /**
  5653. * Static function used to check if the polyfill is required
  5654. * If this is the case then the function will inject the polyfill to window.Promise
  5655. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5656. */
  5657. static Apply(force?: boolean): void;
  5658. }
  5659. }
  5660. declare module "babylonjs/Meshes/buffer" {
  5661. import { Nullable, DataArray } from "babylonjs/types";
  5662. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  5663. /**
  5664. * Class used to store data that will be store in GPU memory
  5665. */
  5666. export class Buffer {
  5667. private _engine;
  5668. private _buffer;
  5669. /** @hidden */
  5670. _data: Nullable<DataArray>;
  5671. private _updatable;
  5672. private _instanced;
  5673. /**
  5674. * Gets the byte stride.
  5675. */
  5676. readonly byteStride: number;
  5677. /**
  5678. * Constructor
  5679. * @param engine the engine
  5680. * @param data the data to use for this buffer
  5681. * @param updatable whether the data is updatable
  5682. * @param stride the stride (optional)
  5683. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5684. * @param instanced whether the buffer is instanced (optional)
  5685. * @param useBytes set to true if the stride in in bytes (optional)
  5686. */
  5687. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5688. /**
  5689. * Create a new VertexBuffer based on the current buffer
  5690. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5691. * @param offset defines offset in the buffer (0 by default)
  5692. * @param size defines the size in floats of attributes (position is 3 for instance)
  5693. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5694. * @param instanced defines if the vertex buffer contains indexed data
  5695. * @param useBytes defines if the offset and stride are in bytes
  5696. * @returns the new vertex buffer
  5697. */
  5698. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5699. /**
  5700. * Gets a boolean indicating if the Buffer is updatable?
  5701. * @returns true if the buffer is updatable
  5702. */
  5703. isUpdatable(): boolean;
  5704. /**
  5705. * Gets current buffer's data
  5706. * @returns a DataArray or null
  5707. */
  5708. getData(): Nullable<DataArray>;
  5709. /**
  5710. * Gets underlying native buffer
  5711. * @returns underlying native buffer
  5712. */
  5713. getBuffer(): Nullable<DataBuffer>;
  5714. /**
  5715. * Gets the stride in float32 units (i.e. byte stride / 4).
  5716. * May not be an integer if the byte stride is not divisible by 4.
  5717. * DEPRECATED. Use byteStride instead.
  5718. * @returns the stride in float32 units
  5719. */
  5720. getStrideSize(): number;
  5721. /**
  5722. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5723. * @param data defines the data to store
  5724. */
  5725. create(data?: Nullable<DataArray>): void;
  5726. /** @hidden */
  5727. _rebuild(): void;
  5728. /**
  5729. * Update current buffer data
  5730. * @param data defines the data to store
  5731. */
  5732. update(data: DataArray): void;
  5733. /**
  5734. * Updates the data directly.
  5735. * @param data the new data
  5736. * @param offset the new offset
  5737. * @param vertexCount the vertex count (optional)
  5738. * @param useBytes set to true if the offset is in bytes
  5739. */
  5740. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5741. /**
  5742. * Release all resources
  5743. */
  5744. dispose(): void;
  5745. }
  5746. /**
  5747. * Specialized buffer used to store vertex data
  5748. */
  5749. export class VertexBuffer {
  5750. /** @hidden */
  5751. _buffer: Buffer;
  5752. private _kind;
  5753. private _size;
  5754. private _ownsBuffer;
  5755. private _instanced;
  5756. private _instanceDivisor;
  5757. /**
  5758. * The byte type.
  5759. */
  5760. static readonly BYTE: number;
  5761. /**
  5762. * The unsigned byte type.
  5763. */
  5764. static readonly UNSIGNED_BYTE: number;
  5765. /**
  5766. * The short type.
  5767. */
  5768. static readonly SHORT: number;
  5769. /**
  5770. * The unsigned short type.
  5771. */
  5772. static readonly UNSIGNED_SHORT: number;
  5773. /**
  5774. * The integer type.
  5775. */
  5776. static readonly INT: number;
  5777. /**
  5778. * The unsigned integer type.
  5779. */
  5780. static readonly UNSIGNED_INT: number;
  5781. /**
  5782. * The float type.
  5783. */
  5784. static readonly FLOAT: number;
  5785. /**
  5786. * Gets or sets the instance divisor when in instanced mode
  5787. */
  5788. instanceDivisor: number;
  5789. /**
  5790. * Gets the byte stride.
  5791. */
  5792. readonly byteStride: number;
  5793. /**
  5794. * Gets the byte offset.
  5795. */
  5796. readonly byteOffset: number;
  5797. /**
  5798. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5799. */
  5800. readonly normalized: boolean;
  5801. /**
  5802. * Gets the data type of each component in the array.
  5803. */
  5804. readonly type: number;
  5805. /**
  5806. * Constructor
  5807. * @param engine the engine
  5808. * @param data the data to use for this vertex buffer
  5809. * @param kind the vertex buffer kind
  5810. * @param updatable whether the data is updatable
  5811. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5812. * @param stride the stride (optional)
  5813. * @param instanced whether the buffer is instanced (optional)
  5814. * @param offset the offset of the data (optional)
  5815. * @param size the number of components (optional)
  5816. * @param type the type of the component (optional)
  5817. * @param normalized whether the data contains normalized data (optional)
  5818. * @param useBytes set to true if stride and offset are in bytes (optional)
  5819. */
  5820. 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);
  5821. /** @hidden */
  5822. _rebuild(): void;
  5823. /**
  5824. * Returns the kind of the VertexBuffer (string)
  5825. * @returns a string
  5826. */
  5827. getKind(): string;
  5828. /**
  5829. * Gets a boolean indicating if the VertexBuffer is updatable?
  5830. * @returns true if the buffer is updatable
  5831. */
  5832. isUpdatable(): boolean;
  5833. /**
  5834. * Gets current buffer's data
  5835. * @returns a DataArray or null
  5836. */
  5837. getData(): Nullable<DataArray>;
  5838. /**
  5839. * Gets underlying native buffer
  5840. * @returns underlying native buffer
  5841. */
  5842. getBuffer(): Nullable<DataBuffer>;
  5843. /**
  5844. * Gets the stride in float32 units (i.e. byte stride / 4).
  5845. * May not be an integer if the byte stride is not divisible by 4.
  5846. * DEPRECATED. Use byteStride instead.
  5847. * @returns the stride in float32 units
  5848. */
  5849. getStrideSize(): number;
  5850. /**
  5851. * Returns the offset as a multiple of the type byte length.
  5852. * DEPRECATED. Use byteOffset instead.
  5853. * @returns the offset in bytes
  5854. */
  5855. getOffset(): number;
  5856. /**
  5857. * Returns the number of components per vertex attribute (integer)
  5858. * @returns the size in float
  5859. */
  5860. getSize(): number;
  5861. /**
  5862. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5863. * @returns true if this buffer is instanced
  5864. */
  5865. getIsInstanced(): boolean;
  5866. /**
  5867. * Returns the instancing divisor, zero for non-instanced (integer).
  5868. * @returns a number
  5869. */
  5870. getInstanceDivisor(): number;
  5871. /**
  5872. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5873. * @param data defines the data to store
  5874. */
  5875. create(data?: DataArray): void;
  5876. /**
  5877. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5878. * This function will create a new buffer if the current one is not updatable
  5879. * @param data defines the data to store
  5880. */
  5881. update(data: DataArray): void;
  5882. /**
  5883. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5884. * Returns the directly updated WebGLBuffer.
  5885. * @param data the new data
  5886. * @param offset the new offset
  5887. * @param useBytes set to true if the offset is in bytes
  5888. */
  5889. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5890. /**
  5891. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5892. */
  5893. dispose(): void;
  5894. /**
  5895. * Enumerates each value of this vertex buffer as numbers.
  5896. * @param count the number of values to enumerate
  5897. * @param callback the callback function called for each value
  5898. */
  5899. forEach(count: number, callback: (value: number, index: number) => void): void;
  5900. /**
  5901. * Positions
  5902. */
  5903. static readonly PositionKind: string;
  5904. /**
  5905. * Normals
  5906. */
  5907. static readonly NormalKind: string;
  5908. /**
  5909. * Tangents
  5910. */
  5911. static readonly TangentKind: string;
  5912. /**
  5913. * Texture coordinates
  5914. */
  5915. static readonly UVKind: string;
  5916. /**
  5917. * Texture coordinates 2
  5918. */
  5919. static readonly UV2Kind: string;
  5920. /**
  5921. * Texture coordinates 3
  5922. */
  5923. static readonly UV3Kind: string;
  5924. /**
  5925. * Texture coordinates 4
  5926. */
  5927. static readonly UV4Kind: string;
  5928. /**
  5929. * Texture coordinates 5
  5930. */
  5931. static readonly UV5Kind: string;
  5932. /**
  5933. * Texture coordinates 6
  5934. */
  5935. static readonly UV6Kind: string;
  5936. /**
  5937. * Colors
  5938. */
  5939. static readonly ColorKind: string;
  5940. /**
  5941. * Matrix indices (for bones)
  5942. */
  5943. static readonly MatricesIndicesKind: string;
  5944. /**
  5945. * Matrix weights (for bones)
  5946. */
  5947. static readonly MatricesWeightsKind: string;
  5948. /**
  5949. * Additional matrix indices (for bones)
  5950. */
  5951. static readonly MatricesIndicesExtraKind: string;
  5952. /**
  5953. * Additional matrix weights (for bones)
  5954. */
  5955. static readonly MatricesWeightsExtraKind: string;
  5956. /**
  5957. * Deduces the stride given a kind.
  5958. * @param kind The kind string to deduce
  5959. * @returns The deduced stride
  5960. */
  5961. static DeduceStride(kind: string): number;
  5962. /**
  5963. * Gets the byte length of the given type.
  5964. * @param type the type
  5965. * @returns the number of bytes
  5966. */
  5967. static GetTypeByteLength(type: number): number;
  5968. /**
  5969. * Enumerates each value of the given parameters as numbers.
  5970. * @param data the data to enumerate
  5971. * @param byteOffset the byte offset of the data
  5972. * @param byteStride the byte stride of the data
  5973. * @param componentCount the number of components per element
  5974. * @param componentType the type of the component
  5975. * @param count the total number of components
  5976. * @param normalized whether the data is normalized
  5977. * @param callback the callback function called for each value
  5978. */
  5979. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5980. private static _GetFloatValue;
  5981. }
  5982. }
  5983. declare module "babylonjs/Maths/sphericalPolynomial" {
  5984. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5985. /**
  5986. * Class representing spherical harmonics coefficients to the 3rd degree
  5987. */
  5988. export class SphericalHarmonics {
  5989. /**
  5990. * Defines whether or not the harmonics have been prescaled for rendering.
  5991. */
  5992. preScaled: boolean;
  5993. /**
  5994. * The l0,0 coefficients of the spherical harmonics
  5995. */
  5996. l00: Vector3;
  5997. /**
  5998. * The l1,-1 coefficients of the spherical harmonics
  5999. */
  6000. l1_1: Vector3;
  6001. /**
  6002. * The l1,0 coefficients of the spherical harmonics
  6003. */
  6004. l10: Vector3;
  6005. /**
  6006. * The l1,1 coefficients of the spherical harmonics
  6007. */
  6008. l11: Vector3;
  6009. /**
  6010. * The l2,-2 coefficients of the spherical harmonics
  6011. */
  6012. l2_2: Vector3;
  6013. /**
  6014. * The l2,-1 coefficients of the spherical harmonics
  6015. */
  6016. l2_1: Vector3;
  6017. /**
  6018. * The l2,0 coefficients of the spherical harmonics
  6019. */
  6020. l20: Vector3;
  6021. /**
  6022. * The l2,1 coefficients of the spherical harmonics
  6023. */
  6024. l21: Vector3;
  6025. /**
  6026. * The l2,2 coefficients of the spherical harmonics
  6027. */
  6028. l22: Vector3;
  6029. /**
  6030. * Adds a light to the spherical harmonics
  6031. * @param direction the direction of the light
  6032. * @param color the color of the light
  6033. * @param deltaSolidAngle the delta solid angle of the light
  6034. */
  6035. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  6036. /**
  6037. * Scales the spherical harmonics by the given amount
  6038. * @param scale the amount to scale
  6039. */
  6040. scaleInPlace(scale: number): void;
  6041. /**
  6042. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  6043. *
  6044. * ```
  6045. * E_lm = A_l * L_lm
  6046. * ```
  6047. *
  6048. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  6049. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  6050. * the scaling factors are given in equation 9.
  6051. */
  6052. convertIncidentRadianceToIrradiance(): void;
  6053. /**
  6054. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  6055. *
  6056. * ```
  6057. * L = (1/pi) * E * rho
  6058. * ```
  6059. *
  6060. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  6061. */
  6062. convertIrradianceToLambertianRadiance(): void;
  6063. /**
  6064. * Integrates the reconstruction coefficients directly in to the SH preventing further
  6065. * required operations at run time.
  6066. *
  6067. * This is simply done by scaling back the SH with Ylm constants parameter.
  6068. * The trigonometric part being applied by the shader at run time.
  6069. */
  6070. preScaleForRendering(): void;
  6071. /**
  6072. * Constructs a spherical harmonics from an array.
  6073. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  6074. * @returns the spherical harmonics
  6075. */
  6076. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  6077. /**
  6078. * Gets the spherical harmonics from polynomial
  6079. * @param polynomial the spherical polynomial
  6080. * @returns the spherical harmonics
  6081. */
  6082. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  6083. }
  6084. /**
  6085. * Class representing spherical polynomial coefficients to the 3rd degree
  6086. */
  6087. export class SphericalPolynomial {
  6088. private _harmonics;
  6089. /**
  6090. * The spherical harmonics used to create the polynomials.
  6091. */
  6092. readonly preScaledHarmonics: SphericalHarmonics;
  6093. /**
  6094. * The x coefficients of the spherical polynomial
  6095. */
  6096. x: Vector3;
  6097. /**
  6098. * The y coefficients of the spherical polynomial
  6099. */
  6100. y: Vector3;
  6101. /**
  6102. * The z coefficients of the spherical polynomial
  6103. */
  6104. z: Vector3;
  6105. /**
  6106. * The xx coefficients of the spherical polynomial
  6107. */
  6108. xx: Vector3;
  6109. /**
  6110. * The yy coefficients of the spherical polynomial
  6111. */
  6112. yy: Vector3;
  6113. /**
  6114. * The zz coefficients of the spherical polynomial
  6115. */
  6116. zz: Vector3;
  6117. /**
  6118. * The xy coefficients of the spherical polynomial
  6119. */
  6120. xy: Vector3;
  6121. /**
  6122. * The yz coefficients of the spherical polynomial
  6123. */
  6124. yz: Vector3;
  6125. /**
  6126. * The zx coefficients of the spherical polynomial
  6127. */
  6128. zx: Vector3;
  6129. /**
  6130. * Adds an ambient color to the spherical polynomial
  6131. * @param color the color to add
  6132. */
  6133. addAmbient(color: Color3): void;
  6134. /**
  6135. * Scales the spherical polynomial by the given amount
  6136. * @param scale the amount to scale
  6137. */
  6138. scaleInPlace(scale: number): void;
  6139. /**
  6140. * Gets the spherical polynomial from harmonics
  6141. * @param harmonics the spherical harmonics
  6142. * @returns the spherical polynomial
  6143. */
  6144. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  6145. /**
  6146. * Constructs a spherical polynomial from an array.
  6147. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  6148. * @returns the spherical polynomial
  6149. */
  6150. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  6151. }
  6152. }
  6153. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  6154. import { Nullable } from "babylonjs/types";
  6155. /**
  6156. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  6157. */
  6158. export interface CubeMapInfo {
  6159. /**
  6160. * The pixel array for the front face.
  6161. * This is stored in format, left to right, up to down format.
  6162. */
  6163. front: Nullable<ArrayBufferView>;
  6164. /**
  6165. * The pixel array for the back face.
  6166. * This is stored in format, left to right, up to down format.
  6167. */
  6168. back: Nullable<ArrayBufferView>;
  6169. /**
  6170. * The pixel array for the left face.
  6171. * This is stored in format, left to right, up to down format.
  6172. */
  6173. left: Nullable<ArrayBufferView>;
  6174. /**
  6175. * The pixel array for the right face.
  6176. * This is stored in format, left to right, up to down format.
  6177. */
  6178. right: Nullable<ArrayBufferView>;
  6179. /**
  6180. * The pixel array for the up face.
  6181. * This is stored in format, left to right, up to down format.
  6182. */
  6183. up: Nullable<ArrayBufferView>;
  6184. /**
  6185. * The pixel array for the down face.
  6186. * This is stored in format, left to right, up to down format.
  6187. */
  6188. down: Nullable<ArrayBufferView>;
  6189. /**
  6190. * The size of the cubemap stored.
  6191. *
  6192. * Each faces will be size * size pixels.
  6193. */
  6194. size: number;
  6195. /**
  6196. * The format of the texture.
  6197. *
  6198. * RGBA, RGB.
  6199. */
  6200. format: number;
  6201. /**
  6202. * The type of the texture data.
  6203. *
  6204. * UNSIGNED_INT, FLOAT.
  6205. */
  6206. type: number;
  6207. /**
  6208. * Specifies whether the texture is in gamma space.
  6209. */
  6210. gammaSpace: boolean;
  6211. }
  6212. /**
  6213. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6214. */
  6215. export class PanoramaToCubeMapTools {
  6216. private static FACE_FRONT;
  6217. private static FACE_BACK;
  6218. private static FACE_RIGHT;
  6219. private static FACE_LEFT;
  6220. private static FACE_DOWN;
  6221. private static FACE_UP;
  6222. /**
  6223. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6224. *
  6225. * @param float32Array The source data.
  6226. * @param inputWidth The width of the input panorama.
  6227. * @param inputHeight The height of the input panorama.
  6228. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6229. * @return The cubemap data
  6230. */
  6231. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6232. private static CreateCubemapTexture;
  6233. private static CalcProjectionSpherical;
  6234. }
  6235. }
  6236. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  6237. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6238. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6239. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  6240. /**
  6241. * Helper class dealing with the extraction of spherical polynomial dataArray
  6242. * from a cube map.
  6243. */
  6244. export class CubeMapToSphericalPolynomialTools {
  6245. private static FileFaces;
  6246. /**
  6247. * Converts a texture to the according Spherical Polynomial data.
  6248. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6249. *
  6250. * @param texture The texture to extract the information from.
  6251. * @return The Spherical Polynomial data.
  6252. */
  6253. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6254. /**
  6255. * Converts a cubemap to the according Spherical Polynomial data.
  6256. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6257. *
  6258. * @param cubeInfo The Cube map to extract the information from.
  6259. * @return The Spherical Polynomial data.
  6260. */
  6261. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6262. }
  6263. }
  6264. declare module "babylonjs/Engines/engineStore" {
  6265. import { Nullable } from "babylonjs/types";
  6266. import { Engine } from "babylonjs/Engines/engine";
  6267. import { Scene } from "babylonjs/scene";
  6268. /**
  6269. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6270. * during the life time of the application.
  6271. */
  6272. export class EngineStore {
  6273. /** Gets the list of created engines */
  6274. static Instances: import("babylonjs/Engines/engine").Engine[];
  6275. /** @hidden */
  6276. static _LastCreatedScene: Nullable<Scene>;
  6277. /**
  6278. * Gets the latest created engine
  6279. */
  6280. static readonly LastCreatedEngine: Nullable<Engine>;
  6281. /**
  6282. * Gets the latest created scene
  6283. */
  6284. static readonly LastCreatedScene: Nullable<Scene>;
  6285. }
  6286. }
  6287. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6288. /**
  6289. * Define options used to create a render target texture
  6290. */
  6291. export class RenderTargetCreationOptions {
  6292. /**
  6293. * Specifies is mipmaps must be generated
  6294. */
  6295. generateMipMaps?: boolean;
  6296. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6297. generateDepthBuffer?: boolean;
  6298. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6299. generateStencilBuffer?: boolean;
  6300. /** Defines texture type (int by default) */
  6301. type?: number;
  6302. /** Defines sampling mode (trilinear by default) */
  6303. samplingMode?: number;
  6304. /** Defines format (RGBA by default) */
  6305. format?: number;
  6306. }
  6307. }
  6308. declare module "babylonjs/States/alphaCullingState" {
  6309. /**
  6310. * @hidden
  6311. **/
  6312. export class _AlphaState {
  6313. private _isAlphaBlendDirty;
  6314. private _isBlendFunctionParametersDirty;
  6315. private _isBlendEquationParametersDirty;
  6316. private _isBlendConstantsDirty;
  6317. private _alphaBlend;
  6318. private _blendFunctionParameters;
  6319. private _blendEquationParameters;
  6320. private _blendConstants;
  6321. /**
  6322. * Initializes the state.
  6323. */
  6324. constructor();
  6325. readonly isDirty: boolean;
  6326. alphaBlend: boolean;
  6327. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6328. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6329. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6330. reset(): void;
  6331. apply(gl: WebGLRenderingContext): void;
  6332. }
  6333. }
  6334. declare module "babylonjs/States/depthCullingState" {
  6335. import { Nullable } from "babylonjs/types";
  6336. /**
  6337. * @hidden
  6338. **/
  6339. export class _DepthCullingState {
  6340. private _isDepthTestDirty;
  6341. private _isDepthMaskDirty;
  6342. private _isDepthFuncDirty;
  6343. private _isCullFaceDirty;
  6344. private _isCullDirty;
  6345. private _isZOffsetDirty;
  6346. private _isFrontFaceDirty;
  6347. private _depthTest;
  6348. private _depthMask;
  6349. private _depthFunc;
  6350. private _cull;
  6351. private _cullFace;
  6352. private _zOffset;
  6353. private _frontFace;
  6354. /**
  6355. * Initializes the state.
  6356. */
  6357. constructor();
  6358. readonly isDirty: boolean;
  6359. zOffset: number;
  6360. cullFace: Nullable<number>;
  6361. cull: Nullable<boolean>;
  6362. depthFunc: Nullable<number>;
  6363. depthMask: boolean;
  6364. depthTest: boolean;
  6365. frontFace: Nullable<number>;
  6366. reset(): void;
  6367. apply(gl: WebGLRenderingContext): void;
  6368. }
  6369. }
  6370. declare module "babylonjs/States/stencilState" {
  6371. /**
  6372. * @hidden
  6373. **/
  6374. export class _StencilState {
  6375. /** 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 */
  6376. static readonly ALWAYS: number;
  6377. /** Passed to stencilOperation to specify that stencil value must be kept */
  6378. static readonly KEEP: number;
  6379. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6380. static readonly REPLACE: number;
  6381. private _isStencilTestDirty;
  6382. private _isStencilMaskDirty;
  6383. private _isStencilFuncDirty;
  6384. private _isStencilOpDirty;
  6385. private _stencilTest;
  6386. private _stencilMask;
  6387. private _stencilFunc;
  6388. private _stencilFuncRef;
  6389. private _stencilFuncMask;
  6390. private _stencilOpStencilFail;
  6391. private _stencilOpDepthFail;
  6392. private _stencilOpStencilDepthPass;
  6393. readonly isDirty: boolean;
  6394. stencilFunc: number;
  6395. stencilFuncRef: number;
  6396. stencilFuncMask: number;
  6397. stencilOpStencilFail: number;
  6398. stencilOpDepthFail: number;
  6399. stencilOpStencilDepthPass: number;
  6400. stencilMask: number;
  6401. stencilTest: boolean;
  6402. constructor();
  6403. reset(): void;
  6404. apply(gl: WebGLRenderingContext): void;
  6405. }
  6406. }
  6407. declare module "babylonjs/States/index" {
  6408. export * from "babylonjs/States/alphaCullingState";
  6409. export * from "babylonjs/States/depthCullingState";
  6410. export * from "babylonjs/States/stencilState";
  6411. }
  6412. declare module "babylonjs/Instrumentation/timeToken" {
  6413. import { Nullable } from "babylonjs/types";
  6414. /**
  6415. * @hidden
  6416. **/
  6417. export class _TimeToken {
  6418. _startTimeQuery: Nullable<WebGLQuery>;
  6419. _endTimeQuery: Nullable<WebGLQuery>;
  6420. _timeElapsedQuery: Nullable<WebGLQuery>;
  6421. _timeElapsedQueryEnded: boolean;
  6422. }
  6423. }
  6424. declare module "babylonjs/Materials/Textures/internalTexture" {
  6425. import { Observable } from "babylonjs/Misc/observable";
  6426. import { Nullable, int } from "babylonjs/types";
  6427. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6428. import { Engine } from "babylonjs/Engines/engine";
  6429. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6430. /**
  6431. * Class used to store data associated with WebGL texture data for the engine
  6432. * This class should not be used directly
  6433. */
  6434. export class InternalTexture {
  6435. /** @hidden */
  6436. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6437. /**
  6438. * The source of the texture data is unknown
  6439. */
  6440. static DATASOURCE_UNKNOWN: number;
  6441. /**
  6442. * Texture data comes from an URL
  6443. */
  6444. static DATASOURCE_URL: number;
  6445. /**
  6446. * Texture data is only used for temporary storage
  6447. */
  6448. static DATASOURCE_TEMP: number;
  6449. /**
  6450. * Texture data comes from raw data (ArrayBuffer)
  6451. */
  6452. static DATASOURCE_RAW: number;
  6453. /**
  6454. * Texture content is dynamic (video or dynamic texture)
  6455. */
  6456. static DATASOURCE_DYNAMIC: number;
  6457. /**
  6458. * Texture content is generated by rendering to it
  6459. */
  6460. static DATASOURCE_RENDERTARGET: number;
  6461. /**
  6462. * Texture content is part of a multi render target process
  6463. */
  6464. static DATASOURCE_MULTIRENDERTARGET: number;
  6465. /**
  6466. * Texture data comes from a cube data file
  6467. */
  6468. static DATASOURCE_CUBE: number;
  6469. /**
  6470. * Texture data comes from a raw cube data
  6471. */
  6472. static DATASOURCE_CUBERAW: number;
  6473. /**
  6474. * Texture data come from a prefiltered cube data file
  6475. */
  6476. static DATASOURCE_CUBEPREFILTERED: number;
  6477. /**
  6478. * Texture content is raw 3D data
  6479. */
  6480. static DATASOURCE_RAW3D: number;
  6481. /**
  6482. * Texture content is a depth texture
  6483. */
  6484. static DATASOURCE_DEPTHTEXTURE: number;
  6485. /**
  6486. * Texture data comes from a raw cube data encoded with RGBD
  6487. */
  6488. static DATASOURCE_CUBERAW_RGBD: number;
  6489. /**
  6490. * Defines if the texture is ready
  6491. */
  6492. isReady: boolean;
  6493. /**
  6494. * Defines if the texture is a cube texture
  6495. */
  6496. isCube: boolean;
  6497. /**
  6498. * Defines if the texture contains 3D data
  6499. */
  6500. is3D: boolean;
  6501. /**
  6502. * Defines if the texture contains multiview data
  6503. */
  6504. isMultiview: boolean;
  6505. /**
  6506. * Gets the URL used to load this texture
  6507. */
  6508. url: string;
  6509. /**
  6510. * Gets the sampling mode of the texture
  6511. */
  6512. samplingMode: number;
  6513. /**
  6514. * Gets a boolean indicating if the texture needs mipmaps generation
  6515. */
  6516. generateMipMaps: boolean;
  6517. /**
  6518. * Gets the number of samples used by the texture (WebGL2+ only)
  6519. */
  6520. samples: number;
  6521. /**
  6522. * Gets the type of the texture (int, float...)
  6523. */
  6524. type: number;
  6525. /**
  6526. * Gets the format of the texture (RGB, RGBA...)
  6527. */
  6528. format: number;
  6529. /**
  6530. * Observable called when the texture is loaded
  6531. */
  6532. onLoadedObservable: Observable<InternalTexture>;
  6533. /**
  6534. * Gets the width of the texture
  6535. */
  6536. width: number;
  6537. /**
  6538. * Gets the height of the texture
  6539. */
  6540. height: number;
  6541. /**
  6542. * Gets the depth of the texture
  6543. */
  6544. depth: number;
  6545. /**
  6546. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6547. */
  6548. baseWidth: number;
  6549. /**
  6550. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6551. */
  6552. baseHeight: number;
  6553. /**
  6554. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6555. */
  6556. baseDepth: number;
  6557. /**
  6558. * Gets a boolean indicating if the texture is inverted on Y axis
  6559. */
  6560. invertY: boolean;
  6561. /** @hidden */
  6562. _invertVScale: boolean;
  6563. /** @hidden */
  6564. _associatedChannel: number;
  6565. /** @hidden */
  6566. _dataSource: number;
  6567. /** @hidden */
  6568. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6569. /** @hidden */
  6570. _bufferView: Nullable<ArrayBufferView>;
  6571. /** @hidden */
  6572. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6573. /** @hidden */
  6574. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6575. /** @hidden */
  6576. _size: number;
  6577. /** @hidden */
  6578. _extension: string;
  6579. /** @hidden */
  6580. _files: Nullable<string[]>;
  6581. /** @hidden */
  6582. _workingCanvas: Nullable<HTMLCanvasElement>;
  6583. /** @hidden */
  6584. _workingContext: Nullable<CanvasRenderingContext2D>;
  6585. /** @hidden */
  6586. _framebuffer: Nullable<WebGLFramebuffer>;
  6587. /** @hidden */
  6588. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6589. /** @hidden */
  6590. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6591. /** @hidden */
  6592. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6593. /** @hidden */
  6594. _attachments: Nullable<number[]>;
  6595. /** @hidden */
  6596. _cachedCoordinatesMode: Nullable<number>;
  6597. /** @hidden */
  6598. _cachedWrapU: Nullable<number>;
  6599. /** @hidden */
  6600. _cachedWrapV: Nullable<number>;
  6601. /** @hidden */
  6602. _cachedWrapR: Nullable<number>;
  6603. /** @hidden */
  6604. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6605. /** @hidden */
  6606. _isDisabled: boolean;
  6607. /** @hidden */
  6608. _compression: Nullable<string>;
  6609. /** @hidden */
  6610. _generateStencilBuffer: boolean;
  6611. /** @hidden */
  6612. _generateDepthBuffer: boolean;
  6613. /** @hidden */
  6614. _comparisonFunction: number;
  6615. /** @hidden */
  6616. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6617. /** @hidden */
  6618. _lodGenerationScale: number;
  6619. /** @hidden */
  6620. _lodGenerationOffset: number;
  6621. /** @hidden */
  6622. _colorTextureArray: Nullable<WebGLTexture>;
  6623. /** @hidden */
  6624. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6625. /** @hidden */
  6626. _lodTextureHigh: Nullable<BaseTexture>;
  6627. /** @hidden */
  6628. _lodTextureMid: Nullable<BaseTexture>;
  6629. /** @hidden */
  6630. _lodTextureLow: Nullable<BaseTexture>;
  6631. /** @hidden */
  6632. _isRGBD: boolean;
  6633. /** @hidden */
  6634. _linearSpecularLOD: boolean;
  6635. /** @hidden */
  6636. _irradianceTexture: Nullable<BaseTexture>;
  6637. /** @hidden */
  6638. _webGLTexture: Nullable<WebGLTexture>;
  6639. /** @hidden */
  6640. _references: number;
  6641. private _engine;
  6642. /**
  6643. * Gets the Engine the texture belongs to.
  6644. * @returns The babylon engine
  6645. */
  6646. getEngine(): Engine;
  6647. /**
  6648. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6649. */
  6650. readonly dataSource: number;
  6651. /**
  6652. * Creates a new InternalTexture
  6653. * @param engine defines the engine to use
  6654. * @param dataSource defines the type of data that will be used
  6655. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6656. */
  6657. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6658. /**
  6659. * Increments the number of references (ie. the number of Texture that point to it)
  6660. */
  6661. incrementReferences(): void;
  6662. /**
  6663. * Change the size of the texture (not the size of the content)
  6664. * @param width defines the new width
  6665. * @param height defines the new height
  6666. * @param depth defines the new depth (1 by default)
  6667. */
  6668. updateSize(width: int, height: int, depth?: int): void;
  6669. /** @hidden */
  6670. _rebuild(): void;
  6671. /** @hidden */
  6672. _swapAndDie(target: InternalTexture): void;
  6673. /**
  6674. * Dispose the current allocated resources
  6675. */
  6676. dispose(): void;
  6677. }
  6678. }
  6679. declare module "babylonjs/Animations/easing" {
  6680. /**
  6681. * This represents the main contract an easing function should follow.
  6682. * Easing functions are used throughout the animation system.
  6683. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6684. */
  6685. export interface IEasingFunction {
  6686. /**
  6687. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6688. * of the easing function.
  6689. * The link below provides some of the most common examples of easing functions.
  6690. * @see https://easings.net/
  6691. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6692. * @returns the corresponding value on the curve defined by the easing function
  6693. */
  6694. ease(gradient: number): number;
  6695. }
  6696. /**
  6697. * Base class used for every default easing function.
  6698. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6699. */
  6700. export class EasingFunction implements IEasingFunction {
  6701. /**
  6702. * Interpolation follows the mathematical formula associated with the easing function.
  6703. */
  6704. static readonly EASINGMODE_EASEIN: number;
  6705. /**
  6706. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6707. */
  6708. static readonly EASINGMODE_EASEOUT: number;
  6709. /**
  6710. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6711. */
  6712. static readonly EASINGMODE_EASEINOUT: number;
  6713. private _easingMode;
  6714. /**
  6715. * Sets the easing mode of the current function.
  6716. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6717. */
  6718. setEasingMode(easingMode: number): void;
  6719. /**
  6720. * Gets the current easing mode.
  6721. * @returns the easing mode
  6722. */
  6723. getEasingMode(): number;
  6724. /**
  6725. * @hidden
  6726. */
  6727. easeInCore(gradient: number): number;
  6728. /**
  6729. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6730. * of the easing function.
  6731. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6732. * @returns the corresponding value on the curve defined by the easing function
  6733. */
  6734. ease(gradient: number): number;
  6735. }
  6736. /**
  6737. * Easing function with a circle shape (see link below).
  6738. * @see https://easings.net/#easeInCirc
  6739. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6740. */
  6741. export class CircleEase extends EasingFunction implements IEasingFunction {
  6742. /** @hidden */
  6743. easeInCore(gradient: number): number;
  6744. }
  6745. /**
  6746. * Easing function with a ease back shape (see link below).
  6747. * @see https://easings.net/#easeInBack
  6748. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6749. */
  6750. export class BackEase extends EasingFunction implements IEasingFunction {
  6751. /** Defines the amplitude of the function */
  6752. amplitude: number;
  6753. /**
  6754. * Instantiates a back ease easing
  6755. * @see https://easings.net/#easeInBack
  6756. * @param amplitude Defines the amplitude of the function
  6757. */
  6758. constructor(
  6759. /** Defines the amplitude of the function */
  6760. amplitude?: number);
  6761. /** @hidden */
  6762. easeInCore(gradient: number): number;
  6763. }
  6764. /**
  6765. * Easing function with a bouncing shape (see link below).
  6766. * @see https://easings.net/#easeInBounce
  6767. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6768. */
  6769. export class BounceEase extends EasingFunction implements IEasingFunction {
  6770. /** Defines the number of bounces */
  6771. bounces: number;
  6772. /** Defines the amplitude of the bounce */
  6773. bounciness: number;
  6774. /**
  6775. * Instantiates a bounce easing
  6776. * @see https://easings.net/#easeInBounce
  6777. * @param bounces Defines the number of bounces
  6778. * @param bounciness Defines the amplitude of the bounce
  6779. */
  6780. constructor(
  6781. /** Defines the number of bounces */
  6782. bounces?: number,
  6783. /** Defines the amplitude of the bounce */
  6784. bounciness?: number);
  6785. /** @hidden */
  6786. easeInCore(gradient: number): number;
  6787. }
  6788. /**
  6789. * Easing function with a power of 3 shape (see link below).
  6790. * @see https://easings.net/#easeInCubic
  6791. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6792. */
  6793. export class CubicEase extends EasingFunction implements IEasingFunction {
  6794. /** @hidden */
  6795. easeInCore(gradient: number): number;
  6796. }
  6797. /**
  6798. * Easing function with an elastic shape (see link below).
  6799. * @see https://easings.net/#easeInElastic
  6800. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6801. */
  6802. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6803. /** Defines the number of oscillations*/
  6804. oscillations: number;
  6805. /** Defines the amplitude of the oscillations*/
  6806. springiness: number;
  6807. /**
  6808. * Instantiates an elastic easing function
  6809. * @see https://easings.net/#easeInElastic
  6810. * @param oscillations Defines the number of oscillations
  6811. * @param springiness Defines the amplitude of the oscillations
  6812. */
  6813. constructor(
  6814. /** Defines the number of oscillations*/
  6815. oscillations?: number,
  6816. /** Defines the amplitude of the oscillations*/
  6817. springiness?: number);
  6818. /** @hidden */
  6819. easeInCore(gradient: number): number;
  6820. }
  6821. /**
  6822. * Easing function with an exponential shape (see link below).
  6823. * @see https://easings.net/#easeInExpo
  6824. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6825. */
  6826. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6827. /** Defines the exponent of the function */
  6828. exponent: number;
  6829. /**
  6830. * Instantiates an exponential easing function
  6831. * @see https://easings.net/#easeInExpo
  6832. * @param exponent Defines the exponent of the function
  6833. */
  6834. constructor(
  6835. /** Defines the exponent of the function */
  6836. exponent?: number);
  6837. /** @hidden */
  6838. easeInCore(gradient: number): number;
  6839. }
  6840. /**
  6841. * Easing function with a power shape (see link below).
  6842. * @see https://easings.net/#easeInQuad
  6843. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6844. */
  6845. export class PowerEase extends EasingFunction implements IEasingFunction {
  6846. /** Defines the power of the function */
  6847. power: number;
  6848. /**
  6849. * Instantiates an power base easing function
  6850. * @see https://easings.net/#easeInQuad
  6851. * @param power Defines the power of the function
  6852. */
  6853. constructor(
  6854. /** Defines the power of the function */
  6855. power?: number);
  6856. /** @hidden */
  6857. easeInCore(gradient: number): number;
  6858. }
  6859. /**
  6860. * Easing function with a power of 2 shape (see link below).
  6861. * @see https://easings.net/#easeInQuad
  6862. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6863. */
  6864. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6865. /** @hidden */
  6866. easeInCore(gradient: number): number;
  6867. }
  6868. /**
  6869. * Easing function with a power of 4 shape (see link below).
  6870. * @see https://easings.net/#easeInQuart
  6871. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6872. */
  6873. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6874. /** @hidden */
  6875. easeInCore(gradient: number): number;
  6876. }
  6877. /**
  6878. * Easing function with a power of 5 shape (see link below).
  6879. * @see https://easings.net/#easeInQuint
  6880. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6881. */
  6882. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6883. /** @hidden */
  6884. easeInCore(gradient: number): number;
  6885. }
  6886. /**
  6887. * Easing function with a sin shape (see link below).
  6888. * @see https://easings.net/#easeInSine
  6889. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6890. */
  6891. export class SineEase extends EasingFunction implements IEasingFunction {
  6892. /** @hidden */
  6893. easeInCore(gradient: number): number;
  6894. }
  6895. /**
  6896. * Easing function with a bezier shape (see link below).
  6897. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6898. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6899. */
  6900. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6901. /** Defines the x component of the start tangent in the bezier curve */
  6902. x1: number;
  6903. /** Defines the y component of the start tangent in the bezier curve */
  6904. y1: number;
  6905. /** Defines the x component of the end tangent in the bezier curve */
  6906. x2: number;
  6907. /** Defines the y component of the end tangent in the bezier curve */
  6908. y2: number;
  6909. /**
  6910. * Instantiates a bezier function
  6911. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6912. * @param x1 Defines the x component of the start tangent in the bezier curve
  6913. * @param y1 Defines the y component of the start tangent in the bezier curve
  6914. * @param x2 Defines the x component of the end tangent in the bezier curve
  6915. * @param y2 Defines the y component of the end tangent in the bezier curve
  6916. */
  6917. constructor(
  6918. /** Defines the x component of the start tangent in the bezier curve */
  6919. x1?: number,
  6920. /** Defines the y component of the start tangent in the bezier curve */
  6921. y1?: number,
  6922. /** Defines the x component of the end tangent in the bezier curve */
  6923. x2?: number,
  6924. /** Defines the y component of the end tangent in the bezier curve */
  6925. y2?: number);
  6926. /** @hidden */
  6927. easeInCore(gradient: number): number;
  6928. }
  6929. }
  6930. declare module "babylonjs/Animations/animationKey" {
  6931. /**
  6932. * Defines an interface which represents an animation key frame
  6933. */
  6934. export interface IAnimationKey {
  6935. /**
  6936. * Frame of the key frame
  6937. */
  6938. frame: number;
  6939. /**
  6940. * Value at the specifies key frame
  6941. */
  6942. value: any;
  6943. /**
  6944. * The input tangent for the cubic hermite spline
  6945. */
  6946. inTangent?: any;
  6947. /**
  6948. * The output tangent for the cubic hermite spline
  6949. */
  6950. outTangent?: any;
  6951. /**
  6952. * The animation interpolation type
  6953. */
  6954. interpolation?: AnimationKeyInterpolation;
  6955. }
  6956. /**
  6957. * Enum for the animation key frame interpolation type
  6958. */
  6959. export enum AnimationKeyInterpolation {
  6960. /**
  6961. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6962. */
  6963. STEP = 1
  6964. }
  6965. }
  6966. declare module "babylonjs/Animations/animationRange" {
  6967. /**
  6968. * Represents the range of an animation
  6969. */
  6970. export class AnimationRange {
  6971. /**The name of the animation range**/
  6972. name: string;
  6973. /**The starting frame of the animation */
  6974. from: number;
  6975. /**The ending frame of the animation*/
  6976. to: number;
  6977. /**
  6978. * Initializes the range of an animation
  6979. * @param name The name of the animation range
  6980. * @param from The starting frame of the animation
  6981. * @param to The ending frame of the animation
  6982. */
  6983. constructor(
  6984. /**The name of the animation range**/
  6985. name: string,
  6986. /**The starting frame of the animation */
  6987. from: number,
  6988. /**The ending frame of the animation*/
  6989. to: number);
  6990. /**
  6991. * Makes a copy of the animation range
  6992. * @returns A copy of the animation range
  6993. */
  6994. clone(): AnimationRange;
  6995. }
  6996. }
  6997. declare module "babylonjs/Animations/animationEvent" {
  6998. /**
  6999. * Composed of a frame, and an action function
  7000. */
  7001. export class AnimationEvent {
  7002. /** The frame for which the event is triggered **/
  7003. frame: number;
  7004. /** The event to perform when triggered **/
  7005. action: (currentFrame: number) => void;
  7006. /** Specifies if the event should be triggered only once**/
  7007. onlyOnce?: boolean | undefined;
  7008. /**
  7009. * Specifies if the animation event is done
  7010. */
  7011. isDone: boolean;
  7012. /**
  7013. * Initializes the animation event
  7014. * @param frame The frame for which the event is triggered
  7015. * @param action The event to perform when triggered
  7016. * @param onlyOnce Specifies if the event should be triggered only once
  7017. */
  7018. constructor(
  7019. /** The frame for which the event is triggered **/
  7020. frame: number,
  7021. /** The event to perform when triggered **/
  7022. action: (currentFrame: number) => void,
  7023. /** Specifies if the event should be triggered only once**/
  7024. onlyOnce?: boolean | undefined);
  7025. /** @hidden */
  7026. _clone(): AnimationEvent;
  7027. }
  7028. }
  7029. declare module "babylonjs/Behaviors/behavior" {
  7030. import { Nullable } from "babylonjs/types";
  7031. /**
  7032. * Interface used to define a behavior
  7033. */
  7034. export interface Behavior<T> {
  7035. /** gets or sets behavior's name */
  7036. name: string;
  7037. /**
  7038. * Function called when the behavior needs to be initialized (after attaching it to a target)
  7039. */
  7040. init(): void;
  7041. /**
  7042. * Called when the behavior is attached to a target
  7043. * @param target defines the target where the behavior is attached to
  7044. */
  7045. attach(target: T): void;
  7046. /**
  7047. * Called when the behavior is detached from its target
  7048. */
  7049. detach(): void;
  7050. }
  7051. /**
  7052. * Interface implemented by classes supporting behaviors
  7053. */
  7054. export interface IBehaviorAware<T> {
  7055. /**
  7056. * Attach a behavior
  7057. * @param behavior defines the behavior to attach
  7058. * @returns the current host
  7059. */
  7060. addBehavior(behavior: Behavior<T>): T;
  7061. /**
  7062. * Remove a behavior from the current object
  7063. * @param behavior defines the behavior to detach
  7064. * @returns the current host
  7065. */
  7066. removeBehavior(behavior: Behavior<T>): T;
  7067. /**
  7068. * Gets a behavior using its name to search
  7069. * @param name defines the name to search
  7070. * @returns the behavior or null if not found
  7071. */
  7072. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  7073. }
  7074. }
  7075. declare module "babylonjs/Collisions/intersectionInfo" {
  7076. import { Nullable } from "babylonjs/types";
  7077. /**
  7078. * @hidden
  7079. */
  7080. export class IntersectionInfo {
  7081. bu: Nullable<number>;
  7082. bv: Nullable<number>;
  7083. distance: number;
  7084. faceId: number;
  7085. subMeshId: number;
  7086. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7087. }
  7088. }
  7089. declare module "babylonjs/Culling/boundingSphere" {
  7090. import { DeepImmutable } from "babylonjs/types";
  7091. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7092. /**
  7093. * Class used to store bounding sphere information
  7094. */
  7095. export class BoundingSphere {
  7096. /**
  7097. * Gets the center of the bounding sphere in local space
  7098. */
  7099. readonly center: Vector3;
  7100. /**
  7101. * Radius of the bounding sphere in local space
  7102. */
  7103. radius: number;
  7104. /**
  7105. * Gets the center of the bounding sphere in world space
  7106. */
  7107. readonly centerWorld: Vector3;
  7108. /**
  7109. * Radius of the bounding sphere in world space
  7110. */
  7111. radiusWorld: number;
  7112. /**
  7113. * Gets the minimum vector in local space
  7114. */
  7115. readonly minimum: Vector3;
  7116. /**
  7117. * Gets the maximum vector in local space
  7118. */
  7119. readonly maximum: Vector3;
  7120. private _worldMatrix;
  7121. private static readonly TmpVector3;
  7122. /**
  7123. * Creates a new bounding sphere
  7124. * @param min defines the minimum vector (in local space)
  7125. * @param max defines the maximum vector (in local space)
  7126. * @param worldMatrix defines the new world matrix
  7127. */
  7128. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7129. /**
  7130. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7131. * @param min defines the new minimum vector (in local space)
  7132. * @param max defines the new maximum vector (in local space)
  7133. * @param worldMatrix defines the new world matrix
  7134. */
  7135. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7136. /**
  7137. * Scale the current bounding sphere by applying a scale factor
  7138. * @param factor defines the scale factor to apply
  7139. * @returns the current bounding box
  7140. */
  7141. scale(factor: number): BoundingSphere;
  7142. /**
  7143. * Gets the world matrix of the bounding box
  7144. * @returns a matrix
  7145. */
  7146. getWorldMatrix(): DeepImmutable<Matrix>;
  7147. /** @hidden */
  7148. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7149. /**
  7150. * Tests if the bounding sphere is intersecting the frustum planes
  7151. * @param frustumPlanes defines the frustum planes to test
  7152. * @returns true if there is an intersection
  7153. */
  7154. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7155. /**
  7156. * Tests if the bounding sphere center is in between the frustum planes.
  7157. * Used for optimistic fast inclusion.
  7158. * @param frustumPlanes defines the frustum planes to test
  7159. * @returns true if the sphere center is in between the frustum planes
  7160. */
  7161. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7162. /**
  7163. * Tests if a point is inside the bounding sphere
  7164. * @param point defines the point to test
  7165. * @returns true if the point is inside the bounding sphere
  7166. */
  7167. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7168. /**
  7169. * Checks if two sphere intersct
  7170. * @param sphere0 sphere 0
  7171. * @param sphere1 sphere 1
  7172. * @returns true if the speres intersect
  7173. */
  7174. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7175. }
  7176. }
  7177. declare module "babylonjs/Culling/boundingBox" {
  7178. import { DeepImmutable } from "babylonjs/types";
  7179. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7180. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7181. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7182. /**
  7183. * Class used to store bounding box information
  7184. */
  7185. export class BoundingBox implements ICullable {
  7186. /**
  7187. * Gets the 8 vectors representing the bounding box in local space
  7188. */
  7189. readonly vectors: Vector3[];
  7190. /**
  7191. * Gets the center of the bounding box in local space
  7192. */
  7193. readonly center: Vector3;
  7194. /**
  7195. * Gets the center of the bounding box in world space
  7196. */
  7197. readonly centerWorld: Vector3;
  7198. /**
  7199. * Gets the extend size in local space
  7200. */
  7201. readonly extendSize: Vector3;
  7202. /**
  7203. * Gets the extend size in world space
  7204. */
  7205. readonly extendSizeWorld: Vector3;
  7206. /**
  7207. * Gets the OBB (object bounding box) directions
  7208. */
  7209. readonly directions: Vector3[];
  7210. /**
  7211. * Gets the 8 vectors representing the bounding box in world space
  7212. */
  7213. readonly vectorsWorld: Vector3[];
  7214. /**
  7215. * Gets the minimum vector in world space
  7216. */
  7217. readonly minimumWorld: Vector3;
  7218. /**
  7219. * Gets the maximum vector in world space
  7220. */
  7221. readonly maximumWorld: Vector3;
  7222. /**
  7223. * Gets the minimum vector in local space
  7224. */
  7225. readonly minimum: Vector3;
  7226. /**
  7227. * Gets the maximum vector in local space
  7228. */
  7229. readonly maximum: Vector3;
  7230. private _worldMatrix;
  7231. private static readonly TmpVector3;
  7232. /**
  7233. * @hidden
  7234. */
  7235. _tag: number;
  7236. /**
  7237. * Creates a new bounding box
  7238. * @param min defines the minimum vector (in local space)
  7239. * @param max defines the maximum vector (in local space)
  7240. * @param worldMatrix defines the new world matrix
  7241. */
  7242. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7243. /**
  7244. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7245. * @param min defines the new minimum vector (in local space)
  7246. * @param max defines the new maximum vector (in local space)
  7247. * @param worldMatrix defines the new world matrix
  7248. */
  7249. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7250. /**
  7251. * Scale the current bounding box by applying a scale factor
  7252. * @param factor defines the scale factor to apply
  7253. * @returns the current bounding box
  7254. */
  7255. scale(factor: number): BoundingBox;
  7256. /**
  7257. * Gets the world matrix of the bounding box
  7258. * @returns a matrix
  7259. */
  7260. getWorldMatrix(): DeepImmutable<Matrix>;
  7261. /** @hidden */
  7262. _update(world: DeepImmutable<Matrix>): void;
  7263. /**
  7264. * Tests if the bounding box is intersecting the frustum planes
  7265. * @param frustumPlanes defines the frustum planes to test
  7266. * @returns true if there is an intersection
  7267. */
  7268. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7269. /**
  7270. * Tests if the bounding box is entirely inside the frustum planes
  7271. * @param frustumPlanes defines the frustum planes to test
  7272. * @returns true if there is an inclusion
  7273. */
  7274. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7275. /**
  7276. * Tests if a point is inside the bounding box
  7277. * @param point defines the point to test
  7278. * @returns true if the point is inside the bounding box
  7279. */
  7280. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7281. /**
  7282. * Tests if the bounding box intersects with a bounding sphere
  7283. * @param sphere defines the sphere to test
  7284. * @returns true if there is an intersection
  7285. */
  7286. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7287. /**
  7288. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7289. * @param min defines the min vector to use
  7290. * @param max defines the max vector to use
  7291. * @returns true if there is an intersection
  7292. */
  7293. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7294. /**
  7295. * Tests if two bounding boxes are intersections
  7296. * @param box0 defines the first box to test
  7297. * @param box1 defines the second box to test
  7298. * @returns true if there is an intersection
  7299. */
  7300. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7301. /**
  7302. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7303. * @param minPoint defines the minimum vector of the bounding box
  7304. * @param maxPoint defines the maximum vector of the bounding box
  7305. * @param sphereCenter defines the sphere center
  7306. * @param sphereRadius defines the sphere radius
  7307. * @returns true if there is an intersection
  7308. */
  7309. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7310. /**
  7311. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7312. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7313. * @param frustumPlanes defines the frustum planes to test
  7314. * @return true if there is an inclusion
  7315. */
  7316. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7317. /**
  7318. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7319. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7320. * @param frustumPlanes defines the frustum planes to test
  7321. * @return true if there is an intersection
  7322. */
  7323. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7324. }
  7325. }
  7326. declare module "babylonjs/Collisions/collider" {
  7327. import { Nullable, IndicesArray } from "babylonjs/types";
  7328. import { Vector3, Plane } from "babylonjs/Maths/math";
  7329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7330. /** @hidden */
  7331. export class Collider {
  7332. /** Define if a collision was found */
  7333. collisionFound: boolean;
  7334. /**
  7335. * Define last intersection point in local space
  7336. */
  7337. intersectionPoint: Vector3;
  7338. /**
  7339. * Define last collided mesh
  7340. */
  7341. collidedMesh: Nullable<AbstractMesh>;
  7342. private _collisionPoint;
  7343. private _planeIntersectionPoint;
  7344. private _tempVector;
  7345. private _tempVector2;
  7346. private _tempVector3;
  7347. private _tempVector4;
  7348. private _edge;
  7349. private _baseToVertex;
  7350. private _destinationPoint;
  7351. private _slidePlaneNormal;
  7352. private _displacementVector;
  7353. /** @hidden */
  7354. _radius: Vector3;
  7355. /** @hidden */
  7356. _retry: number;
  7357. private _velocity;
  7358. private _basePoint;
  7359. private _epsilon;
  7360. /** @hidden */
  7361. _velocityWorldLength: number;
  7362. /** @hidden */
  7363. _basePointWorld: Vector3;
  7364. private _velocityWorld;
  7365. private _normalizedVelocity;
  7366. /** @hidden */
  7367. _initialVelocity: Vector3;
  7368. /** @hidden */
  7369. _initialPosition: Vector3;
  7370. private _nearestDistance;
  7371. private _collisionMask;
  7372. collisionMask: number;
  7373. /**
  7374. * Gets the plane normal used to compute the sliding response (in local space)
  7375. */
  7376. readonly slidePlaneNormal: Vector3;
  7377. /** @hidden */
  7378. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7379. /** @hidden */
  7380. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7381. /** @hidden */
  7382. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7383. /** @hidden */
  7384. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7385. /** @hidden */
  7386. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7387. /** @hidden */
  7388. _getResponse(pos: Vector3, vel: Vector3): void;
  7389. }
  7390. }
  7391. declare module "babylonjs/Culling/boundingInfo" {
  7392. import { DeepImmutable } from "babylonjs/types";
  7393. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7394. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7395. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7396. import { Collider } from "babylonjs/Collisions/collider";
  7397. /**
  7398. * Interface for cullable objects
  7399. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7400. */
  7401. export interface ICullable {
  7402. /**
  7403. * Checks if the object or part of the object is in the frustum
  7404. * @param frustumPlanes Camera near/planes
  7405. * @returns true if the object is in frustum otherwise false
  7406. */
  7407. isInFrustum(frustumPlanes: Plane[]): boolean;
  7408. /**
  7409. * Checks if a cullable object (mesh...) is in the camera frustum
  7410. * Unlike isInFrustum this cheks the full bounding box
  7411. * @param frustumPlanes Camera near/planes
  7412. * @returns true if the object is in frustum otherwise false
  7413. */
  7414. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7415. }
  7416. /**
  7417. * Info for a bounding data of a mesh
  7418. */
  7419. export class BoundingInfo implements ICullable {
  7420. /**
  7421. * Bounding box for the mesh
  7422. */
  7423. readonly boundingBox: BoundingBox;
  7424. /**
  7425. * Bounding sphere for the mesh
  7426. */
  7427. readonly boundingSphere: BoundingSphere;
  7428. private _isLocked;
  7429. private static readonly TmpVector3;
  7430. /**
  7431. * Constructs bounding info
  7432. * @param minimum min vector of the bounding box/sphere
  7433. * @param maximum max vector of the bounding box/sphere
  7434. * @param worldMatrix defines the new world matrix
  7435. */
  7436. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7437. /**
  7438. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7439. * @param min defines the new minimum vector (in local space)
  7440. * @param max defines the new maximum vector (in local space)
  7441. * @param worldMatrix defines the new world matrix
  7442. */
  7443. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7444. /**
  7445. * min vector of the bounding box/sphere
  7446. */
  7447. readonly minimum: Vector3;
  7448. /**
  7449. * max vector of the bounding box/sphere
  7450. */
  7451. readonly maximum: Vector3;
  7452. /**
  7453. * If the info is locked and won't be updated to avoid perf overhead
  7454. */
  7455. isLocked: boolean;
  7456. /**
  7457. * Updates the bounding sphere and box
  7458. * @param world world matrix to be used to update
  7459. */
  7460. update(world: DeepImmutable<Matrix>): void;
  7461. /**
  7462. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7463. * @param center New center of the bounding info
  7464. * @param extend New extend of the bounding info
  7465. * @returns the current bounding info
  7466. */
  7467. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7468. /**
  7469. * Scale the current bounding info by applying a scale factor
  7470. * @param factor defines the scale factor to apply
  7471. * @returns the current bounding info
  7472. */
  7473. scale(factor: number): BoundingInfo;
  7474. /**
  7475. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7476. * @param frustumPlanes defines the frustum to test
  7477. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7478. * @returns true if the bounding info is in the frustum planes
  7479. */
  7480. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7481. /**
  7482. * Gets the world distance between the min and max points of the bounding box
  7483. */
  7484. readonly diagonalLength: number;
  7485. /**
  7486. * Checks if a cullable object (mesh...) is in the camera frustum
  7487. * Unlike isInFrustum this cheks the full bounding box
  7488. * @param frustumPlanes Camera near/planes
  7489. * @returns true if the object is in frustum otherwise false
  7490. */
  7491. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7492. /** @hidden */
  7493. _checkCollision(collider: Collider): boolean;
  7494. /**
  7495. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7496. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7497. * @param point the point to check intersection with
  7498. * @returns if the point intersects
  7499. */
  7500. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7501. /**
  7502. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7503. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7504. * @param boundingInfo the bounding info to check intersection with
  7505. * @param precise if the intersection should be done using OBB
  7506. * @returns if the bounding info intersects
  7507. */
  7508. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7509. }
  7510. }
  7511. declare module "babylonjs/Misc/smartArray" {
  7512. /**
  7513. * Defines an array and its length.
  7514. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7515. */
  7516. export interface ISmartArrayLike<T> {
  7517. /**
  7518. * The data of the array.
  7519. */
  7520. data: Array<T>;
  7521. /**
  7522. * The active length of the array.
  7523. */
  7524. length: number;
  7525. }
  7526. /**
  7527. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7528. */
  7529. export class SmartArray<T> implements ISmartArrayLike<T> {
  7530. /**
  7531. * The full set of data from the array.
  7532. */
  7533. data: Array<T>;
  7534. /**
  7535. * The active length of the array.
  7536. */
  7537. length: number;
  7538. protected _id: number;
  7539. /**
  7540. * Instantiates a Smart Array.
  7541. * @param capacity defines the default capacity of the array.
  7542. */
  7543. constructor(capacity: number);
  7544. /**
  7545. * Pushes a value at the end of the active data.
  7546. * @param value defines the object to push in the array.
  7547. */
  7548. push(value: T): void;
  7549. /**
  7550. * Iterates over the active data and apply the lambda to them.
  7551. * @param func defines the action to apply on each value.
  7552. */
  7553. forEach(func: (content: T) => void): void;
  7554. /**
  7555. * Sorts the full sets of data.
  7556. * @param compareFn defines the comparison function to apply.
  7557. */
  7558. sort(compareFn: (a: T, b: T) => number): void;
  7559. /**
  7560. * Resets the active data to an empty array.
  7561. */
  7562. reset(): void;
  7563. /**
  7564. * Releases all the data from the array as well as the array.
  7565. */
  7566. dispose(): void;
  7567. /**
  7568. * Concats the active data with a given array.
  7569. * @param array defines the data to concatenate with.
  7570. */
  7571. concat(array: any): void;
  7572. /**
  7573. * Returns the position of a value in the active data.
  7574. * @param value defines the value to find the index for
  7575. * @returns the index if found in the active data otherwise -1
  7576. */
  7577. indexOf(value: T): number;
  7578. /**
  7579. * Returns whether an element is part of the active data.
  7580. * @param value defines the value to look for
  7581. * @returns true if found in the active data otherwise false
  7582. */
  7583. contains(value: T): boolean;
  7584. private static _GlobalId;
  7585. }
  7586. /**
  7587. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7588. * The data in this array can only be present once
  7589. */
  7590. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7591. private _duplicateId;
  7592. /**
  7593. * Pushes a value at the end of the active data.
  7594. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7595. * @param value defines the object to push in the array.
  7596. */
  7597. push(value: T): void;
  7598. /**
  7599. * Pushes a value at the end of the active data.
  7600. * If the data is already present, it won t be added again
  7601. * @param value defines the object to push in the array.
  7602. * @returns true if added false if it was already present
  7603. */
  7604. pushNoDuplicate(value: T): boolean;
  7605. /**
  7606. * Resets the active data to an empty array.
  7607. */
  7608. reset(): void;
  7609. /**
  7610. * Concats the active data with a given array.
  7611. * This ensures no dupplicate will be present in the result.
  7612. * @param array defines the data to concatenate with.
  7613. */
  7614. concatWithNoDuplicate(array: any): void;
  7615. }
  7616. }
  7617. declare module "babylonjs/Materials/multiMaterial" {
  7618. import { Nullable } from "babylonjs/types";
  7619. import { Scene } from "babylonjs/scene";
  7620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7621. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7622. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7623. import { Material } from "babylonjs/Materials/material";
  7624. /**
  7625. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7626. * separate meshes. This can be use to improve performances.
  7627. * @see http://doc.babylonjs.com/how_to/multi_materials
  7628. */
  7629. export class MultiMaterial extends Material {
  7630. private _subMaterials;
  7631. /**
  7632. * Gets or Sets the list of Materials used within the multi material.
  7633. * They need to be ordered according to the submeshes order in the associated mesh
  7634. */
  7635. subMaterials: Nullable<Material>[];
  7636. /**
  7637. * Function used to align with Node.getChildren()
  7638. * @returns the list of Materials used within the multi material
  7639. */
  7640. getChildren(): Nullable<Material>[];
  7641. /**
  7642. * Instantiates a new Multi Material
  7643. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7644. * separate meshes. This can be use to improve performances.
  7645. * @see http://doc.babylonjs.com/how_to/multi_materials
  7646. * @param name Define the name in the scene
  7647. * @param scene Define the scene the material belongs to
  7648. */
  7649. constructor(name: string, scene: Scene);
  7650. private _hookArray;
  7651. /**
  7652. * Get one of the submaterial by its index in the submaterials array
  7653. * @param index The index to look the sub material at
  7654. * @returns The Material if the index has been defined
  7655. */
  7656. getSubMaterial(index: number): Nullable<Material>;
  7657. /**
  7658. * Get the list of active textures for the whole sub materials list.
  7659. * @returns All the textures that will be used during the rendering
  7660. */
  7661. getActiveTextures(): BaseTexture[];
  7662. /**
  7663. * Gets the current class name of the material e.g. "MultiMaterial"
  7664. * Mainly use in serialization.
  7665. * @returns the class name
  7666. */
  7667. getClassName(): string;
  7668. /**
  7669. * Checks if the material is ready to render the requested sub mesh
  7670. * @param mesh Define the mesh the submesh belongs to
  7671. * @param subMesh Define the sub mesh to look readyness for
  7672. * @param useInstances Define whether or not the material is used with instances
  7673. * @returns true if ready, otherwise false
  7674. */
  7675. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7676. /**
  7677. * Clones the current material and its related sub materials
  7678. * @param name Define the name of the newly cloned material
  7679. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7680. * @returns the cloned material
  7681. */
  7682. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7683. /**
  7684. * Serializes the materials into a JSON representation.
  7685. * @returns the JSON representation
  7686. */
  7687. serialize(): any;
  7688. /**
  7689. * Dispose the material and release its associated resources
  7690. * @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)
  7691. * @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)
  7692. * @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)
  7693. */
  7694. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7695. /**
  7696. * Creates a MultiMaterial from parsed MultiMaterial data.
  7697. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7698. * @param scene defines the hosting scene
  7699. * @returns a new MultiMaterial
  7700. */
  7701. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7702. }
  7703. }
  7704. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7705. /**
  7706. * Class used to represent data loading progression
  7707. */
  7708. export class SceneLoaderFlags {
  7709. private static _ForceFullSceneLoadingForIncremental;
  7710. private static _ShowLoadingScreen;
  7711. private static _CleanBoneMatrixWeights;
  7712. private static _loggingLevel;
  7713. /**
  7714. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7715. */
  7716. static ForceFullSceneLoadingForIncremental: boolean;
  7717. /**
  7718. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7719. */
  7720. static ShowLoadingScreen: boolean;
  7721. /**
  7722. * Defines the current logging level (while loading the scene)
  7723. * @ignorenaming
  7724. */
  7725. static loggingLevel: number;
  7726. /**
  7727. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7728. */
  7729. static CleanBoneMatrixWeights: boolean;
  7730. }
  7731. }
  7732. declare module "babylonjs/Meshes/transformNode" {
  7733. import { DeepImmutable } from "babylonjs/types";
  7734. import { Observable } from "babylonjs/Misc/observable";
  7735. import { Nullable } from "babylonjs/types";
  7736. import { Camera } from "babylonjs/Cameras/camera";
  7737. import { Scene } from "babylonjs/scene";
  7738. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7739. import { Node } from "babylonjs/node";
  7740. import { Bone } from "babylonjs/Bones/bone";
  7741. /**
  7742. * 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.
  7743. * @see https://doc.babylonjs.com/how_to/transformnode
  7744. */
  7745. export class TransformNode extends Node {
  7746. /**
  7747. * Object will not rotate to face the camera
  7748. */
  7749. static BILLBOARDMODE_NONE: number;
  7750. /**
  7751. * Object will rotate to face the camera but only on the x axis
  7752. */
  7753. static BILLBOARDMODE_X: number;
  7754. /**
  7755. * Object will rotate to face the camera but only on the y axis
  7756. */
  7757. static BILLBOARDMODE_Y: number;
  7758. /**
  7759. * Object will rotate to face the camera but only on the z axis
  7760. */
  7761. static BILLBOARDMODE_Z: number;
  7762. /**
  7763. * Object will rotate to face the camera
  7764. */
  7765. static BILLBOARDMODE_ALL: number;
  7766. private _forward;
  7767. private _forwardInverted;
  7768. private _up;
  7769. private _right;
  7770. private _rightInverted;
  7771. private _position;
  7772. private _rotation;
  7773. private _rotationQuaternion;
  7774. protected _scaling: Vector3;
  7775. protected _isDirty: boolean;
  7776. private _transformToBoneReferal;
  7777. private _billboardMode;
  7778. /**
  7779. * Gets or sets the billboard mode. Default is 0.
  7780. *
  7781. * | Value | Type | Description |
  7782. * | --- | --- | --- |
  7783. * | 0 | BILLBOARDMODE_NONE | |
  7784. * | 1 | BILLBOARDMODE_X | |
  7785. * | 2 | BILLBOARDMODE_Y | |
  7786. * | 4 | BILLBOARDMODE_Z | |
  7787. * | 7 | BILLBOARDMODE_ALL | |
  7788. *
  7789. */
  7790. billboardMode: number;
  7791. private _preserveParentRotationForBillboard;
  7792. /**
  7793. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7794. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7795. */
  7796. preserveParentRotationForBillboard: boolean;
  7797. /**
  7798. * 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
  7799. */
  7800. scalingDeterminant: number;
  7801. private _infiniteDistance;
  7802. /**
  7803. * Gets or sets the distance of the object to max, often used by skybox
  7804. */
  7805. infiniteDistance: boolean;
  7806. /**
  7807. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7808. * By default the system will update normals to compensate
  7809. */
  7810. ignoreNonUniformScaling: boolean;
  7811. /**
  7812. * 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
  7813. */
  7814. reIntegrateRotationIntoRotationQuaternion: boolean;
  7815. /** @hidden */
  7816. _poseMatrix: Nullable<Matrix>;
  7817. /** @hidden */
  7818. _localMatrix: Matrix;
  7819. private _usePivotMatrix;
  7820. private _absolutePosition;
  7821. private _pivotMatrix;
  7822. private _pivotMatrixInverse;
  7823. protected _postMultiplyPivotMatrix: boolean;
  7824. protected _isWorldMatrixFrozen: boolean;
  7825. /** @hidden */
  7826. _indexInSceneTransformNodesArray: number;
  7827. /**
  7828. * An event triggered after the world matrix is updated
  7829. */
  7830. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7831. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7832. /**
  7833. * Gets a string identifying the name of the class
  7834. * @returns "TransformNode" string
  7835. */
  7836. getClassName(): string;
  7837. /**
  7838. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7839. */
  7840. position: Vector3;
  7841. /**
  7842. * 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)).
  7843. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7844. */
  7845. rotation: Vector3;
  7846. /**
  7847. * 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)).
  7848. */
  7849. scaling: Vector3;
  7850. /**
  7851. * 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).
  7852. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7853. */
  7854. rotationQuaternion: Nullable<Quaternion>;
  7855. /**
  7856. * The forward direction of that transform in world space.
  7857. */
  7858. readonly forward: Vector3;
  7859. /**
  7860. * The up direction of that transform in world space.
  7861. */
  7862. readonly up: Vector3;
  7863. /**
  7864. * The right direction of that transform in world space.
  7865. */
  7866. readonly right: Vector3;
  7867. /**
  7868. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7869. * @param matrix the matrix to copy the pose from
  7870. * @returns this TransformNode.
  7871. */
  7872. updatePoseMatrix(matrix: Matrix): TransformNode;
  7873. /**
  7874. * Returns the mesh Pose matrix.
  7875. * @returns the pose matrix
  7876. */
  7877. getPoseMatrix(): Matrix;
  7878. /** @hidden */
  7879. _isSynchronized(): boolean;
  7880. /** @hidden */
  7881. _initCache(): void;
  7882. /**
  7883. * Flag the transform node as dirty (Forcing it to update everything)
  7884. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7885. * @returns this transform node
  7886. */
  7887. markAsDirty(property: string): TransformNode;
  7888. /**
  7889. * Returns the current mesh absolute position.
  7890. * Returns a Vector3.
  7891. */
  7892. readonly absolutePosition: Vector3;
  7893. /**
  7894. * Sets a new matrix to apply before all other transformation
  7895. * @param matrix defines the transform matrix
  7896. * @returns the current TransformNode
  7897. */
  7898. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7899. /**
  7900. * Sets a new pivot matrix to the current node
  7901. * @param matrix defines the new pivot matrix to use
  7902. * @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
  7903. * @returns the current TransformNode
  7904. */
  7905. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7906. /**
  7907. * Returns the mesh pivot matrix.
  7908. * Default : Identity.
  7909. * @returns the matrix
  7910. */
  7911. getPivotMatrix(): Matrix;
  7912. /**
  7913. * Prevents the World matrix to be computed any longer.
  7914. * @returns the TransformNode.
  7915. */
  7916. freezeWorldMatrix(): TransformNode;
  7917. /**
  7918. * Allows back the World matrix computation.
  7919. * @returns the TransformNode.
  7920. */
  7921. unfreezeWorldMatrix(): this;
  7922. /**
  7923. * True if the World matrix has been frozen.
  7924. */
  7925. readonly isWorldMatrixFrozen: boolean;
  7926. /**
  7927. * Retuns the mesh absolute position in the World.
  7928. * @returns a Vector3.
  7929. */
  7930. getAbsolutePosition(): Vector3;
  7931. /**
  7932. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7933. * @param absolutePosition the absolute position to set
  7934. * @returns the TransformNode.
  7935. */
  7936. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7937. /**
  7938. * Sets the mesh position in its local space.
  7939. * @param vector3 the position to set in localspace
  7940. * @returns the TransformNode.
  7941. */
  7942. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7943. /**
  7944. * Returns the mesh position in the local space from the current World matrix values.
  7945. * @returns a new Vector3.
  7946. */
  7947. getPositionExpressedInLocalSpace(): Vector3;
  7948. /**
  7949. * Translates the mesh along the passed Vector3 in its local space.
  7950. * @param vector3 the distance to translate in localspace
  7951. * @returns the TransformNode.
  7952. */
  7953. locallyTranslate(vector3: Vector3): TransformNode;
  7954. private static _lookAtVectorCache;
  7955. /**
  7956. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7957. * @param targetPoint the position (must be in same space as current mesh) to look at
  7958. * @param yawCor optional yaw (y-axis) correction in radians
  7959. * @param pitchCor optional pitch (x-axis) correction in radians
  7960. * @param rollCor optional roll (z-axis) correction in radians
  7961. * @param space the choosen space of the target
  7962. * @returns the TransformNode.
  7963. */
  7964. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7965. /**
  7966. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7967. * This Vector3 is expressed in the World space.
  7968. * @param localAxis axis to rotate
  7969. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7970. */
  7971. getDirection(localAxis: Vector3): Vector3;
  7972. /**
  7973. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7974. * localAxis is expressed in the mesh local space.
  7975. * result is computed in the Wordl space from the mesh World matrix.
  7976. * @param localAxis axis to rotate
  7977. * @param result the resulting transformnode
  7978. * @returns this TransformNode.
  7979. */
  7980. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7981. /**
  7982. * Sets this transform node rotation to the given local axis.
  7983. * @param localAxis the axis in local space
  7984. * @param yawCor optional yaw (y-axis) correction in radians
  7985. * @param pitchCor optional pitch (x-axis) correction in radians
  7986. * @param rollCor optional roll (z-axis) correction in radians
  7987. * @returns this TransformNode
  7988. */
  7989. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7990. /**
  7991. * Sets a new pivot point to the current node
  7992. * @param point defines the new pivot point to use
  7993. * @param space defines if the point is in world or local space (local by default)
  7994. * @returns the current TransformNode
  7995. */
  7996. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7997. /**
  7998. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7999. * @returns the pivot point
  8000. */
  8001. getPivotPoint(): Vector3;
  8002. /**
  8003. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  8004. * @param result the vector3 to store the result
  8005. * @returns this TransformNode.
  8006. */
  8007. getPivotPointToRef(result: Vector3): TransformNode;
  8008. /**
  8009. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  8010. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  8011. */
  8012. getAbsolutePivotPoint(): Vector3;
  8013. /**
  8014. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  8015. * @param result vector3 to store the result
  8016. * @returns this TransformNode.
  8017. */
  8018. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  8019. /**
  8020. * Defines the passed node as the parent of the current node.
  8021. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  8022. * @see https://doc.babylonjs.com/how_to/parenting
  8023. * @param node the node ot set as the parent
  8024. * @returns this TransformNode.
  8025. */
  8026. setParent(node: Nullable<Node>): TransformNode;
  8027. private _nonUniformScaling;
  8028. /**
  8029. * True if the scaling property of this object is non uniform eg. (1,2,1)
  8030. */
  8031. readonly nonUniformScaling: boolean;
  8032. /** @hidden */
  8033. _updateNonUniformScalingState(value: boolean): boolean;
  8034. /**
  8035. * Attach the current TransformNode to another TransformNode associated with a bone
  8036. * @param bone Bone affecting the TransformNode
  8037. * @param affectedTransformNode TransformNode associated with the bone
  8038. * @returns this object
  8039. */
  8040. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  8041. /**
  8042. * Detach the transform node if its associated with a bone
  8043. * @returns this object
  8044. */
  8045. detachFromBone(): TransformNode;
  8046. private static _rotationAxisCache;
  8047. /**
  8048. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  8049. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8050. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8051. * The passed axis is also normalized.
  8052. * @param axis the axis to rotate around
  8053. * @param amount the amount to rotate in radians
  8054. * @param space Space to rotate in (Default: local)
  8055. * @returns the TransformNode.
  8056. */
  8057. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  8058. /**
  8059. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  8060. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8061. * The passed axis is also normalized. .
  8062. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  8063. * @param point the point to rotate around
  8064. * @param axis the axis to rotate around
  8065. * @param amount the amount to rotate in radians
  8066. * @returns the TransformNode
  8067. */
  8068. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  8069. /**
  8070. * Translates the mesh along the axis vector for the passed distance in the given space.
  8071. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8072. * @param axis the axis to translate in
  8073. * @param distance the distance to translate
  8074. * @param space Space to rotate in (Default: local)
  8075. * @returns the TransformNode.
  8076. */
  8077. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  8078. /**
  8079. * Adds a rotation step to the mesh current rotation.
  8080. * x, y, z are Euler angles expressed in radians.
  8081. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  8082. * This means this rotation is made in the mesh local space only.
  8083. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  8084. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  8085. * ```javascript
  8086. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  8087. * ```
  8088. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  8089. * 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.
  8090. * @param x Rotation to add
  8091. * @param y Rotation to add
  8092. * @param z Rotation to add
  8093. * @returns the TransformNode.
  8094. */
  8095. addRotation(x: number, y: number, z: number): TransformNode;
  8096. /**
  8097. * @hidden
  8098. */
  8099. protected _getEffectiveParent(): Nullable<Node>;
  8100. /**
  8101. * Computes the world matrix of the node
  8102. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8103. * @returns the world matrix
  8104. */
  8105. computeWorldMatrix(force?: boolean): Matrix;
  8106. protected _afterComputeWorldMatrix(): void;
  8107. /**
  8108. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  8109. * @param func callback function to add
  8110. *
  8111. * @returns the TransformNode.
  8112. */
  8113. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8114. /**
  8115. * Removes a registered callback function.
  8116. * @param func callback function to remove
  8117. * @returns the TransformNode.
  8118. */
  8119. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8120. /**
  8121. * Gets the position of the current mesh in camera space
  8122. * @param camera defines the camera to use
  8123. * @returns a position
  8124. */
  8125. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  8126. /**
  8127. * Returns the distance from the mesh to the active camera
  8128. * @param camera defines the camera to use
  8129. * @returns the distance
  8130. */
  8131. getDistanceToCamera(camera?: Nullable<Camera>): number;
  8132. /**
  8133. * Clone the current transform node
  8134. * @param name Name of the new clone
  8135. * @param newParent New parent for the clone
  8136. * @param doNotCloneChildren Do not clone children hierarchy
  8137. * @returns the new transform node
  8138. */
  8139. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  8140. /**
  8141. * Serializes the objects information.
  8142. * @param currentSerializationObject defines the object to serialize in
  8143. * @returns the serialized object
  8144. */
  8145. serialize(currentSerializationObject?: any): any;
  8146. /**
  8147. * Returns a new TransformNode object parsed from the source provided.
  8148. * @param parsedTransformNode is the source.
  8149. * @param scene the scne the object belongs to
  8150. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  8151. * @returns a new TransformNode object parsed from the source provided.
  8152. */
  8153. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  8154. /**
  8155. * Get all child-transformNodes of this node
  8156. * @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
  8157. * @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
  8158. * @returns an array of TransformNode
  8159. */
  8160. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  8161. /**
  8162. * Releases resources associated with this transform node.
  8163. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8164. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8165. */
  8166. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8167. }
  8168. }
  8169. declare module "babylonjs/Animations/animationPropertiesOverride" {
  8170. /**
  8171. * Class used to override all child animations of a given target
  8172. */
  8173. export class AnimationPropertiesOverride {
  8174. /**
  8175. * Gets or sets a value indicating if animation blending must be used
  8176. */
  8177. enableBlending: boolean;
  8178. /**
  8179. * Gets or sets the blending speed to use when enableBlending is true
  8180. */
  8181. blendingSpeed: number;
  8182. /**
  8183. * Gets or sets the default loop mode to use
  8184. */
  8185. loopMode: number;
  8186. }
  8187. }
  8188. declare module "babylonjs/Bones/bone" {
  8189. import { Skeleton } from "babylonjs/Bones/skeleton";
  8190. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  8191. import { Nullable } from "babylonjs/types";
  8192. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8193. import { TransformNode } from "babylonjs/Meshes/transformNode";
  8194. import { Node } from "babylonjs/node";
  8195. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  8196. /**
  8197. * Class used to store bone information
  8198. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8199. */
  8200. export class Bone extends Node {
  8201. /**
  8202. * defines the bone name
  8203. */
  8204. name: string;
  8205. private static _tmpVecs;
  8206. private static _tmpQuat;
  8207. private static _tmpMats;
  8208. /**
  8209. * Gets the list of child bones
  8210. */
  8211. children: Bone[];
  8212. /** Gets the animations associated with this bone */
  8213. animations: import("babylonjs/Animations/animation").Animation[];
  8214. /**
  8215. * Gets or sets bone length
  8216. */
  8217. length: number;
  8218. /**
  8219. * @hidden Internal only
  8220. * Set this value to map this bone to a different index in the transform matrices
  8221. * Set this value to -1 to exclude the bone from the transform matrices
  8222. */
  8223. _index: Nullable<number>;
  8224. private _skeleton;
  8225. private _localMatrix;
  8226. private _restPose;
  8227. private _baseMatrix;
  8228. private _absoluteTransform;
  8229. private _invertedAbsoluteTransform;
  8230. private _parent;
  8231. private _scalingDeterminant;
  8232. private _worldTransform;
  8233. private _localScaling;
  8234. private _localRotation;
  8235. private _localPosition;
  8236. private _needToDecompose;
  8237. private _needToCompose;
  8238. /** @hidden */
  8239. _linkedTransformNode: Nullable<TransformNode>;
  8240. /** @hidden */
  8241. _waitingTransformNodeId: Nullable<string>;
  8242. /** @hidden */
  8243. /** @hidden */
  8244. _matrix: Matrix;
  8245. /**
  8246. * Create a new bone
  8247. * @param name defines the bone name
  8248. * @param skeleton defines the parent skeleton
  8249. * @param parentBone defines the parent (can be null if the bone is the root)
  8250. * @param localMatrix defines the local matrix
  8251. * @param restPose defines the rest pose matrix
  8252. * @param baseMatrix defines the base matrix
  8253. * @param index defines index of the bone in the hiearchy
  8254. */
  8255. constructor(
  8256. /**
  8257. * defines the bone name
  8258. */
  8259. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8260. /**
  8261. * Gets the current object class name.
  8262. * @return the class name
  8263. */
  8264. getClassName(): string;
  8265. /**
  8266. * Gets the parent skeleton
  8267. * @returns a skeleton
  8268. */
  8269. getSkeleton(): Skeleton;
  8270. /**
  8271. * Gets parent bone
  8272. * @returns a bone or null if the bone is the root of the bone hierarchy
  8273. */
  8274. getParent(): Nullable<Bone>;
  8275. /**
  8276. * Returns an array containing the root bones
  8277. * @returns an array containing the root bones
  8278. */
  8279. getChildren(): Array<Bone>;
  8280. /**
  8281. * Sets the parent bone
  8282. * @param parent defines the parent (can be null if the bone is the root)
  8283. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8284. */
  8285. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8286. /**
  8287. * Gets the local matrix
  8288. * @returns a matrix
  8289. */
  8290. getLocalMatrix(): Matrix;
  8291. /**
  8292. * Gets the base matrix (initial matrix which remains unchanged)
  8293. * @returns a matrix
  8294. */
  8295. getBaseMatrix(): Matrix;
  8296. /**
  8297. * Gets the rest pose matrix
  8298. * @returns a matrix
  8299. */
  8300. getRestPose(): Matrix;
  8301. /**
  8302. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8303. */
  8304. getWorldMatrix(): Matrix;
  8305. /**
  8306. * Sets the local matrix to rest pose matrix
  8307. */
  8308. returnToRest(): void;
  8309. /**
  8310. * Gets the inverse of the absolute transform matrix.
  8311. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8312. * @returns a matrix
  8313. */
  8314. getInvertedAbsoluteTransform(): Matrix;
  8315. /**
  8316. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8317. * @returns a matrix
  8318. */
  8319. getAbsoluteTransform(): Matrix;
  8320. /**
  8321. * Links with the given transform node.
  8322. * The local matrix of this bone is copied from the transform node every frame.
  8323. * @param transformNode defines the transform node to link to
  8324. */
  8325. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8326. /** Gets or sets current position (in local space) */
  8327. position: Vector3;
  8328. /** Gets or sets current rotation (in local space) */
  8329. rotation: Vector3;
  8330. /** Gets or sets current rotation quaternion (in local space) */
  8331. rotationQuaternion: Quaternion;
  8332. /** Gets or sets current scaling (in local space) */
  8333. scaling: Vector3;
  8334. /**
  8335. * Gets the animation properties override
  8336. */
  8337. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8338. private _decompose;
  8339. private _compose;
  8340. /**
  8341. * Update the base and local matrices
  8342. * @param matrix defines the new base or local matrix
  8343. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8344. * @param updateLocalMatrix defines if the local matrix should be updated
  8345. */
  8346. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8347. /** @hidden */
  8348. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8349. /**
  8350. * Flag the bone as dirty (Forcing it to update everything)
  8351. */
  8352. markAsDirty(): void;
  8353. /** @hidden */
  8354. _markAsDirtyAndCompose(): void;
  8355. private _markAsDirtyAndDecompose;
  8356. /**
  8357. * Translate the bone in local or world space
  8358. * @param vec The amount to translate the bone
  8359. * @param space The space that the translation is in
  8360. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8361. */
  8362. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8363. /**
  8364. * Set the postion of the bone in local or world space
  8365. * @param position The position to set the bone
  8366. * @param space The space that the position is in
  8367. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8368. */
  8369. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8370. /**
  8371. * Set the absolute position of the bone (world space)
  8372. * @param position The position to set the bone
  8373. * @param mesh The mesh that this bone is attached to
  8374. */
  8375. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8376. /**
  8377. * Scale the bone on the x, y and z axes (in local space)
  8378. * @param x The amount to scale the bone on the x axis
  8379. * @param y The amount to scale the bone on the y axis
  8380. * @param z The amount to scale the bone on the z axis
  8381. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8382. */
  8383. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8384. /**
  8385. * Set the bone scaling in local space
  8386. * @param scale defines the scaling vector
  8387. */
  8388. setScale(scale: Vector3): void;
  8389. /**
  8390. * Gets the current scaling in local space
  8391. * @returns the current scaling vector
  8392. */
  8393. getScale(): Vector3;
  8394. /**
  8395. * Gets the current scaling in local space and stores it in a target vector
  8396. * @param result defines the target vector
  8397. */
  8398. getScaleToRef(result: Vector3): void;
  8399. /**
  8400. * Set the yaw, pitch, and roll of the bone in local or world space
  8401. * @param yaw The rotation of the bone on the y axis
  8402. * @param pitch The rotation of the bone on the x axis
  8403. * @param roll The rotation of the bone on the z axis
  8404. * @param space The space that the axes of rotation are in
  8405. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8406. */
  8407. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8408. /**
  8409. * Add a rotation to the bone on an axis in local or world space
  8410. * @param axis The axis to rotate the bone on
  8411. * @param amount The amount to rotate the bone
  8412. * @param space The space that the axis is in
  8413. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8414. */
  8415. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8416. /**
  8417. * Set the rotation of the bone to a particular axis angle in local or world space
  8418. * @param axis The axis to rotate the bone on
  8419. * @param angle The angle that the bone should be rotated to
  8420. * @param space The space that the axis is in
  8421. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8422. */
  8423. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8424. /**
  8425. * Set the euler rotation of the bone in local of world space
  8426. * @param rotation The euler rotation that the bone should be set to
  8427. * @param space The space that the rotation is in
  8428. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8429. */
  8430. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8431. /**
  8432. * Set the quaternion rotation of the bone in local of world space
  8433. * @param quat The quaternion rotation that the bone should be set to
  8434. * @param space The space that the rotation is in
  8435. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8436. */
  8437. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8438. /**
  8439. * Set the rotation matrix of the bone in local of world space
  8440. * @param rotMat The rotation matrix that the bone should be set to
  8441. * @param space The space that the rotation is in
  8442. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8443. */
  8444. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8445. private _rotateWithMatrix;
  8446. private _getNegativeRotationToRef;
  8447. /**
  8448. * Get the position of the bone in local or world space
  8449. * @param space The space that the returned position is in
  8450. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8451. * @returns The position of the bone
  8452. */
  8453. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8454. /**
  8455. * Copy the position of the bone to a vector3 in local or world space
  8456. * @param space The space that the returned position is in
  8457. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8458. * @param result The vector3 to copy the position to
  8459. */
  8460. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8461. /**
  8462. * Get the absolute position of the bone (world space)
  8463. * @param mesh The mesh that this bone is attached to
  8464. * @returns The absolute position of the bone
  8465. */
  8466. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8467. /**
  8468. * Copy the absolute position of the bone (world space) to the result param
  8469. * @param mesh The mesh that this bone is attached to
  8470. * @param result The vector3 to copy the absolute position to
  8471. */
  8472. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8473. /**
  8474. * Compute the absolute transforms of this bone and its children
  8475. */
  8476. computeAbsoluteTransforms(): void;
  8477. /**
  8478. * Get the world direction from an axis that is in the local space of the bone
  8479. * @param localAxis The local direction that is used to compute the world direction
  8480. * @param mesh The mesh that this bone is attached to
  8481. * @returns The world direction
  8482. */
  8483. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8484. /**
  8485. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8486. * @param localAxis The local direction that is used to compute the world direction
  8487. * @param mesh The mesh that this bone is attached to
  8488. * @param result The vector3 that the world direction will be copied to
  8489. */
  8490. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8491. /**
  8492. * Get the euler rotation of the bone in local or world space
  8493. * @param space The space that the rotation should be in
  8494. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8495. * @returns The euler rotation
  8496. */
  8497. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8498. /**
  8499. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8500. * @param space The space that the rotation should be in
  8501. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8502. * @param result The vector3 that the rotation should be copied to
  8503. */
  8504. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8505. /**
  8506. * Get the quaternion rotation of the bone in either local or world space
  8507. * @param space The space that the rotation should be in
  8508. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8509. * @returns The quaternion rotation
  8510. */
  8511. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8512. /**
  8513. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8514. * @param space The space that the rotation should be in
  8515. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8516. * @param result The quaternion that the rotation should be copied to
  8517. */
  8518. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8519. /**
  8520. * Get the rotation matrix of the bone in local or world space
  8521. * @param space The space that the rotation should be in
  8522. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8523. * @returns The rotation matrix
  8524. */
  8525. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8526. /**
  8527. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8528. * @param space The space that the rotation should be in
  8529. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8530. * @param result The quaternion that the rotation should be copied to
  8531. */
  8532. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8533. /**
  8534. * Get the world position of a point that is in the local space of the bone
  8535. * @param position The local position
  8536. * @param mesh The mesh that this bone is attached to
  8537. * @returns The world position
  8538. */
  8539. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8540. /**
  8541. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8542. * @param position The local position
  8543. * @param mesh The mesh that this bone is attached to
  8544. * @param result The vector3 that the world position should be copied to
  8545. */
  8546. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8547. /**
  8548. * Get the local position of a point that is in world space
  8549. * @param position The world position
  8550. * @param mesh The mesh that this bone is attached to
  8551. * @returns The local position
  8552. */
  8553. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8554. /**
  8555. * Get the local position of a point that is in world space and copy it to the result param
  8556. * @param position The world position
  8557. * @param mesh The mesh that this bone is attached to
  8558. * @param result The vector3 that the local position should be copied to
  8559. */
  8560. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8561. }
  8562. }
  8563. declare module "babylonjs/Misc/iInspectable" {
  8564. /**
  8565. * Enum that determines the text-wrapping mode to use.
  8566. */
  8567. export enum InspectableType {
  8568. /**
  8569. * Checkbox for booleans
  8570. */
  8571. Checkbox = 0,
  8572. /**
  8573. * Sliders for numbers
  8574. */
  8575. Slider = 1,
  8576. /**
  8577. * Vector3
  8578. */
  8579. Vector3 = 2,
  8580. /**
  8581. * Quaternions
  8582. */
  8583. Quaternion = 3,
  8584. /**
  8585. * Color3
  8586. */
  8587. Color3 = 4
  8588. }
  8589. /**
  8590. * Interface used to define custom inspectable properties.
  8591. * This interface is used by the inspector to display custom property grids
  8592. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8593. */
  8594. export interface IInspectable {
  8595. /**
  8596. * Gets the label to display
  8597. */
  8598. label: string;
  8599. /**
  8600. * Gets the name of the property to edit
  8601. */
  8602. propertyName: string;
  8603. /**
  8604. * Gets the type of the editor to use
  8605. */
  8606. type: InspectableType;
  8607. /**
  8608. * Gets the minimum value of the property when using in "slider" mode
  8609. */
  8610. min?: number;
  8611. /**
  8612. * Gets the maximum value of the property when using in "slider" mode
  8613. */
  8614. max?: number;
  8615. /**
  8616. * Gets the setp to use when using in "slider" mode
  8617. */
  8618. step?: number;
  8619. }
  8620. }
  8621. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  8622. import { Nullable } from "babylonjs/types";
  8623. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8624. /**
  8625. * This represents the required contract to create a new type of texture loader.
  8626. */
  8627. export interface IInternalTextureLoader {
  8628. /**
  8629. * Defines wether the loader supports cascade loading the different faces.
  8630. */
  8631. supportCascades: boolean;
  8632. /**
  8633. * This returns if the loader support the current file information.
  8634. * @param extension defines the file extension of the file being loaded
  8635. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8636. * @param fallback defines the fallback internal texture if any
  8637. * @param isBase64 defines whether the texture is encoded as a base64
  8638. * @param isBuffer defines whether the texture data are stored as a buffer
  8639. * @returns true if the loader can load the specified file
  8640. */
  8641. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  8642. /**
  8643. * Transform the url before loading if required.
  8644. * @param rootUrl the url of the texture
  8645. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8646. * @returns the transformed texture
  8647. */
  8648. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  8649. /**
  8650. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  8651. * @param rootUrl the url of the texture
  8652. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8653. * @returns the fallback texture
  8654. */
  8655. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  8656. /**
  8657. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  8658. * @param data contains the texture data
  8659. * @param texture defines the BabylonJS internal texture
  8660. * @param createPolynomials will be true if polynomials have been requested
  8661. * @param onLoad defines the callback to trigger once the texture is ready
  8662. * @param onError defines the callback to trigger in case of error
  8663. */
  8664. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  8665. /**
  8666. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  8667. * @param data contains the texture data
  8668. * @param texture defines the BabylonJS internal texture
  8669. * @param callback defines the method to call once ready to upload
  8670. */
  8671. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  8672. }
  8673. }
  8674. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  8675. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8676. import { Nullable } from "babylonjs/types";
  8677. import { Scene } from "babylonjs/scene";
  8678. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  8679. module "babylonjs/Engines/engine" {
  8680. interface Engine {
  8681. /**
  8682. * Creates a depth stencil cube texture.
  8683. * This is only available in WebGL 2.
  8684. * @param size The size of face edge in the cube texture.
  8685. * @param options The options defining the cube texture.
  8686. * @returns The cube texture
  8687. */
  8688. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  8689. /**
  8690. * Creates a cube texture
  8691. * @param rootUrl defines the url where the files to load is located
  8692. * @param scene defines the current scene
  8693. * @param files defines the list of files to load (1 per face)
  8694. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8695. * @param onLoad defines an optional callback raised when the texture is loaded
  8696. * @param onError defines an optional callback raised if there is an issue to load the texture
  8697. * @param format defines the format of the data
  8698. * @param forcedExtension defines the extension to use to pick the right loader
  8699. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8700. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8701. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8702. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8703. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  8704. * @returns the cube texture as an InternalTexture
  8705. */
  8706. 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;
  8707. /**
  8708. * Creates a cube texture
  8709. * @param rootUrl defines the url where the files to load is located
  8710. * @param scene defines the current scene
  8711. * @param files defines the list of files to load (1 per face)
  8712. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8713. * @param onLoad defines an optional callback raised when the texture is loaded
  8714. * @param onError defines an optional callback raised if there is an issue to load the texture
  8715. * @param format defines the format of the data
  8716. * @param forcedExtension defines the extension to use to pick the right loader
  8717. * @returns the cube texture as an InternalTexture
  8718. */
  8719. 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;
  8720. /**
  8721. * Creates a cube texture
  8722. * @param rootUrl defines the url where the files to load is located
  8723. * @param scene defines the current scene
  8724. * @param files defines the list of files to load (1 per face)
  8725. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8726. * @param onLoad defines an optional callback raised when the texture is loaded
  8727. * @param onError defines an optional callback raised if there is an issue to load the texture
  8728. * @param format defines the format of the data
  8729. * @param forcedExtension defines the extension to use to pick the right loader
  8730. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8731. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8732. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8733. * @returns the cube texture as an InternalTexture
  8734. */
  8735. 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;
  8736. /** @hidden */
  8737. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8738. /** @hidden */
  8739. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8740. /** @hidden */
  8741. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8742. /** @hidden */
  8743. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8744. }
  8745. }
  8746. }
  8747. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8748. import { Nullable } from "babylonjs/types";
  8749. import { Scene } from "babylonjs/scene";
  8750. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8751. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8752. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  8753. /**
  8754. * Class for creating a cube texture
  8755. */
  8756. export class CubeTexture extends BaseTexture {
  8757. private _delayedOnLoad;
  8758. /**
  8759. * The url of the texture
  8760. */
  8761. url: string;
  8762. /**
  8763. * Gets or sets the center of the bounding box associated with the cube texture.
  8764. * It must define where the camera used to render the texture was set
  8765. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8766. */
  8767. boundingBoxPosition: Vector3;
  8768. private _boundingBoxSize;
  8769. /**
  8770. * Gets or sets the size of the bounding box associated with the cube texture
  8771. * When defined, the cubemap will switch to local mode
  8772. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8773. * @example https://www.babylonjs-playground.com/#RNASML
  8774. */
  8775. /**
  8776. * Returns the bounding box size
  8777. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8778. */
  8779. boundingBoxSize: Vector3;
  8780. protected _rotationY: number;
  8781. /**
  8782. * Sets texture matrix rotation angle around Y axis in radians.
  8783. */
  8784. /**
  8785. * Gets texture matrix rotation angle around Y axis radians.
  8786. */
  8787. rotationY: number;
  8788. /**
  8789. * Are mip maps generated for this texture or not.
  8790. */
  8791. readonly noMipmap: boolean;
  8792. private _noMipmap;
  8793. private _files;
  8794. private _extensions;
  8795. private _textureMatrix;
  8796. private _format;
  8797. private _createPolynomials;
  8798. /** @hidden */
  8799. _prefiltered: boolean;
  8800. /**
  8801. * Creates a cube texture from an array of image urls
  8802. * @param files defines an array of image urls
  8803. * @param scene defines the hosting scene
  8804. * @param noMipmap specifies if mip maps are not used
  8805. * @returns a cube texture
  8806. */
  8807. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8808. /**
  8809. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8810. * @param url defines the url of the prefiltered texture
  8811. * @param scene defines the scene the texture is attached to
  8812. * @param forcedExtension defines the extension of the file if different from the url
  8813. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8814. * @return the prefiltered texture
  8815. */
  8816. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8817. /**
  8818. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8819. * as prefiltered data.
  8820. * @param rootUrl defines the url of the texture or the root name of the six images
  8821. * @param scene defines the scene the texture is attached to
  8822. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8823. * @param noMipmap defines if mipmaps should be created or not
  8824. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8825. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8826. * @param onError defines a callback triggered in case of error during load
  8827. * @param format defines the internal format to use for the texture once loaded
  8828. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8829. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8830. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8831. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8832. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8833. * @return the cube texture
  8834. */
  8835. 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);
  8836. /**
  8837. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  8838. */
  8839. readonly isPrefiltered: boolean;
  8840. /**
  8841. * Get the current class name of the texture useful for serialization or dynamic coding.
  8842. * @returns "CubeTexture"
  8843. */
  8844. getClassName(): string;
  8845. /**
  8846. * Update the url (and optional buffer) of this texture if url was null during construction.
  8847. * @param url the url of the texture
  8848. * @param forcedExtension defines the extension to use
  8849. * @param onLoad callback called when the texture is loaded (defaults to null)
  8850. */
  8851. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8852. /**
  8853. * Delays loading of the cube texture
  8854. * @param forcedExtension defines the extension to use
  8855. */
  8856. delayLoad(forcedExtension?: string): void;
  8857. /**
  8858. * Returns the reflection texture matrix
  8859. * @returns the reflection texture matrix
  8860. */
  8861. getReflectionTextureMatrix(): Matrix;
  8862. /**
  8863. * Sets the reflection texture matrix
  8864. * @param value Reflection texture matrix
  8865. */
  8866. setReflectionTextureMatrix(value: Matrix): void;
  8867. /**
  8868. * Parses text to create a cube texture
  8869. * @param parsedTexture define the serialized text to read from
  8870. * @param scene defines the hosting scene
  8871. * @param rootUrl defines the root url of the cube texture
  8872. * @returns a cube texture
  8873. */
  8874. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8875. /**
  8876. * Makes a clone, or deep copy, of the cube texture
  8877. * @returns a new cube texture
  8878. */
  8879. clone(): CubeTexture;
  8880. }
  8881. }
  8882. declare module "babylonjs/Shaders/postprocess.vertex" {
  8883. /** @hidden */
  8884. export var postprocessVertexShader: {
  8885. name: string;
  8886. shader: string;
  8887. };
  8888. }
  8889. declare module "babylonjs/Cameras/targetCamera" {
  8890. import { Nullable } from "babylonjs/types";
  8891. import { Camera } from "babylonjs/Cameras/camera";
  8892. import { Scene } from "babylonjs/scene";
  8893. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8894. /**
  8895. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8896. * This is the base of the follow, arc rotate cameras and Free camera
  8897. * @see http://doc.babylonjs.com/features/cameras
  8898. */
  8899. export class TargetCamera extends Camera {
  8900. private static _RigCamTransformMatrix;
  8901. private static _TargetTransformMatrix;
  8902. private static _TargetFocalPoint;
  8903. /**
  8904. * Define the current direction the camera is moving to
  8905. */
  8906. cameraDirection: Vector3;
  8907. /**
  8908. * Define the current rotation the camera is rotating to
  8909. */
  8910. cameraRotation: Vector2;
  8911. /**
  8912. * When set, the up vector of the camera will be updated by the rotation of the camera
  8913. */
  8914. updateUpVectorFromRotation: boolean;
  8915. private _tmpQuaternion;
  8916. /**
  8917. * Define the current rotation of the camera
  8918. */
  8919. rotation: Vector3;
  8920. /**
  8921. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8922. */
  8923. rotationQuaternion: Quaternion;
  8924. /**
  8925. * Define the current speed of the camera
  8926. */
  8927. speed: number;
  8928. /**
  8929. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8930. * around all axis.
  8931. */
  8932. noRotationConstraint: boolean;
  8933. /**
  8934. * Define the current target of the camera as an object or a position.
  8935. */
  8936. lockedTarget: any;
  8937. /** @hidden */
  8938. _currentTarget: Vector3;
  8939. /** @hidden */
  8940. _initialFocalDistance: number;
  8941. /** @hidden */
  8942. _viewMatrix: Matrix;
  8943. /** @hidden */
  8944. _camMatrix: Matrix;
  8945. /** @hidden */
  8946. _cameraTransformMatrix: Matrix;
  8947. /** @hidden */
  8948. _cameraRotationMatrix: Matrix;
  8949. /** @hidden */
  8950. _referencePoint: Vector3;
  8951. /** @hidden */
  8952. _transformedReferencePoint: Vector3;
  8953. protected _globalCurrentTarget: Vector3;
  8954. protected _globalCurrentUpVector: Vector3;
  8955. /** @hidden */
  8956. _reset: () => void;
  8957. private _defaultUp;
  8958. /**
  8959. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8960. * This is the base of the follow, arc rotate cameras and Free camera
  8961. * @see http://doc.babylonjs.com/features/cameras
  8962. * @param name Defines the name of the camera in the scene
  8963. * @param position Defines the start position of the camera in the scene
  8964. * @param scene Defines the scene the camera belongs to
  8965. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8966. */
  8967. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8968. /**
  8969. * Gets the position in front of the camera at a given distance.
  8970. * @param distance The distance from the camera we want the position to be
  8971. * @returns the position
  8972. */
  8973. getFrontPosition(distance: number): Vector3;
  8974. /** @hidden */
  8975. _getLockedTargetPosition(): Nullable<Vector3>;
  8976. private _storedPosition;
  8977. private _storedRotation;
  8978. private _storedRotationQuaternion;
  8979. /**
  8980. * Store current camera state of the camera (fov, position, rotation, etc..)
  8981. * @returns the camera
  8982. */
  8983. storeState(): Camera;
  8984. /**
  8985. * Restored camera state. You must call storeState() first
  8986. * @returns whether it was successful or not
  8987. * @hidden
  8988. */
  8989. _restoreStateValues(): boolean;
  8990. /** @hidden */
  8991. _initCache(): void;
  8992. /** @hidden */
  8993. _updateCache(ignoreParentClass?: boolean): void;
  8994. /** @hidden */
  8995. _isSynchronizedViewMatrix(): boolean;
  8996. /** @hidden */
  8997. _computeLocalCameraSpeed(): number;
  8998. /**
  8999. * Defines the target the camera should look at.
  9000. * This will automatically adapt alpha beta and radius to fit within the new target.
  9001. * @param target Defines the new target as a Vector or a mesh
  9002. */
  9003. setTarget(target: Vector3): void;
  9004. /**
  9005. * Return the current target position of the camera. This value is expressed in local space.
  9006. * @returns the target position
  9007. */
  9008. getTarget(): Vector3;
  9009. /** @hidden */
  9010. _decideIfNeedsToMove(): boolean;
  9011. /** @hidden */
  9012. _updatePosition(): void;
  9013. /** @hidden */
  9014. _checkInputs(): void;
  9015. protected _updateCameraRotationMatrix(): void;
  9016. /**
  9017. * 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)
  9018. * @returns the current camera
  9019. */
  9020. private _rotateUpVectorWithCameraRotationMatrix;
  9021. private _cachedRotationZ;
  9022. private _cachedQuaternionRotationZ;
  9023. /** @hidden */
  9024. _getViewMatrix(): Matrix;
  9025. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9026. /**
  9027. * @hidden
  9028. */
  9029. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9030. /**
  9031. * @hidden
  9032. */
  9033. _updateRigCameras(): void;
  9034. private _getRigCamPositionAndTarget;
  9035. /**
  9036. * Gets the current object class name.
  9037. * @return the class name
  9038. */
  9039. getClassName(): string;
  9040. }
  9041. }
  9042. declare module "babylonjs/Cameras/cameraInputsManager" {
  9043. import { Nullable } from "babylonjs/types";
  9044. import { Camera } from "babylonjs/Cameras/camera";
  9045. /**
  9046. * @ignore
  9047. * This is a list of all the different input types that are available in the application.
  9048. * Fo instance: ArcRotateCameraGamepadInput...
  9049. */
  9050. export var CameraInputTypes: {};
  9051. /**
  9052. * This is the contract to implement in order to create a new input class.
  9053. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  9054. */
  9055. export interface ICameraInput<TCamera extends Camera> {
  9056. /**
  9057. * Defines the camera the input is attached to.
  9058. */
  9059. camera: Nullable<TCamera>;
  9060. /**
  9061. * Gets the class name of the current intput.
  9062. * @returns the class name
  9063. */
  9064. getClassName(): string;
  9065. /**
  9066. * Get the friendly name associated with the input class.
  9067. * @returns the input friendly name
  9068. */
  9069. getSimpleName(): string;
  9070. /**
  9071. * Attach the input controls to a specific dom element to get the input from.
  9072. * @param element Defines the element the controls should be listened from
  9073. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9074. */
  9075. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  9076. /**
  9077. * Detach the current controls from the specified dom element.
  9078. * @param element Defines the element to stop listening the inputs from
  9079. */
  9080. detachControl(element: Nullable<HTMLElement>): void;
  9081. /**
  9082. * Update the current camera state depending on the inputs that have been used this frame.
  9083. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9084. */
  9085. checkInputs?: () => void;
  9086. }
  9087. /**
  9088. * Represents a map of input types to input instance or input index to input instance.
  9089. */
  9090. export interface CameraInputsMap<TCamera extends Camera> {
  9091. /**
  9092. * Accessor to the input by input type.
  9093. */
  9094. [name: string]: ICameraInput<TCamera>;
  9095. /**
  9096. * Accessor to the input by input index.
  9097. */
  9098. [idx: number]: ICameraInput<TCamera>;
  9099. }
  9100. /**
  9101. * This represents the input manager used within a camera.
  9102. * It helps dealing with all the different kind of input attached to a camera.
  9103. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9104. */
  9105. export class CameraInputsManager<TCamera extends Camera> {
  9106. /**
  9107. * Defines the list of inputs attahed to the camera.
  9108. */
  9109. attached: CameraInputsMap<TCamera>;
  9110. /**
  9111. * Defines the dom element the camera is collecting inputs from.
  9112. * This is null if the controls have not been attached.
  9113. */
  9114. attachedElement: Nullable<HTMLElement>;
  9115. /**
  9116. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9117. */
  9118. noPreventDefault: boolean;
  9119. /**
  9120. * Defined the camera the input manager belongs to.
  9121. */
  9122. camera: TCamera;
  9123. /**
  9124. * Update the current camera state depending on the inputs that have been used this frame.
  9125. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9126. */
  9127. checkInputs: () => void;
  9128. /**
  9129. * Instantiate a new Camera Input Manager.
  9130. * @param camera Defines the camera the input manager blongs to
  9131. */
  9132. constructor(camera: TCamera);
  9133. /**
  9134. * Add an input method to a camera
  9135. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9136. * @param input camera input method
  9137. */
  9138. add(input: ICameraInput<TCamera>): void;
  9139. /**
  9140. * Remove a specific input method from a camera
  9141. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  9142. * @param inputToRemove camera input method
  9143. */
  9144. remove(inputToRemove: ICameraInput<TCamera>): void;
  9145. /**
  9146. * Remove a specific input type from a camera
  9147. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  9148. * @param inputType the type of the input to remove
  9149. */
  9150. removeByType(inputType: string): void;
  9151. private _addCheckInputs;
  9152. /**
  9153. * Attach the input controls to the currently attached dom element to listen the events from.
  9154. * @param input Defines the input to attach
  9155. */
  9156. attachInput(input: ICameraInput<TCamera>): void;
  9157. /**
  9158. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  9159. * @param element Defines the dom element to collect the events from
  9160. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9161. */
  9162. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  9163. /**
  9164. * Detach the current manager inputs controls from a specific dom element.
  9165. * @param element Defines the dom element to collect the events from
  9166. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  9167. */
  9168. detachElement(element: HTMLElement, disconnect?: boolean): void;
  9169. /**
  9170. * Rebuild the dynamic inputCheck function from the current list of
  9171. * defined inputs in the manager.
  9172. */
  9173. rebuildInputCheck(): void;
  9174. /**
  9175. * Remove all attached input methods from a camera
  9176. */
  9177. clear(): void;
  9178. /**
  9179. * Serialize the current input manager attached to a camera.
  9180. * This ensures than once parsed,
  9181. * the input associated to the camera will be identical to the current ones
  9182. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9183. */
  9184. serialize(serializedCamera: any): void;
  9185. /**
  9186. * Parses an input manager serialized JSON to restore the previous list of inputs
  9187. * and states associated to a camera.
  9188. * @param parsedCamera Defines the JSON to parse
  9189. */
  9190. parse(parsedCamera: any): void;
  9191. }
  9192. }
  9193. declare module "babylonjs/Events/keyboardEvents" {
  9194. /**
  9195. * Gather the list of keyboard event types as constants.
  9196. */
  9197. export class KeyboardEventTypes {
  9198. /**
  9199. * The keydown event is fired when a key becomes active (pressed).
  9200. */
  9201. static readonly KEYDOWN: number;
  9202. /**
  9203. * The keyup event is fired when a key has been released.
  9204. */
  9205. static readonly KEYUP: number;
  9206. }
  9207. /**
  9208. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9209. */
  9210. export class KeyboardInfo {
  9211. /**
  9212. * Defines the type of event (KeyboardEventTypes)
  9213. */
  9214. type: number;
  9215. /**
  9216. * Defines the related dom event
  9217. */
  9218. event: KeyboardEvent;
  9219. /**
  9220. * Instantiates a new keyboard info.
  9221. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9222. * @param type Defines the type of event (KeyboardEventTypes)
  9223. * @param event Defines the related dom event
  9224. */
  9225. constructor(
  9226. /**
  9227. * Defines the type of event (KeyboardEventTypes)
  9228. */
  9229. type: number,
  9230. /**
  9231. * Defines the related dom event
  9232. */
  9233. event: KeyboardEvent);
  9234. }
  9235. /**
  9236. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9237. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9238. */
  9239. export class KeyboardInfoPre extends KeyboardInfo {
  9240. /**
  9241. * Defines the type of event (KeyboardEventTypes)
  9242. */
  9243. type: number;
  9244. /**
  9245. * Defines the related dom event
  9246. */
  9247. event: KeyboardEvent;
  9248. /**
  9249. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9250. */
  9251. skipOnPointerObservable: boolean;
  9252. /**
  9253. * Instantiates a new keyboard pre info.
  9254. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9255. * @param type Defines the type of event (KeyboardEventTypes)
  9256. * @param event Defines the related dom event
  9257. */
  9258. constructor(
  9259. /**
  9260. * Defines the type of event (KeyboardEventTypes)
  9261. */
  9262. type: number,
  9263. /**
  9264. * Defines the related dom event
  9265. */
  9266. event: KeyboardEvent);
  9267. }
  9268. }
  9269. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  9270. import { Nullable } from "babylonjs/types";
  9271. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  9272. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  9273. /**
  9274. * Manage the keyboard inputs to control the movement of a free camera.
  9275. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9276. */
  9277. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9278. /**
  9279. * Defines the camera the input is attached to.
  9280. */
  9281. camera: FreeCamera;
  9282. /**
  9283. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9284. */
  9285. keysUp: number[];
  9286. /**
  9287. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9288. */
  9289. keysDown: number[];
  9290. /**
  9291. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9292. */
  9293. keysLeft: number[];
  9294. /**
  9295. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9296. */
  9297. keysRight: number[];
  9298. private _keys;
  9299. private _onCanvasBlurObserver;
  9300. private _onKeyboardObserver;
  9301. private _engine;
  9302. private _scene;
  9303. /**
  9304. * Attach the input controls to a specific dom element to get the input from.
  9305. * @param element Defines the element the controls should be listened from
  9306. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9307. */
  9308. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  9309. /**
  9310. * Detach the current controls from the specified dom element.
  9311. * @param element Defines the element to stop listening the inputs from
  9312. */
  9313. detachControl(element: Nullable<HTMLElement>): void;
  9314. /**
  9315. * Update the current camera state depending on the inputs that have been used this frame.
  9316. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9317. */
  9318. checkInputs(): void;
  9319. /**
  9320. * Gets the class name of the current intput.
  9321. * @returns the class name
  9322. */
  9323. getClassName(): string;
  9324. /** @hidden */
  9325. _onLostFocus(): void;
  9326. /**
  9327. * Get the friendly name associated with the input class.
  9328. * @returns the input friendly name
  9329. */
  9330. getSimpleName(): string;
  9331. }
  9332. }
  9333. declare module "babylonjs/Lights/shadowLight" {
  9334. import { Camera } from "babylonjs/Cameras/camera";
  9335. import { Scene } from "babylonjs/scene";
  9336. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  9337. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9338. import { Light } from "babylonjs/Lights/light";
  9339. /**
  9340. * Interface describing all the common properties and methods a shadow light needs to implement.
  9341. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9342. * as well as binding the different shadow properties to the effects.
  9343. */
  9344. export interface IShadowLight extends Light {
  9345. /**
  9346. * The light id in the scene (used in scene.findLighById for instance)
  9347. */
  9348. id: string;
  9349. /**
  9350. * The position the shdow will be casted from.
  9351. */
  9352. position: Vector3;
  9353. /**
  9354. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9355. */
  9356. direction: Vector3;
  9357. /**
  9358. * The transformed position. Position of the light in world space taking parenting in account.
  9359. */
  9360. transformedPosition: Vector3;
  9361. /**
  9362. * The transformed direction. Direction of the light in world space taking parenting in account.
  9363. */
  9364. transformedDirection: Vector3;
  9365. /**
  9366. * The friendly name of the light in the scene.
  9367. */
  9368. name: string;
  9369. /**
  9370. * Defines the shadow projection clipping minimum z value.
  9371. */
  9372. shadowMinZ: number;
  9373. /**
  9374. * Defines the shadow projection clipping maximum z value.
  9375. */
  9376. shadowMaxZ: number;
  9377. /**
  9378. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9379. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9380. */
  9381. computeTransformedInformation(): boolean;
  9382. /**
  9383. * Gets the scene the light belongs to.
  9384. * @returns The scene
  9385. */
  9386. getScene(): Scene;
  9387. /**
  9388. * Callback defining a custom Projection Matrix Builder.
  9389. * This can be used to override the default projection matrix computation.
  9390. */
  9391. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9392. /**
  9393. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9394. * @param matrix The materix to updated with the projection information
  9395. * @param viewMatrix The transform matrix of the light
  9396. * @param renderList The list of mesh to render in the map
  9397. * @returns The current light
  9398. */
  9399. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9400. /**
  9401. * Gets the current depth scale used in ESM.
  9402. * @returns The scale
  9403. */
  9404. getDepthScale(): number;
  9405. /**
  9406. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9407. * @returns true if a cube texture needs to be use
  9408. */
  9409. needCube(): boolean;
  9410. /**
  9411. * Detects if the projection matrix requires to be recomputed this frame.
  9412. * @returns true if it requires to be recomputed otherwise, false.
  9413. */
  9414. needProjectionMatrixCompute(): boolean;
  9415. /**
  9416. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9417. */
  9418. forceProjectionMatrixCompute(): void;
  9419. /**
  9420. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9421. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9422. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9423. */
  9424. getShadowDirection(faceIndex?: number): Vector3;
  9425. /**
  9426. * Gets the minZ used for shadow according to both the scene and the light.
  9427. * @param activeCamera The camera we are returning the min for
  9428. * @returns the depth min z
  9429. */
  9430. getDepthMinZ(activeCamera: Camera): number;
  9431. /**
  9432. * Gets the maxZ used for shadow according to both the scene and the light.
  9433. * @param activeCamera The camera we are returning the max for
  9434. * @returns the depth max z
  9435. */
  9436. getDepthMaxZ(activeCamera: Camera): number;
  9437. }
  9438. /**
  9439. * Base implementation IShadowLight
  9440. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9441. */
  9442. export abstract class ShadowLight extends Light implements IShadowLight {
  9443. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9444. protected _position: Vector3;
  9445. protected _setPosition(value: Vector3): void;
  9446. /**
  9447. * Sets the position the shadow will be casted from. Also use as the light position for both
  9448. * point and spot lights.
  9449. */
  9450. /**
  9451. * Sets the position the shadow will be casted from. Also use as the light position for both
  9452. * point and spot lights.
  9453. */
  9454. position: Vector3;
  9455. protected _direction: Vector3;
  9456. protected _setDirection(value: Vector3): void;
  9457. /**
  9458. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9459. * Also use as the light direction on spot and directional lights.
  9460. */
  9461. /**
  9462. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9463. * Also use as the light direction on spot and directional lights.
  9464. */
  9465. direction: Vector3;
  9466. private _shadowMinZ;
  9467. /**
  9468. * Gets the shadow projection clipping minimum z value.
  9469. */
  9470. /**
  9471. * Sets the shadow projection clipping minimum z value.
  9472. */
  9473. shadowMinZ: number;
  9474. private _shadowMaxZ;
  9475. /**
  9476. * Sets the shadow projection clipping maximum z value.
  9477. */
  9478. /**
  9479. * Gets the shadow projection clipping maximum z value.
  9480. */
  9481. shadowMaxZ: number;
  9482. /**
  9483. * Callback defining a custom Projection Matrix Builder.
  9484. * This can be used to override the default projection matrix computation.
  9485. */
  9486. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9487. /**
  9488. * The transformed position. Position of the light in world space taking parenting in account.
  9489. */
  9490. transformedPosition: Vector3;
  9491. /**
  9492. * The transformed direction. Direction of the light in world space taking parenting in account.
  9493. */
  9494. transformedDirection: Vector3;
  9495. private _needProjectionMatrixCompute;
  9496. /**
  9497. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9498. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9499. */
  9500. computeTransformedInformation(): boolean;
  9501. /**
  9502. * Return the depth scale used for the shadow map.
  9503. * @returns the depth scale.
  9504. */
  9505. getDepthScale(): number;
  9506. /**
  9507. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9508. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9509. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9510. */
  9511. getShadowDirection(faceIndex?: number): Vector3;
  9512. /**
  9513. * Returns the ShadowLight absolute position in the World.
  9514. * @returns the position vector in world space
  9515. */
  9516. getAbsolutePosition(): Vector3;
  9517. /**
  9518. * Sets the ShadowLight direction toward the passed target.
  9519. * @param target The point to target in local space
  9520. * @returns the updated ShadowLight direction
  9521. */
  9522. setDirectionToTarget(target: Vector3): Vector3;
  9523. /**
  9524. * Returns the light rotation in euler definition.
  9525. * @returns the x y z rotation in local space.
  9526. */
  9527. getRotation(): Vector3;
  9528. /**
  9529. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9530. * @returns true if a cube texture needs to be use
  9531. */
  9532. needCube(): boolean;
  9533. /**
  9534. * Detects if the projection matrix requires to be recomputed this frame.
  9535. * @returns true if it requires to be recomputed otherwise, false.
  9536. */
  9537. needProjectionMatrixCompute(): boolean;
  9538. /**
  9539. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9540. */
  9541. forceProjectionMatrixCompute(): void;
  9542. /** @hidden */
  9543. _initCache(): void;
  9544. /** @hidden */
  9545. _isSynchronized(): boolean;
  9546. /**
  9547. * Computes the world matrix of the node
  9548. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9549. * @returns the world matrix
  9550. */
  9551. computeWorldMatrix(force?: boolean): Matrix;
  9552. /**
  9553. * Gets the minZ used for shadow according to both the scene and the light.
  9554. * @param activeCamera The camera we are returning the min for
  9555. * @returns the depth min z
  9556. */
  9557. getDepthMinZ(activeCamera: Camera): number;
  9558. /**
  9559. * Gets the maxZ used for shadow according to both the scene and the light.
  9560. * @param activeCamera The camera we are returning the max for
  9561. * @returns the depth max z
  9562. */
  9563. getDepthMaxZ(activeCamera: Camera): number;
  9564. /**
  9565. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9566. * @param matrix The materix to updated with the projection information
  9567. * @param viewMatrix The transform matrix of the light
  9568. * @param renderList The list of mesh to render in the map
  9569. * @returns The current light
  9570. */
  9571. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9572. }
  9573. }
  9574. declare module "babylonjs/Materials/materialHelper" {
  9575. import { Nullable } from "babylonjs/types";
  9576. import { Scene } from "babylonjs/scene";
  9577. import { Engine } from "babylonjs/Engines/engine";
  9578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9579. import { Light } from "babylonjs/Lights/light";
  9580. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9581. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9582. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9583. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9584. /**
  9585. * "Static Class" containing the most commonly used helper while dealing with material for
  9586. * rendering purpose.
  9587. *
  9588. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9589. *
  9590. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9591. */
  9592. export class MaterialHelper {
  9593. /**
  9594. * Bind the current view position to an effect.
  9595. * @param effect The effect to be bound
  9596. * @param scene The scene the eyes position is used from
  9597. */
  9598. static BindEyePosition(effect: Effect, scene: Scene): void;
  9599. /**
  9600. * Helps preparing the defines values about the UVs in used in the effect.
  9601. * UVs are shared as much as we can accross channels in the shaders.
  9602. * @param texture The texture we are preparing the UVs for
  9603. * @param defines The defines to update
  9604. * @param key The channel key "diffuse", "specular"... used in the shader
  9605. */
  9606. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9607. /**
  9608. * Binds a texture matrix value to its corrsponding uniform
  9609. * @param texture The texture to bind the matrix for
  9610. * @param uniformBuffer The uniform buffer receivin the data
  9611. * @param key The channel key "diffuse", "specular"... used in the shader
  9612. */
  9613. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9614. /**
  9615. * Gets the current status of the fog (should it be enabled?)
  9616. * @param mesh defines the mesh to evaluate for fog support
  9617. * @param scene defines the hosting scene
  9618. * @returns true if fog must be enabled
  9619. */
  9620. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9621. /**
  9622. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9623. * @param mesh defines the current mesh
  9624. * @param scene defines the current scene
  9625. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9626. * @param pointsCloud defines if point cloud rendering has to be turned on
  9627. * @param fogEnabled defines if fog has to be turned on
  9628. * @param alphaTest defines if alpha testing has to be turned on
  9629. * @param defines defines the current list of defines
  9630. */
  9631. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9632. /**
  9633. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9634. * @param scene defines the current scene
  9635. * @param engine defines the current engine
  9636. * @param defines specifies the list of active defines
  9637. * @param useInstances defines if instances have to be turned on
  9638. * @param useClipPlane defines if clip plane have to be turned on
  9639. */
  9640. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9641. /**
  9642. * Prepares the defines for bones
  9643. * @param mesh The mesh containing the geometry data we will draw
  9644. * @param defines The defines to update
  9645. */
  9646. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9647. /**
  9648. * Prepares the defines for morph targets
  9649. * @param mesh The mesh containing the geometry data we will draw
  9650. * @param defines The defines to update
  9651. */
  9652. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9653. /**
  9654. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9655. * @param mesh The mesh containing the geometry data we will draw
  9656. * @param defines The defines to update
  9657. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9658. * @param useBones Precise whether bones should be used or not (override mesh info)
  9659. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9660. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9661. * @returns false if defines are considered not dirty and have not been checked
  9662. */
  9663. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9664. /**
  9665. * Prepares the defines related to multiview
  9666. * @param scene The scene we are intending to draw
  9667. * @param defines The defines to update
  9668. */
  9669. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9670. /**
  9671. * Prepares the defines related to the light information passed in parameter
  9672. * @param scene The scene we are intending to draw
  9673. * @param mesh The mesh the effect is compiling for
  9674. * @param defines The defines to update
  9675. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9676. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9677. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9678. * @returns true if normals will be required for the rest of the effect
  9679. */
  9680. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9681. /**
  9682. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9683. * that won t be acctive due to defines being turned off.
  9684. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9685. * @param samplersList The samplers list
  9686. * @param defines The defines helping in the list generation
  9687. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9688. */
  9689. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9690. /**
  9691. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9692. * @param defines The defines to update while falling back
  9693. * @param fallbacks The authorized effect fallbacks
  9694. * @param maxSimultaneousLights The maximum number of lights allowed
  9695. * @param rank the current rank of the Effect
  9696. * @returns The newly affected rank
  9697. */
  9698. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9699. /**
  9700. * Prepares the list of attributes required for morph targets according to the effect defines.
  9701. * @param attribs The current list of supported attribs
  9702. * @param mesh The mesh to prepare the morph targets attributes for
  9703. * @param defines The current Defines of the effect
  9704. */
  9705. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9706. /**
  9707. * Prepares the list of attributes required for bones according to the effect defines.
  9708. * @param attribs The current list of supported attribs
  9709. * @param mesh The mesh to prepare the bones attributes for
  9710. * @param defines The current Defines of the effect
  9711. * @param fallbacks The current efffect fallback strategy
  9712. */
  9713. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9714. /**
  9715. * Check and prepare the list of attributes required for instances according to the effect defines.
  9716. * @param attribs The current list of supported attribs
  9717. * @param defines The current MaterialDefines of the effect
  9718. */
  9719. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9720. /**
  9721. * Add the list of attributes required for instances to the attribs array.
  9722. * @param attribs The current list of supported attribs
  9723. */
  9724. static PushAttributesForInstances(attribs: string[]): void;
  9725. /**
  9726. * Binds the light shadow information to the effect for the given mesh.
  9727. * @param light The light containing the generator
  9728. * @param scene The scene the lights belongs to
  9729. * @param mesh The mesh we are binding the information to render
  9730. * @param lightIndex The light index in the effect used to render the mesh
  9731. * @param effect The effect we are binding the data to
  9732. */
  9733. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9734. /**
  9735. * Binds the light information to the effect.
  9736. * @param light The light containing the generator
  9737. * @param effect The effect we are binding the data to
  9738. * @param lightIndex The light index in the effect used to render
  9739. */
  9740. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9741. /**
  9742. * Binds the lights information from the scene to the effect for the given mesh.
  9743. * @param scene The scene the lights belongs to
  9744. * @param mesh The mesh we are binding the information to render
  9745. * @param effect The effect we are binding the data to
  9746. * @param defines The generated defines for the effect
  9747. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9748. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9749. */
  9750. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9751. private static _tempFogColor;
  9752. /**
  9753. * Binds the fog information from the scene to the effect for the given mesh.
  9754. * @param scene The scene the lights belongs to
  9755. * @param mesh The mesh we are binding the information to render
  9756. * @param effect The effect we are binding the data to
  9757. * @param linearSpace Defines if the fog effect is applied in linear space
  9758. */
  9759. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9760. /**
  9761. * Binds the bones information from the mesh to the effect.
  9762. * @param mesh The mesh we are binding the information to render
  9763. * @param effect The effect we are binding the data to
  9764. */
  9765. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9766. /**
  9767. * Binds the morph targets information from the mesh to the effect.
  9768. * @param abstractMesh The mesh we are binding the information to render
  9769. * @param effect The effect we are binding the data to
  9770. */
  9771. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9772. /**
  9773. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9774. * @param defines The generated defines used in the effect
  9775. * @param effect The effect we are binding the data to
  9776. * @param scene The scene we are willing to render with logarithmic scale for
  9777. */
  9778. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9779. /**
  9780. * Binds the clip plane information from the scene to the effect.
  9781. * @param scene The scene the clip plane information are extracted from
  9782. * @param effect The effect we are binding the data to
  9783. */
  9784. static BindClipPlane(effect: Effect, scene: Scene): void;
  9785. }
  9786. }
  9787. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9788. /** @hidden */
  9789. export var kernelBlurVaryingDeclaration: {
  9790. name: string;
  9791. shader: string;
  9792. };
  9793. }
  9794. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9795. /** @hidden */
  9796. export var kernelBlurFragment: {
  9797. name: string;
  9798. shader: string;
  9799. };
  9800. }
  9801. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9802. /** @hidden */
  9803. export var kernelBlurFragment2: {
  9804. name: string;
  9805. shader: string;
  9806. };
  9807. }
  9808. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9809. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9810. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9811. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9812. /** @hidden */
  9813. export var kernelBlurPixelShader: {
  9814. name: string;
  9815. shader: string;
  9816. };
  9817. }
  9818. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9819. /** @hidden */
  9820. export var kernelBlurVertex: {
  9821. name: string;
  9822. shader: string;
  9823. };
  9824. }
  9825. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9826. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9827. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9828. /** @hidden */
  9829. export var kernelBlurVertexShader: {
  9830. name: string;
  9831. shader: string;
  9832. };
  9833. }
  9834. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9835. import { Vector2 } from "babylonjs/Maths/math";
  9836. import { Nullable } from "babylonjs/types";
  9837. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9838. import { Camera } from "babylonjs/Cameras/camera";
  9839. import { Effect } from "babylonjs/Materials/effect";
  9840. import { Engine } from "babylonjs/Engines/engine";
  9841. import "babylonjs/Shaders/kernelBlur.fragment";
  9842. import "babylonjs/Shaders/kernelBlur.vertex";
  9843. /**
  9844. * The Blur Post Process which blurs an image based on a kernel and direction.
  9845. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9846. */
  9847. export class BlurPostProcess extends PostProcess {
  9848. /** The direction in which to blur the image. */
  9849. direction: Vector2;
  9850. private blockCompilation;
  9851. protected _kernel: number;
  9852. protected _idealKernel: number;
  9853. protected _packedFloat: boolean;
  9854. private _staticDefines;
  9855. /**
  9856. * Sets the length in pixels of the blur sample region
  9857. */
  9858. /**
  9859. * Gets the length in pixels of the blur sample region
  9860. */
  9861. kernel: number;
  9862. /**
  9863. * Sets wether or not the blur needs to unpack/repack floats
  9864. */
  9865. /**
  9866. * Gets wether or not the blur is unpacking/repacking floats
  9867. */
  9868. packedFloat: boolean;
  9869. /**
  9870. * Creates a new instance BlurPostProcess
  9871. * @param name The name of the effect.
  9872. * @param direction The direction in which to blur the image.
  9873. * @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.
  9874. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9875. * @param camera The camera to apply the render pass to.
  9876. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9877. * @param engine The engine which the post process will be applied. (default: current engine)
  9878. * @param reusable If the post process can be reused on the same frame. (default: false)
  9879. * @param textureType Type of textures used when performing the post process. (default: 0)
  9880. * @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)
  9881. */
  9882. constructor(name: string,
  9883. /** The direction in which to blur the image. */
  9884. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9885. /**
  9886. * Updates the effect with the current post process compile time values and recompiles the shader.
  9887. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9888. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9889. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9890. * @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
  9891. * @param onCompiled Called when the shader has been compiled.
  9892. * @param onError Called if there is an error when compiling a shader.
  9893. */
  9894. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9895. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9896. /**
  9897. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9898. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9899. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9900. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9901. * The gaps between physical kernels are compensated for in the weighting of the samples
  9902. * @param idealKernel Ideal blur kernel.
  9903. * @return Nearest best kernel.
  9904. */
  9905. protected _nearestBestKernel(idealKernel: number): number;
  9906. /**
  9907. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9908. * @param x The point on the Gaussian distribution to sample.
  9909. * @return the value of the Gaussian function at x.
  9910. */
  9911. protected _gaussianWeight(x: number): number;
  9912. /**
  9913. * Generates a string that can be used as a floating point number in GLSL.
  9914. * @param x Value to print.
  9915. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9916. * @return GLSL float string.
  9917. */
  9918. protected _glslFloat(x: number, decimalFigures?: number): string;
  9919. }
  9920. }
  9921. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9922. /** @hidden */
  9923. export var shadowMapPixelShader: {
  9924. name: string;
  9925. shader: string;
  9926. };
  9927. }
  9928. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9929. /** @hidden */
  9930. export var bonesDeclaration: {
  9931. name: string;
  9932. shader: string;
  9933. };
  9934. }
  9935. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9936. /** @hidden */
  9937. export var morphTargetsVertexGlobalDeclaration: {
  9938. name: string;
  9939. shader: string;
  9940. };
  9941. }
  9942. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9943. /** @hidden */
  9944. export var morphTargetsVertexDeclaration: {
  9945. name: string;
  9946. shader: string;
  9947. };
  9948. }
  9949. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9950. /** @hidden */
  9951. export var instancesDeclaration: {
  9952. name: string;
  9953. shader: string;
  9954. };
  9955. }
  9956. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9957. /** @hidden */
  9958. export var helperFunctions: {
  9959. name: string;
  9960. shader: string;
  9961. };
  9962. }
  9963. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9964. /** @hidden */
  9965. export var morphTargetsVertex: {
  9966. name: string;
  9967. shader: string;
  9968. };
  9969. }
  9970. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9971. /** @hidden */
  9972. export var instancesVertex: {
  9973. name: string;
  9974. shader: string;
  9975. };
  9976. }
  9977. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9978. /** @hidden */
  9979. export var bonesVertex: {
  9980. name: string;
  9981. shader: string;
  9982. };
  9983. }
  9984. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9985. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9986. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9987. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9988. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9989. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9990. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9991. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9992. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9993. /** @hidden */
  9994. export var shadowMapVertexShader: {
  9995. name: string;
  9996. shader: string;
  9997. };
  9998. }
  9999. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  10000. /** @hidden */
  10001. export var depthBoxBlurPixelShader: {
  10002. name: string;
  10003. shader: string;
  10004. };
  10005. }
  10006. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  10007. import { Nullable } from "babylonjs/types";
  10008. import { Scene } from "babylonjs/scene";
  10009. import { Matrix } from "babylonjs/Maths/math";
  10010. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10011. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10012. import { Mesh } from "babylonjs/Meshes/mesh";
  10013. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  10014. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  10015. import { Effect } from "babylonjs/Materials/effect";
  10016. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10017. import "babylonjs/Shaders/shadowMap.fragment";
  10018. import "babylonjs/Shaders/shadowMap.vertex";
  10019. import "babylonjs/Shaders/depthBoxBlur.fragment";
  10020. import { Observable } from "babylonjs/Misc/observable";
  10021. /**
  10022. * Defines the options associated with the creation of a custom shader for a shadow generator.
  10023. */
  10024. export interface ICustomShaderOptions {
  10025. /**
  10026. * Gets or sets the custom shader name to use
  10027. */
  10028. shaderName: string;
  10029. /**
  10030. * The list of attribute names used in the shader
  10031. */
  10032. attributes?: string[];
  10033. /**
  10034. * The list of unifrom names used in the shader
  10035. */
  10036. uniforms?: string[];
  10037. /**
  10038. * The list of sampler names used in the shader
  10039. */
  10040. samplers?: string[];
  10041. /**
  10042. * The list of defines used in the shader
  10043. */
  10044. defines?: string[];
  10045. }
  10046. /**
  10047. * Interface to implement to create a shadow generator compatible with BJS.
  10048. */
  10049. export interface IShadowGenerator {
  10050. /**
  10051. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10052. * @returns The render target texture if present otherwise, null
  10053. */
  10054. getShadowMap(): Nullable<RenderTargetTexture>;
  10055. /**
  10056. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10057. * @returns The render target texture if the shadow map is present otherwise, null
  10058. */
  10059. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10060. /**
  10061. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10062. * @param subMesh The submesh we want to render in the shadow map
  10063. * @param useInstances Defines wether will draw in the map using instances
  10064. * @returns true if ready otherwise, false
  10065. */
  10066. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10067. /**
  10068. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10069. * @param defines Defines of the material we want to update
  10070. * @param lightIndex Index of the light in the enabled light list of the material
  10071. */
  10072. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  10073. /**
  10074. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10075. * defined in the generator but impacting the effect).
  10076. * It implies the unifroms available on the materials are the standard BJS ones.
  10077. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10078. * @param effect The effect we are binfing the information for
  10079. */
  10080. bindShadowLight(lightIndex: string, effect: Effect): void;
  10081. /**
  10082. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10083. * (eq to shadow prjection matrix * light transform matrix)
  10084. * @returns The transform matrix used to create the shadow map
  10085. */
  10086. getTransformMatrix(): Matrix;
  10087. /**
  10088. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10089. * Cube and 2D textures for instance.
  10090. */
  10091. recreateShadowMap(): void;
  10092. /**
  10093. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10094. * @param onCompiled Callback triggered at the and of the effects compilation
  10095. * @param options Sets of optional options forcing the compilation with different modes
  10096. */
  10097. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10098. useInstances: boolean;
  10099. }>): void;
  10100. /**
  10101. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10102. * @param options Sets of optional options forcing the compilation with different modes
  10103. * @returns A promise that resolves when the compilation completes
  10104. */
  10105. forceCompilationAsync(options?: Partial<{
  10106. useInstances: boolean;
  10107. }>): Promise<void>;
  10108. /**
  10109. * Serializes the shadow generator setup to a json object.
  10110. * @returns The serialized JSON object
  10111. */
  10112. serialize(): any;
  10113. /**
  10114. * Disposes the Shadow map and related Textures and effects.
  10115. */
  10116. dispose(): void;
  10117. }
  10118. /**
  10119. * Default implementation IShadowGenerator.
  10120. * This is the main object responsible of generating shadows in the framework.
  10121. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  10122. */
  10123. export class ShadowGenerator implements IShadowGenerator {
  10124. /**
  10125. * Shadow generator mode None: no filtering applied.
  10126. */
  10127. static readonly FILTER_NONE: number;
  10128. /**
  10129. * Shadow generator mode ESM: Exponential Shadow Mapping.
  10130. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10131. */
  10132. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  10133. /**
  10134. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  10135. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  10136. */
  10137. static readonly FILTER_POISSONSAMPLING: number;
  10138. /**
  10139. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  10140. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10141. */
  10142. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  10143. /**
  10144. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  10145. * edge artifacts on steep falloff.
  10146. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10147. */
  10148. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  10149. /**
  10150. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  10151. * edge artifacts on steep falloff.
  10152. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10153. */
  10154. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  10155. /**
  10156. * Shadow generator mode PCF: Percentage Closer Filtering
  10157. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  10158. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  10159. */
  10160. static readonly FILTER_PCF: number;
  10161. /**
  10162. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  10163. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  10164. * Contact Hardening
  10165. */
  10166. static readonly FILTER_PCSS: number;
  10167. /**
  10168. * Reserved for PCF and PCSS
  10169. * Highest Quality.
  10170. *
  10171. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  10172. *
  10173. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  10174. */
  10175. static readonly QUALITY_HIGH: number;
  10176. /**
  10177. * Reserved for PCF and PCSS
  10178. * Good tradeoff for quality/perf cross devices
  10179. *
  10180. * Execute PCF on a 3*3 kernel.
  10181. *
  10182. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  10183. */
  10184. static readonly QUALITY_MEDIUM: number;
  10185. /**
  10186. * Reserved for PCF and PCSS
  10187. * The lowest quality but the fastest.
  10188. *
  10189. * Execute PCF on a 1*1 kernel.
  10190. *
  10191. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  10192. */
  10193. static readonly QUALITY_LOW: number;
  10194. /** Gets or sets the custom shader name to use */
  10195. customShaderOptions: ICustomShaderOptions;
  10196. /**
  10197. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  10198. */
  10199. onBeforeShadowMapRenderObservable: Observable<Effect>;
  10200. /**
  10201. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  10202. */
  10203. onAfterShadowMapRenderObservable: Observable<Effect>;
  10204. /**
  10205. * Observable triggered before a mesh is rendered in the shadow map.
  10206. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  10207. */
  10208. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  10209. /**
  10210. * Observable triggered after a mesh is rendered in the shadow map.
  10211. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  10212. */
  10213. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  10214. private _bias;
  10215. /**
  10216. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  10217. */
  10218. /**
  10219. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  10220. */
  10221. bias: number;
  10222. private _normalBias;
  10223. /**
  10224. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10225. */
  10226. /**
  10227. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10228. */
  10229. normalBias: number;
  10230. private _blurBoxOffset;
  10231. /**
  10232. * Gets the blur box offset: offset applied during the blur pass.
  10233. * Only useful if useKernelBlur = false
  10234. */
  10235. /**
  10236. * Sets the blur box offset: offset applied during the blur pass.
  10237. * Only useful if useKernelBlur = false
  10238. */
  10239. blurBoxOffset: number;
  10240. private _blurScale;
  10241. /**
  10242. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  10243. * 2 means half of the size.
  10244. */
  10245. /**
  10246. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  10247. * 2 means half of the size.
  10248. */
  10249. blurScale: number;
  10250. private _blurKernel;
  10251. /**
  10252. * Gets the blur kernel: kernel size of the blur pass.
  10253. * Only useful if useKernelBlur = true
  10254. */
  10255. /**
  10256. * Sets the blur kernel: kernel size of the blur pass.
  10257. * Only useful if useKernelBlur = true
  10258. */
  10259. blurKernel: number;
  10260. private _useKernelBlur;
  10261. /**
  10262. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  10263. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10264. */
  10265. /**
  10266. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  10267. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10268. */
  10269. useKernelBlur: boolean;
  10270. private _depthScale;
  10271. /**
  10272. * Gets the depth scale used in ESM mode.
  10273. */
  10274. /**
  10275. * Sets the depth scale used in ESM mode.
  10276. * This can override the scale stored on the light.
  10277. */
  10278. depthScale: number;
  10279. private _filter;
  10280. /**
  10281. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  10282. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10283. */
  10284. /**
  10285. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  10286. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10287. */
  10288. filter: number;
  10289. /**
  10290. * Gets if the current filter is set to Poisson Sampling.
  10291. */
  10292. /**
  10293. * Sets the current filter to Poisson Sampling.
  10294. */
  10295. usePoissonSampling: boolean;
  10296. /**
  10297. * Gets if the current filter is set to ESM.
  10298. */
  10299. /**
  10300. * Sets the current filter is to ESM.
  10301. */
  10302. useExponentialShadowMap: boolean;
  10303. /**
  10304. * Gets if the current filter is set to filtered ESM.
  10305. */
  10306. /**
  10307. * Gets if the current filter is set to filtered ESM.
  10308. */
  10309. useBlurExponentialShadowMap: boolean;
  10310. /**
  10311. * Gets if the current filter is set to "close ESM" (using the inverse of the
  10312. * exponential to prevent steep falloff artifacts).
  10313. */
  10314. /**
  10315. * Sets the current filter to "close ESM" (using the inverse of the
  10316. * exponential to prevent steep falloff artifacts).
  10317. */
  10318. useCloseExponentialShadowMap: boolean;
  10319. /**
  10320. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  10321. * exponential to prevent steep falloff artifacts).
  10322. */
  10323. /**
  10324. * Sets the current filter to filtered "close ESM" (using the inverse of the
  10325. * exponential to prevent steep falloff artifacts).
  10326. */
  10327. useBlurCloseExponentialShadowMap: boolean;
  10328. /**
  10329. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  10330. */
  10331. /**
  10332. * Sets the current filter to "PCF" (percentage closer filtering).
  10333. */
  10334. usePercentageCloserFiltering: boolean;
  10335. private _filteringQuality;
  10336. /**
  10337. * Gets the PCF or PCSS Quality.
  10338. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10339. */
  10340. /**
  10341. * Sets the PCF or PCSS Quality.
  10342. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10343. */
  10344. filteringQuality: number;
  10345. /**
  10346. * Gets if the current filter is set to "PCSS" (contact hardening).
  10347. */
  10348. /**
  10349. * Sets the current filter to "PCSS" (contact hardening).
  10350. */
  10351. useContactHardeningShadow: boolean;
  10352. private _contactHardeningLightSizeUVRatio;
  10353. /**
  10354. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10355. * Using a ratio helps keeping shape stability independently of the map size.
  10356. *
  10357. * It does not account for the light projection as it was having too much
  10358. * instability during the light setup or during light position changes.
  10359. *
  10360. * Only valid if useContactHardeningShadow is true.
  10361. */
  10362. /**
  10363. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10364. * Using a ratio helps keeping shape stability independently of the map size.
  10365. *
  10366. * It does not account for the light projection as it was having too much
  10367. * instability during the light setup or during light position changes.
  10368. *
  10369. * Only valid if useContactHardeningShadow is true.
  10370. */
  10371. contactHardeningLightSizeUVRatio: number;
  10372. private _darkness;
  10373. /** Gets or sets the actual darkness of a shadow */
  10374. darkness: number;
  10375. /**
  10376. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  10377. * 0 means strongest and 1 would means no shadow.
  10378. * @returns the darkness.
  10379. */
  10380. getDarkness(): number;
  10381. /**
  10382. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  10383. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  10384. * @returns the shadow generator allowing fluent coding.
  10385. */
  10386. setDarkness(darkness: number): ShadowGenerator;
  10387. private _transparencyShadow;
  10388. /** Gets or sets the ability to have transparent shadow */
  10389. transparencyShadow: boolean;
  10390. /**
  10391. * Sets the ability to have transparent shadow (boolean).
  10392. * @param transparent True if transparent else False
  10393. * @returns the shadow generator allowing fluent coding
  10394. */
  10395. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  10396. private _shadowMap;
  10397. private _shadowMap2;
  10398. /**
  10399. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10400. * @returns The render target texture if present otherwise, null
  10401. */
  10402. getShadowMap(): Nullable<RenderTargetTexture>;
  10403. /**
  10404. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10405. * @returns The render target texture if the shadow map is present otherwise, null
  10406. */
  10407. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10408. /**
  10409. * Gets the class name of that object
  10410. * @returns "ShadowGenerator"
  10411. */
  10412. getClassName(): string;
  10413. /**
  10414. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10415. * @param mesh Mesh to add
  10416. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10417. * @returns the Shadow Generator itself
  10418. */
  10419. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10420. /**
  10421. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10422. * @param mesh Mesh to remove
  10423. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10424. * @returns the Shadow Generator itself
  10425. */
  10426. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10427. /**
  10428. * Controls the extent to which the shadows fade out at the edge of the frustum
  10429. * Used only by directionals and spots
  10430. */
  10431. frustumEdgeFalloff: number;
  10432. private _light;
  10433. /**
  10434. * Returns the associated light object.
  10435. * @returns the light generating the shadow
  10436. */
  10437. getLight(): IShadowLight;
  10438. /**
  10439. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10440. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10441. * It might on the other hand introduce peter panning.
  10442. */
  10443. forceBackFacesOnly: boolean;
  10444. private _scene;
  10445. private _lightDirection;
  10446. private _effect;
  10447. private _viewMatrix;
  10448. private _projectionMatrix;
  10449. private _transformMatrix;
  10450. private _cachedPosition;
  10451. private _cachedDirection;
  10452. private _cachedDefines;
  10453. private _currentRenderID;
  10454. private _boxBlurPostprocess;
  10455. private _kernelBlurXPostprocess;
  10456. private _kernelBlurYPostprocess;
  10457. private _blurPostProcesses;
  10458. private _mapSize;
  10459. private _currentFaceIndex;
  10460. private _currentFaceIndexCache;
  10461. private _textureType;
  10462. private _defaultTextureMatrix;
  10463. /** @hidden */
  10464. static _SceneComponentInitialization: (scene: Scene) => void;
  10465. /**
  10466. * Creates a ShadowGenerator object.
  10467. * A ShadowGenerator is the required tool to use the shadows.
  10468. * Each light casting shadows needs to use its own ShadowGenerator.
  10469. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10470. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10471. * @param light The light object generating the shadows.
  10472. * @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.
  10473. */
  10474. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10475. private _initializeGenerator;
  10476. private _initializeShadowMap;
  10477. private _initializeBlurRTTAndPostProcesses;
  10478. private _renderForShadowMap;
  10479. private _renderSubMeshForShadowMap;
  10480. private _applyFilterValues;
  10481. /**
  10482. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10483. * @param onCompiled Callback triggered at the and of the effects compilation
  10484. * @param options Sets of optional options forcing the compilation with different modes
  10485. */
  10486. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10487. useInstances: boolean;
  10488. }>): void;
  10489. /**
  10490. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10491. * @param options Sets of optional options forcing the compilation with different modes
  10492. * @returns A promise that resolves when the compilation completes
  10493. */
  10494. forceCompilationAsync(options?: Partial<{
  10495. useInstances: boolean;
  10496. }>): Promise<void>;
  10497. /**
  10498. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10499. * @param subMesh The submesh we want to render in the shadow map
  10500. * @param useInstances Defines wether will draw in the map using instances
  10501. * @returns true if ready otherwise, false
  10502. */
  10503. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10504. /**
  10505. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10506. * @param defines Defines of the material we want to update
  10507. * @param lightIndex Index of the light in the enabled light list of the material
  10508. */
  10509. prepareDefines(defines: any, lightIndex: number): void;
  10510. /**
  10511. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10512. * defined in the generator but impacting the effect).
  10513. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10514. * @param effect The effect we are binfing the information for
  10515. */
  10516. bindShadowLight(lightIndex: string, effect: Effect): void;
  10517. /**
  10518. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10519. * (eq to shadow prjection matrix * light transform matrix)
  10520. * @returns The transform matrix used to create the shadow map
  10521. */
  10522. getTransformMatrix(): Matrix;
  10523. /**
  10524. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10525. * Cube and 2D textures for instance.
  10526. */
  10527. recreateShadowMap(): void;
  10528. private _disposeBlurPostProcesses;
  10529. private _disposeRTTandPostProcesses;
  10530. /**
  10531. * Disposes the ShadowGenerator.
  10532. * Returns nothing.
  10533. */
  10534. dispose(): void;
  10535. /**
  10536. * Serializes the shadow generator setup to a json object.
  10537. * @returns The serialized JSON object
  10538. */
  10539. serialize(): any;
  10540. /**
  10541. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10542. * @param parsedShadowGenerator The JSON object to parse
  10543. * @param scene The scene to create the shadow map for
  10544. * @returns The parsed shadow generator
  10545. */
  10546. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10547. }
  10548. }
  10549. declare module "babylonjs/Lights/light" {
  10550. import { Nullable } from "babylonjs/types";
  10551. import { Scene } from "babylonjs/scene";
  10552. import { Vector3, Color3 } from "babylonjs/Maths/math";
  10553. import { Node } from "babylonjs/node";
  10554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10555. import { Effect } from "babylonjs/Materials/effect";
  10556. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10557. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10558. /**
  10559. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10560. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10561. * 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.
  10562. */
  10563. export abstract class Light extends Node {
  10564. /**
  10565. * Falloff Default: light is falling off following the material specification:
  10566. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10567. */
  10568. static readonly FALLOFF_DEFAULT: number;
  10569. /**
  10570. * Falloff Physical: light is falling off following the inverse squared distance law.
  10571. */
  10572. static readonly FALLOFF_PHYSICAL: number;
  10573. /**
  10574. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10575. * to enhance interoperability with other engines.
  10576. */
  10577. static readonly FALLOFF_GLTF: number;
  10578. /**
  10579. * Falloff Standard: light is falling off like in the standard material
  10580. * to enhance interoperability with other materials.
  10581. */
  10582. static readonly FALLOFF_STANDARD: number;
  10583. /**
  10584. * If every light affecting the material is in this lightmapMode,
  10585. * material.lightmapTexture adds or multiplies
  10586. * (depends on material.useLightmapAsShadowmap)
  10587. * after every other light calculations.
  10588. */
  10589. static readonly LIGHTMAP_DEFAULT: number;
  10590. /**
  10591. * material.lightmapTexture as only diffuse lighting from this light
  10592. * adds only specular lighting from this light
  10593. * adds dynamic shadows
  10594. */
  10595. static readonly LIGHTMAP_SPECULAR: number;
  10596. /**
  10597. * material.lightmapTexture as only lighting
  10598. * no light calculation from this light
  10599. * only adds dynamic shadows from this light
  10600. */
  10601. static readonly LIGHTMAP_SHADOWSONLY: number;
  10602. /**
  10603. * Each light type uses the default quantity according to its type:
  10604. * point/spot lights use luminous intensity
  10605. * directional lights use illuminance
  10606. */
  10607. static readonly INTENSITYMODE_AUTOMATIC: number;
  10608. /**
  10609. * lumen (lm)
  10610. */
  10611. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10612. /**
  10613. * candela (lm/sr)
  10614. */
  10615. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10616. /**
  10617. * lux (lm/m^2)
  10618. */
  10619. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10620. /**
  10621. * nit (cd/m^2)
  10622. */
  10623. static readonly INTENSITYMODE_LUMINANCE: number;
  10624. /**
  10625. * Light type const id of the point light.
  10626. */
  10627. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10628. /**
  10629. * Light type const id of the directional light.
  10630. */
  10631. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10632. /**
  10633. * Light type const id of the spot light.
  10634. */
  10635. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10636. /**
  10637. * Light type const id of the hemispheric light.
  10638. */
  10639. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10640. /**
  10641. * Diffuse gives the basic color to an object.
  10642. */
  10643. diffuse: Color3;
  10644. /**
  10645. * Specular produces a highlight color on an object.
  10646. * Note: This is note affecting PBR materials.
  10647. */
  10648. specular: Color3;
  10649. /**
  10650. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10651. * falling off base on range or angle.
  10652. * This can be set to any values in Light.FALLOFF_x.
  10653. *
  10654. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10655. * other types of materials.
  10656. */
  10657. falloffType: number;
  10658. /**
  10659. * Strength of the light.
  10660. * Note: By default it is define in the framework own unit.
  10661. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10662. */
  10663. intensity: number;
  10664. private _range;
  10665. protected _inverseSquaredRange: number;
  10666. /**
  10667. * Defines how far from the source the light is impacting in scene units.
  10668. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10669. */
  10670. /**
  10671. * Defines how far from the source the light is impacting in scene units.
  10672. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10673. */
  10674. range: number;
  10675. /**
  10676. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10677. * of light.
  10678. */
  10679. private _photometricScale;
  10680. private _intensityMode;
  10681. /**
  10682. * Gets the photometric scale used to interpret the intensity.
  10683. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10684. */
  10685. /**
  10686. * Sets the photometric scale used to interpret the intensity.
  10687. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10688. */
  10689. intensityMode: number;
  10690. private _radius;
  10691. /**
  10692. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10693. */
  10694. /**
  10695. * sets the light radius used by PBR Materials to simulate soft area lights.
  10696. */
  10697. radius: number;
  10698. private _renderPriority;
  10699. /**
  10700. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10701. * exceeding the number allowed of the materials.
  10702. */
  10703. renderPriority: number;
  10704. private _shadowEnabled;
  10705. /**
  10706. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10707. * the current shadow generator.
  10708. */
  10709. /**
  10710. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10711. * the current shadow generator.
  10712. */
  10713. shadowEnabled: boolean;
  10714. private _includedOnlyMeshes;
  10715. /**
  10716. * Gets the only meshes impacted by this light.
  10717. */
  10718. /**
  10719. * Sets the only meshes impacted by this light.
  10720. */
  10721. includedOnlyMeshes: AbstractMesh[];
  10722. private _excludedMeshes;
  10723. /**
  10724. * Gets the meshes not impacted by this light.
  10725. */
  10726. /**
  10727. * Sets the meshes not impacted by this light.
  10728. */
  10729. excludedMeshes: AbstractMesh[];
  10730. private _excludeWithLayerMask;
  10731. /**
  10732. * Gets the layer id use to find what meshes are not impacted by the light.
  10733. * Inactive if 0
  10734. */
  10735. /**
  10736. * Sets the layer id use to find what meshes are not impacted by the light.
  10737. * Inactive if 0
  10738. */
  10739. excludeWithLayerMask: number;
  10740. private _includeOnlyWithLayerMask;
  10741. /**
  10742. * Gets the layer id use to find what meshes are impacted by the light.
  10743. * Inactive if 0
  10744. */
  10745. /**
  10746. * Sets the layer id use to find what meshes are impacted by the light.
  10747. * Inactive if 0
  10748. */
  10749. includeOnlyWithLayerMask: number;
  10750. private _lightmapMode;
  10751. /**
  10752. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10753. */
  10754. /**
  10755. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10756. */
  10757. lightmapMode: number;
  10758. /**
  10759. * Shadow generator associted to the light.
  10760. * @hidden Internal use only.
  10761. */
  10762. _shadowGenerator: Nullable<IShadowGenerator>;
  10763. /**
  10764. * @hidden Internal use only.
  10765. */
  10766. _excludedMeshesIds: string[];
  10767. /**
  10768. * @hidden Internal use only.
  10769. */
  10770. _includedOnlyMeshesIds: string[];
  10771. /**
  10772. * The current light unifom buffer.
  10773. * @hidden Internal use only.
  10774. */
  10775. _uniformBuffer: UniformBuffer;
  10776. /**
  10777. * Creates a Light object in the scene.
  10778. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10779. * @param name The firendly name of the light
  10780. * @param scene The scene the light belongs too
  10781. */
  10782. constructor(name: string, scene: Scene);
  10783. protected abstract _buildUniformLayout(): void;
  10784. /**
  10785. * Sets the passed Effect "effect" with the Light information.
  10786. * @param effect The effect to update
  10787. * @param lightIndex The index of the light in the effect to update
  10788. * @returns The light
  10789. */
  10790. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10791. /**
  10792. * Returns the string "Light".
  10793. * @returns the class name
  10794. */
  10795. getClassName(): string;
  10796. /** @hidden */
  10797. readonly _isLight: boolean;
  10798. /**
  10799. * Converts the light information to a readable string for debug purpose.
  10800. * @param fullDetails Supports for multiple levels of logging within scene loading
  10801. * @returns the human readable light info
  10802. */
  10803. toString(fullDetails?: boolean): string;
  10804. /** @hidden */
  10805. protected _syncParentEnabledState(): void;
  10806. /**
  10807. * Set the enabled state of this node.
  10808. * @param value - the new enabled state
  10809. */
  10810. setEnabled(value: boolean): void;
  10811. /**
  10812. * Returns the Light associated shadow generator if any.
  10813. * @return the associated shadow generator.
  10814. */
  10815. getShadowGenerator(): Nullable<IShadowGenerator>;
  10816. /**
  10817. * Returns a Vector3, the absolute light position in the World.
  10818. * @returns the world space position of the light
  10819. */
  10820. getAbsolutePosition(): Vector3;
  10821. /**
  10822. * Specifies if the light will affect the passed mesh.
  10823. * @param mesh The mesh to test against the light
  10824. * @return true the mesh is affected otherwise, false.
  10825. */
  10826. canAffectMesh(mesh: AbstractMesh): boolean;
  10827. /**
  10828. * Sort function to order lights for rendering.
  10829. * @param a First Light object to compare to second.
  10830. * @param b Second Light object to compare first.
  10831. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10832. */
  10833. static CompareLightsPriority(a: Light, b: Light): number;
  10834. /**
  10835. * Releases resources associated with this node.
  10836. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10837. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10838. */
  10839. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10840. /**
  10841. * Returns the light type ID (integer).
  10842. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10843. */
  10844. getTypeID(): number;
  10845. /**
  10846. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10847. * @returns the scaled intensity in intensity mode unit
  10848. */
  10849. getScaledIntensity(): number;
  10850. /**
  10851. * Returns a new Light object, named "name", from the current one.
  10852. * @param name The name of the cloned light
  10853. * @returns the new created light
  10854. */
  10855. clone(name: string): Nullable<Light>;
  10856. /**
  10857. * Serializes the current light into a Serialization object.
  10858. * @returns the serialized object.
  10859. */
  10860. serialize(): any;
  10861. /**
  10862. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10863. * This new light is named "name" and added to the passed scene.
  10864. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10865. * @param name The friendly name of the light
  10866. * @param scene The scene the new light will belong to
  10867. * @returns the constructor function
  10868. */
  10869. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10870. /**
  10871. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10872. * @param parsedLight The JSON representation of the light
  10873. * @param scene The scene to create the parsed light in
  10874. * @returns the created light after parsing
  10875. */
  10876. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10877. private _hookArrayForExcluded;
  10878. private _hookArrayForIncludedOnly;
  10879. private _resyncMeshes;
  10880. /**
  10881. * Forces the meshes to update their light related information in their rendering used effects
  10882. * @hidden Internal Use Only
  10883. */
  10884. _markMeshesAsLightDirty(): void;
  10885. /**
  10886. * Recomputes the cached photometric scale if needed.
  10887. */
  10888. private _computePhotometricScale;
  10889. /**
  10890. * Returns the Photometric Scale according to the light type and intensity mode.
  10891. */
  10892. private _getPhotometricScale;
  10893. /**
  10894. * Reorder the light in the scene according to their defined priority.
  10895. * @hidden Internal Use Only
  10896. */
  10897. _reorderLightsInScene(): void;
  10898. /**
  10899. * Prepares the list of defines specific to the light type.
  10900. * @param defines the list of defines
  10901. * @param lightIndex defines the index of the light for the effect
  10902. */
  10903. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10904. }
  10905. }
  10906. declare module "babylonjs/Actions/action" {
  10907. import { Observable } from "babylonjs/Misc/observable";
  10908. import { Condition } from "babylonjs/Actions/condition";
  10909. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10910. import { ActionManager } from "babylonjs/Actions/actionManager";
  10911. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10912. /**
  10913. * Interface used to define Action
  10914. */
  10915. export interface IAction {
  10916. /**
  10917. * Trigger for the action
  10918. */
  10919. trigger: number;
  10920. /** Options of the trigger */
  10921. triggerOptions: any;
  10922. /**
  10923. * Gets the trigger parameters
  10924. * @returns the trigger parameters
  10925. */
  10926. getTriggerParameter(): any;
  10927. /**
  10928. * Internal only - executes current action event
  10929. * @hidden
  10930. */
  10931. _executeCurrent(evt?: ActionEvent): void;
  10932. /**
  10933. * Serialize placeholder for child classes
  10934. * @param parent of child
  10935. * @returns the serialized object
  10936. */
  10937. serialize(parent: any): any;
  10938. /**
  10939. * Internal only
  10940. * @hidden
  10941. */
  10942. _prepare(): void;
  10943. /**
  10944. * Internal only - manager for action
  10945. * @hidden
  10946. */
  10947. _actionManager: AbstractActionManager;
  10948. /**
  10949. * Adds action to chain of actions, may be a DoNothingAction
  10950. * @param action defines the next action to execute
  10951. * @returns The action passed in
  10952. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10953. */
  10954. then(action: IAction): IAction;
  10955. }
  10956. /**
  10957. * The action to be carried out following a trigger
  10958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10959. */
  10960. export class Action implements IAction {
  10961. /** the trigger, with or without parameters, for the action */
  10962. triggerOptions: any;
  10963. /**
  10964. * Trigger for the action
  10965. */
  10966. trigger: number;
  10967. /**
  10968. * Internal only - manager for action
  10969. * @hidden
  10970. */
  10971. _actionManager: ActionManager;
  10972. private _nextActiveAction;
  10973. private _child;
  10974. private _condition?;
  10975. private _triggerParameter;
  10976. /**
  10977. * An event triggered prior to action being executed.
  10978. */
  10979. onBeforeExecuteObservable: Observable<Action>;
  10980. /**
  10981. * Creates a new Action
  10982. * @param triggerOptions the trigger, with or without parameters, for the action
  10983. * @param condition an optional determinant of action
  10984. */
  10985. constructor(
  10986. /** the trigger, with or without parameters, for the action */
  10987. triggerOptions: any, condition?: Condition);
  10988. /**
  10989. * Internal only
  10990. * @hidden
  10991. */
  10992. _prepare(): void;
  10993. /**
  10994. * Gets the trigger parameters
  10995. * @returns the trigger parameters
  10996. */
  10997. getTriggerParameter(): any;
  10998. /**
  10999. * Internal only - executes current action event
  11000. * @hidden
  11001. */
  11002. _executeCurrent(evt?: ActionEvent): void;
  11003. /**
  11004. * Execute placeholder for child classes
  11005. * @param evt optional action event
  11006. */
  11007. execute(evt?: ActionEvent): void;
  11008. /**
  11009. * Skips to next active action
  11010. */
  11011. skipToNextActiveAction(): void;
  11012. /**
  11013. * Adds action to chain of actions, may be a DoNothingAction
  11014. * @param action defines the next action to execute
  11015. * @returns The action passed in
  11016. * @see https://www.babylonjs-playground.com/#1T30HR#0
  11017. */
  11018. then(action: Action): Action;
  11019. /**
  11020. * Internal only
  11021. * @hidden
  11022. */
  11023. _getProperty(propertyPath: string): string;
  11024. /**
  11025. * Internal only
  11026. * @hidden
  11027. */
  11028. _getEffectiveTarget(target: any, propertyPath: string): any;
  11029. /**
  11030. * Serialize placeholder for child classes
  11031. * @param parent of child
  11032. * @returns the serialized object
  11033. */
  11034. serialize(parent: any): any;
  11035. /**
  11036. * Internal only called by serialize
  11037. * @hidden
  11038. */
  11039. protected _serialize(serializedAction: any, parent?: any): any;
  11040. /**
  11041. * Internal only
  11042. * @hidden
  11043. */
  11044. static _SerializeValueAsString: (value: any) => string;
  11045. /**
  11046. * Internal only
  11047. * @hidden
  11048. */
  11049. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  11050. name: string;
  11051. targetType: string;
  11052. value: string;
  11053. };
  11054. }
  11055. }
  11056. declare module "babylonjs/Actions/condition" {
  11057. import { ActionManager } from "babylonjs/Actions/actionManager";
  11058. /**
  11059. * A Condition applied to an Action
  11060. */
  11061. export class Condition {
  11062. /**
  11063. * Internal only - manager for action
  11064. * @hidden
  11065. */
  11066. _actionManager: ActionManager;
  11067. /**
  11068. * Internal only
  11069. * @hidden
  11070. */
  11071. _evaluationId: number;
  11072. /**
  11073. * Internal only
  11074. * @hidden
  11075. */
  11076. _currentResult: boolean;
  11077. /**
  11078. * Creates a new Condition
  11079. * @param actionManager the manager of the action the condition is applied to
  11080. */
  11081. constructor(actionManager: ActionManager);
  11082. /**
  11083. * Check if the current condition is valid
  11084. * @returns a boolean
  11085. */
  11086. isValid(): boolean;
  11087. /**
  11088. * Internal only
  11089. * @hidden
  11090. */
  11091. _getProperty(propertyPath: string): string;
  11092. /**
  11093. * Internal only
  11094. * @hidden
  11095. */
  11096. _getEffectiveTarget(target: any, propertyPath: string): any;
  11097. /**
  11098. * Serialize placeholder for child classes
  11099. * @returns the serialized object
  11100. */
  11101. serialize(): any;
  11102. /**
  11103. * Internal only
  11104. * @hidden
  11105. */
  11106. protected _serialize(serializedCondition: any): any;
  11107. }
  11108. /**
  11109. * Defines specific conditional operators as extensions of Condition
  11110. */
  11111. export class ValueCondition extends Condition {
  11112. /** path to specify the property of the target the conditional operator uses */
  11113. propertyPath: string;
  11114. /** the value compared by the conditional operator against the current value of the property */
  11115. value: any;
  11116. /** the conditional operator, default ValueCondition.IsEqual */
  11117. operator: number;
  11118. /**
  11119. * Internal only
  11120. * @hidden
  11121. */
  11122. private static _IsEqual;
  11123. /**
  11124. * Internal only
  11125. * @hidden
  11126. */
  11127. private static _IsDifferent;
  11128. /**
  11129. * Internal only
  11130. * @hidden
  11131. */
  11132. private static _IsGreater;
  11133. /**
  11134. * Internal only
  11135. * @hidden
  11136. */
  11137. private static _IsLesser;
  11138. /**
  11139. * returns the number for IsEqual
  11140. */
  11141. static readonly IsEqual: number;
  11142. /**
  11143. * Returns the number for IsDifferent
  11144. */
  11145. static readonly IsDifferent: number;
  11146. /**
  11147. * Returns the number for IsGreater
  11148. */
  11149. static readonly IsGreater: number;
  11150. /**
  11151. * Returns the number for IsLesser
  11152. */
  11153. static readonly IsLesser: number;
  11154. /**
  11155. * Internal only The action manager for the condition
  11156. * @hidden
  11157. */
  11158. _actionManager: ActionManager;
  11159. /**
  11160. * Internal only
  11161. * @hidden
  11162. */
  11163. private _target;
  11164. /**
  11165. * Internal only
  11166. * @hidden
  11167. */
  11168. private _effectiveTarget;
  11169. /**
  11170. * Internal only
  11171. * @hidden
  11172. */
  11173. private _property;
  11174. /**
  11175. * Creates a new ValueCondition
  11176. * @param actionManager manager for the action the condition applies to
  11177. * @param target for the action
  11178. * @param propertyPath path to specify the property of the target the conditional operator uses
  11179. * @param value the value compared by the conditional operator against the current value of the property
  11180. * @param operator the conditional operator, default ValueCondition.IsEqual
  11181. */
  11182. constructor(actionManager: ActionManager, target: any,
  11183. /** path to specify the property of the target the conditional operator uses */
  11184. propertyPath: string,
  11185. /** the value compared by the conditional operator against the current value of the property */
  11186. value: any,
  11187. /** the conditional operator, default ValueCondition.IsEqual */
  11188. operator?: number);
  11189. /**
  11190. * Compares the given value with the property value for the specified conditional operator
  11191. * @returns the result of the comparison
  11192. */
  11193. isValid(): boolean;
  11194. /**
  11195. * Serialize the ValueCondition into a JSON compatible object
  11196. * @returns serialization object
  11197. */
  11198. serialize(): any;
  11199. /**
  11200. * Gets the name of the conditional operator for the ValueCondition
  11201. * @param operator the conditional operator
  11202. * @returns the name
  11203. */
  11204. static GetOperatorName(operator: number): string;
  11205. }
  11206. /**
  11207. * Defines a predicate condition as an extension of Condition
  11208. */
  11209. export class PredicateCondition extends Condition {
  11210. /** defines the predicate function used to validate the condition */
  11211. predicate: () => boolean;
  11212. /**
  11213. * Internal only - manager for action
  11214. * @hidden
  11215. */
  11216. _actionManager: ActionManager;
  11217. /**
  11218. * Creates a new PredicateCondition
  11219. * @param actionManager manager for the action the condition applies to
  11220. * @param predicate defines the predicate function used to validate the condition
  11221. */
  11222. constructor(actionManager: ActionManager,
  11223. /** defines the predicate function used to validate the condition */
  11224. predicate: () => boolean);
  11225. /**
  11226. * @returns the validity of the predicate condition
  11227. */
  11228. isValid(): boolean;
  11229. }
  11230. /**
  11231. * Defines a state condition as an extension of Condition
  11232. */
  11233. export class StateCondition extends Condition {
  11234. /** Value to compare with target state */
  11235. value: string;
  11236. /**
  11237. * Internal only - manager for action
  11238. * @hidden
  11239. */
  11240. _actionManager: ActionManager;
  11241. /**
  11242. * Internal only
  11243. * @hidden
  11244. */
  11245. private _target;
  11246. /**
  11247. * Creates a new StateCondition
  11248. * @param actionManager manager for the action the condition applies to
  11249. * @param target of the condition
  11250. * @param value to compare with target state
  11251. */
  11252. constructor(actionManager: ActionManager, target: any,
  11253. /** Value to compare with target state */
  11254. value: string);
  11255. /**
  11256. * Gets a boolean indicating if the current condition is met
  11257. * @returns the validity of the state
  11258. */
  11259. isValid(): boolean;
  11260. /**
  11261. * Serialize the StateCondition into a JSON compatible object
  11262. * @returns serialization object
  11263. */
  11264. serialize(): any;
  11265. }
  11266. }
  11267. declare module "babylonjs/Actions/directActions" {
  11268. import { Action } from "babylonjs/Actions/action";
  11269. import { Condition } from "babylonjs/Actions/condition";
  11270. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  11271. /**
  11272. * This defines an action responsible to toggle a boolean once triggered.
  11273. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11274. */
  11275. export class SwitchBooleanAction extends Action {
  11276. /**
  11277. * The path to the boolean property in the target object
  11278. */
  11279. propertyPath: string;
  11280. private _target;
  11281. private _effectiveTarget;
  11282. private _property;
  11283. /**
  11284. * Instantiate the action
  11285. * @param triggerOptions defines the trigger options
  11286. * @param target defines the object containing the boolean
  11287. * @param propertyPath defines the path to the boolean property in the target object
  11288. * @param condition defines the trigger related conditions
  11289. */
  11290. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  11291. /** @hidden */
  11292. _prepare(): void;
  11293. /**
  11294. * Execute the action toggle the boolean value.
  11295. */
  11296. execute(): void;
  11297. /**
  11298. * Serializes the actions and its related information.
  11299. * @param parent defines the object to serialize in
  11300. * @returns the serialized object
  11301. */
  11302. serialize(parent: any): any;
  11303. }
  11304. /**
  11305. * This defines an action responsible to set a the state field of the target
  11306. * to a desired value once triggered.
  11307. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11308. */
  11309. export class SetStateAction extends Action {
  11310. /**
  11311. * The value to store in the state field.
  11312. */
  11313. value: string;
  11314. private _target;
  11315. /**
  11316. * Instantiate the action
  11317. * @param triggerOptions defines the trigger options
  11318. * @param target defines the object containing the state property
  11319. * @param value defines the value to store in the state field
  11320. * @param condition defines the trigger related conditions
  11321. */
  11322. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  11323. /**
  11324. * Execute the action and store the value on the target state property.
  11325. */
  11326. execute(): void;
  11327. /**
  11328. * Serializes the actions and its related information.
  11329. * @param parent defines the object to serialize in
  11330. * @returns the serialized object
  11331. */
  11332. serialize(parent: any): any;
  11333. }
  11334. /**
  11335. * This defines an action responsible to set a property of the target
  11336. * to a desired value once triggered.
  11337. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11338. */
  11339. export class SetValueAction extends Action {
  11340. /**
  11341. * The path of the property to set in the target.
  11342. */
  11343. propertyPath: string;
  11344. /**
  11345. * The value to set in the property
  11346. */
  11347. value: any;
  11348. private _target;
  11349. private _effectiveTarget;
  11350. private _property;
  11351. /**
  11352. * Instantiate the action
  11353. * @param triggerOptions defines the trigger options
  11354. * @param target defines the object containing the property
  11355. * @param propertyPath defines the path of the property to set in the target
  11356. * @param value defines the value to set in the property
  11357. * @param condition defines the trigger related conditions
  11358. */
  11359. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11360. /** @hidden */
  11361. _prepare(): void;
  11362. /**
  11363. * Execute the action and set the targetted property to the desired value.
  11364. */
  11365. execute(): void;
  11366. /**
  11367. * Serializes the actions and its related information.
  11368. * @param parent defines the object to serialize in
  11369. * @returns the serialized object
  11370. */
  11371. serialize(parent: any): any;
  11372. }
  11373. /**
  11374. * This defines an action responsible to increment the target value
  11375. * to a desired value once triggered.
  11376. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11377. */
  11378. export class IncrementValueAction extends Action {
  11379. /**
  11380. * The path of the property to increment in the target.
  11381. */
  11382. propertyPath: string;
  11383. /**
  11384. * The value we should increment the property by.
  11385. */
  11386. value: any;
  11387. private _target;
  11388. private _effectiveTarget;
  11389. private _property;
  11390. /**
  11391. * Instantiate the action
  11392. * @param triggerOptions defines the trigger options
  11393. * @param target defines the object containing the property
  11394. * @param propertyPath defines the path of the property to increment in the target
  11395. * @param value defines the value value we should increment the property by
  11396. * @param condition defines the trigger related conditions
  11397. */
  11398. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11399. /** @hidden */
  11400. _prepare(): void;
  11401. /**
  11402. * Execute the action and increment the target of the value amount.
  11403. */
  11404. execute(): void;
  11405. /**
  11406. * Serializes the actions and its related information.
  11407. * @param parent defines the object to serialize in
  11408. * @returns the serialized object
  11409. */
  11410. serialize(parent: any): any;
  11411. }
  11412. /**
  11413. * This defines an action responsible to start an animation once triggered.
  11414. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11415. */
  11416. export class PlayAnimationAction extends Action {
  11417. /**
  11418. * Where the animation should start (animation frame)
  11419. */
  11420. from: number;
  11421. /**
  11422. * Where the animation should stop (animation frame)
  11423. */
  11424. to: number;
  11425. /**
  11426. * Define if the animation should loop or stop after the first play.
  11427. */
  11428. loop?: boolean;
  11429. private _target;
  11430. /**
  11431. * Instantiate the action
  11432. * @param triggerOptions defines the trigger options
  11433. * @param target defines the target animation or animation name
  11434. * @param from defines from where the animation should start (animation frame)
  11435. * @param end defines where the animation should stop (animation frame)
  11436. * @param loop defines if the animation should loop or stop after the first play
  11437. * @param condition defines the trigger related conditions
  11438. */
  11439. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11440. /** @hidden */
  11441. _prepare(): void;
  11442. /**
  11443. * Execute the action and play the animation.
  11444. */
  11445. execute(): void;
  11446. /**
  11447. * Serializes the actions and its related information.
  11448. * @param parent defines the object to serialize in
  11449. * @returns the serialized object
  11450. */
  11451. serialize(parent: any): any;
  11452. }
  11453. /**
  11454. * This defines an action responsible to stop an animation once triggered.
  11455. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11456. */
  11457. export class StopAnimationAction extends Action {
  11458. private _target;
  11459. /**
  11460. * Instantiate the action
  11461. * @param triggerOptions defines the trigger options
  11462. * @param target defines the target animation or animation name
  11463. * @param condition defines the trigger related conditions
  11464. */
  11465. constructor(triggerOptions: any, target: any, condition?: Condition);
  11466. /** @hidden */
  11467. _prepare(): void;
  11468. /**
  11469. * Execute the action and stop the animation.
  11470. */
  11471. execute(): void;
  11472. /**
  11473. * Serializes the actions and its related information.
  11474. * @param parent defines the object to serialize in
  11475. * @returns the serialized object
  11476. */
  11477. serialize(parent: any): any;
  11478. }
  11479. /**
  11480. * This defines an action responsible that does nothing once triggered.
  11481. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11482. */
  11483. export class DoNothingAction extends Action {
  11484. /**
  11485. * Instantiate the action
  11486. * @param triggerOptions defines the trigger options
  11487. * @param condition defines the trigger related conditions
  11488. */
  11489. constructor(triggerOptions?: any, condition?: Condition);
  11490. /**
  11491. * Execute the action and do nothing.
  11492. */
  11493. execute(): void;
  11494. /**
  11495. * Serializes the actions and its related information.
  11496. * @param parent defines the object to serialize in
  11497. * @returns the serialized object
  11498. */
  11499. serialize(parent: any): any;
  11500. }
  11501. /**
  11502. * This defines an action responsible to trigger several actions once triggered.
  11503. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11504. */
  11505. export class CombineAction extends Action {
  11506. /**
  11507. * The list of aggregated animations to run.
  11508. */
  11509. children: Action[];
  11510. /**
  11511. * Instantiate the action
  11512. * @param triggerOptions defines the trigger options
  11513. * @param children defines the list of aggregated animations to run
  11514. * @param condition defines the trigger related conditions
  11515. */
  11516. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11517. /** @hidden */
  11518. _prepare(): void;
  11519. /**
  11520. * Execute the action and executes all the aggregated actions.
  11521. */
  11522. execute(evt: ActionEvent): void;
  11523. /**
  11524. * Serializes the actions and its related information.
  11525. * @param parent defines the object to serialize in
  11526. * @returns the serialized object
  11527. */
  11528. serialize(parent: any): any;
  11529. }
  11530. /**
  11531. * This defines an action responsible to run code (external event) once triggered.
  11532. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11533. */
  11534. export class ExecuteCodeAction extends Action {
  11535. /**
  11536. * The callback function to run.
  11537. */
  11538. func: (evt: ActionEvent) => void;
  11539. /**
  11540. * Instantiate the action
  11541. * @param triggerOptions defines the trigger options
  11542. * @param func defines the callback function to run
  11543. * @param condition defines the trigger related conditions
  11544. */
  11545. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11546. /**
  11547. * Execute the action and run the attached code.
  11548. */
  11549. execute(evt: ActionEvent): void;
  11550. }
  11551. /**
  11552. * This defines an action responsible to set the parent property of the target once triggered.
  11553. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11554. */
  11555. export class SetParentAction extends Action {
  11556. private _parent;
  11557. private _target;
  11558. /**
  11559. * Instantiate the action
  11560. * @param triggerOptions defines the trigger options
  11561. * @param target defines the target containing the parent property
  11562. * @param parent defines from where the animation should start (animation frame)
  11563. * @param condition defines the trigger related conditions
  11564. */
  11565. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11566. /** @hidden */
  11567. _prepare(): void;
  11568. /**
  11569. * Execute the action and set the parent property.
  11570. */
  11571. execute(): void;
  11572. /**
  11573. * Serializes the actions and its related information.
  11574. * @param parent defines the object to serialize in
  11575. * @returns the serialized object
  11576. */
  11577. serialize(parent: any): any;
  11578. }
  11579. }
  11580. declare module "babylonjs/Actions/actionManager" {
  11581. import { Nullable } from "babylonjs/types";
  11582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11583. import { Scene } from "babylonjs/scene";
  11584. import { IAction } from "babylonjs/Actions/action";
  11585. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11586. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11587. /**
  11588. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11589. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11590. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11591. */
  11592. export class ActionManager extends AbstractActionManager {
  11593. /**
  11594. * Nothing
  11595. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11596. */
  11597. static readonly NothingTrigger: number;
  11598. /**
  11599. * On pick
  11600. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11601. */
  11602. static readonly OnPickTrigger: number;
  11603. /**
  11604. * On left pick
  11605. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11606. */
  11607. static readonly OnLeftPickTrigger: number;
  11608. /**
  11609. * On right pick
  11610. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11611. */
  11612. static readonly OnRightPickTrigger: number;
  11613. /**
  11614. * On center pick
  11615. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11616. */
  11617. static readonly OnCenterPickTrigger: number;
  11618. /**
  11619. * On pick down
  11620. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11621. */
  11622. static readonly OnPickDownTrigger: number;
  11623. /**
  11624. * On double pick
  11625. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11626. */
  11627. static readonly OnDoublePickTrigger: number;
  11628. /**
  11629. * On pick up
  11630. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11631. */
  11632. static readonly OnPickUpTrigger: number;
  11633. /**
  11634. * On pick out.
  11635. * This trigger will only be raised if you also declared a OnPickDown
  11636. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11637. */
  11638. static readonly OnPickOutTrigger: number;
  11639. /**
  11640. * On long press
  11641. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11642. */
  11643. static readonly OnLongPressTrigger: number;
  11644. /**
  11645. * On pointer over
  11646. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11647. */
  11648. static readonly OnPointerOverTrigger: number;
  11649. /**
  11650. * On pointer out
  11651. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11652. */
  11653. static readonly OnPointerOutTrigger: number;
  11654. /**
  11655. * On every frame
  11656. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11657. */
  11658. static readonly OnEveryFrameTrigger: number;
  11659. /**
  11660. * On intersection enter
  11661. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11662. */
  11663. static readonly OnIntersectionEnterTrigger: number;
  11664. /**
  11665. * On intersection exit
  11666. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11667. */
  11668. static readonly OnIntersectionExitTrigger: number;
  11669. /**
  11670. * On key down
  11671. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11672. */
  11673. static readonly OnKeyDownTrigger: number;
  11674. /**
  11675. * On key up
  11676. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11677. */
  11678. static readonly OnKeyUpTrigger: number;
  11679. private _scene;
  11680. /**
  11681. * Creates a new action manager
  11682. * @param scene defines the hosting scene
  11683. */
  11684. constructor(scene: Scene);
  11685. /**
  11686. * Releases all associated resources
  11687. */
  11688. dispose(): void;
  11689. /**
  11690. * Gets hosting scene
  11691. * @returns the hosting scene
  11692. */
  11693. getScene(): Scene;
  11694. /**
  11695. * Does this action manager handles actions of any of the given triggers
  11696. * @param triggers defines the triggers to be tested
  11697. * @return a boolean indicating whether one (or more) of the triggers is handled
  11698. */
  11699. hasSpecificTriggers(triggers: number[]): boolean;
  11700. /**
  11701. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11702. * speed.
  11703. * @param triggerA defines the trigger to be tested
  11704. * @param triggerB defines the trigger to be tested
  11705. * @return a boolean indicating whether one (or more) of the triggers is handled
  11706. */
  11707. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11708. /**
  11709. * Does this action manager handles actions of a given trigger
  11710. * @param trigger defines the trigger to be tested
  11711. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11712. * @return whether the trigger is handled
  11713. */
  11714. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11715. /**
  11716. * Does this action manager has pointer triggers
  11717. */
  11718. readonly hasPointerTriggers: boolean;
  11719. /**
  11720. * Does this action manager has pick triggers
  11721. */
  11722. readonly hasPickTriggers: boolean;
  11723. /**
  11724. * Registers an action to this action manager
  11725. * @param action defines the action to be registered
  11726. * @return the action amended (prepared) after registration
  11727. */
  11728. registerAction(action: IAction): Nullable<IAction>;
  11729. /**
  11730. * Unregisters an action to this action manager
  11731. * @param action defines the action to be unregistered
  11732. * @return a boolean indicating whether the action has been unregistered
  11733. */
  11734. unregisterAction(action: IAction): Boolean;
  11735. /**
  11736. * Process a specific trigger
  11737. * @param trigger defines the trigger to process
  11738. * @param evt defines the event details to be processed
  11739. */
  11740. processTrigger(trigger: number, evt?: IActionEvent): void;
  11741. /** @hidden */
  11742. _getEffectiveTarget(target: any, propertyPath: string): any;
  11743. /** @hidden */
  11744. _getProperty(propertyPath: string): string;
  11745. /**
  11746. * Serialize this manager to a JSON object
  11747. * @param name defines the property name to store this manager
  11748. * @returns a JSON representation of this manager
  11749. */
  11750. serialize(name: string): any;
  11751. /**
  11752. * Creates a new ActionManager from a JSON data
  11753. * @param parsedActions defines the JSON data to read from
  11754. * @param object defines the hosting mesh
  11755. * @param scene defines the hosting scene
  11756. */
  11757. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11758. /**
  11759. * Get a trigger name by index
  11760. * @param trigger defines the trigger index
  11761. * @returns a trigger name
  11762. */
  11763. static GetTriggerName(trigger: number): string;
  11764. }
  11765. }
  11766. declare module "babylonjs/Culling/ray" {
  11767. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11768. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11770. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11771. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11772. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11773. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11774. /**
  11775. * Class representing a ray with position and direction
  11776. */
  11777. export class Ray {
  11778. /** origin point */
  11779. origin: Vector3;
  11780. /** direction */
  11781. direction: Vector3;
  11782. /** length of the ray */
  11783. length: number;
  11784. private static readonly TmpVector3;
  11785. private _tmpRay;
  11786. /**
  11787. * Creates a new ray
  11788. * @param origin origin point
  11789. * @param direction direction
  11790. * @param length length of the ray
  11791. */
  11792. constructor(
  11793. /** origin point */
  11794. origin: Vector3,
  11795. /** direction */
  11796. direction: Vector3,
  11797. /** length of the ray */
  11798. length?: number);
  11799. /**
  11800. * Checks if the ray intersects a box
  11801. * @param minimum bound of the box
  11802. * @param maximum bound of the box
  11803. * @param intersectionTreshold extra extend to be added to the box in all direction
  11804. * @returns if the box was hit
  11805. */
  11806. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11807. /**
  11808. * Checks if the ray intersects a box
  11809. * @param box the bounding box to check
  11810. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11811. * @returns if the box was hit
  11812. */
  11813. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11814. /**
  11815. * If the ray hits a sphere
  11816. * @param sphere the bounding sphere to check
  11817. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11818. * @returns true if it hits the sphere
  11819. */
  11820. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11821. /**
  11822. * If the ray hits a triange
  11823. * @param vertex0 triangle vertex
  11824. * @param vertex1 triangle vertex
  11825. * @param vertex2 triangle vertex
  11826. * @returns intersection information if hit
  11827. */
  11828. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11829. /**
  11830. * Checks if ray intersects a plane
  11831. * @param plane the plane to check
  11832. * @returns the distance away it was hit
  11833. */
  11834. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11835. /**
  11836. * Checks if ray intersects a mesh
  11837. * @param mesh the mesh to check
  11838. * @param fastCheck if only the bounding box should checked
  11839. * @returns picking info of the intersecton
  11840. */
  11841. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11842. /**
  11843. * Checks if ray intersects a mesh
  11844. * @param meshes the meshes to check
  11845. * @param fastCheck if only the bounding box should checked
  11846. * @param results array to store result in
  11847. * @returns Array of picking infos
  11848. */
  11849. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11850. private _comparePickingInfo;
  11851. private static smallnum;
  11852. private static rayl;
  11853. /**
  11854. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11855. * @param sega the first point of the segment to test the intersection against
  11856. * @param segb the second point of the segment to test the intersection against
  11857. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11858. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11859. */
  11860. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11861. /**
  11862. * Update the ray from viewport position
  11863. * @param x position
  11864. * @param y y position
  11865. * @param viewportWidth viewport width
  11866. * @param viewportHeight viewport height
  11867. * @param world world matrix
  11868. * @param view view matrix
  11869. * @param projection projection matrix
  11870. * @returns this ray updated
  11871. */
  11872. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11873. /**
  11874. * Creates a ray with origin and direction of 0,0,0
  11875. * @returns the new ray
  11876. */
  11877. static Zero(): Ray;
  11878. /**
  11879. * Creates a new ray from screen space and viewport
  11880. * @param x position
  11881. * @param y y position
  11882. * @param viewportWidth viewport width
  11883. * @param viewportHeight viewport height
  11884. * @param world world matrix
  11885. * @param view view matrix
  11886. * @param projection projection matrix
  11887. * @returns new ray
  11888. */
  11889. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11890. /**
  11891. * 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
  11892. * transformed to the given world matrix.
  11893. * @param origin The origin point
  11894. * @param end The end point
  11895. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11896. * @returns the new ray
  11897. */
  11898. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11899. /**
  11900. * Transforms a ray by a matrix
  11901. * @param ray ray to transform
  11902. * @param matrix matrix to apply
  11903. * @returns the resulting new ray
  11904. */
  11905. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11906. /**
  11907. * Transforms a ray by a matrix
  11908. * @param ray ray to transform
  11909. * @param matrix matrix to apply
  11910. * @param result ray to store result in
  11911. */
  11912. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11913. /**
  11914. * Unproject a ray from screen space to object space
  11915. * @param sourceX defines the screen space x coordinate to use
  11916. * @param sourceY defines the screen space y coordinate to use
  11917. * @param viewportWidth defines the current width of the viewport
  11918. * @param viewportHeight defines the current height of the viewport
  11919. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11920. * @param view defines the view matrix to use
  11921. * @param projection defines the projection matrix to use
  11922. */
  11923. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11924. }
  11925. /**
  11926. * Type used to define predicate used to select faces when a mesh intersection is detected
  11927. */
  11928. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11929. module "babylonjs/scene" {
  11930. interface Scene {
  11931. /** @hidden */
  11932. _tempPickingRay: Nullable<Ray>;
  11933. /** @hidden */
  11934. _cachedRayForTransform: Ray;
  11935. /** @hidden */
  11936. _pickWithRayInverseMatrix: Matrix;
  11937. /** @hidden */
  11938. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11939. /** @hidden */
  11940. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11941. }
  11942. }
  11943. }
  11944. declare module "babylonjs/sceneComponent" {
  11945. import { Scene } from "babylonjs/scene";
  11946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11947. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11948. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11949. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11950. import { Nullable } from "babylonjs/types";
  11951. import { Camera } from "babylonjs/Cameras/camera";
  11952. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11953. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11954. import { AbstractScene } from "babylonjs/abstractScene";
  11955. /**
  11956. * Groups all the scene component constants in one place to ease maintenance.
  11957. * @hidden
  11958. */
  11959. export class SceneComponentConstants {
  11960. static readonly NAME_EFFECTLAYER: string;
  11961. static readonly NAME_LAYER: string;
  11962. static readonly NAME_LENSFLARESYSTEM: string;
  11963. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11964. static readonly NAME_PARTICLESYSTEM: string;
  11965. static readonly NAME_GAMEPAD: string;
  11966. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11967. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11968. static readonly NAME_DEPTHRENDERER: string;
  11969. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11970. static readonly NAME_SPRITE: string;
  11971. static readonly NAME_OUTLINERENDERER: string;
  11972. static readonly NAME_PROCEDURALTEXTURE: string;
  11973. static readonly NAME_SHADOWGENERATOR: string;
  11974. static readonly NAME_OCTREE: string;
  11975. static readonly NAME_PHYSICSENGINE: string;
  11976. static readonly NAME_AUDIO: string;
  11977. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11978. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11979. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11980. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11981. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11982. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11983. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11984. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11985. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11986. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11987. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11988. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11989. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11990. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11991. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11992. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11993. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11994. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11995. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11996. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11997. static readonly STEP_AFTERRENDER_AUDIO: number;
  11998. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11999. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  12000. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  12001. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  12002. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  12003. static readonly STEP_POINTERMOVE_SPRITE: number;
  12004. static readonly STEP_POINTERDOWN_SPRITE: number;
  12005. static readonly STEP_POINTERUP_SPRITE: number;
  12006. }
  12007. /**
  12008. * This represents a scene component.
  12009. *
  12010. * This is used to decouple the dependency the scene is having on the different workloads like
  12011. * layers, post processes...
  12012. */
  12013. export interface ISceneComponent {
  12014. /**
  12015. * The name of the component. Each component must have a unique name.
  12016. */
  12017. name: string;
  12018. /**
  12019. * The scene the component belongs to.
  12020. */
  12021. scene: Scene;
  12022. /**
  12023. * Register the component to one instance of a scene.
  12024. */
  12025. register(): void;
  12026. /**
  12027. * Rebuilds the elements related to this component in case of
  12028. * context lost for instance.
  12029. */
  12030. rebuild(): void;
  12031. /**
  12032. * Disposes the component and the associated ressources.
  12033. */
  12034. dispose(): void;
  12035. }
  12036. /**
  12037. * This represents a SERIALIZABLE scene component.
  12038. *
  12039. * This extends Scene Component to add Serialization methods on top.
  12040. */
  12041. export interface ISceneSerializableComponent extends ISceneComponent {
  12042. /**
  12043. * Adds all the elements from the container to the scene
  12044. * @param container the container holding the elements
  12045. */
  12046. addFromContainer(container: AbstractScene): void;
  12047. /**
  12048. * Removes all the elements in the container from the scene
  12049. * @param container contains the elements to remove
  12050. * @param dispose if the removed element should be disposed (default: false)
  12051. */
  12052. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  12053. /**
  12054. * Serializes the component data to the specified json object
  12055. * @param serializationObject The object to serialize to
  12056. */
  12057. serialize(serializationObject: any): void;
  12058. }
  12059. /**
  12060. * Strong typing of a Mesh related stage step action
  12061. */
  12062. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  12063. /**
  12064. * Strong typing of a Evaluate Sub Mesh related stage step action
  12065. */
  12066. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  12067. /**
  12068. * Strong typing of a Active Mesh related stage step action
  12069. */
  12070. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  12071. /**
  12072. * Strong typing of a Camera related stage step action
  12073. */
  12074. export type CameraStageAction = (camera: Camera) => void;
  12075. /**
  12076. * Strong typing of a Camera Frame buffer related stage step action
  12077. */
  12078. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  12079. /**
  12080. * Strong typing of a Render Target related stage step action
  12081. */
  12082. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  12083. /**
  12084. * Strong typing of a RenderingGroup related stage step action
  12085. */
  12086. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  12087. /**
  12088. * Strong typing of a Mesh Render related stage step action
  12089. */
  12090. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  12091. /**
  12092. * Strong typing of a simple stage step action
  12093. */
  12094. export type SimpleStageAction = () => void;
  12095. /**
  12096. * Strong typing of a render target action.
  12097. */
  12098. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  12099. /**
  12100. * Strong typing of a pointer move action.
  12101. */
  12102. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  12103. /**
  12104. * Strong typing of a pointer up/down action.
  12105. */
  12106. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  12107. /**
  12108. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  12109. * @hidden
  12110. */
  12111. export class Stage<T extends Function> extends Array<{
  12112. index: number;
  12113. component: ISceneComponent;
  12114. action: T;
  12115. }> {
  12116. /**
  12117. * Hide ctor from the rest of the world.
  12118. * @param items The items to add.
  12119. */
  12120. private constructor();
  12121. /**
  12122. * Creates a new Stage.
  12123. * @returns A new instance of a Stage
  12124. */
  12125. static Create<T extends Function>(): Stage<T>;
  12126. /**
  12127. * Registers a step in an ordered way in the targeted stage.
  12128. * @param index Defines the position to register the step in
  12129. * @param component Defines the component attached to the step
  12130. * @param action Defines the action to launch during the step
  12131. */
  12132. registerStep(index: number, component: ISceneComponent, action: T): void;
  12133. /**
  12134. * Clears all the steps from the stage.
  12135. */
  12136. clear(): void;
  12137. }
  12138. }
  12139. declare module "babylonjs/Sprites/spriteSceneComponent" {
  12140. import { Nullable } from "babylonjs/types";
  12141. import { Observable } from "babylonjs/Misc/observable";
  12142. import { Scene } from "babylonjs/scene";
  12143. import { Sprite } from "babylonjs/Sprites/sprite";
  12144. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  12145. import { Ray } from "babylonjs/Culling/ray";
  12146. import { Camera } from "babylonjs/Cameras/camera";
  12147. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12148. import { ISceneComponent } from "babylonjs/sceneComponent";
  12149. module "babylonjs/scene" {
  12150. interface Scene {
  12151. /** @hidden */
  12152. _pointerOverSprite: Nullable<Sprite>;
  12153. /** @hidden */
  12154. _pickedDownSprite: Nullable<Sprite>;
  12155. /** @hidden */
  12156. _tempSpritePickingRay: Nullable<Ray>;
  12157. /**
  12158. * All of the sprite managers added to this scene
  12159. * @see http://doc.babylonjs.com/babylon101/sprites
  12160. */
  12161. spriteManagers: Array<ISpriteManager>;
  12162. /**
  12163. * An event triggered when sprites rendering is about to start
  12164. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  12165. */
  12166. onBeforeSpritesRenderingObservable: Observable<Scene>;
  12167. /**
  12168. * An event triggered when sprites rendering is done
  12169. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  12170. */
  12171. onAfterSpritesRenderingObservable: Observable<Scene>;
  12172. /** @hidden */
  12173. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  12174. /** Launch a ray to try to pick a sprite in the scene
  12175. * @param x position on screen
  12176. * @param y position on screen
  12177. * @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
  12178. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  12179. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  12180. * @returns a PickingInfo
  12181. */
  12182. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  12183. /** Use the given ray to pick a sprite in the scene
  12184. * @param ray The ray (in world space) to use to pick meshes
  12185. * @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
  12186. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  12187. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  12188. * @returns a PickingInfo
  12189. */
  12190. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  12191. /**
  12192. * Force the sprite under the pointer
  12193. * @param sprite defines the sprite to use
  12194. */
  12195. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  12196. /**
  12197. * Gets the sprite under the pointer
  12198. * @returns a Sprite or null if no sprite is under the pointer
  12199. */
  12200. getPointerOverSprite(): Nullable<Sprite>;
  12201. }
  12202. }
  12203. /**
  12204. * Defines the sprite scene component responsible to manage sprites
  12205. * in a given scene.
  12206. */
  12207. export class SpriteSceneComponent implements ISceneComponent {
  12208. /**
  12209. * The component name helpfull to identify the component in the list of scene components.
  12210. */
  12211. readonly name: string;
  12212. /**
  12213. * The scene the component belongs to.
  12214. */
  12215. scene: Scene;
  12216. /** @hidden */
  12217. private _spritePredicate;
  12218. /**
  12219. * Creates a new instance of the component for the given scene
  12220. * @param scene Defines the scene to register the component in
  12221. */
  12222. constructor(scene: Scene);
  12223. /**
  12224. * Registers the component in a given scene
  12225. */
  12226. register(): void;
  12227. /**
  12228. * Rebuilds the elements related to this component in case of
  12229. * context lost for instance.
  12230. */
  12231. rebuild(): void;
  12232. /**
  12233. * Disposes the component and the associated ressources.
  12234. */
  12235. dispose(): void;
  12236. private _pickSpriteButKeepRay;
  12237. private _pointerMove;
  12238. private _pointerDown;
  12239. private _pointerUp;
  12240. }
  12241. }
  12242. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  12243. /** @hidden */
  12244. export var fogFragmentDeclaration: {
  12245. name: string;
  12246. shader: string;
  12247. };
  12248. }
  12249. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  12250. /** @hidden */
  12251. export var fogFragment: {
  12252. name: string;
  12253. shader: string;
  12254. };
  12255. }
  12256. declare module "babylonjs/Shaders/sprites.fragment" {
  12257. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  12258. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  12259. /** @hidden */
  12260. export var spritesPixelShader: {
  12261. name: string;
  12262. shader: string;
  12263. };
  12264. }
  12265. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  12266. /** @hidden */
  12267. export var fogVertexDeclaration: {
  12268. name: string;
  12269. shader: string;
  12270. };
  12271. }
  12272. declare module "babylonjs/Shaders/sprites.vertex" {
  12273. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  12274. /** @hidden */
  12275. export var spritesVertexShader: {
  12276. name: string;
  12277. shader: string;
  12278. };
  12279. }
  12280. declare module "babylonjs/Sprites/spriteManager" {
  12281. import { IDisposable, Scene } from "babylonjs/scene";
  12282. import { Nullable } from "babylonjs/types";
  12283. import { Observable } from "babylonjs/Misc/observable";
  12284. import { Sprite } from "babylonjs/Sprites/sprite";
  12285. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12286. import { Camera } from "babylonjs/Cameras/camera";
  12287. import { Texture } from "babylonjs/Materials/Textures/texture";
  12288. import "babylonjs/Shaders/sprites.fragment";
  12289. import "babylonjs/Shaders/sprites.vertex";
  12290. import { Ray } from "babylonjs/Culling/ray";
  12291. /**
  12292. * Defines the minimum interface to fullfil in order to be a sprite manager.
  12293. */
  12294. export interface ISpriteManager extends IDisposable {
  12295. /**
  12296. * Restricts the camera to viewing objects with the same layerMask.
  12297. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  12298. */
  12299. layerMask: number;
  12300. /**
  12301. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  12302. */
  12303. isPickable: boolean;
  12304. /**
  12305. * Specifies the rendering group id for this mesh (0 by default)
  12306. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  12307. */
  12308. renderingGroupId: number;
  12309. /**
  12310. * Defines the list of sprites managed by the manager.
  12311. */
  12312. sprites: Array<Sprite>;
  12313. /**
  12314. * Tests the intersection of a sprite with a specific ray.
  12315. * @param ray The ray we are sending to test the collision
  12316. * @param camera The camera space we are sending rays in
  12317. * @param predicate A predicate allowing excluding sprites from the list of object to test
  12318. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  12319. * @returns picking info or null.
  12320. */
  12321. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12322. /**
  12323. * Renders the list of sprites on screen.
  12324. */
  12325. render(): void;
  12326. }
  12327. /**
  12328. * Class used to manage multiple sprites on the same spritesheet
  12329. * @see http://doc.babylonjs.com/babylon101/sprites
  12330. */
  12331. export class SpriteManager implements ISpriteManager {
  12332. /** defines the manager's name */
  12333. name: string;
  12334. /** Gets the list of sprites */
  12335. sprites: Sprite[];
  12336. /** Gets or sets the rendering group id (0 by default) */
  12337. renderingGroupId: number;
  12338. /** Gets or sets camera layer mask */
  12339. layerMask: number;
  12340. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  12341. fogEnabled: boolean;
  12342. /** Gets or sets a boolean indicating if the sprites are pickable */
  12343. isPickable: boolean;
  12344. /** Defines the default width of a cell in the spritesheet */
  12345. cellWidth: number;
  12346. /** Defines the default height of a cell in the spritesheet */
  12347. cellHeight: number;
  12348. /**
  12349. * An event triggered when the manager is disposed.
  12350. */
  12351. onDisposeObservable: Observable<SpriteManager>;
  12352. private _onDisposeObserver;
  12353. /**
  12354. * Callback called when the manager is disposed
  12355. */
  12356. onDispose: () => void;
  12357. private _capacity;
  12358. private _spriteTexture;
  12359. private _epsilon;
  12360. private _scene;
  12361. private _vertexData;
  12362. private _buffer;
  12363. private _vertexBuffers;
  12364. private _indexBuffer;
  12365. private _effectBase;
  12366. private _effectFog;
  12367. /**
  12368. * Gets or sets the spritesheet texture
  12369. */
  12370. texture: Texture;
  12371. /**
  12372. * Creates a new sprite manager
  12373. * @param name defines the manager's name
  12374. * @param imgUrl defines the sprite sheet url
  12375. * @param capacity defines the maximum allowed number of sprites
  12376. * @param cellSize defines the size of a sprite cell
  12377. * @param scene defines the hosting scene
  12378. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  12379. * @param samplingMode defines the smapling mode to use with spritesheet
  12380. */
  12381. constructor(
  12382. /** defines the manager's name */
  12383. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  12384. private _appendSpriteVertex;
  12385. /**
  12386. * Intersects the sprites with a ray
  12387. * @param ray defines the ray to intersect with
  12388. * @param camera defines the current active camera
  12389. * @param predicate defines a predicate used to select candidate sprites
  12390. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  12391. * @returns null if no hit or a PickingInfo
  12392. */
  12393. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12394. /**
  12395. * Render all child sprites
  12396. */
  12397. render(): void;
  12398. /**
  12399. * Release associated resources
  12400. */
  12401. dispose(): void;
  12402. }
  12403. }
  12404. declare module "babylonjs/Sprites/sprite" {
  12405. import { Vector3, Color4 } from "babylonjs/Maths/math";
  12406. import { Nullable } from "babylonjs/types";
  12407. import { ActionManager } from "babylonjs/Actions/actionManager";
  12408. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  12409. /**
  12410. * Class used to represent a sprite
  12411. * @see http://doc.babylonjs.com/babylon101/sprites
  12412. */
  12413. export class Sprite {
  12414. /** defines the name */
  12415. name: string;
  12416. /** Gets or sets the current world position */
  12417. position: Vector3;
  12418. /** Gets or sets the main color */
  12419. color: Color4;
  12420. /** Gets or sets the width */
  12421. width: number;
  12422. /** Gets or sets the height */
  12423. height: number;
  12424. /** Gets or sets rotation angle */
  12425. angle: number;
  12426. /** Gets or sets the cell index in the sprite sheet */
  12427. cellIndex: number;
  12428. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12429. invertU: number;
  12430. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12431. invertV: number;
  12432. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12433. disposeWhenFinishedAnimating: boolean;
  12434. /** Gets the list of attached animations */
  12435. animations: Animation[];
  12436. /** Gets or sets a boolean indicating if the sprite can be picked */
  12437. isPickable: boolean;
  12438. /**
  12439. * Gets or sets the associated action manager
  12440. */
  12441. actionManager: Nullable<ActionManager>;
  12442. private _animationStarted;
  12443. private _loopAnimation;
  12444. private _fromIndex;
  12445. private _toIndex;
  12446. private _delay;
  12447. private _direction;
  12448. private _manager;
  12449. private _time;
  12450. private _onAnimationEnd;
  12451. /**
  12452. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12453. */
  12454. isVisible: boolean;
  12455. /**
  12456. * Gets or sets the sprite size
  12457. */
  12458. size: number;
  12459. /**
  12460. * Creates a new Sprite
  12461. * @param name defines the name
  12462. * @param manager defines the manager
  12463. */
  12464. constructor(
  12465. /** defines the name */
  12466. name: string, manager: ISpriteManager);
  12467. /**
  12468. * Starts an animation
  12469. * @param from defines the initial key
  12470. * @param to defines the end key
  12471. * @param loop defines if the animation must loop
  12472. * @param delay defines the start delay (in ms)
  12473. * @param onAnimationEnd defines a callback to call when animation ends
  12474. */
  12475. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12476. /** Stops current animation (if any) */
  12477. stopAnimation(): void;
  12478. /** @hidden */
  12479. _animate(deltaTime: number): void;
  12480. /** Release associated resources */
  12481. dispose(): void;
  12482. }
  12483. }
  12484. declare module "babylonjs/Collisions/pickingInfo" {
  12485. import { Nullable } from "babylonjs/types";
  12486. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  12487. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12488. import { Sprite } from "babylonjs/Sprites/sprite";
  12489. import { Ray } from "babylonjs/Culling/ray";
  12490. /**
  12491. * Information about the result of picking within a scene
  12492. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12493. */
  12494. export class PickingInfo {
  12495. /** @hidden */
  12496. _pickingUnavailable: boolean;
  12497. /**
  12498. * If the pick collided with an object
  12499. */
  12500. hit: boolean;
  12501. /**
  12502. * Distance away where the pick collided
  12503. */
  12504. distance: number;
  12505. /**
  12506. * The location of pick collision
  12507. */
  12508. pickedPoint: Nullable<Vector3>;
  12509. /**
  12510. * The mesh corresponding the the pick collision
  12511. */
  12512. pickedMesh: Nullable<AbstractMesh>;
  12513. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  12514. bu: number;
  12515. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  12516. bv: number;
  12517. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12518. faceId: number;
  12519. /** Id of the the submesh that was picked */
  12520. subMeshId: number;
  12521. /** If a sprite was picked, this will be the sprite the pick collided with */
  12522. pickedSprite: Nullable<Sprite>;
  12523. /**
  12524. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12525. */
  12526. originMesh: Nullable<AbstractMesh>;
  12527. /**
  12528. * The ray that was used to perform the picking.
  12529. */
  12530. ray: Nullable<Ray>;
  12531. /**
  12532. * Gets the normal correspodning to the face the pick collided with
  12533. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12534. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12535. * @returns The normal correspodning to the face the pick collided with
  12536. */
  12537. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12538. /**
  12539. * Gets the texture coordinates of where the pick occured
  12540. * @returns the vector containing the coordnates of the texture
  12541. */
  12542. getTextureCoordinates(): Nullable<Vector2>;
  12543. }
  12544. }
  12545. declare module "babylonjs/Events/pointerEvents" {
  12546. import { Nullable } from "babylonjs/types";
  12547. import { Vector2 } from "babylonjs/Maths/math";
  12548. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12549. import { Ray } from "babylonjs/Culling/ray";
  12550. /**
  12551. * Gather the list of pointer event types as constants.
  12552. */
  12553. export class PointerEventTypes {
  12554. /**
  12555. * 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.
  12556. */
  12557. static readonly POINTERDOWN: number;
  12558. /**
  12559. * The pointerup event is fired when a pointer is no longer active.
  12560. */
  12561. static readonly POINTERUP: number;
  12562. /**
  12563. * The pointermove event is fired when a pointer changes coordinates.
  12564. */
  12565. static readonly POINTERMOVE: number;
  12566. /**
  12567. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12568. */
  12569. static readonly POINTERWHEEL: number;
  12570. /**
  12571. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12572. */
  12573. static readonly POINTERPICK: number;
  12574. /**
  12575. * The pointertap event is fired when a the object has been touched and released without drag.
  12576. */
  12577. static readonly POINTERTAP: number;
  12578. /**
  12579. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12580. */
  12581. static readonly POINTERDOUBLETAP: number;
  12582. }
  12583. /**
  12584. * Base class of pointer info types.
  12585. */
  12586. export class PointerInfoBase {
  12587. /**
  12588. * Defines the type of event (PointerEventTypes)
  12589. */
  12590. type: number;
  12591. /**
  12592. * Defines the related dom event
  12593. */
  12594. event: PointerEvent | MouseWheelEvent;
  12595. /**
  12596. * Instantiates the base class of pointers info.
  12597. * @param type Defines the type of event (PointerEventTypes)
  12598. * @param event Defines the related dom event
  12599. */
  12600. constructor(
  12601. /**
  12602. * Defines the type of event (PointerEventTypes)
  12603. */
  12604. type: number,
  12605. /**
  12606. * Defines the related dom event
  12607. */
  12608. event: PointerEvent | MouseWheelEvent);
  12609. }
  12610. /**
  12611. * This class is used to store pointer related info for the onPrePointerObservable event.
  12612. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12613. */
  12614. export class PointerInfoPre extends PointerInfoBase {
  12615. /**
  12616. * Ray from a pointer if availible (eg. 6dof controller)
  12617. */
  12618. ray: Nullable<Ray>;
  12619. /**
  12620. * Defines the local position of the pointer on the canvas.
  12621. */
  12622. localPosition: Vector2;
  12623. /**
  12624. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12625. */
  12626. skipOnPointerObservable: boolean;
  12627. /**
  12628. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12629. * @param type Defines the type of event (PointerEventTypes)
  12630. * @param event Defines the related dom event
  12631. * @param localX Defines the local x coordinates of the pointer when the event occured
  12632. * @param localY Defines the local y coordinates of the pointer when the event occured
  12633. */
  12634. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12635. }
  12636. /**
  12637. * This type contains all the data related to a pointer event in Babylon.js.
  12638. * 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.
  12639. */
  12640. export class PointerInfo extends PointerInfoBase {
  12641. /**
  12642. * Defines the picking info associated to the info (if any)\
  12643. */
  12644. pickInfo: Nullable<PickingInfo>;
  12645. /**
  12646. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12647. * @param type Defines the type of event (PointerEventTypes)
  12648. * @param event Defines the related dom event
  12649. * @param pickInfo Defines the picking info associated to the info (if any)\
  12650. */
  12651. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12652. /**
  12653. * Defines the picking info associated to the info (if any)\
  12654. */
  12655. pickInfo: Nullable<PickingInfo>);
  12656. }
  12657. /**
  12658. * Data relating to a touch event on the screen.
  12659. */
  12660. export interface PointerTouch {
  12661. /**
  12662. * X coordinate of touch.
  12663. */
  12664. x: number;
  12665. /**
  12666. * Y coordinate of touch.
  12667. */
  12668. y: number;
  12669. /**
  12670. * Id of touch. Unique for each finger.
  12671. */
  12672. pointerId: number;
  12673. /**
  12674. * Event type passed from DOM.
  12675. */
  12676. type: any;
  12677. }
  12678. }
  12679. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12680. import { Observable } from "babylonjs/Misc/observable";
  12681. import { Nullable } from "babylonjs/types";
  12682. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12683. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12684. /**
  12685. * Manage the mouse inputs to control the movement of a free camera.
  12686. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12687. */
  12688. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12689. /**
  12690. * Define if touch is enabled in the mouse input
  12691. */
  12692. touchEnabled: boolean;
  12693. /**
  12694. * Defines the camera the input is attached to.
  12695. */
  12696. camera: FreeCamera;
  12697. /**
  12698. * Defines the buttons associated with the input to handle camera move.
  12699. */
  12700. buttons: number[];
  12701. /**
  12702. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12703. */
  12704. angularSensibility: number;
  12705. private _pointerInput;
  12706. private _onMouseMove;
  12707. private _observer;
  12708. private previousPosition;
  12709. /**
  12710. * Observable for when a pointer move event occurs containing the move offset
  12711. */
  12712. onPointerMovedObservable: Observable<{
  12713. offsetX: number;
  12714. offsetY: number;
  12715. }>;
  12716. /**
  12717. * @hidden
  12718. * If the camera should be rotated automatically based on pointer movement
  12719. */
  12720. _allowCameraRotation: boolean;
  12721. /**
  12722. * Manage the mouse inputs to control the movement of a free camera.
  12723. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12724. * @param touchEnabled Defines if touch is enabled or not
  12725. */
  12726. constructor(
  12727. /**
  12728. * Define if touch is enabled in the mouse input
  12729. */
  12730. touchEnabled?: boolean);
  12731. /**
  12732. * Attach the input controls to a specific dom element to get the input from.
  12733. * @param element Defines the element the controls should be listened from
  12734. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12735. */
  12736. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12737. /**
  12738. * Called on JS contextmenu event.
  12739. * Override this method to provide functionality.
  12740. */
  12741. protected onContextMenu(evt: PointerEvent): void;
  12742. /**
  12743. * Detach the current controls from the specified dom element.
  12744. * @param element Defines the element to stop listening the inputs from
  12745. */
  12746. detachControl(element: Nullable<HTMLElement>): void;
  12747. /**
  12748. * Gets the class name of the current intput.
  12749. * @returns the class name
  12750. */
  12751. getClassName(): string;
  12752. /**
  12753. * Get the friendly name associated with the input class.
  12754. * @returns the input friendly name
  12755. */
  12756. getSimpleName(): string;
  12757. }
  12758. }
  12759. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12760. import { Nullable } from "babylonjs/types";
  12761. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12762. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12763. /**
  12764. * Manage the touch inputs to control the movement of a free camera.
  12765. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12766. */
  12767. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12768. /**
  12769. * Defines the camera the input is attached to.
  12770. */
  12771. camera: FreeCamera;
  12772. /**
  12773. * Defines the touch sensibility for rotation.
  12774. * The higher the faster.
  12775. */
  12776. touchAngularSensibility: number;
  12777. /**
  12778. * Defines the touch sensibility for move.
  12779. * The higher the faster.
  12780. */
  12781. touchMoveSensibility: number;
  12782. private _offsetX;
  12783. private _offsetY;
  12784. private _pointerPressed;
  12785. private _pointerInput;
  12786. private _observer;
  12787. private _onLostFocus;
  12788. /**
  12789. * Attach the input controls to a specific dom element to get the input from.
  12790. * @param element Defines the element the controls should be listened from
  12791. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12792. */
  12793. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12794. /**
  12795. * Detach the current controls from the specified dom element.
  12796. * @param element Defines the element to stop listening the inputs from
  12797. */
  12798. detachControl(element: Nullable<HTMLElement>): void;
  12799. /**
  12800. * Update the current camera state depending on the inputs that have been used this frame.
  12801. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12802. */
  12803. checkInputs(): void;
  12804. /**
  12805. * Gets the class name of the current intput.
  12806. * @returns the class name
  12807. */
  12808. getClassName(): string;
  12809. /**
  12810. * Get the friendly name associated with the input class.
  12811. * @returns the input friendly name
  12812. */
  12813. getSimpleName(): string;
  12814. }
  12815. }
  12816. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12817. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12818. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12819. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12820. import { Nullable } from "babylonjs/types";
  12821. /**
  12822. * Default Inputs manager for the FreeCamera.
  12823. * It groups all the default supported inputs for ease of use.
  12824. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12825. */
  12826. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12827. /**
  12828. * @hidden
  12829. */
  12830. _mouseInput: Nullable<FreeCameraMouseInput>;
  12831. /**
  12832. * Instantiates a new FreeCameraInputsManager.
  12833. * @param camera Defines the camera the inputs belong to
  12834. */
  12835. constructor(camera: FreeCamera);
  12836. /**
  12837. * Add keyboard input support to the input manager.
  12838. * @returns the current input manager
  12839. */
  12840. addKeyboard(): FreeCameraInputsManager;
  12841. /**
  12842. * Add mouse input support to the input manager.
  12843. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12844. * @returns the current input manager
  12845. */
  12846. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12847. /**
  12848. * Removes the mouse input support from the manager
  12849. * @returns the current input manager
  12850. */
  12851. removeMouse(): FreeCameraInputsManager;
  12852. /**
  12853. * Add touch input support to the input manager.
  12854. * @returns the current input manager
  12855. */
  12856. addTouch(): FreeCameraInputsManager;
  12857. /**
  12858. * Remove all attached input methods from a camera
  12859. */
  12860. clear(): void;
  12861. }
  12862. }
  12863. declare module "babylonjs/Cameras/freeCamera" {
  12864. import { Vector3 } from "babylonjs/Maths/math";
  12865. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12866. import { Scene } from "babylonjs/scene";
  12867. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12868. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12869. /**
  12870. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12871. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12872. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12873. */
  12874. export class FreeCamera extends TargetCamera {
  12875. /**
  12876. * Define the collision ellipsoid of the camera.
  12877. * This is helpful to simulate a camera body like the player body around the camera
  12878. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12879. */
  12880. ellipsoid: Vector3;
  12881. /**
  12882. * Define an offset for the position of the ellipsoid around the camera.
  12883. * This can be helpful to determine the center of the body near the gravity center of the body
  12884. * instead of its head.
  12885. */
  12886. ellipsoidOffset: Vector3;
  12887. /**
  12888. * Enable or disable collisions of the camera with the rest of the scene objects.
  12889. */
  12890. checkCollisions: boolean;
  12891. /**
  12892. * Enable or disable gravity on the camera.
  12893. */
  12894. applyGravity: boolean;
  12895. /**
  12896. * Define the input manager associated to the camera.
  12897. */
  12898. inputs: FreeCameraInputsManager;
  12899. /**
  12900. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12901. * Higher values reduce sensitivity.
  12902. */
  12903. /**
  12904. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12905. * Higher values reduce sensitivity.
  12906. */
  12907. angularSensibility: number;
  12908. /**
  12909. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12910. */
  12911. keysUp: number[];
  12912. /**
  12913. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12914. */
  12915. keysDown: number[];
  12916. /**
  12917. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12918. */
  12919. keysLeft: number[];
  12920. /**
  12921. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12922. */
  12923. keysRight: number[];
  12924. /**
  12925. * Event raised when the camera collide with a mesh in the scene.
  12926. */
  12927. onCollide: (collidedMesh: AbstractMesh) => void;
  12928. private _collider;
  12929. private _needMoveForGravity;
  12930. private _oldPosition;
  12931. private _diffPosition;
  12932. private _newPosition;
  12933. /** @hidden */
  12934. _localDirection: Vector3;
  12935. /** @hidden */
  12936. _transformedDirection: Vector3;
  12937. /**
  12938. * Instantiates a Free Camera.
  12939. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12940. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12941. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12942. * @param name Define the name of the camera in the scene
  12943. * @param position Define the start position of the camera in the scene
  12944. * @param scene Define the scene the camera belongs to
  12945. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12946. */
  12947. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12948. /**
  12949. * Attached controls to the current camera.
  12950. * @param element Defines the element the controls should be listened from
  12951. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12952. */
  12953. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12954. /**
  12955. * Detach the current controls from the camera.
  12956. * The camera will stop reacting to inputs.
  12957. * @param element Defines the element to stop listening the inputs from
  12958. */
  12959. detachControl(element: HTMLElement): void;
  12960. private _collisionMask;
  12961. /**
  12962. * Define a collision mask to limit the list of object the camera can collide with
  12963. */
  12964. collisionMask: number;
  12965. /** @hidden */
  12966. _collideWithWorld(displacement: Vector3): void;
  12967. private _onCollisionPositionChange;
  12968. /** @hidden */
  12969. _checkInputs(): void;
  12970. /** @hidden */
  12971. _decideIfNeedsToMove(): boolean;
  12972. /** @hidden */
  12973. _updatePosition(): void;
  12974. /**
  12975. * Destroy the camera and release the current resources hold by it.
  12976. */
  12977. dispose(): void;
  12978. /**
  12979. * Gets the current object class name.
  12980. * @return the class name
  12981. */
  12982. getClassName(): string;
  12983. }
  12984. }
  12985. declare module "babylonjs/Gamepads/gamepad" {
  12986. import { Observable } from "babylonjs/Misc/observable";
  12987. /**
  12988. * Represents a gamepad control stick position
  12989. */
  12990. export class StickValues {
  12991. /**
  12992. * The x component of the control stick
  12993. */
  12994. x: number;
  12995. /**
  12996. * The y component of the control stick
  12997. */
  12998. y: number;
  12999. /**
  13000. * Initializes the gamepad x and y control stick values
  13001. * @param x The x component of the gamepad control stick value
  13002. * @param y The y component of the gamepad control stick value
  13003. */
  13004. constructor(
  13005. /**
  13006. * The x component of the control stick
  13007. */
  13008. x: number,
  13009. /**
  13010. * The y component of the control stick
  13011. */
  13012. y: number);
  13013. }
  13014. /**
  13015. * An interface which manages callbacks for gamepad button changes
  13016. */
  13017. export interface GamepadButtonChanges {
  13018. /**
  13019. * Called when a gamepad has been changed
  13020. */
  13021. changed: boolean;
  13022. /**
  13023. * Called when a gamepad press event has been triggered
  13024. */
  13025. pressChanged: boolean;
  13026. /**
  13027. * Called when a touch event has been triggered
  13028. */
  13029. touchChanged: boolean;
  13030. /**
  13031. * Called when a value has changed
  13032. */
  13033. valueChanged: boolean;
  13034. }
  13035. /**
  13036. * Represents a gamepad
  13037. */
  13038. export class Gamepad {
  13039. /**
  13040. * The id of the gamepad
  13041. */
  13042. id: string;
  13043. /**
  13044. * The index of the gamepad
  13045. */
  13046. index: number;
  13047. /**
  13048. * The browser gamepad
  13049. */
  13050. browserGamepad: any;
  13051. /**
  13052. * Specifies what type of gamepad this represents
  13053. */
  13054. type: number;
  13055. private _leftStick;
  13056. private _rightStick;
  13057. /** @hidden */
  13058. _isConnected: boolean;
  13059. private _leftStickAxisX;
  13060. private _leftStickAxisY;
  13061. private _rightStickAxisX;
  13062. private _rightStickAxisY;
  13063. /**
  13064. * Triggered when the left control stick has been changed
  13065. */
  13066. private _onleftstickchanged;
  13067. /**
  13068. * Triggered when the right control stick has been changed
  13069. */
  13070. private _onrightstickchanged;
  13071. /**
  13072. * Represents a gamepad controller
  13073. */
  13074. static GAMEPAD: number;
  13075. /**
  13076. * Represents a generic controller
  13077. */
  13078. static GENERIC: number;
  13079. /**
  13080. * Represents an XBox controller
  13081. */
  13082. static XBOX: number;
  13083. /**
  13084. * Represents a pose-enabled controller
  13085. */
  13086. static POSE_ENABLED: number;
  13087. /**
  13088. * Specifies whether the left control stick should be Y-inverted
  13089. */
  13090. protected _invertLeftStickY: boolean;
  13091. /**
  13092. * Specifies if the gamepad has been connected
  13093. */
  13094. readonly isConnected: boolean;
  13095. /**
  13096. * Initializes the gamepad
  13097. * @param id The id of the gamepad
  13098. * @param index The index of the gamepad
  13099. * @param browserGamepad The browser gamepad
  13100. * @param leftStickX The x component of the left joystick
  13101. * @param leftStickY The y component of the left joystick
  13102. * @param rightStickX The x component of the right joystick
  13103. * @param rightStickY The y component of the right joystick
  13104. */
  13105. constructor(
  13106. /**
  13107. * The id of the gamepad
  13108. */
  13109. id: string,
  13110. /**
  13111. * The index of the gamepad
  13112. */
  13113. index: number,
  13114. /**
  13115. * The browser gamepad
  13116. */
  13117. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  13118. /**
  13119. * Callback triggered when the left joystick has changed
  13120. * @param callback
  13121. */
  13122. onleftstickchanged(callback: (values: StickValues) => void): void;
  13123. /**
  13124. * Callback triggered when the right joystick has changed
  13125. * @param callback
  13126. */
  13127. onrightstickchanged(callback: (values: StickValues) => void): void;
  13128. /**
  13129. * Gets the left joystick
  13130. */
  13131. /**
  13132. * Sets the left joystick values
  13133. */
  13134. leftStick: StickValues;
  13135. /**
  13136. * Gets the right joystick
  13137. */
  13138. /**
  13139. * Sets the right joystick value
  13140. */
  13141. rightStick: StickValues;
  13142. /**
  13143. * Updates the gamepad joystick positions
  13144. */
  13145. update(): void;
  13146. /**
  13147. * Disposes the gamepad
  13148. */
  13149. dispose(): void;
  13150. }
  13151. /**
  13152. * Represents a generic gamepad
  13153. */
  13154. export class GenericPad extends Gamepad {
  13155. private _buttons;
  13156. private _onbuttondown;
  13157. private _onbuttonup;
  13158. /**
  13159. * Observable triggered when a button has been pressed
  13160. */
  13161. onButtonDownObservable: Observable<number>;
  13162. /**
  13163. * Observable triggered when a button has been released
  13164. */
  13165. onButtonUpObservable: Observable<number>;
  13166. /**
  13167. * Callback triggered when a button has been pressed
  13168. * @param callback Called when a button has been pressed
  13169. */
  13170. onbuttondown(callback: (buttonPressed: number) => void): void;
  13171. /**
  13172. * Callback triggered when a button has been released
  13173. * @param callback Called when a button has been released
  13174. */
  13175. onbuttonup(callback: (buttonReleased: number) => void): void;
  13176. /**
  13177. * Initializes the generic gamepad
  13178. * @param id The id of the generic gamepad
  13179. * @param index The index of the generic gamepad
  13180. * @param browserGamepad The browser gamepad
  13181. */
  13182. constructor(id: string, index: number, browserGamepad: any);
  13183. private _setButtonValue;
  13184. /**
  13185. * Updates the generic gamepad
  13186. */
  13187. update(): void;
  13188. /**
  13189. * Disposes the generic gamepad
  13190. */
  13191. dispose(): void;
  13192. }
  13193. }
  13194. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  13195. import { Observable } from "babylonjs/Misc/observable";
  13196. import { Nullable } from "babylonjs/types";
  13197. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13198. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13200. import { Ray } from "babylonjs/Culling/ray";
  13201. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  13202. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  13203. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  13204. /**
  13205. * Defines the types of pose enabled controllers that are supported
  13206. */
  13207. export enum PoseEnabledControllerType {
  13208. /**
  13209. * HTC Vive
  13210. */
  13211. VIVE = 0,
  13212. /**
  13213. * Oculus Rift
  13214. */
  13215. OCULUS = 1,
  13216. /**
  13217. * Windows mixed reality
  13218. */
  13219. WINDOWS = 2,
  13220. /**
  13221. * Samsung gear VR
  13222. */
  13223. GEAR_VR = 3,
  13224. /**
  13225. * Google Daydream
  13226. */
  13227. DAYDREAM = 4,
  13228. /**
  13229. * Generic
  13230. */
  13231. GENERIC = 5
  13232. }
  13233. /**
  13234. * Defines the MutableGamepadButton interface for the state of a gamepad button
  13235. */
  13236. export interface MutableGamepadButton {
  13237. /**
  13238. * Value of the button/trigger
  13239. */
  13240. value: number;
  13241. /**
  13242. * If the button/trigger is currently touched
  13243. */
  13244. touched: boolean;
  13245. /**
  13246. * If the button/trigger is currently pressed
  13247. */
  13248. pressed: boolean;
  13249. }
  13250. /**
  13251. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  13252. * @hidden
  13253. */
  13254. export interface ExtendedGamepadButton extends GamepadButton {
  13255. /**
  13256. * If the button/trigger is currently pressed
  13257. */
  13258. readonly pressed: boolean;
  13259. /**
  13260. * If the button/trigger is currently touched
  13261. */
  13262. readonly touched: boolean;
  13263. /**
  13264. * Value of the button/trigger
  13265. */
  13266. readonly value: number;
  13267. }
  13268. /** @hidden */
  13269. export interface _GamePadFactory {
  13270. /**
  13271. * Returns wether or not the current gamepad can be created for this type of controller.
  13272. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  13273. * @returns true if it can be created, otherwise false
  13274. */
  13275. canCreate(gamepadInfo: any): boolean;
  13276. /**
  13277. * Creates a new instance of the Gamepad.
  13278. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  13279. * @returns the new gamepad instance
  13280. */
  13281. create(gamepadInfo: any): Gamepad;
  13282. }
  13283. /**
  13284. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  13285. */
  13286. export class PoseEnabledControllerHelper {
  13287. /** @hidden */
  13288. static _ControllerFactories: _GamePadFactory[];
  13289. /** @hidden */
  13290. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  13291. /**
  13292. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  13293. * @param vrGamepad the gamepad to initialized
  13294. * @returns a vr controller of the type the gamepad identified as
  13295. */
  13296. static InitiateController(vrGamepad: any): Gamepad;
  13297. }
  13298. /**
  13299. * Defines the PoseEnabledController object that contains state of a vr capable controller
  13300. */
  13301. export class PoseEnabledController extends Gamepad implements PoseControlled {
  13302. private _deviceRoomPosition;
  13303. private _deviceRoomRotationQuaternion;
  13304. /**
  13305. * The device position in babylon space
  13306. */
  13307. devicePosition: Vector3;
  13308. /**
  13309. * The device rotation in babylon space
  13310. */
  13311. deviceRotationQuaternion: Quaternion;
  13312. /**
  13313. * The scale factor of the device in babylon space
  13314. */
  13315. deviceScaleFactor: number;
  13316. /**
  13317. * (Likely devicePosition should be used instead) The device position in its room space
  13318. */
  13319. position: Vector3;
  13320. /**
  13321. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  13322. */
  13323. rotationQuaternion: Quaternion;
  13324. /**
  13325. * The type of controller (Eg. Windows mixed reality)
  13326. */
  13327. controllerType: PoseEnabledControllerType;
  13328. protected _calculatedPosition: Vector3;
  13329. private _calculatedRotation;
  13330. /**
  13331. * The raw pose from the device
  13332. */
  13333. rawPose: DevicePose;
  13334. private _trackPosition;
  13335. private _maxRotationDistFromHeadset;
  13336. private _draggedRoomRotation;
  13337. /**
  13338. * @hidden
  13339. */
  13340. _disableTrackPosition(fixedPosition: Vector3): void;
  13341. /**
  13342. * Internal, the mesh attached to the controller
  13343. * @hidden
  13344. */
  13345. _mesh: Nullable<AbstractMesh>;
  13346. private _poseControlledCamera;
  13347. private _leftHandSystemQuaternion;
  13348. /**
  13349. * Internal, matrix used to convert room space to babylon space
  13350. * @hidden
  13351. */
  13352. _deviceToWorld: Matrix;
  13353. /**
  13354. * Node to be used when casting a ray from the controller
  13355. * @hidden
  13356. */
  13357. _pointingPoseNode: Nullable<TransformNode>;
  13358. /**
  13359. * Name of the child mesh that can be used to cast a ray from the controller
  13360. */
  13361. static readonly POINTING_POSE: string;
  13362. /**
  13363. * Creates a new PoseEnabledController from a gamepad
  13364. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  13365. */
  13366. constructor(browserGamepad: any);
  13367. private _workingMatrix;
  13368. /**
  13369. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  13370. */
  13371. update(): void;
  13372. /**
  13373. * Updates only the pose device and mesh without doing any button event checking
  13374. */
  13375. protected _updatePoseAndMesh(): void;
  13376. /**
  13377. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  13378. * @param poseData raw pose fromthe device
  13379. */
  13380. updateFromDevice(poseData: DevicePose): void;
  13381. /**
  13382. * @hidden
  13383. */
  13384. _meshAttachedObservable: Observable<AbstractMesh>;
  13385. /**
  13386. * Attaches a mesh to the controller
  13387. * @param mesh the mesh to be attached
  13388. */
  13389. attachToMesh(mesh: AbstractMesh): void;
  13390. /**
  13391. * Attaches the controllers mesh to a camera
  13392. * @param camera the camera the mesh should be attached to
  13393. */
  13394. attachToPoseControlledCamera(camera: TargetCamera): void;
  13395. /**
  13396. * Disposes of the controller
  13397. */
  13398. dispose(): void;
  13399. /**
  13400. * The mesh that is attached to the controller
  13401. */
  13402. readonly mesh: Nullable<AbstractMesh>;
  13403. /**
  13404. * Gets the ray of the controller in the direction the controller is pointing
  13405. * @param length the length the resulting ray should be
  13406. * @returns a ray in the direction the controller is pointing
  13407. */
  13408. getForwardRay(length?: number): Ray;
  13409. }
  13410. }
  13411. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  13412. import { Observable } from "babylonjs/Misc/observable";
  13413. import { Scene } from "babylonjs/scene";
  13414. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13415. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  13416. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  13417. /**
  13418. * Defines the WebVRController object that represents controllers tracked in 3D space
  13419. */
  13420. export abstract class WebVRController extends PoseEnabledController {
  13421. /**
  13422. * Internal, the default controller model for the controller
  13423. */
  13424. protected _defaultModel: AbstractMesh;
  13425. /**
  13426. * Fired when the trigger state has changed
  13427. */
  13428. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  13429. /**
  13430. * Fired when the main button state has changed
  13431. */
  13432. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13433. /**
  13434. * Fired when the secondary button state has changed
  13435. */
  13436. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13437. /**
  13438. * Fired when the pad state has changed
  13439. */
  13440. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  13441. /**
  13442. * Fired when controllers stick values have changed
  13443. */
  13444. onPadValuesChangedObservable: Observable<StickValues>;
  13445. /**
  13446. * Array of button availible on the controller
  13447. */
  13448. protected _buttons: Array<MutableGamepadButton>;
  13449. private _onButtonStateChange;
  13450. /**
  13451. * Fired when a controller button's state has changed
  13452. * @param callback the callback containing the button that was modified
  13453. */
  13454. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  13455. /**
  13456. * X and Y axis corrisponding to the controllers joystick
  13457. */
  13458. pad: StickValues;
  13459. /**
  13460. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  13461. */
  13462. hand: string;
  13463. /**
  13464. * The default controller model for the controller
  13465. */
  13466. readonly defaultModel: AbstractMesh;
  13467. /**
  13468. * Creates a new WebVRController from a gamepad
  13469. * @param vrGamepad the gamepad that the WebVRController should be created from
  13470. */
  13471. constructor(vrGamepad: any);
  13472. /**
  13473. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13474. */
  13475. update(): void;
  13476. /**
  13477. * Function to be called when a button is modified
  13478. */
  13479. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13480. /**
  13481. * Loads a mesh and attaches it to the controller
  13482. * @param scene the scene the mesh should be added to
  13483. * @param meshLoaded callback for when the mesh has been loaded
  13484. */
  13485. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13486. private _setButtonValue;
  13487. private _changes;
  13488. private _checkChanges;
  13489. /**
  13490. * Disposes of th webVRCOntroller
  13491. */
  13492. dispose(): void;
  13493. }
  13494. }
  13495. declare module "babylonjs/Lights/hemisphericLight" {
  13496. import { Nullable } from "babylonjs/types";
  13497. import { Scene } from "babylonjs/scene";
  13498. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  13499. import { Effect } from "babylonjs/Materials/effect";
  13500. import { Light } from "babylonjs/Lights/light";
  13501. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  13502. /**
  13503. * The HemisphericLight simulates the ambient environment light,
  13504. * so the passed direction is the light reflection direction, not the incoming direction.
  13505. */
  13506. export class HemisphericLight extends Light {
  13507. /**
  13508. * The groundColor is the light in the opposite direction to the one specified during creation.
  13509. * 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.
  13510. */
  13511. groundColor: Color3;
  13512. /**
  13513. * The light reflection direction, not the incoming direction.
  13514. */
  13515. direction: Vector3;
  13516. /**
  13517. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13518. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13519. * The HemisphericLight can't cast shadows.
  13520. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13521. * @param name The friendly name of the light
  13522. * @param direction The direction of the light reflection
  13523. * @param scene The scene the light belongs to
  13524. */
  13525. constructor(name: string, direction: Vector3, scene: Scene);
  13526. protected _buildUniformLayout(): void;
  13527. /**
  13528. * Returns the string "HemisphericLight".
  13529. * @return The class name
  13530. */
  13531. getClassName(): string;
  13532. /**
  13533. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13534. * Returns the updated direction.
  13535. * @param target The target the direction should point to
  13536. * @return The computed direction
  13537. */
  13538. setDirectionToTarget(target: Vector3): Vector3;
  13539. /**
  13540. * Returns the shadow generator associated to the light.
  13541. * @returns Always null for hemispheric lights because it does not support shadows.
  13542. */
  13543. getShadowGenerator(): Nullable<IShadowGenerator>;
  13544. /**
  13545. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13546. * @param effect The effect to update
  13547. * @param lightIndex The index of the light in the effect to update
  13548. * @returns The hemispheric light
  13549. */
  13550. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13551. /**
  13552. * Computes the world matrix of the node
  13553. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13554. * @param useWasUpdatedFlag defines a reserved property
  13555. * @returns the world matrix
  13556. */
  13557. computeWorldMatrix(): Matrix;
  13558. /**
  13559. * Returns the integer 3.
  13560. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13561. */
  13562. getTypeID(): number;
  13563. /**
  13564. * Prepares the list of defines specific to the light type.
  13565. * @param defines the list of defines
  13566. * @param lightIndex defines the index of the light for the effect
  13567. */
  13568. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13569. }
  13570. }
  13571. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  13572. /** @hidden */
  13573. export var vrMultiviewToSingleviewPixelShader: {
  13574. name: string;
  13575. shader: string;
  13576. };
  13577. }
  13578. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  13579. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13580. import { Scene } from "babylonjs/scene";
  13581. /**
  13582. * Renders to multiple views with a single draw call
  13583. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  13584. */
  13585. export class MultiviewRenderTarget extends RenderTargetTexture {
  13586. /**
  13587. * Creates a multiview render target
  13588. * @param scene scene used with the render target
  13589. * @param size the size of the render target (used for each view)
  13590. */
  13591. constructor(scene: Scene, size?: number | {
  13592. width: number;
  13593. height: number;
  13594. } | {
  13595. ratio: number;
  13596. });
  13597. /**
  13598. * @hidden
  13599. * @param faceIndex the face index, if its a cube texture
  13600. */
  13601. _bindFrameBuffer(faceIndex?: number): void;
  13602. /**
  13603. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  13604. * @returns the view count
  13605. */
  13606. getViewCount(): number;
  13607. }
  13608. }
  13609. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  13610. import { Camera } from "babylonjs/Cameras/camera";
  13611. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13612. import { Nullable } from "babylonjs/types";
  13613. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13614. import { Matrix } from "babylonjs/Maths/math";
  13615. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  13616. module "babylonjs/Engines/engine" {
  13617. interface Engine {
  13618. /**
  13619. * Creates a new multiview render target
  13620. * @param width defines the width of the texture
  13621. * @param height defines the height of the texture
  13622. * @returns the created multiview texture
  13623. */
  13624. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  13625. /**
  13626. * Binds a multiview framebuffer to be drawn to
  13627. * @param multiviewTexture texture to bind
  13628. */
  13629. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  13630. }
  13631. }
  13632. module "babylonjs/Cameras/camera" {
  13633. interface Camera {
  13634. /**
  13635. * @hidden
  13636. * 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)
  13637. */
  13638. _useMultiviewToSingleView: boolean;
  13639. /**
  13640. * @hidden
  13641. * 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)
  13642. */
  13643. _multiviewTexture: Nullable<RenderTargetTexture>;
  13644. /**
  13645. * @hidden
  13646. * ensures the multiview texture of the camera exists and has the specified width/height
  13647. * @param width height to set on the multiview texture
  13648. * @param height width to set on the multiview texture
  13649. */
  13650. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  13651. }
  13652. }
  13653. module "babylonjs/scene" {
  13654. interface Scene {
  13655. /** @hidden */
  13656. _transformMatrixR: Matrix;
  13657. /** @hidden */
  13658. _multiviewSceneUbo: Nullable<UniformBuffer>;
  13659. /** @hidden */
  13660. _createMultiviewUbo(): void;
  13661. /** @hidden */
  13662. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13663. /** @hidden */
  13664. _renderMultiviewToSingleView(camera: Camera): void;
  13665. }
  13666. }
  13667. }
  13668. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  13669. import { Camera } from "babylonjs/Cameras/camera";
  13670. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13671. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  13672. import "babylonjs/Engines/Extensions/engine.multiview";
  13673. /**
  13674. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13675. * This will not be used for webXR as it supports displaying texture arrays directly
  13676. */
  13677. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13678. /**
  13679. * Initializes a VRMultiviewToSingleview
  13680. * @param name name of the post process
  13681. * @param camera camera to be applied to
  13682. * @param scaleFactor scaling factor to the size of the output texture
  13683. */
  13684. constructor(name: string, camera: Camera, scaleFactor: number);
  13685. }
  13686. }
  13687. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  13688. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  13689. import { Nullable } from "babylonjs/types";
  13690. import { Size } from "babylonjs/Maths/math";
  13691. import { Observable } from "babylonjs/Misc/observable";
  13692. module "babylonjs/Engines/engine" {
  13693. interface Engine {
  13694. /** @hidden */
  13695. _vrDisplay: any;
  13696. /** @hidden */
  13697. _vrSupported: boolean;
  13698. /** @hidden */
  13699. _oldSize: Size;
  13700. /** @hidden */
  13701. _oldHardwareScaleFactor: number;
  13702. /** @hidden */
  13703. _vrExclusivePointerMode: boolean;
  13704. /** @hidden */
  13705. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  13706. /** @hidden */
  13707. _onVRDisplayPointerRestricted: () => void;
  13708. /** @hidden */
  13709. _onVRDisplayPointerUnrestricted: () => void;
  13710. /** @hidden */
  13711. _onVrDisplayConnect: Nullable<(display: any) => void>;
  13712. /** @hidden */
  13713. _onVrDisplayDisconnect: Nullable<() => void>;
  13714. /** @hidden */
  13715. _onVrDisplayPresentChange: Nullable<() => void>;
  13716. /**
  13717. * Observable signaled when VR display mode changes
  13718. */
  13719. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  13720. /**
  13721. * Observable signaled when VR request present is complete
  13722. */
  13723. onVRRequestPresentComplete: Observable<boolean>;
  13724. /**
  13725. * Observable signaled when VR request present starts
  13726. */
  13727. onVRRequestPresentStart: Observable<Engine>;
  13728. /**
  13729. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  13730. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  13731. */
  13732. isInVRExclusivePointerMode: boolean;
  13733. /**
  13734. * Gets a boolean indicating if a webVR device was detected
  13735. * @returns true if a webVR device was detected
  13736. */
  13737. isVRDevicePresent(): boolean;
  13738. /**
  13739. * Gets the current webVR device
  13740. * @returns the current webVR device (or null)
  13741. */
  13742. getVRDevice(): any;
  13743. /**
  13744. * Initializes a webVR display and starts listening to display change events
  13745. * The onVRDisplayChangedObservable will be notified upon these changes
  13746. * @returns A promise containing a VRDisplay and if vr is supported
  13747. */
  13748. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  13749. /** @hidden */
  13750. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  13751. /**
  13752. * Call this function to switch to webVR mode
  13753. * Will do nothing if webVR is not supported or if there is no webVR device
  13754. * @see http://doc.babylonjs.com/how_to/webvr_camera
  13755. */
  13756. enableVR(): void;
  13757. /** @hidden */
  13758. _onVRFullScreenTriggered(): void;
  13759. }
  13760. }
  13761. }
  13762. declare module "babylonjs/Cameras/VR/webVRCamera" {
  13763. import { Nullable } from "babylonjs/types";
  13764. import { Observable } from "babylonjs/Misc/observable";
  13765. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  13766. import { Scene } from "babylonjs/scene";
  13767. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13768. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  13769. import { Node } from "babylonjs/node";
  13770. import { Ray } from "babylonjs/Culling/ray";
  13771. import "babylonjs/Cameras/RigModes/webVRRigMode";
  13772. import "babylonjs/Engines/Extensions/engine.webVR";
  13773. /**
  13774. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13775. * IMPORTANT!! The data is right-hand data.
  13776. * @export
  13777. * @interface DevicePose
  13778. */
  13779. export interface DevicePose {
  13780. /**
  13781. * The position of the device, values in array are [x,y,z].
  13782. */
  13783. readonly position: Nullable<Float32Array>;
  13784. /**
  13785. * The linearVelocity of the device, values in array are [x,y,z].
  13786. */
  13787. readonly linearVelocity: Nullable<Float32Array>;
  13788. /**
  13789. * The linearAcceleration of the device, values in array are [x,y,z].
  13790. */
  13791. readonly linearAcceleration: Nullable<Float32Array>;
  13792. /**
  13793. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13794. */
  13795. readonly orientation: Nullable<Float32Array>;
  13796. /**
  13797. * The angularVelocity of the device, values in array are [x,y,z].
  13798. */
  13799. readonly angularVelocity: Nullable<Float32Array>;
  13800. /**
  13801. * The angularAcceleration of the device, values in array are [x,y,z].
  13802. */
  13803. readonly angularAcceleration: Nullable<Float32Array>;
  13804. }
  13805. /**
  13806. * Interface representing a pose controlled object in Babylon.
  13807. * A pose controlled object has both regular pose values as well as pose values
  13808. * from an external device such as a VR head mounted display
  13809. */
  13810. export interface PoseControlled {
  13811. /**
  13812. * The position of the object in babylon space.
  13813. */
  13814. position: Vector3;
  13815. /**
  13816. * The rotation quaternion of the object in babylon space.
  13817. */
  13818. rotationQuaternion: Quaternion;
  13819. /**
  13820. * The position of the device in babylon space.
  13821. */
  13822. devicePosition?: Vector3;
  13823. /**
  13824. * The rotation quaternion of the device in babylon space.
  13825. */
  13826. deviceRotationQuaternion: Quaternion;
  13827. /**
  13828. * The raw pose coming from the device.
  13829. */
  13830. rawPose: Nullable<DevicePose>;
  13831. /**
  13832. * The scale of the device to be used when translating from device space to babylon space.
  13833. */
  13834. deviceScaleFactor: number;
  13835. /**
  13836. * Updates the poseControlled values based on the input device pose.
  13837. * @param poseData the pose data to update the object with
  13838. */
  13839. updateFromDevice(poseData: DevicePose): void;
  13840. }
  13841. /**
  13842. * Set of options to customize the webVRCamera
  13843. */
  13844. export interface WebVROptions {
  13845. /**
  13846. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13847. */
  13848. trackPosition?: boolean;
  13849. /**
  13850. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13851. */
  13852. positionScale?: number;
  13853. /**
  13854. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13855. */
  13856. displayName?: string;
  13857. /**
  13858. * Should the native controller meshes be initialized. (default: true)
  13859. */
  13860. controllerMeshes?: boolean;
  13861. /**
  13862. * Creating a default HemiLight only on controllers. (default: true)
  13863. */
  13864. defaultLightingOnControllers?: boolean;
  13865. /**
  13866. * If you don't want to use the default VR button of the helper. (default: false)
  13867. */
  13868. useCustomVRButton?: boolean;
  13869. /**
  13870. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13871. */
  13872. customVRButton?: HTMLButtonElement;
  13873. /**
  13874. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13875. */
  13876. rayLength?: number;
  13877. /**
  13878. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13879. */
  13880. defaultHeight?: number;
  13881. /**
  13882. * If multiview should be used if availible (default: false)
  13883. */
  13884. useMultiview?: boolean;
  13885. }
  13886. /**
  13887. * This represents a WebVR camera.
  13888. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13889. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13890. */
  13891. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13892. private webVROptions;
  13893. /**
  13894. * @hidden
  13895. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13896. */
  13897. _vrDevice: any;
  13898. /**
  13899. * The rawPose of the vrDevice.
  13900. */
  13901. rawPose: Nullable<DevicePose>;
  13902. private _onVREnabled;
  13903. private _specsVersion;
  13904. private _attached;
  13905. private _frameData;
  13906. protected _descendants: Array<Node>;
  13907. private _deviceRoomPosition;
  13908. /** @hidden */
  13909. _deviceRoomRotationQuaternion: Quaternion;
  13910. private _standingMatrix;
  13911. /**
  13912. * Represents device position in babylon space.
  13913. */
  13914. devicePosition: Vector3;
  13915. /**
  13916. * Represents device rotation in babylon space.
  13917. */
  13918. deviceRotationQuaternion: Quaternion;
  13919. /**
  13920. * The scale of the device to be used when translating from device space to babylon space.
  13921. */
  13922. deviceScaleFactor: number;
  13923. private _deviceToWorld;
  13924. private _worldToDevice;
  13925. /**
  13926. * References to the webVR controllers for the vrDevice.
  13927. */
  13928. controllers: Array<WebVRController>;
  13929. /**
  13930. * Emits an event when a controller is attached.
  13931. */
  13932. onControllersAttachedObservable: Observable<WebVRController[]>;
  13933. /**
  13934. * Emits an event when a controller's mesh has been loaded;
  13935. */
  13936. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13937. /**
  13938. * Emits an event when the HMD's pose has been updated.
  13939. */
  13940. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13941. private _poseSet;
  13942. /**
  13943. * If the rig cameras be used as parent instead of this camera.
  13944. */
  13945. rigParenting: boolean;
  13946. private _lightOnControllers;
  13947. private _defaultHeight?;
  13948. /**
  13949. * Instantiates a WebVRFreeCamera.
  13950. * @param name The name of the WebVRFreeCamera
  13951. * @param position The starting anchor position for the camera
  13952. * @param scene The scene the camera belongs to
  13953. * @param webVROptions a set of customizable options for the webVRCamera
  13954. */
  13955. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13956. /**
  13957. * Gets the device distance from the ground in meters.
  13958. * @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.
  13959. */
  13960. deviceDistanceToRoomGround(): number;
  13961. /**
  13962. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13963. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13964. */
  13965. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13966. /**
  13967. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13968. * @returns A promise with a boolean set to if the standing matrix is supported.
  13969. */
  13970. useStandingMatrixAsync(): Promise<boolean>;
  13971. /**
  13972. * Disposes the camera
  13973. */
  13974. dispose(): void;
  13975. /**
  13976. * Gets a vrController by name.
  13977. * @param name The name of the controller to retreive
  13978. * @returns the controller matching the name specified or null if not found
  13979. */
  13980. getControllerByName(name: string): Nullable<WebVRController>;
  13981. private _leftController;
  13982. /**
  13983. * The controller corrisponding to the users left hand.
  13984. */
  13985. readonly leftController: Nullable<WebVRController>;
  13986. private _rightController;
  13987. /**
  13988. * The controller corrisponding to the users right hand.
  13989. */
  13990. readonly rightController: Nullable<WebVRController>;
  13991. /**
  13992. * Casts a ray forward from the vrCamera's gaze.
  13993. * @param length Length of the ray (default: 100)
  13994. * @returns the ray corrisponding to the gaze
  13995. */
  13996. getForwardRay(length?: number): Ray;
  13997. /**
  13998. * @hidden
  13999. * Updates the camera based on device's frame data
  14000. */
  14001. _checkInputs(): void;
  14002. /**
  14003. * Updates the poseControlled values based on the input device pose.
  14004. * @param poseData Pose coming from the device
  14005. */
  14006. updateFromDevice(poseData: DevicePose): void;
  14007. private _htmlElementAttached;
  14008. private _detachIfAttached;
  14009. /**
  14010. * WebVR's attach control will start broadcasting frames to the device.
  14011. * Note that in certain browsers (chrome for example) this function must be called
  14012. * within a user-interaction callback. Example:
  14013. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  14014. *
  14015. * @param element html element to attach the vrDevice to
  14016. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  14017. */
  14018. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  14019. /**
  14020. * Detaches the camera from the html element and disables VR
  14021. *
  14022. * @param element html element to detach from
  14023. */
  14024. detachControl(element: HTMLElement): void;
  14025. /**
  14026. * @returns the name of this class
  14027. */
  14028. getClassName(): string;
  14029. /**
  14030. * Calls resetPose on the vrDisplay
  14031. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  14032. */
  14033. resetToCurrentRotation(): void;
  14034. /**
  14035. * @hidden
  14036. * Updates the rig cameras (left and right eye)
  14037. */
  14038. _updateRigCameras(): void;
  14039. private _workingVector;
  14040. private _oneVector;
  14041. private _workingMatrix;
  14042. private updateCacheCalled;
  14043. private _correctPositionIfNotTrackPosition;
  14044. /**
  14045. * @hidden
  14046. * Updates the cached values of the camera
  14047. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  14048. */
  14049. _updateCache(ignoreParentClass?: boolean): void;
  14050. /**
  14051. * @hidden
  14052. * Get current device position in babylon world
  14053. */
  14054. _computeDevicePosition(): void;
  14055. /**
  14056. * Updates the current device position and rotation in the babylon world
  14057. */
  14058. update(): void;
  14059. /**
  14060. * @hidden
  14061. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  14062. * @returns an identity matrix
  14063. */
  14064. _getViewMatrix(): Matrix;
  14065. private _tmpMatrix;
  14066. /**
  14067. * This function is called by the two RIG cameras.
  14068. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  14069. * @hidden
  14070. */
  14071. _getWebVRViewMatrix(): Matrix;
  14072. /** @hidden */
  14073. _getWebVRProjectionMatrix(): Matrix;
  14074. private _onGamepadConnectedObserver;
  14075. private _onGamepadDisconnectedObserver;
  14076. private _updateCacheWhenTrackingDisabledObserver;
  14077. /**
  14078. * Initializes the controllers and their meshes
  14079. */
  14080. initControllers(): void;
  14081. }
  14082. }
  14083. declare module "babylonjs/PostProcesses/postProcess" {
  14084. import { Nullable } from "babylonjs/types";
  14085. import { SmartArray } from "babylonjs/Misc/smartArray";
  14086. import { Observable } from "babylonjs/Misc/observable";
  14087. import { Color4, Vector2 } from "babylonjs/Maths/math";
  14088. import { Camera } from "babylonjs/Cameras/camera";
  14089. import { Effect } from "babylonjs/Materials/effect";
  14090. import "babylonjs/Shaders/postprocess.vertex";
  14091. import { IInspectable } from "babylonjs/Misc/iInspectable";
  14092. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14093. import { Engine } from "babylonjs/Engines/engine";
  14094. /**
  14095. * Size options for a post process
  14096. */
  14097. export type PostProcessOptions = {
  14098. width: number;
  14099. height: number;
  14100. };
  14101. /**
  14102. * PostProcess can be used to apply a shader to a texture after it has been rendered
  14103. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  14104. */
  14105. export class PostProcess {
  14106. /** Name of the PostProcess. */
  14107. name: string;
  14108. /**
  14109. * Gets or sets the unique id of the post process
  14110. */
  14111. uniqueId: number;
  14112. /**
  14113. * Width of the texture to apply the post process on
  14114. */
  14115. width: number;
  14116. /**
  14117. * Height of the texture to apply the post process on
  14118. */
  14119. height: number;
  14120. /**
  14121. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  14122. * @hidden
  14123. */
  14124. _outputTexture: Nullable<InternalTexture>;
  14125. /**
  14126. * Sampling mode used by the shader
  14127. * See https://doc.babylonjs.com/classes/3.1/texture
  14128. */
  14129. renderTargetSamplingMode: number;
  14130. /**
  14131. * Clear color to use when screen clearing
  14132. */
  14133. clearColor: Color4;
  14134. /**
  14135. * If the buffer needs to be cleared before applying the post process. (default: true)
  14136. * Should be set to false if shader will overwrite all previous pixels.
  14137. */
  14138. autoClear: boolean;
  14139. /**
  14140. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  14141. */
  14142. alphaMode: number;
  14143. /**
  14144. * Sets the setAlphaBlendConstants of the babylon engine
  14145. */
  14146. alphaConstants: Color4;
  14147. /**
  14148. * Animations to be used for the post processing
  14149. */
  14150. animations: import("babylonjs/Animations/animation").Animation[];
  14151. /**
  14152. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  14153. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  14154. */
  14155. enablePixelPerfectMode: boolean;
  14156. /**
  14157. * Force the postprocess to be applied without taking in account viewport
  14158. */
  14159. forceFullscreenViewport: boolean;
  14160. /**
  14161. * List of inspectable custom properties (used by the Inspector)
  14162. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  14163. */
  14164. inspectableCustomProperties: IInspectable[];
  14165. /**
  14166. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  14167. *
  14168. * | Value | Type | Description |
  14169. * | ----- | ----------------------------------- | ----------- |
  14170. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  14171. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  14172. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  14173. *
  14174. */
  14175. scaleMode: number;
  14176. /**
  14177. * Force textures to be a power of two (default: false)
  14178. */
  14179. alwaysForcePOT: boolean;
  14180. private _samples;
  14181. /**
  14182. * Number of sample textures (default: 1)
  14183. */
  14184. samples: number;
  14185. /**
  14186. * Modify the scale of the post process to be the same as the viewport (default: false)
  14187. */
  14188. adaptScaleToCurrentViewport: boolean;
  14189. private _camera;
  14190. private _scene;
  14191. private _engine;
  14192. private _options;
  14193. private _reusable;
  14194. private _textureType;
  14195. /**
  14196. * Smart array of input and output textures for the post process.
  14197. * @hidden
  14198. */
  14199. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  14200. /**
  14201. * The index in _textures that corresponds to the output texture.
  14202. * @hidden
  14203. */
  14204. _currentRenderTextureInd: number;
  14205. private _effect;
  14206. private _samplers;
  14207. private _fragmentUrl;
  14208. private _vertexUrl;
  14209. private _parameters;
  14210. private _scaleRatio;
  14211. protected _indexParameters: any;
  14212. private _shareOutputWithPostProcess;
  14213. private _texelSize;
  14214. private _forcedOutputTexture;
  14215. /**
  14216. * Returns the fragment url or shader name used in the post process.
  14217. * @returns the fragment url or name in the shader store.
  14218. */
  14219. getEffectName(): string;
  14220. /**
  14221. * An event triggered when the postprocess is activated.
  14222. */
  14223. onActivateObservable: Observable<Camera>;
  14224. private _onActivateObserver;
  14225. /**
  14226. * A function that is added to the onActivateObservable
  14227. */
  14228. onActivate: Nullable<(camera: Camera) => void>;
  14229. /**
  14230. * An event triggered when the postprocess changes its size.
  14231. */
  14232. onSizeChangedObservable: Observable<PostProcess>;
  14233. private _onSizeChangedObserver;
  14234. /**
  14235. * A function that is added to the onSizeChangedObservable
  14236. */
  14237. onSizeChanged: (postProcess: PostProcess) => void;
  14238. /**
  14239. * An event triggered when the postprocess applies its effect.
  14240. */
  14241. onApplyObservable: Observable<Effect>;
  14242. private _onApplyObserver;
  14243. /**
  14244. * A function that is added to the onApplyObservable
  14245. */
  14246. onApply: (effect: Effect) => void;
  14247. /**
  14248. * An event triggered before rendering the postprocess
  14249. */
  14250. onBeforeRenderObservable: Observable<Effect>;
  14251. private _onBeforeRenderObserver;
  14252. /**
  14253. * A function that is added to the onBeforeRenderObservable
  14254. */
  14255. onBeforeRender: (effect: Effect) => void;
  14256. /**
  14257. * An event triggered after rendering the postprocess
  14258. */
  14259. onAfterRenderObservable: Observable<Effect>;
  14260. private _onAfterRenderObserver;
  14261. /**
  14262. * A function that is added to the onAfterRenderObservable
  14263. */
  14264. onAfterRender: (efect: Effect) => void;
  14265. /**
  14266. * 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
  14267. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  14268. */
  14269. inputTexture: InternalTexture;
  14270. /**
  14271. * Gets the camera which post process is applied to.
  14272. * @returns The camera the post process is applied to.
  14273. */
  14274. getCamera(): Camera;
  14275. /**
  14276. * Gets the texel size of the postprocess.
  14277. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  14278. */
  14279. readonly texelSize: Vector2;
  14280. /**
  14281. * Creates a new instance PostProcess
  14282. * @param name The name of the PostProcess.
  14283. * @param fragmentUrl The url of the fragment shader to be used.
  14284. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  14285. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  14286. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  14287. * @param camera The camera to apply the render pass to.
  14288. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  14289. * @param engine The engine which the post process will be applied. (default: current engine)
  14290. * @param reusable If the post process can be reused on the same frame. (default: false)
  14291. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  14292. * @param textureType Type of textures used when performing the post process. (default: 0)
  14293. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  14294. * @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
  14295. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  14296. */
  14297. constructor(
  14298. /** Name of the PostProcess. */
  14299. 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);
  14300. /**
  14301. * Gets a string idenfifying the name of the class
  14302. * @returns "PostProcess" string
  14303. */
  14304. getClassName(): string;
  14305. /**
  14306. * Gets the engine which this post process belongs to.
  14307. * @returns The engine the post process was enabled with.
  14308. */
  14309. getEngine(): Engine;
  14310. /**
  14311. * The effect that is created when initializing the post process.
  14312. * @returns The created effect corrisponding the the postprocess.
  14313. */
  14314. getEffect(): Effect;
  14315. /**
  14316. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  14317. * @param postProcess The post process to share the output with.
  14318. * @returns This post process.
  14319. */
  14320. shareOutputWith(postProcess: PostProcess): PostProcess;
  14321. /**
  14322. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  14323. * This should be called if the post process that shares output with this post process is disabled/disposed.
  14324. */
  14325. useOwnOutput(): void;
  14326. /**
  14327. * Updates the effect with the current post process compile time values and recompiles the shader.
  14328. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  14329. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  14330. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  14331. * @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
  14332. * @param onCompiled Called when the shader has been compiled.
  14333. * @param onError Called if there is an error when compiling a shader.
  14334. */
  14335. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  14336. /**
  14337. * The post process is reusable if it can be used multiple times within one frame.
  14338. * @returns If the post process is reusable
  14339. */
  14340. isReusable(): boolean;
  14341. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  14342. markTextureDirty(): void;
  14343. /**
  14344. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  14345. * 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.
  14346. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  14347. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  14348. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  14349. * @returns The target texture that was bound to be written to.
  14350. */
  14351. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  14352. /**
  14353. * If the post process is supported.
  14354. */
  14355. readonly isSupported: boolean;
  14356. /**
  14357. * The aspect ratio of the output texture.
  14358. */
  14359. readonly aspectRatio: number;
  14360. /**
  14361. * Get a value indicating if the post-process is ready to be used
  14362. * @returns true if the post-process is ready (shader is compiled)
  14363. */
  14364. isReady(): boolean;
  14365. /**
  14366. * Binds all textures and uniforms to the shader, this will be run on every pass.
  14367. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  14368. */
  14369. apply(): Nullable<Effect>;
  14370. private _disposeTextures;
  14371. /**
  14372. * Disposes the post process.
  14373. * @param camera The camera to dispose the post process on.
  14374. */
  14375. dispose(camera?: Camera): void;
  14376. }
  14377. }
  14378. declare module "babylonjs/PostProcesses/postProcessManager" {
  14379. import { Nullable } from "babylonjs/types";
  14380. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14381. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14382. import { Scene } from "babylonjs/scene";
  14383. /**
  14384. * PostProcessManager is used to manage one or more post processes or post process pipelines
  14385. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  14386. */
  14387. export class PostProcessManager {
  14388. private _scene;
  14389. private _indexBuffer;
  14390. private _vertexBuffers;
  14391. /**
  14392. * Creates a new instance PostProcess
  14393. * @param scene The scene that the post process is associated with.
  14394. */
  14395. constructor(scene: Scene);
  14396. private _prepareBuffers;
  14397. private _buildIndexBuffer;
  14398. /**
  14399. * Rebuilds the vertex buffers of the manager.
  14400. * @hidden
  14401. */
  14402. _rebuild(): void;
  14403. /**
  14404. * Prepares a frame to be run through a post process.
  14405. * @param sourceTexture The input texture to the post procesess. (default: null)
  14406. * @param postProcesses An array of post processes to be run. (default: null)
  14407. * @returns True if the post processes were able to be run.
  14408. * @hidden
  14409. */
  14410. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  14411. /**
  14412. * Manually render a set of post processes to a texture.
  14413. * @param postProcesses An array of post processes to be run.
  14414. * @param targetTexture The target texture to render to.
  14415. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  14416. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  14417. * @param lodLevel defines which lod of the texture to render to
  14418. */
  14419. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  14420. /**
  14421. * Finalize the result of the output of the postprocesses.
  14422. * @param doNotPresent If true the result will not be displayed to the screen.
  14423. * @param targetTexture The target texture to render to.
  14424. * @param faceIndex The index of the face to bind the target texture to.
  14425. * @param postProcesses The array of post processes to render.
  14426. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  14427. * @hidden
  14428. */
  14429. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  14430. /**
  14431. * Disposes of the post process manager.
  14432. */
  14433. dispose(): void;
  14434. }
  14435. }
  14436. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14437. import { Scene } from "babylonjs/scene";
  14438. import { ISceneComponent } from "babylonjs/sceneComponent";
  14439. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14440. module "babylonjs/abstractScene" {
  14441. interface AbstractScene {
  14442. /**
  14443. * The list of procedural textures added to the scene
  14444. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14445. */
  14446. proceduralTextures: Array<ProceduralTexture>;
  14447. }
  14448. }
  14449. /**
  14450. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14451. * in a given scene.
  14452. */
  14453. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14454. /**
  14455. * The component name helpfull to identify the component in the list of scene components.
  14456. */
  14457. readonly name: string;
  14458. /**
  14459. * The scene the component belongs to.
  14460. */
  14461. scene: Scene;
  14462. /**
  14463. * Creates a new instance of the component for the given scene
  14464. * @param scene Defines the scene to register the component in
  14465. */
  14466. constructor(scene: Scene);
  14467. /**
  14468. * Registers the component in a given scene
  14469. */
  14470. register(): void;
  14471. /**
  14472. * Rebuilds the elements related to this component in case of
  14473. * context lost for instance.
  14474. */
  14475. rebuild(): void;
  14476. /**
  14477. * Disposes the component and the associated ressources.
  14478. */
  14479. dispose(): void;
  14480. private _beforeClear;
  14481. }
  14482. }
  14483. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  14484. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14485. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  14486. module "babylonjs/Engines/engine" {
  14487. interface Engine {
  14488. /**
  14489. * Creates a new render target cube texture
  14490. * @param size defines the size of the texture
  14491. * @param options defines the options used to create the texture
  14492. * @returns a new render target cube texture stored in an InternalTexture
  14493. */
  14494. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14495. }
  14496. }
  14497. }
  14498. declare module "babylonjs/Shaders/procedural.vertex" {
  14499. /** @hidden */
  14500. export var proceduralVertexShader: {
  14501. name: string;
  14502. shader: string;
  14503. };
  14504. }
  14505. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14506. import { Observable } from "babylonjs/Misc/observable";
  14507. import { Nullable } from "babylonjs/types";
  14508. import { Scene } from "babylonjs/scene";
  14509. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  14510. import { Effect } from "babylonjs/Materials/effect";
  14511. import { Texture } from "babylonjs/Materials/Textures/texture";
  14512. import "babylonjs/Engines/Extensions/engine.renderTarget";
  14513. import "babylonjs/Shaders/procedural.vertex";
  14514. /**
  14515. * 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.
  14516. * This is the base class of any Procedural texture and contains most of the shareable code.
  14517. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14518. */
  14519. export class ProceduralTexture extends Texture {
  14520. isCube: boolean;
  14521. /**
  14522. * Define if the texture is enabled or not (disabled texture will not render)
  14523. */
  14524. isEnabled: boolean;
  14525. /**
  14526. * Define if the texture must be cleared before rendering (default is true)
  14527. */
  14528. autoClear: boolean;
  14529. /**
  14530. * Callback called when the texture is generated
  14531. */
  14532. onGenerated: () => void;
  14533. /**
  14534. * Event raised when the texture is generated
  14535. */
  14536. onGeneratedObservable: Observable<ProceduralTexture>;
  14537. /** @hidden */
  14538. _generateMipMaps: boolean;
  14539. /** @hidden **/
  14540. _effect: Effect;
  14541. /** @hidden */
  14542. _textures: {
  14543. [key: string]: Texture;
  14544. };
  14545. private _size;
  14546. private _currentRefreshId;
  14547. private _refreshRate;
  14548. private _vertexBuffers;
  14549. private _indexBuffer;
  14550. private _uniforms;
  14551. private _samplers;
  14552. private _fragment;
  14553. private _floats;
  14554. private _ints;
  14555. private _floatsArrays;
  14556. private _colors3;
  14557. private _colors4;
  14558. private _vectors2;
  14559. private _vectors3;
  14560. private _matrices;
  14561. private _fallbackTexture;
  14562. private _fallbackTextureUsed;
  14563. private _engine;
  14564. private _cachedDefines;
  14565. private _contentUpdateId;
  14566. private _contentData;
  14567. /**
  14568. * Instantiates a new procedural texture.
  14569. * 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.
  14570. * This is the base class of any Procedural texture and contains most of the shareable code.
  14571. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14572. * @param name Define the name of the texture
  14573. * @param size Define the size of the texture to create
  14574. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14575. * @param scene Define the scene the texture belongs to
  14576. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14577. * @param generateMipMaps Define if the texture should creates mip maps or not
  14578. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14579. */
  14580. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14581. /**
  14582. * The effect that is created when initializing the post process.
  14583. * @returns The created effect corrisponding the the postprocess.
  14584. */
  14585. getEffect(): Effect;
  14586. /**
  14587. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14588. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14589. */
  14590. getContent(): Nullable<ArrayBufferView>;
  14591. private _createIndexBuffer;
  14592. /** @hidden */
  14593. _rebuild(): void;
  14594. /**
  14595. * Resets the texture in order to recreate its associated resources.
  14596. * This can be called in case of context loss
  14597. */
  14598. reset(): void;
  14599. protected _getDefines(): string;
  14600. /**
  14601. * Is the texture ready to be used ? (rendered at least once)
  14602. * @returns true if ready, otherwise, false.
  14603. */
  14604. isReady(): boolean;
  14605. /**
  14606. * Resets the refresh counter of the texture and start bak from scratch.
  14607. * Could be useful to regenerate the texture if it is setup to render only once.
  14608. */
  14609. resetRefreshCounter(): void;
  14610. /**
  14611. * Set the fragment shader to use in order to render the texture.
  14612. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14613. */
  14614. setFragment(fragment: any): void;
  14615. /**
  14616. * Define the refresh rate of the texture or the rendering frequency.
  14617. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14618. */
  14619. refreshRate: number;
  14620. /** @hidden */
  14621. _shouldRender(): boolean;
  14622. /**
  14623. * Get the size the texture is rendering at.
  14624. * @returns the size (texture is always squared)
  14625. */
  14626. getRenderSize(): number;
  14627. /**
  14628. * Resize the texture to new value.
  14629. * @param size Define the new size the texture should have
  14630. * @param generateMipMaps Define whether the new texture should create mip maps
  14631. */
  14632. resize(size: number, generateMipMaps: boolean): void;
  14633. private _checkUniform;
  14634. /**
  14635. * Set a texture in the shader program used to render.
  14636. * @param name Define the name of the uniform samplers as defined in the shader
  14637. * @param texture Define the texture to bind to this sampler
  14638. * @return the texture itself allowing "fluent" like uniform updates
  14639. */
  14640. setTexture(name: string, texture: Texture): ProceduralTexture;
  14641. /**
  14642. * Set a float in the shader.
  14643. * @param name Define the name of the uniform as defined in the shader
  14644. * @param value Define the value to give to the uniform
  14645. * @return the texture itself allowing "fluent" like uniform updates
  14646. */
  14647. setFloat(name: string, value: number): ProceduralTexture;
  14648. /**
  14649. * Set a int in the shader.
  14650. * @param name Define the name of the uniform as defined in the shader
  14651. * @param value Define the value to give to the uniform
  14652. * @return the texture itself allowing "fluent" like uniform updates
  14653. */
  14654. setInt(name: string, value: number): ProceduralTexture;
  14655. /**
  14656. * Set an array of floats in the shader.
  14657. * @param name Define the name of the uniform as defined in the shader
  14658. * @param value Define the value to give to the uniform
  14659. * @return the texture itself allowing "fluent" like uniform updates
  14660. */
  14661. setFloats(name: string, value: number[]): ProceduralTexture;
  14662. /**
  14663. * Set a vec3 in the shader from a Color3.
  14664. * @param name Define the name of the uniform as defined in the shader
  14665. * @param value Define the value to give to the uniform
  14666. * @return the texture itself allowing "fluent" like uniform updates
  14667. */
  14668. setColor3(name: string, value: Color3): ProceduralTexture;
  14669. /**
  14670. * Set a vec4 in the shader from a Color4.
  14671. * @param name Define the name of the uniform as defined in the shader
  14672. * @param value Define the value to give to the uniform
  14673. * @return the texture itself allowing "fluent" like uniform updates
  14674. */
  14675. setColor4(name: string, value: Color4): ProceduralTexture;
  14676. /**
  14677. * Set a vec2 in the shader from a Vector2.
  14678. * @param name Define the name of the uniform as defined in the shader
  14679. * @param value Define the value to give to the uniform
  14680. * @return the texture itself allowing "fluent" like uniform updates
  14681. */
  14682. setVector2(name: string, value: Vector2): ProceduralTexture;
  14683. /**
  14684. * Set a vec3 in the shader from a Vector3.
  14685. * @param name Define the name of the uniform as defined in the shader
  14686. * @param value Define the value to give to the uniform
  14687. * @return the texture itself allowing "fluent" like uniform updates
  14688. */
  14689. setVector3(name: string, value: Vector3): ProceduralTexture;
  14690. /**
  14691. * Set a mat4 in the shader from a MAtrix.
  14692. * @param name Define the name of the uniform as defined in the shader
  14693. * @param value Define the value to give to the uniform
  14694. * @return the texture itself allowing "fluent" like uniform updates
  14695. */
  14696. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14697. /**
  14698. * Render the texture to its associated render target.
  14699. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14700. */
  14701. render(useCameraPostProcess?: boolean): void;
  14702. /**
  14703. * Clone the texture.
  14704. * @returns the cloned texture
  14705. */
  14706. clone(): ProceduralTexture;
  14707. /**
  14708. * Dispose the texture and release its asoociated resources.
  14709. */
  14710. dispose(): void;
  14711. }
  14712. }
  14713. declare module "babylonjs/Particles/baseParticleSystem" {
  14714. import { Nullable } from "babylonjs/types";
  14715. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14716. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14717. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14718. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14719. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14720. import { Scene } from "babylonjs/scene";
  14721. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14722. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14723. import { Texture } from "babylonjs/Materials/Textures/texture";
  14724. import { Animation } from "babylonjs/Animations/animation";
  14725. /**
  14726. * This represents the base class for particle system in Babylon.
  14727. * 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.
  14728. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14729. * @example https://doc.babylonjs.com/babylon101/particles
  14730. */
  14731. export class BaseParticleSystem {
  14732. /**
  14733. * Source color is added to the destination color without alpha affecting the result
  14734. */
  14735. static BLENDMODE_ONEONE: number;
  14736. /**
  14737. * Blend current color and particle color using particle’s alpha
  14738. */
  14739. static BLENDMODE_STANDARD: number;
  14740. /**
  14741. * Add current color and particle color multiplied by particle’s alpha
  14742. */
  14743. static BLENDMODE_ADD: number;
  14744. /**
  14745. * Multiply current color with particle color
  14746. */
  14747. static BLENDMODE_MULTIPLY: number;
  14748. /**
  14749. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14750. */
  14751. static BLENDMODE_MULTIPLYADD: number;
  14752. /**
  14753. * List of animations used by the particle system.
  14754. */
  14755. animations: Animation[];
  14756. /**
  14757. * The id of the Particle system.
  14758. */
  14759. id: string;
  14760. /**
  14761. * The friendly name of the Particle system.
  14762. */
  14763. name: string;
  14764. /**
  14765. * The rendering group used by the Particle system to chose when to render.
  14766. */
  14767. renderingGroupId: number;
  14768. /**
  14769. * The emitter represents the Mesh or position we are attaching the particle system to.
  14770. */
  14771. emitter: Nullable<AbstractMesh | Vector3>;
  14772. /**
  14773. * The maximum number of particles to emit per frame
  14774. */
  14775. emitRate: number;
  14776. /**
  14777. * If you want to launch only a few particles at once, that can be done, as well.
  14778. */
  14779. manualEmitCount: number;
  14780. /**
  14781. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14782. */
  14783. updateSpeed: number;
  14784. /**
  14785. * The amount of time the particle system is running (depends of the overall update speed).
  14786. */
  14787. targetStopDuration: number;
  14788. /**
  14789. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14790. */
  14791. disposeOnStop: boolean;
  14792. /**
  14793. * Minimum power of emitting particles.
  14794. */
  14795. minEmitPower: number;
  14796. /**
  14797. * Maximum power of emitting particles.
  14798. */
  14799. maxEmitPower: number;
  14800. /**
  14801. * Minimum life time of emitting particles.
  14802. */
  14803. minLifeTime: number;
  14804. /**
  14805. * Maximum life time of emitting particles.
  14806. */
  14807. maxLifeTime: number;
  14808. /**
  14809. * Minimum Size of emitting particles.
  14810. */
  14811. minSize: number;
  14812. /**
  14813. * Maximum Size of emitting particles.
  14814. */
  14815. maxSize: number;
  14816. /**
  14817. * Minimum scale of emitting particles on X axis.
  14818. */
  14819. minScaleX: number;
  14820. /**
  14821. * Maximum scale of emitting particles on X axis.
  14822. */
  14823. maxScaleX: number;
  14824. /**
  14825. * Minimum scale of emitting particles on Y axis.
  14826. */
  14827. minScaleY: number;
  14828. /**
  14829. * Maximum scale of emitting particles on Y axis.
  14830. */
  14831. maxScaleY: number;
  14832. /**
  14833. * Gets or sets the minimal initial rotation in radians.
  14834. */
  14835. minInitialRotation: number;
  14836. /**
  14837. * Gets or sets the maximal initial rotation in radians.
  14838. */
  14839. maxInitialRotation: number;
  14840. /**
  14841. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14842. */
  14843. minAngularSpeed: number;
  14844. /**
  14845. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14846. */
  14847. maxAngularSpeed: number;
  14848. /**
  14849. * The texture used to render each particle. (this can be a spritesheet)
  14850. */
  14851. particleTexture: Nullable<Texture>;
  14852. /**
  14853. * The layer mask we are rendering the particles through.
  14854. */
  14855. layerMask: number;
  14856. /**
  14857. * This can help using your own shader to render the particle system.
  14858. * The according effect will be created
  14859. */
  14860. customShader: any;
  14861. /**
  14862. * By default particle system starts as soon as they are created. This prevents the
  14863. * automatic start to happen and let you decide when to start emitting particles.
  14864. */
  14865. preventAutoStart: boolean;
  14866. private _noiseTexture;
  14867. /**
  14868. * Gets or sets a texture used to add random noise to particle positions
  14869. */
  14870. noiseTexture: Nullable<ProceduralTexture>;
  14871. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14872. noiseStrength: Vector3;
  14873. /**
  14874. * Callback triggered when the particle animation is ending.
  14875. */
  14876. onAnimationEnd: Nullable<() => void>;
  14877. /**
  14878. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14879. */
  14880. blendMode: number;
  14881. /**
  14882. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14883. * to override the particles.
  14884. */
  14885. forceDepthWrite: boolean;
  14886. /** 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 */
  14887. preWarmCycles: number;
  14888. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14889. preWarmStepOffset: number;
  14890. /**
  14891. * 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)
  14892. */
  14893. spriteCellChangeSpeed: number;
  14894. /**
  14895. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14896. */
  14897. startSpriteCellID: number;
  14898. /**
  14899. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14900. */
  14901. endSpriteCellID: number;
  14902. /**
  14903. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14904. */
  14905. spriteCellWidth: number;
  14906. /**
  14907. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14908. */
  14909. spriteCellHeight: number;
  14910. /**
  14911. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14912. */
  14913. spriteRandomStartCell: boolean;
  14914. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14915. translationPivot: Vector2;
  14916. /** @hidden */
  14917. protected _isAnimationSheetEnabled: boolean;
  14918. /**
  14919. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14920. */
  14921. beginAnimationOnStart: boolean;
  14922. /**
  14923. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14924. */
  14925. beginAnimationFrom: number;
  14926. /**
  14927. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14928. */
  14929. beginAnimationTo: number;
  14930. /**
  14931. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14932. */
  14933. beginAnimationLoop: boolean;
  14934. /**
  14935. * Gets or sets a world offset applied to all particles
  14936. */
  14937. worldOffset: Vector3;
  14938. /**
  14939. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14940. */
  14941. isAnimationSheetEnabled: boolean;
  14942. /**
  14943. * Get hosting scene
  14944. * @returns the scene
  14945. */
  14946. getScene(): Scene;
  14947. /**
  14948. * You can use gravity if you want to give an orientation to your particles.
  14949. */
  14950. gravity: Vector3;
  14951. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14952. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14953. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14954. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14955. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14956. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14957. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14958. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14959. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14960. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14961. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14962. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14963. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14964. /**
  14965. * Defines the delay in milliseconds before starting the system (0 by default)
  14966. */
  14967. startDelay: number;
  14968. /**
  14969. * Gets the current list of drag gradients.
  14970. * You must use addDragGradient and removeDragGradient to udpate this list
  14971. * @returns the list of drag gradients
  14972. */
  14973. getDragGradients(): Nullable<Array<FactorGradient>>;
  14974. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14975. limitVelocityDamping: number;
  14976. /**
  14977. * Gets the current list of limit velocity gradients.
  14978. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14979. * @returns the list of limit velocity gradients
  14980. */
  14981. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14982. /**
  14983. * Gets the current list of color gradients.
  14984. * You must use addColorGradient and removeColorGradient to udpate this list
  14985. * @returns the list of color gradients
  14986. */
  14987. getColorGradients(): Nullable<Array<ColorGradient>>;
  14988. /**
  14989. * Gets the current list of size gradients.
  14990. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14991. * @returns the list of size gradients
  14992. */
  14993. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14994. /**
  14995. * Gets the current list of color remap gradients.
  14996. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14997. * @returns the list of color remap gradients
  14998. */
  14999. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  15000. /**
  15001. * Gets the current list of alpha remap gradients.
  15002. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  15003. * @returns the list of alpha remap gradients
  15004. */
  15005. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  15006. /**
  15007. * Gets the current list of life time gradients.
  15008. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  15009. * @returns the list of life time gradients
  15010. */
  15011. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  15012. /**
  15013. * Gets the current list of angular speed gradients.
  15014. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  15015. * @returns the list of angular speed gradients
  15016. */
  15017. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  15018. /**
  15019. * Gets the current list of velocity gradients.
  15020. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  15021. * @returns the list of velocity gradients
  15022. */
  15023. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  15024. /**
  15025. * Gets the current list of start size gradients.
  15026. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  15027. * @returns the list of start size gradients
  15028. */
  15029. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15030. /**
  15031. * Gets the current list of emit rate gradients.
  15032. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  15033. * @returns the list of emit rate gradients
  15034. */
  15035. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15036. /**
  15037. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15038. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15039. */
  15040. direction1: Vector3;
  15041. /**
  15042. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15043. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15044. */
  15045. direction2: Vector3;
  15046. /**
  15047. * 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.
  15048. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15049. */
  15050. minEmitBox: Vector3;
  15051. /**
  15052. * 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.
  15053. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15054. */
  15055. maxEmitBox: Vector3;
  15056. /**
  15057. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15058. */
  15059. color1: Color4;
  15060. /**
  15061. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15062. */
  15063. color2: Color4;
  15064. /**
  15065. * Color the particle will have at the end of its lifetime
  15066. */
  15067. colorDead: Color4;
  15068. /**
  15069. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  15070. */
  15071. textureMask: Color4;
  15072. /**
  15073. * The particle emitter type defines the emitter used by the particle system.
  15074. * It can be for example box, sphere, or cone...
  15075. */
  15076. particleEmitterType: IParticleEmitterType;
  15077. /** @hidden */
  15078. _isSubEmitter: boolean;
  15079. /**
  15080. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15081. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15082. */
  15083. billboardMode: number;
  15084. protected _isBillboardBased: boolean;
  15085. /**
  15086. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15087. */
  15088. isBillboardBased: boolean;
  15089. /**
  15090. * The scene the particle system belongs to.
  15091. */
  15092. protected _scene: Scene;
  15093. /**
  15094. * Local cache of defines for image processing.
  15095. */
  15096. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  15097. /**
  15098. * Default configuration related to image processing available in the standard Material.
  15099. */
  15100. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  15101. /**
  15102. * Gets the image processing configuration used either in this material.
  15103. */
  15104. /**
  15105. * Sets the Default image processing configuration used either in the this material.
  15106. *
  15107. * If sets to null, the scene one is in use.
  15108. */
  15109. imageProcessingConfiguration: ImageProcessingConfiguration;
  15110. /**
  15111. * Attaches a new image processing configuration to the Standard Material.
  15112. * @param configuration
  15113. */
  15114. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15115. /** @hidden */
  15116. protected _reset(): void;
  15117. /** @hidden */
  15118. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  15119. /**
  15120. * Instantiates a particle system.
  15121. * 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.
  15122. * @param name The name of the particle system
  15123. */
  15124. constructor(name: string);
  15125. /**
  15126. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15127. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15128. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15129. * @returns the emitter
  15130. */
  15131. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15132. /**
  15133. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15134. * @param radius The radius of the hemisphere to emit from
  15135. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15136. * @returns the emitter
  15137. */
  15138. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  15139. /**
  15140. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15141. * @param radius The radius of the sphere to emit from
  15142. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15143. * @returns the emitter
  15144. */
  15145. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15146. /**
  15147. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15148. * @param radius The radius of the sphere to emit from
  15149. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15150. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15151. * @returns the emitter
  15152. */
  15153. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15154. /**
  15155. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15156. * @param radius The radius of the emission cylinder
  15157. * @param height The height of the emission cylinder
  15158. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15159. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15160. * @returns the emitter
  15161. */
  15162. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15163. /**
  15164. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15165. * @param radius The radius of the cylinder to emit from
  15166. * @param height The height of the emission cylinder
  15167. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15168. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15169. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15170. * @returns the emitter
  15171. */
  15172. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15173. /**
  15174. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15175. * @param radius The radius of the cone to emit from
  15176. * @param angle The base angle of the cone
  15177. * @returns the emitter
  15178. */
  15179. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15180. /**
  15181. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15182. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15183. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15184. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15185. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15186. * @returns the emitter
  15187. */
  15188. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15189. }
  15190. }
  15191. declare module "babylonjs/Particles/subEmitter" {
  15192. import { Scene } from "babylonjs/scene";
  15193. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15194. /**
  15195. * Type of sub emitter
  15196. */
  15197. export enum SubEmitterType {
  15198. /**
  15199. * Attached to the particle over it's lifetime
  15200. */
  15201. ATTACHED = 0,
  15202. /**
  15203. * Created when the particle dies
  15204. */
  15205. END = 1
  15206. }
  15207. /**
  15208. * Sub emitter class used to emit particles from an existing particle
  15209. */
  15210. export class SubEmitter {
  15211. /**
  15212. * the particle system to be used by the sub emitter
  15213. */
  15214. particleSystem: ParticleSystem;
  15215. /**
  15216. * Type of the submitter (Default: END)
  15217. */
  15218. type: SubEmitterType;
  15219. /**
  15220. * 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)
  15221. * Note: This only is supported when using an emitter of type Mesh
  15222. */
  15223. inheritDirection: boolean;
  15224. /**
  15225. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15226. */
  15227. inheritedVelocityAmount: number;
  15228. /**
  15229. * Creates a sub emitter
  15230. * @param particleSystem the particle system to be used by the sub emitter
  15231. */
  15232. constructor(
  15233. /**
  15234. * the particle system to be used by the sub emitter
  15235. */
  15236. particleSystem: ParticleSystem);
  15237. /**
  15238. * Clones the sub emitter
  15239. * @returns the cloned sub emitter
  15240. */
  15241. clone(): SubEmitter;
  15242. /**
  15243. * Serialize current object to a JSON object
  15244. * @returns the serialized object
  15245. */
  15246. serialize(): any;
  15247. /** @hidden */
  15248. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  15249. /**
  15250. * Creates a new SubEmitter from a serialized JSON version
  15251. * @param serializationObject defines the JSON object to read from
  15252. * @param scene defines the hosting scene
  15253. * @param rootUrl defines the rootUrl for data loading
  15254. * @returns a new SubEmitter
  15255. */
  15256. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  15257. /** Release associated resources */
  15258. dispose(): void;
  15259. }
  15260. }
  15261. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  15262. /** @hidden */
  15263. export var clipPlaneFragmentDeclaration: {
  15264. name: string;
  15265. shader: string;
  15266. };
  15267. }
  15268. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  15269. /** @hidden */
  15270. export var imageProcessingDeclaration: {
  15271. name: string;
  15272. shader: string;
  15273. };
  15274. }
  15275. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  15276. /** @hidden */
  15277. export var imageProcessingFunctions: {
  15278. name: string;
  15279. shader: string;
  15280. };
  15281. }
  15282. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  15283. /** @hidden */
  15284. export var clipPlaneFragment: {
  15285. name: string;
  15286. shader: string;
  15287. };
  15288. }
  15289. declare module "babylonjs/Shaders/particles.fragment" {
  15290. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15291. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  15292. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  15293. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  15294. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15295. /** @hidden */
  15296. export var particlesPixelShader: {
  15297. name: string;
  15298. shader: string;
  15299. };
  15300. }
  15301. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  15302. /** @hidden */
  15303. export var clipPlaneVertexDeclaration: {
  15304. name: string;
  15305. shader: string;
  15306. };
  15307. }
  15308. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  15309. /** @hidden */
  15310. export var clipPlaneVertex: {
  15311. name: string;
  15312. shader: string;
  15313. };
  15314. }
  15315. declare module "babylonjs/Shaders/particles.vertex" {
  15316. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15317. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15318. /** @hidden */
  15319. export var particlesVertexShader: {
  15320. name: string;
  15321. shader: string;
  15322. };
  15323. }
  15324. declare module "babylonjs/Particles/particleSystem" {
  15325. import { Nullable } from "babylonjs/types";
  15326. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15327. import { Observable } from "babylonjs/Misc/observable";
  15328. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  15329. import { Effect } from "babylonjs/Materials/effect";
  15330. import { Scene, IDisposable } from "babylonjs/scene";
  15331. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  15332. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15333. import { Particle } from "babylonjs/Particles/particle";
  15334. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15335. import "babylonjs/Shaders/particles.fragment";
  15336. import "babylonjs/Shaders/particles.vertex";
  15337. /**
  15338. * This represents a particle system in Babylon.
  15339. * 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.
  15340. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15341. * @example https://doc.babylonjs.com/babylon101/particles
  15342. */
  15343. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15344. /**
  15345. * Billboard mode will only apply to Y axis
  15346. */
  15347. static readonly BILLBOARDMODE_Y: number;
  15348. /**
  15349. * Billboard mode will apply to all axes
  15350. */
  15351. static readonly BILLBOARDMODE_ALL: number;
  15352. /**
  15353. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15354. */
  15355. static readonly BILLBOARDMODE_STRETCHED: number;
  15356. /**
  15357. * This function can be defined to provide custom update for active particles.
  15358. * This function will be called instead of regular update (age, position, color, etc.).
  15359. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15360. */
  15361. updateFunction: (particles: Particle[]) => void;
  15362. private _emitterWorldMatrix;
  15363. /**
  15364. * This function can be defined to specify initial direction for every new particle.
  15365. * It by default use the emitterType defined function
  15366. */
  15367. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  15368. /**
  15369. * This function can be defined to specify initial position for every new particle.
  15370. * It by default use the emitterType defined function
  15371. */
  15372. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  15373. /**
  15374. * @hidden
  15375. */
  15376. _inheritedVelocityOffset: Vector3;
  15377. /**
  15378. * An event triggered when the system is disposed
  15379. */
  15380. onDisposeObservable: Observable<ParticleSystem>;
  15381. private _onDisposeObserver;
  15382. /**
  15383. * Sets a callback that will be triggered when the system is disposed
  15384. */
  15385. onDispose: () => void;
  15386. private _particles;
  15387. private _epsilon;
  15388. private _capacity;
  15389. private _stockParticles;
  15390. private _newPartsExcess;
  15391. private _vertexData;
  15392. private _vertexBuffer;
  15393. private _vertexBuffers;
  15394. private _spriteBuffer;
  15395. private _indexBuffer;
  15396. private _effect;
  15397. private _customEffect;
  15398. private _cachedDefines;
  15399. private _scaledColorStep;
  15400. private _colorDiff;
  15401. private _scaledDirection;
  15402. private _scaledGravity;
  15403. private _currentRenderId;
  15404. private _alive;
  15405. private _useInstancing;
  15406. private _started;
  15407. private _stopped;
  15408. private _actualFrame;
  15409. private _scaledUpdateSpeed;
  15410. private _vertexBufferSize;
  15411. /** @hidden */
  15412. _currentEmitRateGradient: Nullable<FactorGradient>;
  15413. /** @hidden */
  15414. _currentEmitRate1: number;
  15415. /** @hidden */
  15416. _currentEmitRate2: number;
  15417. /** @hidden */
  15418. _currentStartSizeGradient: Nullable<FactorGradient>;
  15419. /** @hidden */
  15420. _currentStartSize1: number;
  15421. /** @hidden */
  15422. _currentStartSize2: number;
  15423. private readonly _rawTextureWidth;
  15424. private _rampGradientsTexture;
  15425. private _useRampGradients;
  15426. /** Gets or sets a boolean indicating that ramp gradients must be used
  15427. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15428. */
  15429. useRampGradients: boolean;
  15430. /**
  15431. * 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.
  15432. * 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: [])
  15433. */
  15434. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15435. private _subEmitters;
  15436. /**
  15437. * @hidden
  15438. * If the particle systems emitter should be disposed when the particle system is disposed
  15439. */
  15440. _disposeEmitterOnDispose: boolean;
  15441. /**
  15442. * The current active Sub-systems, this property is used by the root particle system only.
  15443. */
  15444. activeSubSystems: Array<ParticleSystem>;
  15445. private _rootParticleSystem;
  15446. /**
  15447. * Gets the current list of active particles
  15448. */
  15449. readonly particles: Particle[];
  15450. /**
  15451. * Returns the string "ParticleSystem"
  15452. * @returns a string containing the class name
  15453. */
  15454. getClassName(): string;
  15455. /**
  15456. * Instantiates a particle system.
  15457. * 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.
  15458. * @param name The name of the particle system
  15459. * @param capacity The max number of particles alive at the same time
  15460. * @param scene The scene the particle system belongs to
  15461. * @param customEffect a custom effect used to change the way particles are rendered by default
  15462. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15463. * @param epsilon Offset used to render the particles
  15464. */
  15465. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15466. private _addFactorGradient;
  15467. private _removeFactorGradient;
  15468. /**
  15469. * Adds a new life time gradient
  15470. * @param gradient defines the gradient to use (between 0 and 1)
  15471. * @param factor defines the life time factor to affect to the specified gradient
  15472. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15473. * @returns the current particle system
  15474. */
  15475. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15476. /**
  15477. * Remove a specific life time gradient
  15478. * @param gradient defines the gradient to remove
  15479. * @returns the current particle system
  15480. */
  15481. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15482. /**
  15483. * Adds a new size gradient
  15484. * @param gradient defines the gradient to use (between 0 and 1)
  15485. * @param factor defines the size factor to affect to the specified gradient
  15486. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15487. * @returns the current particle system
  15488. */
  15489. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15490. /**
  15491. * Remove a specific size gradient
  15492. * @param gradient defines the gradient to remove
  15493. * @returns the current particle system
  15494. */
  15495. removeSizeGradient(gradient: number): IParticleSystem;
  15496. /**
  15497. * Adds a new color remap gradient
  15498. * @param gradient defines the gradient to use (between 0 and 1)
  15499. * @param min defines the color remap minimal range
  15500. * @param max defines the color remap maximal range
  15501. * @returns the current particle system
  15502. */
  15503. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15504. /**
  15505. * Remove a specific color remap gradient
  15506. * @param gradient defines the gradient to remove
  15507. * @returns the current particle system
  15508. */
  15509. removeColorRemapGradient(gradient: number): IParticleSystem;
  15510. /**
  15511. * Adds a new alpha remap gradient
  15512. * @param gradient defines the gradient to use (between 0 and 1)
  15513. * @param min defines the alpha remap minimal range
  15514. * @param max defines the alpha remap maximal range
  15515. * @returns the current particle system
  15516. */
  15517. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15518. /**
  15519. * Remove a specific alpha remap gradient
  15520. * @param gradient defines the gradient to remove
  15521. * @returns the current particle system
  15522. */
  15523. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15524. /**
  15525. * Adds a new angular speed gradient
  15526. * @param gradient defines the gradient to use (between 0 and 1)
  15527. * @param factor defines the angular speed to affect to the specified gradient
  15528. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15529. * @returns the current particle system
  15530. */
  15531. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15532. /**
  15533. * Remove a specific angular speed gradient
  15534. * @param gradient defines the gradient to remove
  15535. * @returns the current particle system
  15536. */
  15537. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15538. /**
  15539. * Adds a new velocity gradient
  15540. * @param gradient defines the gradient to use (between 0 and 1)
  15541. * @param factor defines the velocity to affect to the specified gradient
  15542. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15543. * @returns the current particle system
  15544. */
  15545. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15546. /**
  15547. * Remove a specific velocity gradient
  15548. * @param gradient defines the gradient to remove
  15549. * @returns the current particle system
  15550. */
  15551. removeVelocityGradient(gradient: number): IParticleSystem;
  15552. /**
  15553. * Adds a new limit velocity gradient
  15554. * @param gradient defines the gradient to use (between 0 and 1)
  15555. * @param factor defines the limit velocity value to affect to the specified gradient
  15556. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15557. * @returns the current particle system
  15558. */
  15559. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15560. /**
  15561. * Remove a specific limit velocity gradient
  15562. * @param gradient defines the gradient to remove
  15563. * @returns the current particle system
  15564. */
  15565. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15566. /**
  15567. * Adds a new drag gradient
  15568. * @param gradient defines the gradient to use (between 0 and 1)
  15569. * @param factor defines the drag value to affect to the specified gradient
  15570. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15571. * @returns the current particle system
  15572. */
  15573. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15574. /**
  15575. * Remove a specific drag gradient
  15576. * @param gradient defines the gradient to remove
  15577. * @returns the current particle system
  15578. */
  15579. removeDragGradient(gradient: number): IParticleSystem;
  15580. /**
  15581. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15582. * @param gradient defines the gradient to use (between 0 and 1)
  15583. * @param factor defines the emit rate value to affect to the specified gradient
  15584. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15585. * @returns the current particle system
  15586. */
  15587. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15588. /**
  15589. * Remove a specific emit rate gradient
  15590. * @param gradient defines the gradient to remove
  15591. * @returns the current particle system
  15592. */
  15593. removeEmitRateGradient(gradient: number): IParticleSystem;
  15594. /**
  15595. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15596. * @param gradient defines the gradient to use (between 0 and 1)
  15597. * @param factor defines the start size value to affect to the specified gradient
  15598. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15599. * @returns the current particle system
  15600. */
  15601. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15602. /**
  15603. * Remove a specific start size gradient
  15604. * @param gradient defines the gradient to remove
  15605. * @returns the current particle system
  15606. */
  15607. removeStartSizeGradient(gradient: number): IParticleSystem;
  15608. private _createRampGradientTexture;
  15609. /**
  15610. * Gets the current list of ramp gradients.
  15611. * You must use addRampGradient and removeRampGradient to udpate this list
  15612. * @returns the list of ramp gradients
  15613. */
  15614. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15615. /**
  15616. * Adds a new ramp gradient used to remap particle colors
  15617. * @param gradient defines the gradient to use (between 0 and 1)
  15618. * @param color defines the color to affect to the specified gradient
  15619. * @returns the current particle system
  15620. */
  15621. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15622. /**
  15623. * Remove a specific ramp gradient
  15624. * @param gradient defines the gradient to remove
  15625. * @returns the current particle system
  15626. */
  15627. removeRampGradient(gradient: number): ParticleSystem;
  15628. /**
  15629. * Adds a new color gradient
  15630. * @param gradient defines the gradient to use (between 0 and 1)
  15631. * @param color1 defines the color to affect to the specified gradient
  15632. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15633. * @returns this particle system
  15634. */
  15635. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15636. /**
  15637. * Remove a specific color gradient
  15638. * @param gradient defines the gradient to remove
  15639. * @returns this particle system
  15640. */
  15641. removeColorGradient(gradient: number): IParticleSystem;
  15642. private _fetchR;
  15643. protected _reset(): void;
  15644. private _resetEffect;
  15645. private _createVertexBuffers;
  15646. private _createIndexBuffer;
  15647. /**
  15648. * Gets the maximum number of particles active at the same time.
  15649. * @returns The max number of active particles.
  15650. */
  15651. getCapacity(): number;
  15652. /**
  15653. * Gets whether there are still active particles in the system.
  15654. * @returns True if it is alive, otherwise false.
  15655. */
  15656. isAlive(): boolean;
  15657. /**
  15658. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15659. * @returns True if it has been started, otherwise false.
  15660. */
  15661. isStarted(): boolean;
  15662. private _prepareSubEmitterInternalArray;
  15663. /**
  15664. * Starts the particle system and begins to emit
  15665. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15666. */
  15667. start(delay?: number): void;
  15668. /**
  15669. * Stops the particle system.
  15670. * @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.
  15671. */
  15672. stop(stopSubEmitters?: boolean): void;
  15673. /**
  15674. * Remove all active particles
  15675. */
  15676. reset(): void;
  15677. /**
  15678. * @hidden (for internal use only)
  15679. */
  15680. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15681. /**
  15682. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15683. * Its lifetime will start back at 0.
  15684. */
  15685. recycleParticle: (particle: Particle) => void;
  15686. private _stopSubEmitters;
  15687. private _createParticle;
  15688. private _removeFromRoot;
  15689. private _emitFromParticle;
  15690. private _update;
  15691. /** @hidden */
  15692. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15693. /** @hidden */
  15694. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15695. /** @hidden */
  15696. private _getEffect;
  15697. /**
  15698. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15699. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15700. */
  15701. animate(preWarmOnly?: boolean): void;
  15702. private _appendParticleVertices;
  15703. /**
  15704. * Rebuilds the particle system.
  15705. */
  15706. rebuild(): void;
  15707. /**
  15708. * Is this system ready to be used/rendered
  15709. * @return true if the system is ready
  15710. */
  15711. isReady(): boolean;
  15712. private _render;
  15713. /**
  15714. * Renders the particle system in its current state.
  15715. * @returns the current number of particles
  15716. */
  15717. render(): number;
  15718. /**
  15719. * Disposes the particle system and free the associated resources
  15720. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15721. */
  15722. dispose(disposeTexture?: boolean): void;
  15723. /**
  15724. * Clones the particle system.
  15725. * @param name The name of the cloned object
  15726. * @param newEmitter The new emitter to use
  15727. * @returns the cloned particle system
  15728. */
  15729. clone(name: string, newEmitter: any): ParticleSystem;
  15730. /**
  15731. * Serializes the particle system to a JSON object.
  15732. * @returns the JSON object
  15733. */
  15734. serialize(): any;
  15735. /** @hidden */
  15736. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15737. /** @hidden */
  15738. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15739. /**
  15740. * Parses a JSON object to create a particle system.
  15741. * @param parsedParticleSystem The JSON object to parse
  15742. * @param scene The scene to create the particle system in
  15743. * @param rootUrl The root url to use to load external dependencies like texture
  15744. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15745. * @returns the Parsed particle system
  15746. */
  15747. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15748. }
  15749. }
  15750. declare module "babylonjs/Particles/particle" {
  15751. import { Nullable } from "babylonjs/types";
  15752. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15753. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15754. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15755. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15756. /**
  15757. * A particle represents one of the element emitted by a particle system.
  15758. * This is mainly define by its coordinates, direction, velocity and age.
  15759. */
  15760. export class Particle {
  15761. /**
  15762. * The particle system the particle belongs to.
  15763. */
  15764. particleSystem: ParticleSystem;
  15765. private static _Count;
  15766. /**
  15767. * Unique ID of the particle
  15768. */
  15769. id: number;
  15770. /**
  15771. * The world position of the particle in the scene.
  15772. */
  15773. position: Vector3;
  15774. /**
  15775. * The world direction of the particle in the scene.
  15776. */
  15777. direction: Vector3;
  15778. /**
  15779. * The color of the particle.
  15780. */
  15781. color: Color4;
  15782. /**
  15783. * The color change of the particle per step.
  15784. */
  15785. colorStep: Color4;
  15786. /**
  15787. * Defines how long will the life of the particle be.
  15788. */
  15789. lifeTime: number;
  15790. /**
  15791. * The current age of the particle.
  15792. */
  15793. age: number;
  15794. /**
  15795. * The current size of the particle.
  15796. */
  15797. size: number;
  15798. /**
  15799. * The current scale of the particle.
  15800. */
  15801. scale: Vector2;
  15802. /**
  15803. * The current angle of the particle.
  15804. */
  15805. angle: number;
  15806. /**
  15807. * Defines how fast is the angle changing.
  15808. */
  15809. angularSpeed: number;
  15810. /**
  15811. * Defines the cell index used by the particle to be rendered from a sprite.
  15812. */
  15813. cellIndex: number;
  15814. /**
  15815. * The information required to support color remapping
  15816. */
  15817. remapData: Vector4;
  15818. /** @hidden */
  15819. _randomCellOffset?: number;
  15820. /** @hidden */
  15821. _initialDirection: Nullable<Vector3>;
  15822. /** @hidden */
  15823. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15824. /** @hidden */
  15825. _initialStartSpriteCellID: number;
  15826. /** @hidden */
  15827. _initialEndSpriteCellID: number;
  15828. /** @hidden */
  15829. _currentColorGradient: Nullable<ColorGradient>;
  15830. /** @hidden */
  15831. _currentColor1: Color4;
  15832. /** @hidden */
  15833. _currentColor2: Color4;
  15834. /** @hidden */
  15835. _currentSizeGradient: Nullable<FactorGradient>;
  15836. /** @hidden */
  15837. _currentSize1: number;
  15838. /** @hidden */
  15839. _currentSize2: number;
  15840. /** @hidden */
  15841. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15842. /** @hidden */
  15843. _currentAngularSpeed1: number;
  15844. /** @hidden */
  15845. _currentAngularSpeed2: number;
  15846. /** @hidden */
  15847. _currentVelocityGradient: Nullable<FactorGradient>;
  15848. /** @hidden */
  15849. _currentVelocity1: number;
  15850. /** @hidden */
  15851. _currentVelocity2: number;
  15852. /** @hidden */
  15853. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15854. /** @hidden */
  15855. _currentLimitVelocity1: number;
  15856. /** @hidden */
  15857. _currentLimitVelocity2: number;
  15858. /** @hidden */
  15859. _currentDragGradient: Nullable<FactorGradient>;
  15860. /** @hidden */
  15861. _currentDrag1: number;
  15862. /** @hidden */
  15863. _currentDrag2: number;
  15864. /** @hidden */
  15865. _randomNoiseCoordinates1: Vector3;
  15866. /** @hidden */
  15867. _randomNoiseCoordinates2: Vector3;
  15868. /**
  15869. * Creates a new instance Particle
  15870. * @param particleSystem the particle system the particle belongs to
  15871. */
  15872. constructor(
  15873. /**
  15874. * The particle system the particle belongs to.
  15875. */
  15876. particleSystem: ParticleSystem);
  15877. private updateCellInfoFromSystem;
  15878. /**
  15879. * Defines how the sprite cell index is updated for the particle
  15880. */
  15881. updateCellIndex(): void;
  15882. /** @hidden */
  15883. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15884. /** @hidden */
  15885. _inheritParticleInfoToSubEmitters(): void;
  15886. /** @hidden */
  15887. _reset(): void;
  15888. /**
  15889. * Copy the properties of particle to another one.
  15890. * @param other the particle to copy the information to.
  15891. */
  15892. copyTo(other: Particle): void;
  15893. }
  15894. }
  15895. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15896. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15897. import { Effect } from "babylonjs/Materials/effect";
  15898. import { Particle } from "babylonjs/Particles/particle";
  15899. /**
  15900. * Particle emitter represents a volume emitting particles.
  15901. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15902. */
  15903. export interface IParticleEmitterType {
  15904. /**
  15905. * Called by the particle System when the direction is computed for the created particle.
  15906. * @param worldMatrix is the world matrix of the particle system
  15907. * @param directionToUpdate is the direction vector to update with the result
  15908. * @param particle is the particle we are computed the direction for
  15909. */
  15910. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15911. /**
  15912. * Called by the particle System when the position is computed for the created particle.
  15913. * @param worldMatrix is the world matrix of the particle system
  15914. * @param positionToUpdate is the position vector to update with the result
  15915. * @param particle is the particle we are computed the position for
  15916. */
  15917. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15918. /**
  15919. * Clones the current emitter and returns a copy of it
  15920. * @returns the new emitter
  15921. */
  15922. clone(): IParticleEmitterType;
  15923. /**
  15924. * Called by the GPUParticleSystem to setup the update shader
  15925. * @param effect defines the update shader
  15926. */
  15927. applyToShader(effect: Effect): void;
  15928. /**
  15929. * Returns a string to use to update the GPU particles update shader
  15930. * @returns the effect defines string
  15931. */
  15932. getEffectDefines(): string;
  15933. /**
  15934. * Returns a string representing the class name
  15935. * @returns a string containing the class name
  15936. */
  15937. getClassName(): string;
  15938. /**
  15939. * Serializes the particle system to a JSON object.
  15940. * @returns the JSON object
  15941. */
  15942. serialize(): any;
  15943. /**
  15944. * Parse properties from a JSON object
  15945. * @param serializationObject defines the JSON object
  15946. */
  15947. parse(serializationObject: any): void;
  15948. }
  15949. }
  15950. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15951. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15952. import { Effect } from "babylonjs/Materials/effect";
  15953. import { Particle } from "babylonjs/Particles/particle";
  15954. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15955. /**
  15956. * Particle emitter emitting particles from the inside of a box.
  15957. * It emits the particles randomly between 2 given directions.
  15958. */
  15959. export class BoxParticleEmitter implements IParticleEmitterType {
  15960. /**
  15961. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15962. */
  15963. direction1: Vector3;
  15964. /**
  15965. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15966. */
  15967. direction2: Vector3;
  15968. /**
  15969. * 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.
  15970. */
  15971. minEmitBox: Vector3;
  15972. /**
  15973. * 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.
  15974. */
  15975. maxEmitBox: Vector3;
  15976. /**
  15977. * Creates a new instance BoxParticleEmitter
  15978. */
  15979. constructor();
  15980. /**
  15981. * Called by the particle System when the direction is computed for the created particle.
  15982. * @param worldMatrix is the world matrix of the particle system
  15983. * @param directionToUpdate is the direction vector to update with the result
  15984. * @param particle is the particle we are computed the direction for
  15985. */
  15986. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15987. /**
  15988. * Called by the particle System when the position is computed for the created particle.
  15989. * @param worldMatrix is the world matrix of the particle system
  15990. * @param positionToUpdate is the position vector to update with the result
  15991. * @param particle is the particle we are computed the position for
  15992. */
  15993. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15994. /**
  15995. * Clones the current emitter and returns a copy of it
  15996. * @returns the new emitter
  15997. */
  15998. clone(): BoxParticleEmitter;
  15999. /**
  16000. * Called by the GPUParticleSystem to setup the update shader
  16001. * @param effect defines the update shader
  16002. */
  16003. applyToShader(effect: Effect): void;
  16004. /**
  16005. * Returns a string to use to update the GPU particles update shader
  16006. * @returns a string containng the defines string
  16007. */
  16008. getEffectDefines(): string;
  16009. /**
  16010. * Returns the string "BoxParticleEmitter"
  16011. * @returns a string containing the class name
  16012. */
  16013. getClassName(): string;
  16014. /**
  16015. * Serializes the particle system to a JSON object.
  16016. * @returns the JSON object
  16017. */
  16018. serialize(): any;
  16019. /**
  16020. * Parse properties from a JSON object
  16021. * @param serializationObject defines the JSON object
  16022. */
  16023. parse(serializationObject: any): void;
  16024. }
  16025. }
  16026. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  16027. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16028. import { Effect } from "babylonjs/Materials/effect";
  16029. import { Particle } from "babylonjs/Particles/particle";
  16030. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16031. /**
  16032. * Particle emitter emitting particles from the inside of a cone.
  16033. * It emits the particles alongside the cone volume from the base to the particle.
  16034. * The emission direction might be randomized.
  16035. */
  16036. export class ConeParticleEmitter implements IParticleEmitterType {
  16037. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16038. directionRandomizer: number;
  16039. private _radius;
  16040. private _angle;
  16041. private _height;
  16042. /**
  16043. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  16044. */
  16045. radiusRange: number;
  16046. /**
  16047. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  16048. */
  16049. heightRange: number;
  16050. /**
  16051. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  16052. */
  16053. emitFromSpawnPointOnly: boolean;
  16054. /**
  16055. * Gets or sets the radius of the emission cone
  16056. */
  16057. radius: number;
  16058. /**
  16059. * Gets or sets the angle of the emission cone
  16060. */
  16061. angle: number;
  16062. private _buildHeight;
  16063. /**
  16064. * Creates a new instance ConeParticleEmitter
  16065. * @param radius the radius of the emission cone (1 by default)
  16066. * @param angle the cone base angle (PI by default)
  16067. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  16068. */
  16069. constructor(radius?: number, angle?: number,
  16070. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16071. directionRandomizer?: number);
  16072. /**
  16073. * Called by the particle System when the direction is computed for the created particle.
  16074. * @param worldMatrix is the world matrix of the particle system
  16075. * @param directionToUpdate is the direction vector to update with the result
  16076. * @param particle is the particle we are computed the direction for
  16077. */
  16078. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16079. /**
  16080. * Called by the particle System when the position is computed for the created particle.
  16081. * @param worldMatrix is the world matrix of the particle system
  16082. * @param positionToUpdate is the position vector to update with the result
  16083. * @param particle is the particle we are computed the position for
  16084. */
  16085. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16086. /**
  16087. * Clones the current emitter and returns a copy of it
  16088. * @returns the new emitter
  16089. */
  16090. clone(): ConeParticleEmitter;
  16091. /**
  16092. * Called by the GPUParticleSystem to setup the update shader
  16093. * @param effect defines the update shader
  16094. */
  16095. applyToShader(effect: Effect): void;
  16096. /**
  16097. * Returns a string to use to update the GPU particles update shader
  16098. * @returns a string containng the defines string
  16099. */
  16100. getEffectDefines(): string;
  16101. /**
  16102. * Returns the string "ConeParticleEmitter"
  16103. * @returns a string containing the class name
  16104. */
  16105. getClassName(): string;
  16106. /**
  16107. * Serializes the particle system to a JSON object.
  16108. * @returns the JSON object
  16109. */
  16110. serialize(): any;
  16111. /**
  16112. * Parse properties from a JSON object
  16113. * @param serializationObject defines the JSON object
  16114. */
  16115. parse(serializationObject: any): void;
  16116. }
  16117. }
  16118. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  16119. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16120. import { Effect } from "babylonjs/Materials/effect";
  16121. import { Particle } from "babylonjs/Particles/particle";
  16122. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16123. /**
  16124. * Particle emitter emitting particles from the inside of a cylinder.
  16125. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  16126. */
  16127. export class CylinderParticleEmitter implements IParticleEmitterType {
  16128. /**
  16129. * The radius of the emission cylinder.
  16130. */
  16131. radius: number;
  16132. /**
  16133. * The height of the emission cylinder.
  16134. */
  16135. height: number;
  16136. /**
  16137. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16138. */
  16139. radiusRange: number;
  16140. /**
  16141. * How much to randomize the particle direction [0-1].
  16142. */
  16143. directionRandomizer: number;
  16144. /**
  16145. * Creates a new instance CylinderParticleEmitter
  16146. * @param radius the radius of the emission cylinder (1 by default)
  16147. * @param height the height of the emission cylinder (1 by default)
  16148. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16149. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16150. */
  16151. constructor(
  16152. /**
  16153. * The radius of the emission cylinder.
  16154. */
  16155. radius?: number,
  16156. /**
  16157. * The height of the emission cylinder.
  16158. */
  16159. height?: number,
  16160. /**
  16161. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16162. */
  16163. radiusRange?: number,
  16164. /**
  16165. * How much to randomize the particle direction [0-1].
  16166. */
  16167. directionRandomizer?: number);
  16168. /**
  16169. * Called by the particle System when the direction is computed for the created particle.
  16170. * @param worldMatrix is the world matrix of the particle system
  16171. * @param directionToUpdate is the direction vector to update with the result
  16172. * @param particle is the particle we are computed the direction for
  16173. */
  16174. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16175. /**
  16176. * Called by the particle System when the position is computed for the created particle.
  16177. * @param worldMatrix is the world matrix of the particle system
  16178. * @param positionToUpdate is the position vector to update with the result
  16179. * @param particle is the particle we are computed the position for
  16180. */
  16181. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16182. /**
  16183. * Clones the current emitter and returns a copy of it
  16184. * @returns the new emitter
  16185. */
  16186. clone(): CylinderParticleEmitter;
  16187. /**
  16188. * Called by the GPUParticleSystem to setup the update shader
  16189. * @param effect defines the update shader
  16190. */
  16191. applyToShader(effect: Effect): void;
  16192. /**
  16193. * Returns a string to use to update the GPU particles update shader
  16194. * @returns a string containng the defines string
  16195. */
  16196. getEffectDefines(): string;
  16197. /**
  16198. * Returns the string "CylinderParticleEmitter"
  16199. * @returns a string containing the class name
  16200. */
  16201. getClassName(): string;
  16202. /**
  16203. * Serializes the particle system to a JSON object.
  16204. * @returns the JSON object
  16205. */
  16206. serialize(): any;
  16207. /**
  16208. * Parse properties from a JSON object
  16209. * @param serializationObject defines the JSON object
  16210. */
  16211. parse(serializationObject: any): void;
  16212. }
  16213. /**
  16214. * Particle emitter emitting particles from the inside of a cylinder.
  16215. * It emits the particles randomly between two vectors.
  16216. */
  16217. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16218. /**
  16219. * The min limit of the emission direction.
  16220. */
  16221. direction1: Vector3;
  16222. /**
  16223. * The max limit of the emission direction.
  16224. */
  16225. direction2: Vector3;
  16226. /**
  16227. * Creates a new instance CylinderDirectedParticleEmitter
  16228. * @param radius the radius of the emission cylinder (1 by default)
  16229. * @param height the height of the emission cylinder (1 by default)
  16230. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16231. * @param direction1 the min limit of the emission direction (up vector by default)
  16232. * @param direction2 the max limit of the emission direction (up vector by default)
  16233. */
  16234. constructor(radius?: number, height?: number, radiusRange?: number,
  16235. /**
  16236. * The min limit of the emission direction.
  16237. */
  16238. direction1?: Vector3,
  16239. /**
  16240. * The max limit of the emission direction.
  16241. */
  16242. direction2?: Vector3);
  16243. /**
  16244. * Called by the particle System when the direction is computed for the created particle.
  16245. * @param worldMatrix is the world matrix of the particle system
  16246. * @param directionToUpdate is the direction vector to update with the result
  16247. * @param particle is the particle we are computed the direction for
  16248. */
  16249. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16250. /**
  16251. * Clones the current emitter and returns a copy of it
  16252. * @returns the new emitter
  16253. */
  16254. clone(): CylinderDirectedParticleEmitter;
  16255. /**
  16256. * Called by the GPUParticleSystem to setup the update shader
  16257. * @param effect defines the update shader
  16258. */
  16259. applyToShader(effect: Effect): void;
  16260. /**
  16261. * Returns a string to use to update the GPU particles update shader
  16262. * @returns a string containng the defines string
  16263. */
  16264. getEffectDefines(): string;
  16265. /**
  16266. * Returns the string "CylinderDirectedParticleEmitter"
  16267. * @returns a string containing the class name
  16268. */
  16269. getClassName(): string;
  16270. /**
  16271. * Serializes the particle system to a JSON object.
  16272. * @returns the JSON object
  16273. */
  16274. serialize(): any;
  16275. /**
  16276. * Parse properties from a JSON object
  16277. * @param serializationObject defines the JSON object
  16278. */
  16279. parse(serializationObject: any): void;
  16280. }
  16281. }
  16282. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  16283. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16284. import { Effect } from "babylonjs/Materials/effect";
  16285. import { Particle } from "babylonjs/Particles/particle";
  16286. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16287. /**
  16288. * Particle emitter emitting particles from the inside of a hemisphere.
  16289. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16290. */
  16291. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16292. /**
  16293. * The radius of the emission hemisphere.
  16294. */
  16295. radius: number;
  16296. /**
  16297. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16298. */
  16299. radiusRange: number;
  16300. /**
  16301. * How much to randomize the particle direction [0-1].
  16302. */
  16303. directionRandomizer: number;
  16304. /**
  16305. * Creates a new instance HemisphericParticleEmitter
  16306. * @param radius the radius of the emission hemisphere (1 by default)
  16307. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16308. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16309. */
  16310. constructor(
  16311. /**
  16312. * The radius of the emission hemisphere.
  16313. */
  16314. radius?: number,
  16315. /**
  16316. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16317. */
  16318. radiusRange?: number,
  16319. /**
  16320. * How much to randomize the particle direction [0-1].
  16321. */
  16322. directionRandomizer?: number);
  16323. /**
  16324. * Called by the particle System when the direction is computed for the created particle.
  16325. * @param worldMatrix is the world matrix of the particle system
  16326. * @param directionToUpdate is the direction vector to update with the result
  16327. * @param particle is the particle we are computed the direction for
  16328. */
  16329. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16330. /**
  16331. * Called by the particle System when the position is computed for the created particle.
  16332. * @param worldMatrix is the world matrix of the particle system
  16333. * @param positionToUpdate is the position vector to update with the result
  16334. * @param particle is the particle we are computed the position for
  16335. */
  16336. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16337. /**
  16338. * Clones the current emitter and returns a copy of it
  16339. * @returns the new emitter
  16340. */
  16341. clone(): HemisphericParticleEmitter;
  16342. /**
  16343. * Called by the GPUParticleSystem to setup the update shader
  16344. * @param effect defines the update shader
  16345. */
  16346. applyToShader(effect: Effect): void;
  16347. /**
  16348. * Returns a string to use to update the GPU particles update shader
  16349. * @returns a string containng the defines string
  16350. */
  16351. getEffectDefines(): string;
  16352. /**
  16353. * Returns the string "HemisphericParticleEmitter"
  16354. * @returns a string containing the class name
  16355. */
  16356. getClassName(): string;
  16357. /**
  16358. * Serializes the particle system to a JSON object.
  16359. * @returns the JSON object
  16360. */
  16361. serialize(): any;
  16362. /**
  16363. * Parse properties from a JSON object
  16364. * @param serializationObject defines the JSON object
  16365. */
  16366. parse(serializationObject: any): void;
  16367. }
  16368. }
  16369. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  16370. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16371. import { Effect } from "babylonjs/Materials/effect";
  16372. import { Particle } from "babylonjs/Particles/particle";
  16373. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16374. /**
  16375. * Particle emitter emitting particles from a point.
  16376. * It emits the particles randomly between 2 given directions.
  16377. */
  16378. export class PointParticleEmitter implements IParticleEmitterType {
  16379. /**
  16380. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16381. */
  16382. direction1: Vector3;
  16383. /**
  16384. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16385. */
  16386. direction2: Vector3;
  16387. /**
  16388. * Creates a new instance PointParticleEmitter
  16389. */
  16390. constructor();
  16391. /**
  16392. * Called by the particle System when the direction is computed for the created particle.
  16393. * @param worldMatrix is the world matrix of the particle system
  16394. * @param directionToUpdate is the direction vector to update with the result
  16395. * @param particle is the particle we are computed the direction for
  16396. */
  16397. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16398. /**
  16399. * Called by the particle System when the position is computed for the created particle.
  16400. * @param worldMatrix is the world matrix of the particle system
  16401. * @param positionToUpdate is the position vector to update with the result
  16402. * @param particle is the particle we are computed the position for
  16403. */
  16404. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16405. /**
  16406. * Clones the current emitter and returns a copy of it
  16407. * @returns the new emitter
  16408. */
  16409. clone(): PointParticleEmitter;
  16410. /**
  16411. * Called by the GPUParticleSystem to setup the update shader
  16412. * @param effect defines the update shader
  16413. */
  16414. applyToShader(effect: Effect): void;
  16415. /**
  16416. * Returns a string to use to update the GPU particles update shader
  16417. * @returns a string containng the defines string
  16418. */
  16419. getEffectDefines(): string;
  16420. /**
  16421. * Returns the string "PointParticleEmitter"
  16422. * @returns a string containing the class name
  16423. */
  16424. getClassName(): string;
  16425. /**
  16426. * Serializes the particle system to a JSON object.
  16427. * @returns the JSON object
  16428. */
  16429. serialize(): any;
  16430. /**
  16431. * Parse properties from a JSON object
  16432. * @param serializationObject defines the JSON object
  16433. */
  16434. parse(serializationObject: any): void;
  16435. }
  16436. }
  16437. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  16438. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16439. import { Effect } from "babylonjs/Materials/effect";
  16440. import { Particle } from "babylonjs/Particles/particle";
  16441. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16442. /**
  16443. * Particle emitter emitting particles from the inside of a sphere.
  16444. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16445. */
  16446. export class SphereParticleEmitter implements IParticleEmitterType {
  16447. /**
  16448. * The radius of the emission sphere.
  16449. */
  16450. radius: number;
  16451. /**
  16452. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16453. */
  16454. radiusRange: number;
  16455. /**
  16456. * How much to randomize the particle direction [0-1].
  16457. */
  16458. directionRandomizer: number;
  16459. /**
  16460. * Creates a new instance SphereParticleEmitter
  16461. * @param radius the radius of the emission sphere (1 by default)
  16462. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16463. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16464. */
  16465. constructor(
  16466. /**
  16467. * The radius of the emission sphere.
  16468. */
  16469. radius?: number,
  16470. /**
  16471. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16472. */
  16473. radiusRange?: number,
  16474. /**
  16475. * How much to randomize the particle direction [0-1].
  16476. */
  16477. directionRandomizer?: number);
  16478. /**
  16479. * Called by the particle System when the direction is computed for the created particle.
  16480. * @param worldMatrix is the world matrix of the particle system
  16481. * @param directionToUpdate is the direction vector to update with the result
  16482. * @param particle is the particle we are computed the direction for
  16483. */
  16484. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16485. /**
  16486. * Called by the particle System when the position is computed for the created particle.
  16487. * @param worldMatrix is the world matrix of the particle system
  16488. * @param positionToUpdate is the position vector to update with the result
  16489. * @param particle is the particle we are computed the position for
  16490. */
  16491. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16492. /**
  16493. * Clones the current emitter and returns a copy of it
  16494. * @returns the new emitter
  16495. */
  16496. clone(): SphereParticleEmitter;
  16497. /**
  16498. * Called by the GPUParticleSystem to setup the update shader
  16499. * @param effect defines the update shader
  16500. */
  16501. applyToShader(effect: Effect): void;
  16502. /**
  16503. * Returns a string to use to update the GPU particles update shader
  16504. * @returns a string containng the defines string
  16505. */
  16506. getEffectDefines(): string;
  16507. /**
  16508. * Returns the string "SphereParticleEmitter"
  16509. * @returns a string containing the class name
  16510. */
  16511. getClassName(): string;
  16512. /**
  16513. * Serializes the particle system to a JSON object.
  16514. * @returns the JSON object
  16515. */
  16516. serialize(): any;
  16517. /**
  16518. * Parse properties from a JSON object
  16519. * @param serializationObject defines the JSON object
  16520. */
  16521. parse(serializationObject: any): void;
  16522. }
  16523. /**
  16524. * Particle emitter emitting particles from the inside of a sphere.
  16525. * It emits the particles randomly between two vectors.
  16526. */
  16527. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16528. /**
  16529. * The min limit of the emission direction.
  16530. */
  16531. direction1: Vector3;
  16532. /**
  16533. * The max limit of the emission direction.
  16534. */
  16535. direction2: Vector3;
  16536. /**
  16537. * Creates a new instance SphereDirectedParticleEmitter
  16538. * @param radius the radius of the emission sphere (1 by default)
  16539. * @param direction1 the min limit of the emission direction (up vector by default)
  16540. * @param direction2 the max limit of the emission direction (up vector by default)
  16541. */
  16542. constructor(radius?: number,
  16543. /**
  16544. * The min limit of the emission direction.
  16545. */
  16546. direction1?: Vector3,
  16547. /**
  16548. * The max limit of the emission direction.
  16549. */
  16550. direction2?: Vector3);
  16551. /**
  16552. * Called by the particle System when the direction is computed for the created particle.
  16553. * @param worldMatrix is the world matrix of the particle system
  16554. * @param directionToUpdate is the direction vector to update with the result
  16555. * @param particle is the particle we are computed the direction for
  16556. */
  16557. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16558. /**
  16559. * Clones the current emitter and returns a copy of it
  16560. * @returns the new emitter
  16561. */
  16562. clone(): SphereDirectedParticleEmitter;
  16563. /**
  16564. * Called by the GPUParticleSystem to setup the update shader
  16565. * @param effect defines the update shader
  16566. */
  16567. applyToShader(effect: Effect): void;
  16568. /**
  16569. * Returns a string to use to update the GPU particles update shader
  16570. * @returns a string containng the defines string
  16571. */
  16572. getEffectDefines(): string;
  16573. /**
  16574. * Returns the string "SphereDirectedParticleEmitter"
  16575. * @returns a string containing the class name
  16576. */
  16577. getClassName(): string;
  16578. /**
  16579. * Serializes the particle system to a JSON object.
  16580. * @returns the JSON object
  16581. */
  16582. serialize(): any;
  16583. /**
  16584. * Parse properties from a JSON object
  16585. * @param serializationObject defines the JSON object
  16586. */
  16587. parse(serializationObject: any): void;
  16588. }
  16589. }
  16590. declare module "babylonjs/Particles/EmitterTypes/index" {
  16591. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16592. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16593. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16594. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16595. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16596. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16597. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16598. }
  16599. declare module "babylonjs/Particles/IParticleSystem" {
  16600. import { Nullable } from "babylonjs/types";
  16601. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16603. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16604. import { Texture } from "babylonjs/Materials/Textures/texture";
  16605. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16606. import { Scene } from "babylonjs/scene";
  16607. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16608. import { Animation } from "babylonjs/Animations/animation";
  16609. /**
  16610. * Interface representing a particle system in Babylon.js.
  16611. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16612. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16613. */
  16614. export interface IParticleSystem {
  16615. /**
  16616. * List of animations used by the particle system.
  16617. */
  16618. animations: Animation[];
  16619. /**
  16620. * The id of the Particle system.
  16621. */
  16622. id: string;
  16623. /**
  16624. * The name of the Particle system.
  16625. */
  16626. name: string;
  16627. /**
  16628. * The emitter represents the Mesh or position we are attaching the particle system to.
  16629. */
  16630. emitter: Nullable<AbstractMesh | Vector3>;
  16631. /**
  16632. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16633. */
  16634. isBillboardBased: boolean;
  16635. /**
  16636. * The rendering group used by the Particle system to chose when to render.
  16637. */
  16638. renderingGroupId: number;
  16639. /**
  16640. * The layer mask we are rendering the particles through.
  16641. */
  16642. layerMask: number;
  16643. /**
  16644. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16645. */
  16646. updateSpeed: number;
  16647. /**
  16648. * The amount of time the particle system is running (depends of the overall update speed).
  16649. */
  16650. targetStopDuration: number;
  16651. /**
  16652. * The texture used to render each particle. (this can be a spritesheet)
  16653. */
  16654. particleTexture: Nullable<Texture>;
  16655. /**
  16656. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16657. */
  16658. blendMode: number;
  16659. /**
  16660. * Minimum life time of emitting particles.
  16661. */
  16662. minLifeTime: number;
  16663. /**
  16664. * Maximum life time of emitting particles.
  16665. */
  16666. maxLifeTime: number;
  16667. /**
  16668. * Minimum Size of emitting particles.
  16669. */
  16670. minSize: number;
  16671. /**
  16672. * Maximum Size of emitting particles.
  16673. */
  16674. maxSize: number;
  16675. /**
  16676. * Minimum scale of emitting particles on X axis.
  16677. */
  16678. minScaleX: number;
  16679. /**
  16680. * Maximum scale of emitting particles on X axis.
  16681. */
  16682. maxScaleX: number;
  16683. /**
  16684. * Minimum scale of emitting particles on Y axis.
  16685. */
  16686. minScaleY: number;
  16687. /**
  16688. * Maximum scale of emitting particles on Y axis.
  16689. */
  16690. maxScaleY: number;
  16691. /**
  16692. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16693. */
  16694. color1: Color4;
  16695. /**
  16696. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16697. */
  16698. color2: Color4;
  16699. /**
  16700. * Color the particle will have at the end of its lifetime.
  16701. */
  16702. colorDead: Color4;
  16703. /**
  16704. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16705. */
  16706. emitRate: number;
  16707. /**
  16708. * You can use gravity if you want to give an orientation to your particles.
  16709. */
  16710. gravity: Vector3;
  16711. /**
  16712. * Minimum power of emitting particles.
  16713. */
  16714. minEmitPower: number;
  16715. /**
  16716. * Maximum power of emitting particles.
  16717. */
  16718. maxEmitPower: number;
  16719. /**
  16720. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16721. */
  16722. minAngularSpeed: number;
  16723. /**
  16724. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16725. */
  16726. maxAngularSpeed: number;
  16727. /**
  16728. * Gets or sets the minimal initial rotation in radians.
  16729. */
  16730. minInitialRotation: number;
  16731. /**
  16732. * Gets or sets the maximal initial rotation in radians.
  16733. */
  16734. maxInitialRotation: number;
  16735. /**
  16736. * The particle emitter type defines the emitter used by the particle system.
  16737. * It can be for example box, sphere, or cone...
  16738. */
  16739. particleEmitterType: Nullable<IParticleEmitterType>;
  16740. /**
  16741. * Defines the delay in milliseconds before starting the system (0 by default)
  16742. */
  16743. startDelay: number;
  16744. /**
  16745. * 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
  16746. */
  16747. preWarmCycles: number;
  16748. /**
  16749. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16750. */
  16751. preWarmStepOffset: number;
  16752. /**
  16753. * 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)
  16754. */
  16755. spriteCellChangeSpeed: number;
  16756. /**
  16757. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16758. */
  16759. startSpriteCellID: number;
  16760. /**
  16761. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16762. */
  16763. endSpriteCellID: number;
  16764. /**
  16765. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16766. */
  16767. spriteCellWidth: number;
  16768. /**
  16769. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16770. */
  16771. spriteCellHeight: number;
  16772. /**
  16773. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16774. */
  16775. spriteRandomStartCell: boolean;
  16776. /**
  16777. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16778. */
  16779. isAnimationSheetEnabled: boolean;
  16780. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16781. translationPivot: Vector2;
  16782. /**
  16783. * Gets or sets a texture used to add random noise to particle positions
  16784. */
  16785. noiseTexture: Nullable<BaseTexture>;
  16786. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16787. noiseStrength: Vector3;
  16788. /**
  16789. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16790. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16791. */
  16792. billboardMode: number;
  16793. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16794. limitVelocityDamping: number;
  16795. /**
  16796. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16797. */
  16798. beginAnimationOnStart: boolean;
  16799. /**
  16800. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16801. */
  16802. beginAnimationFrom: number;
  16803. /**
  16804. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16805. */
  16806. beginAnimationTo: number;
  16807. /**
  16808. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16809. */
  16810. beginAnimationLoop: boolean;
  16811. /**
  16812. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16813. */
  16814. disposeOnStop: boolean;
  16815. /**
  16816. * Gets the maximum number of particles active at the same time.
  16817. * @returns The max number of active particles.
  16818. */
  16819. getCapacity(): number;
  16820. /**
  16821. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16822. * @returns True if it has been started, otherwise false.
  16823. */
  16824. isStarted(): boolean;
  16825. /**
  16826. * Animates the particle system for this frame.
  16827. */
  16828. animate(): void;
  16829. /**
  16830. * Renders the particle system in its current state.
  16831. * @returns the current number of particles
  16832. */
  16833. render(): number;
  16834. /**
  16835. * Dispose the particle system and frees its associated resources.
  16836. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16837. */
  16838. dispose(disposeTexture?: boolean): void;
  16839. /**
  16840. * Clones the particle system.
  16841. * @param name The name of the cloned object
  16842. * @param newEmitter The new emitter to use
  16843. * @returns the cloned particle system
  16844. */
  16845. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16846. /**
  16847. * Serializes the particle system to a JSON object.
  16848. * @returns the JSON object
  16849. */
  16850. serialize(): any;
  16851. /**
  16852. * Rebuild the particle system
  16853. */
  16854. rebuild(): void;
  16855. /**
  16856. * Starts the particle system and begins to emit
  16857. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16858. */
  16859. start(delay?: number): void;
  16860. /**
  16861. * Stops the particle system.
  16862. */
  16863. stop(): void;
  16864. /**
  16865. * Remove all active particles
  16866. */
  16867. reset(): void;
  16868. /**
  16869. * Is this system ready to be used/rendered
  16870. * @return true if the system is ready
  16871. */
  16872. isReady(): boolean;
  16873. /**
  16874. * Adds a new color gradient
  16875. * @param gradient defines the gradient to use (between 0 and 1)
  16876. * @param color1 defines the color to affect to the specified gradient
  16877. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16878. * @returns the current particle system
  16879. */
  16880. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16881. /**
  16882. * Remove a specific color gradient
  16883. * @param gradient defines the gradient to remove
  16884. * @returns the current particle system
  16885. */
  16886. removeColorGradient(gradient: number): IParticleSystem;
  16887. /**
  16888. * Adds a new size gradient
  16889. * @param gradient defines the gradient to use (between 0 and 1)
  16890. * @param factor defines the size factor to affect to the specified gradient
  16891. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16892. * @returns the current particle system
  16893. */
  16894. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16895. /**
  16896. * Remove a specific size gradient
  16897. * @param gradient defines the gradient to remove
  16898. * @returns the current particle system
  16899. */
  16900. removeSizeGradient(gradient: number): IParticleSystem;
  16901. /**
  16902. * Gets the current list of color gradients.
  16903. * You must use addColorGradient and removeColorGradient to udpate this list
  16904. * @returns the list of color gradients
  16905. */
  16906. getColorGradients(): Nullable<Array<ColorGradient>>;
  16907. /**
  16908. * Gets the current list of size gradients.
  16909. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16910. * @returns the list of size gradients
  16911. */
  16912. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16913. /**
  16914. * Gets the current list of angular speed gradients.
  16915. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16916. * @returns the list of angular speed gradients
  16917. */
  16918. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16919. /**
  16920. * Adds a new angular speed gradient
  16921. * @param gradient defines the gradient to use (between 0 and 1)
  16922. * @param factor defines the angular speed to affect to the specified gradient
  16923. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16924. * @returns the current particle system
  16925. */
  16926. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16927. /**
  16928. * Remove a specific angular speed gradient
  16929. * @param gradient defines the gradient to remove
  16930. * @returns the current particle system
  16931. */
  16932. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16933. /**
  16934. * Gets the current list of velocity gradients.
  16935. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16936. * @returns the list of velocity gradients
  16937. */
  16938. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16939. /**
  16940. * Adds a new velocity gradient
  16941. * @param gradient defines the gradient to use (between 0 and 1)
  16942. * @param factor defines the velocity to affect to the specified gradient
  16943. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16944. * @returns the current particle system
  16945. */
  16946. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16947. /**
  16948. * Remove a specific velocity gradient
  16949. * @param gradient defines the gradient to remove
  16950. * @returns the current particle system
  16951. */
  16952. removeVelocityGradient(gradient: number): IParticleSystem;
  16953. /**
  16954. * Gets the current list of limit velocity gradients.
  16955. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16956. * @returns the list of limit velocity gradients
  16957. */
  16958. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16959. /**
  16960. * Adds a new limit velocity gradient
  16961. * @param gradient defines the gradient to use (between 0 and 1)
  16962. * @param factor defines the limit velocity to affect to the specified gradient
  16963. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16964. * @returns the current particle system
  16965. */
  16966. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16967. /**
  16968. * Remove a specific limit velocity gradient
  16969. * @param gradient defines the gradient to remove
  16970. * @returns the current particle system
  16971. */
  16972. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16973. /**
  16974. * Adds a new drag gradient
  16975. * @param gradient defines the gradient to use (between 0 and 1)
  16976. * @param factor defines the drag to affect to the specified gradient
  16977. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16978. * @returns the current particle system
  16979. */
  16980. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16981. /**
  16982. * Remove a specific drag gradient
  16983. * @param gradient defines the gradient to remove
  16984. * @returns the current particle system
  16985. */
  16986. removeDragGradient(gradient: number): IParticleSystem;
  16987. /**
  16988. * Gets the current list of drag gradients.
  16989. * You must use addDragGradient and removeDragGradient to udpate this list
  16990. * @returns the list of drag gradients
  16991. */
  16992. getDragGradients(): Nullable<Array<FactorGradient>>;
  16993. /**
  16994. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16995. * @param gradient defines the gradient to use (between 0 and 1)
  16996. * @param factor defines the emit rate to affect to the specified gradient
  16997. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16998. * @returns the current particle system
  16999. */
  17000. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17001. /**
  17002. * Remove a specific emit rate gradient
  17003. * @param gradient defines the gradient to remove
  17004. * @returns the current particle system
  17005. */
  17006. removeEmitRateGradient(gradient: number): IParticleSystem;
  17007. /**
  17008. * Gets the current list of emit rate gradients.
  17009. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17010. * @returns the list of emit rate gradients
  17011. */
  17012. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17013. /**
  17014. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17015. * @param gradient defines the gradient to use (between 0 and 1)
  17016. * @param factor defines the start size to affect to the specified gradient
  17017. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17018. * @returns the current particle system
  17019. */
  17020. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17021. /**
  17022. * Remove a specific start size gradient
  17023. * @param gradient defines the gradient to remove
  17024. * @returns the current particle system
  17025. */
  17026. removeStartSizeGradient(gradient: number): IParticleSystem;
  17027. /**
  17028. * Gets the current list of start size gradients.
  17029. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17030. * @returns the list of start size gradients
  17031. */
  17032. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17033. /**
  17034. * Adds a new life time gradient
  17035. * @param gradient defines the gradient to use (between 0 and 1)
  17036. * @param factor defines the life time factor to affect to the specified gradient
  17037. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17038. * @returns the current particle system
  17039. */
  17040. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17041. /**
  17042. * Remove a specific life time gradient
  17043. * @param gradient defines the gradient to remove
  17044. * @returns the current particle system
  17045. */
  17046. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17047. /**
  17048. * Gets the current list of life time gradients.
  17049. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17050. * @returns the list of life time gradients
  17051. */
  17052. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17053. /**
  17054. * Gets the current list of color gradients.
  17055. * You must use addColorGradient and removeColorGradient to udpate this list
  17056. * @returns the list of color gradients
  17057. */
  17058. getColorGradients(): Nullable<Array<ColorGradient>>;
  17059. /**
  17060. * Adds a new ramp gradient used to remap particle colors
  17061. * @param gradient defines the gradient to use (between 0 and 1)
  17062. * @param color defines the color to affect to the specified gradient
  17063. * @returns the current particle system
  17064. */
  17065. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  17066. /**
  17067. * Gets the current list of ramp gradients.
  17068. * You must use addRampGradient and removeRampGradient to udpate this list
  17069. * @returns the list of ramp gradients
  17070. */
  17071. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17072. /** Gets or sets a boolean indicating that ramp gradients must be used
  17073. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17074. */
  17075. useRampGradients: boolean;
  17076. /**
  17077. * Adds a new color remap gradient
  17078. * @param gradient defines the gradient to use (between 0 and 1)
  17079. * @param min defines the color remap minimal range
  17080. * @param max defines the color remap maximal range
  17081. * @returns the current particle system
  17082. */
  17083. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17084. /**
  17085. * Gets the current list of color remap gradients.
  17086. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17087. * @returns the list of color remap gradients
  17088. */
  17089. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17090. /**
  17091. * Adds a new alpha remap gradient
  17092. * @param gradient defines the gradient to use (between 0 and 1)
  17093. * @param min defines the alpha remap minimal range
  17094. * @param max defines the alpha remap maximal range
  17095. * @returns the current particle system
  17096. */
  17097. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17098. /**
  17099. * Gets the current list of alpha remap gradients.
  17100. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17101. * @returns the list of alpha remap gradients
  17102. */
  17103. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17104. /**
  17105. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17106. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17107. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17108. * @returns the emitter
  17109. */
  17110. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17111. /**
  17112. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17113. * @param radius The radius of the hemisphere to emit from
  17114. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17115. * @returns the emitter
  17116. */
  17117. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17118. /**
  17119. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17120. * @param radius The radius of the sphere to emit from
  17121. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17122. * @returns the emitter
  17123. */
  17124. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17125. /**
  17126. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17127. * @param radius The radius of the sphere to emit from
  17128. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17129. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17130. * @returns the emitter
  17131. */
  17132. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17133. /**
  17134. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17135. * @param radius The radius of the emission cylinder
  17136. * @param height The height of the emission cylinder
  17137. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17138. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17139. * @returns the emitter
  17140. */
  17141. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17142. /**
  17143. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17144. * @param radius The radius of the cylinder to emit from
  17145. * @param height The height of the emission cylinder
  17146. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17147. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17148. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17149. * @returns the emitter
  17150. */
  17151. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17152. /**
  17153. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17154. * @param radius The radius of the cone to emit from
  17155. * @param angle The base angle of the cone
  17156. * @returns the emitter
  17157. */
  17158. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17159. /**
  17160. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17161. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17162. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17163. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17164. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17165. * @returns the emitter
  17166. */
  17167. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17168. /**
  17169. * Get hosting scene
  17170. * @returns the scene
  17171. */
  17172. getScene(): Scene;
  17173. }
  17174. }
  17175. declare module "babylonjs/Meshes/instancedMesh" {
  17176. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  17177. import { Vector3, Matrix } from "babylonjs/Maths/math";
  17178. import { Camera } from "babylonjs/Cameras/camera";
  17179. import { Node } from "babylonjs/node";
  17180. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17181. import { Mesh } from "babylonjs/Meshes/mesh";
  17182. import { Material } from "babylonjs/Materials/material";
  17183. import { Skeleton } from "babylonjs/Bones/skeleton";
  17184. import { Light } from "babylonjs/Lights/light";
  17185. /**
  17186. * Creates an instance based on a source mesh.
  17187. */
  17188. export class InstancedMesh extends AbstractMesh {
  17189. private _sourceMesh;
  17190. private _currentLOD;
  17191. /** @hidden */
  17192. _indexInSourceMeshInstanceArray: number;
  17193. constructor(name: string, source: Mesh);
  17194. /**
  17195. * Returns the string "InstancedMesh".
  17196. */
  17197. getClassName(): string;
  17198. /** Gets the list of lights affecting that mesh */
  17199. readonly lightSources: Light[];
  17200. _resyncLightSources(): void;
  17201. _resyncLighSource(light: Light): void;
  17202. _removeLightSource(light: Light): void;
  17203. /**
  17204. * If the source mesh receives shadows
  17205. */
  17206. readonly receiveShadows: boolean;
  17207. /**
  17208. * The material of the source mesh
  17209. */
  17210. readonly material: Nullable<Material>;
  17211. /**
  17212. * Visibility of the source mesh
  17213. */
  17214. readonly visibility: number;
  17215. /**
  17216. * Skeleton of the source mesh
  17217. */
  17218. readonly skeleton: Nullable<Skeleton>;
  17219. /**
  17220. * Rendering ground id of the source mesh
  17221. */
  17222. renderingGroupId: number;
  17223. /**
  17224. * Returns the total number of vertices (integer).
  17225. */
  17226. getTotalVertices(): number;
  17227. /**
  17228. * Returns a positive integer : the total number of indices in this mesh geometry.
  17229. * @returns the numner of indices or zero if the mesh has no geometry.
  17230. */
  17231. getTotalIndices(): number;
  17232. /**
  17233. * The source mesh of the instance
  17234. */
  17235. readonly sourceMesh: Mesh;
  17236. /**
  17237. * Is this node ready to be used/rendered
  17238. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  17239. * @return {boolean} is it ready
  17240. */
  17241. isReady(completeCheck?: boolean): boolean;
  17242. /**
  17243. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  17244. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  17245. * @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.
  17246. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  17247. */
  17248. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  17249. /**
  17250. * Sets the vertex data of the mesh geometry for the requested `kind`.
  17251. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  17252. * The `data` are either a numeric array either a Float32Array.
  17253. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  17254. * 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).
  17255. * Note that a new underlying VertexBuffer object is created each call.
  17256. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  17257. *
  17258. * Possible `kind` values :
  17259. * - VertexBuffer.PositionKind
  17260. * - VertexBuffer.UVKind
  17261. * - VertexBuffer.UV2Kind
  17262. * - VertexBuffer.UV3Kind
  17263. * - VertexBuffer.UV4Kind
  17264. * - VertexBuffer.UV5Kind
  17265. * - VertexBuffer.UV6Kind
  17266. * - VertexBuffer.ColorKind
  17267. * - VertexBuffer.MatricesIndicesKind
  17268. * - VertexBuffer.MatricesIndicesExtraKind
  17269. * - VertexBuffer.MatricesWeightsKind
  17270. * - VertexBuffer.MatricesWeightsExtraKind
  17271. *
  17272. * Returns the Mesh.
  17273. */
  17274. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  17275. /**
  17276. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  17277. * If the mesh has no geometry, it is simply returned as it is.
  17278. * The `data` are either a numeric array either a Float32Array.
  17279. * No new underlying VertexBuffer object is created.
  17280. * 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.
  17281. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  17282. *
  17283. * Possible `kind` values :
  17284. * - VertexBuffer.PositionKind
  17285. * - VertexBuffer.UVKind
  17286. * - VertexBuffer.UV2Kind
  17287. * - VertexBuffer.UV3Kind
  17288. * - VertexBuffer.UV4Kind
  17289. * - VertexBuffer.UV5Kind
  17290. * - VertexBuffer.UV6Kind
  17291. * - VertexBuffer.ColorKind
  17292. * - VertexBuffer.MatricesIndicesKind
  17293. * - VertexBuffer.MatricesIndicesExtraKind
  17294. * - VertexBuffer.MatricesWeightsKind
  17295. * - VertexBuffer.MatricesWeightsExtraKind
  17296. *
  17297. * Returns the Mesh.
  17298. */
  17299. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  17300. /**
  17301. * Sets the mesh indices.
  17302. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  17303. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  17304. * This method creates a new index buffer each call.
  17305. * Returns the Mesh.
  17306. */
  17307. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  17308. /**
  17309. * Boolean : True if the mesh owns the requested kind of data.
  17310. */
  17311. isVerticesDataPresent(kind: string): boolean;
  17312. /**
  17313. * Returns an array of indices (IndicesArray).
  17314. */
  17315. getIndices(): Nullable<IndicesArray>;
  17316. readonly _positions: Nullable<Vector3[]>;
  17317. /**
  17318. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  17319. * This means the mesh underlying bounding box and sphere are recomputed.
  17320. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  17321. * @returns the current mesh
  17322. */
  17323. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  17324. /** @hidden */
  17325. _preActivate(): InstancedMesh;
  17326. /** @hidden */
  17327. _activate(renderId: number, intermediateRendering: boolean): boolean;
  17328. /** @hidden */
  17329. _postActivate(): void;
  17330. getWorldMatrix(): Matrix;
  17331. readonly isAnInstance: boolean;
  17332. /**
  17333. * Returns the current associated LOD AbstractMesh.
  17334. */
  17335. getLOD(camera: Camera): AbstractMesh;
  17336. /** @hidden */
  17337. _syncSubMeshes(): InstancedMesh;
  17338. /** @hidden */
  17339. _generatePointsArray(): boolean;
  17340. /**
  17341. * Creates a new InstancedMesh from the current mesh.
  17342. * - name (string) : the cloned mesh name
  17343. * - newParent (optional Node) : the optional Node to parent the clone to.
  17344. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  17345. *
  17346. * Returns the clone.
  17347. */
  17348. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  17349. /**
  17350. * Disposes the InstancedMesh.
  17351. * Returns nothing.
  17352. */
  17353. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17354. }
  17355. }
  17356. declare module "babylonjs/Materials/shaderMaterial" {
  17357. import { Scene } from "babylonjs/scene";
  17358. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  17359. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17360. import { Mesh } from "babylonjs/Meshes/mesh";
  17361. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  17362. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17363. import { Texture } from "babylonjs/Materials/Textures/texture";
  17364. import { Material } from "babylonjs/Materials/material";
  17365. /**
  17366. * Defines the options associated with the creation of a shader material.
  17367. */
  17368. export interface IShaderMaterialOptions {
  17369. /**
  17370. * Does the material work in alpha blend mode
  17371. */
  17372. needAlphaBlending: boolean;
  17373. /**
  17374. * Does the material work in alpha test mode
  17375. */
  17376. needAlphaTesting: boolean;
  17377. /**
  17378. * The list of attribute names used in the shader
  17379. */
  17380. attributes: string[];
  17381. /**
  17382. * The list of unifrom names used in the shader
  17383. */
  17384. uniforms: string[];
  17385. /**
  17386. * The list of UBO names used in the shader
  17387. */
  17388. uniformBuffers: string[];
  17389. /**
  17390. * The list of sampler names used in the shader
  17391. */
  17392. samplers: string[];
  17393. /**
  17394. * The list of defines used in the shader
  17395. */
  17396. defines: string[];
  17397. }
  17398. /**
  17399. * 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.
  17400. *
  17401. * This returned material effects how the mesh will look based on the code in the shaders.
  17402. *
  17403. * @see http://doc.babylonjs.com/how_to/shader_material
  17404. */
  17405. export class ShaderMaterial extends Material {
  17406. private _shaderPath;
  17407. private _options;
  17408. private _textures;
  17409. private _textureArrays;
  17410. private _floats;
  17411. private _ints;
  17412. private _floatsArrays;
  17413. private _colors3;
  17414. private _colors3Arrays;
  17415. private _colors4;
  17416. private _vectors2;
  17417. private _vectors3;
  17418. private _vectors4;
  17419. private _matrices;
  17420. private _matrices3x3;
  17421. private _matrices2x2;
  17422. private _vectors2Arrays;
  17423. private _vectors3Arrays;
  17424. private _cachedWorldViewMatrix;
  17425. private _cachedWorldViewProjectionMatrix;
  17426. private _renderId;
  17427. /**
  17428. * Instantiate a new shader material.
  17429. * 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.
  17430. * This returned material effects how the mesh will look based on the code in the shaders.
  17431. * @see http://doc.babylonjs.com/how_to/shader_material
  17432. * @param name Define the name of the material in the scene
  17433. * @param scene Define the scene the material belongs to
  17434. * @param shaderPath Defines the route to the shader code in one of three ways:
  17435. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17436. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  17437. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17438. * @param options Define the options used to create the shader
  17439. */
  17440. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17441. /**
  17442. * Gets the options used to compile the shader.
  17443. * They can be modified to trigger a new compilation
  17444. */
  17445. readonly options: IShaderMaterialOptions;
  17446. /**
  17447. * Gets the current class name of the material e.g. "ShaderMaterial"
  17448. * Mainly use in serialization.
  17449. * @returns the class name
  17450. */
  17451. getClassName(): string;
  17452. /**
  17453. * Specifies if the material will require alpha blending
  17454. * @returns a boolean specifying if alpha blending is needed
  17455. */
  17456. needAlphaBlending(): boolean;
  17457. /**
  17458. * Specifies if this material should be rendered in alpha test mode
  17459. * @returns a boolean specifying if an alpha test is needed.
  17460. */
  17461. needAlphaTesting(): boolean;
  17462. private _checkUniform;
  17463. /**
  17464. * Set a texture in the shader.
  17465. * @param name Define the name of the uniform samplers as defined in the shader
  17466. * @param texture Define the texture to bind to this sampler
  17467. * @return the material itself allowing "fluent" like uniform updates
  17468. */
  17469. setTexture(name: string, texture: Texture): ShaderMaterial;
  17470. /**
  17471. * Set a texture array in the shader.
  17472. * @param name Define the name of the uniform sampler array as defined in the shader
  17473. * @param textures Define the list of textures to bind to this sampler
  17474. * @return the material itself allowing "fluent" like uniform updates
  17475. */
  17476. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17477. /**
  17478. * Set a float in the shader.
  17479. * @param name Define the name of the uniform as defined in the shader
  17480. * @param value Define the value to give to the uniform
  17481. * @return the material itself allowing "fluent" like uniform updates
  17482. */
  17483. setFloat(name: string, value: number): ShaderMaterial;
  17484. /**
  17485. * Set a int in the shader.
  17486. * @param name Define the name of the uniform as defined in the shader
  17487. * @param value Define the value to give to the uniform
  17488. * @return the material itself allowing "fluent" like uniform updates
  17489. */
  17490. setInt(name: string, value: number): ShaderMaterial;
  17491. /**
  17492. * Set an array of floats in the shader.
  17493. * @param name Define the name of the uniform as defined in the shader
  17494. * @param value Define the value to give to the uniform
  17495. * @return the material itself allowing "fluent" like uniform updates
  17496. */
  17497. setFloats(name: string, value: number[]): ShaderMaterial;
  17498. /**
  17499. * Set a vec3 in the shader from a Color3.
  17500. * @param name Define the name of the uniform as defined in the shader
  17501. * @param value Define the value to give to the uniform
  17502. * @return the material itself allowing "fluent" like uniform updates
  17503. */
  17504. setColor3(name: string, value: Color3): ShaderMaterial;
  17505. /**
  17506. * Set a vec3 array in the shader from a Color3 array.
  17507. * @param name Define the name of the uniform as defined in the shader
  17508. * @param value Define the value to give to the uniform
  17509. * @return the material itself allowing "fluent" like uniform updates
  17510. */
  17511. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17512. /**
  17513. * Set a vec4 in the shader from a Color4.
  17514. * @param name Define the name of the uniform as defined in the shader
  17515. * @param value Define the value to give to the uniform
  17516. * @return the material itself allowing "fluent" like uniform updates
  17517. */
  17518. setColor4(name: string, value: Color4): ShaderMaterial;
  17519. /**
  17520. * Set a vec2 in the shader from a Vector2.
  17521. * @param name Define the name of the uniform as defined in the shader
  17522. * @param value Define the value to give to the uniform
  17523. * @return the material itself allowing "fluent" like uniform updates
  17524. */
  17525. setVector2(name: string, value: Vector2): ShaderMaterial;
  17526. /**
  17527. * Set a vec3 in the shader from a Vector3.
  17528. * @param name Define the name of the uniform as defined in the shader
  17529. * @param value Define the value to give to the uniform
  17530. * @return the material itself allowing "fluent" like uniform updates
  17531. */
  17532. setVector3(name: string, value: Vector3): ShaderMaterial;
  17533. /**
  17534. * Set a vec4 in the shader from a Vector4.
  17535. * @param name Define the name of the uniform as defined in the shader
  17536. * @param value Define the value to give to the uniform
  17537. * @return the material itself allowing "fluent" like uniform updates
  17538. */
  17539. setVector4(name: string, value: Vector4): ShaderMaterial;
  17540. /**
  17541. * Set a mat4 in the shader from a Matrix.
  17542. * @param name Define the name of the uniform as defined in the shader
  17543. * @param value Define the value to give to the uniform
  17544. * @return the material itself allowing "fluent" like uniform updates
  17545. */
  17546. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17547. /**
  17548. * Set a mat3 in the shader from a Float32Array.
  17549. * @param name Define the name of the uniform as defined in the shader
  17550. * @param value Define the value to give to the uniform
  17551. * @return the material itself allowing "fluent" like uniform updates
  17552. */
  17553. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17554. /**
  17555. * Set a mat2 in the shader from a Float32Array.
  17556. * @param name Define the name of the uniform as defined in the shader
  17557. * @param value Define the value to give to the uniform
  17558. * @return the material itself allowing "fluent" like uniform updates
  17559. */
  17560. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17561. /**
  17562. * Set a vec2 array in the shader from a number array.
  17563. * @param name Define the name of the uniform as defined in the shader
  17564. * @param value Define the value to give to the uniform
  17565. * @return the material itself allowing "fluent" like uniform updates
  17566. */
  17567. setArray2(name: string, value: number[]): ShaderMaterial;
  17568. /**
  17569. * Set a vec3 array in the shader from a number array.
  17570. * @param name Define the name of the uniform as defined in the shader
  17571. * @param value Define the value to give to the uniform
  17572. * @return the material itself allowing "fluent" like uniform updates
  17573. */
  17574. setArray3(name: string, value: number[]): ShaderMaterial;
  17575. private _checkCache;
  17576. /**
  17577. * Specifies that the submesh is ready to be used
  17578. * @param mesh defines the mesh to check
  17579. * @param subMesh defines which submesh to check
  17580. * @param useInstances specifies that instances should be used
  17581. * @returns a boolean indicating that the submesh is ready or not
  17582. */
  17583. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17584. /**
  17585. * Checks if the material is ready to render the requested mesh
  17586. * @param mesh Define the mesh to render
  17587. * @param useInstances Define whether or not the material is used with instances
  17588. * @returns true if ready, otherwise false
  17589. */
  17590. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17591. /**
  17592. * Binds the world matrix to the material
  17593. * @param world defines the world transformation matrix
  17594. */
  17595. bindOnlyWorldMatrix(world: Matrix): void;
  17596. /**
  17597. * Binds the material to the mesh
  17598. * @param world defines the world transformation matrix
  17599. * @param mesh defines the mesh to bind the material to
  17600. */
  17601. bind(world: Matrix, mesh?: Mesh): void;
  17602. /**
  17603. * Gets the active textures from the material
  17604. * @returns an array of textures
  17605. */
  17606. getActiveTextures(): BaseTexture[];
  17607. /**
  17608. * Specifies if the material uses a texture
  17609. * @param texture defines the texture to check against the material
  17610. * @returns a boolean specifying if the material uses the texture
  17611. */
  17612. hasTexture(texture: BaseTexture): boolean;
  17613. /**
  17614. * Makes a duplicate of the material, and gives it a new name
  17615. * @param name defines the new name for the duplicated material
  17616. * @returns the cloned material
  17617. */
  17618. clone(name: string): ShaderMaterial;
  17619. /**
  17620. * Disposes the material
  17621. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17622. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17623. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17624. */
  17625. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17626. /**
  17627. * Serializes this material in a JSON representation
  17628. * @returns the serialized material object
  17629. */
  17630. serialize(): any;
  17631. /**
  17632. * Creates a shader material from parsed shader material data
  17633. * @param source defines the JSON represnetation of the material
  17634. * @param scene defines the hosting scene
  17635. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17636. * @returns a new material
  17637. */
  17638. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17639. }
  17640. }
  17641. declare module "babylonjs/Shaders/color.fragment" {
  17642. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17643. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17644. /** @hidden */
  17645. export var colorPixelShader: {
  17646. name: string;
  17647. shader: string;
  17648. };
  17649. }
  17650. declare module "babylonjs/Shaders/color.vertex" {
  17651. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17652. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17653. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17654. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17655. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17656. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17657. /** @hidden */
  17658. export var colorVertexShader: {
  17659. name: string;
  17660. shader: string;
  17661. };
  17662. }
  17663. declare module "babylonjs/Meshes/linesMesh" {
  17664. import { Nullable } from "babylonjs/types";
  17665. import { Scene } from "babylonjs/scene";
  17666. import { Color3 } from "babylonjs/Maths/math";
  17667. import { Node } from "babylonjs/node";
  17668. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17669. import { Mesh } from "babylonjs/Meshes/mesh";
  17670. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17671. import { Effect } from "babylonjs/Materials/effect";
  17672. import { Material } from "babylonjs/Materials/material";
  17673. import "babylonjs/Shaders/color.fragment";
  17674. import "babylonjs/Shaders/color.vertex";
  17675. /**
  17676. * Line mesh
  17677. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17678. */
  17679. export class LinesMesh extends Mesh {
  17680. /**
  17681. * If vertex color should be applied to the mesh
  17682. */
  17683. readonly useVertexColor?: boolean | undefined;
  17684. /**
  17685. * If vertex alpha should be applied to the mesh
  17686. */
  17687. readonly useVertexAlpha?: boolean | undefined;
  17688. /**
  17689. * Color of the line (Default: White)
  17690. */
  17691. color: Color3;
  17692. /**
  17693. * Alpha of the line (Default: 1)
  17694. */
  17695. alpha: number;
  17696. /**
  17697. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17698. * This margin is expressed in world space coordinates, so its value may vary.
  17699. * Default value is 0.1
  17700. */
  17701. intersectionThreshold: number;
  17702. private _colorShader;
  17703. private color4;
  17704. /**
  17705. * Creates a new LinesMesh
  17706. * @param name defines the name
  17707. * @param scene defines the hosting scene
  17708. * @param parent defines the parent mesh if any
  17709. * @param source defines the optional source LinesMesh used to clone data from
  17710. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17711. * When false, achieved by calling a clone(), also passing False.
  17712. * This will make creation of children, recursive.
  17713. * @param useVertexColor defines if this LinesMesh supports vertex color
  17714. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17715. */
  17716. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17717. /**
  17718. * If vertex color should be applied to the mesh
  17719. */
  17720. useVertexColor?: boolean | undefined,
  17721. /**
  17722. * If vertex alpha should be applied to the mesh
  17723. */
  17724. useVertexAlpha?: boolean | undefined);
  17725. private _addClipPlaneDefine;
  17726. private _removeClipPlaneDefine;
  17727. isReady(): boolean;
  17728. /**
  17729. * Returns the string "LineMesh"
  17730. */
  17731. getClassName(): string;
  17732. /**
  17733. * @hidden
  17734. */
  17735. /**
  17736. * @hidden
  17737. */
  17738. material: Material;
  17739. /**
  17740. * @hidden
  17741. */
  17742. readonly checkCollisions: boolean;
  17743. /** @hidden */
  17744. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17745. /** @hidden */
  17746. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17747. /**
  17748. * Disposes of the line mesh
  17749. * @param doNotRecurse If children should be disposed
  17750. */
  17751. dispose(doNotRecurse?: boolean): void;
  17752. /**
  17753. * Returns a new LineMesh object cloned from the current one.
  17754. */
  17755. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17756. /**
  17757. * Creates a new InstancedLinesMesh object from the mesh model.
  17758. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17759. * @param name defines the name of the new instance
  17760. * @returns a new InstancedLinesMesh
  17761. */
  17762. createInstance(name: string): InstancedLinesMesh;
  17763. }
  17764. /**
  17765. * Creates an instance based on a source LinesMesh
  17766. */
  17767. export class InstancedLinesMesh extends InstancedMesh {
  17768. /**
  17769. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17770. * This margin is expressed in world space coordinates, so its value may vary.
  17771. * Initilized with the intersectionThreshold value of the source LinesMesh
  17772. */
  17773. intersectionThreshold: number;
  17774. constructor(name: string, source: LinesMesh);
  17775. /**
  17776. * Returns the string "InstancedLinesMesh".
  17777. */
  17778. getClassName(): string;
  17779. }
  17780. }
  17781. declare module "babylonjs/Shaders/line.fragment" {
  17782. /** @hidden */
  17783. export var linePixelShader: {
  17784. name: string;
  17785. shader: string;
  17786. };
  17787. }
  17788. declare module "babylonjs/Shaders/line.vertex" {
  17789. /** @hidden */
  17790. export var lineVertexShader: {
  17791. name: string;
  17792. shader: string;
  17793. };
  17794. }
  17795. declare module "babylonjs/Rendering/edgesRenderer" {
  17796. import { Nullable } from "babylonjs/types";
  17797. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17798. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17799. import { Vector3 } from "babylonjs/Maths/math";
  17800. import { IDisposable } from "babylonjs/scene";
  17801. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17802. import "babylonjs/Shaders/line.fragment";
  17803. import "babylonjs/Shaders/line.vertex";
  17804. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17805. module "babylonjs/Meshes/abstractMesh" {
  17806. interface AbstractMesh {
  17807. /**
  17808. * Gets the edgesRenderer associated with the mesh
  17809. */
  17810. edgesRenderer: Nullable<EdgesRenderer>;
  17811. }
  17812. }
  17813. module "babylonjs/Meshes/linesMesh" {
  17814. interface LinesMesh {
  17815. /**
  17816. * Enables the edge rendering mode on the mesh.
  17817. * This mode makes the mesh edges visible
  17818. * @param epsilon defines the maximal distance between two angles to detect a face
  17819. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17820. * @returns the currentAbstractMesh
  17821. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17822. */
  17823. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17824. }
  17825. }
  17826. module "babylonjs/Meshes/linesMesh" {
  17827. interface InstancedLinesMesh {
  17828. /**
  17829. * Enables the edge rendering mode on the mesh.
  17830. * This mode makes the mesh edges visible
  17831. * @param epsilon defines the maximal distance between two angles to detect a face
  17832. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17833. * @returns the current InstancedLinesMesh
  17834. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17835. */
  17836. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17837. }
  17838. }
  17839. /**
  17840. * Defines the minimum contract an Edges renderer should follow.
  17841. */
  17842. export interface IEdgesRenderer extends IDisposable {
  17843. /**
  17844. * Gets or sets a boolean indicating if the edgesRenderer is active
  17845. */
  17846. isEnabled: boolean;
  17847. /**
  17848. * Renders the edges of the attached mesh,
  17849. */
  17850. render(): void;
  17851. /**
  17852. * Checks wether or not the edges renderer is ready to render.
  17853. * @return true if ready, otherwise false.
  17854. */
  17855. isReady(): boolean;
  17856. }
  17857. /**
  17858. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17859. */
  17860. export class EdgesRenderer implements IEdgesRenderer {
  17861. /**
  17862. * Define the size of the edges with an orthographic camera
  17863. */
  17864. edgesWidthScalerForOrthographic: number;
  17865. /**
  17866. * Define the size of the edges with a perspective camera
  17867. */
  17868. edgesWidthScalerForPerspective: number;
  17869. protected _source: AbstractMesh;
  17870. protected _linesPositions: number[];
  17871. protected _linesNormals: number[];
  17872. protected _linesIndices: number[];
  17873. protected _epsilon: number;
  17874. protected _indicesCount: number;
  17875. protected _lineShader: ShaderMaterial;
  17876. protected _ib: DataBuffer;
  17877. protected _buffers: {
  17878. [key: string]: Nullable<VertexBuffer>;
  17879. };
  17880. protected _checkVerticesInsteadOfIndices: boolean;
  17881. private _meshRebuildObserver;
  17882. private _meshDisposeObserver;
  17883. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17884. isEnabled: boolean;
  17885. /**
  17886. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17887. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17888. * @param source Mesh used to create edges
  17889. * @param epsilon sum of angles in adjacency to check for edge
  17890. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17891. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17892. */
  17893. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17894. protected _prepareRessources(): void;
  17895. /** @hidden */
  17896. _rebuild(): void;
  17897. /**
  17898. * Releases the required resources for the edges renderer
  17899. */
  17900. dispose(): void;
  17901. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17902. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17903. /**
  17904. * Checks if the pair of p0 and p1 is en edge
  17905. * @param faceIndex
  17906. * @param edge
  17907. * @param faceNormals
  17908. * @param p0
  17909. * @param p1
  17910. * @private
  17911. */
  17912. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17913. /**
  17914. * push line into the position, normal and index buffer
  17915. * @protected
  17916. */
  17917. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17918. /**
  17919. * Generates lines edges from adjacencjes
  17920. * @private
  17921. */
  17922. _generateEdgesLines(): void;
  17923. /**
  17924. * Checks wether or not the edges renderer is ready to render.
  17925. * @return true if ready, otherwise false.
  17926. */
  17927. isReady(): boolean;
  17928. /**
  17929. * Renders the edges of the attached mesh,
  17930. */
  17931. render(): void;
  17932. }
  17933. /**
  17934. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17935. */
  17936. export class LineEdgesRenderer extends EdgesRenderer {
  17937. /**
  17938. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17939. * @param source LineMesh used to generate edges
  17940. * @param epsilon not important (specified angle for edge detection)
  17941. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17942. */
  17943. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17944. /**
  17945. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17946. */
  17947. _generateEdgesLines(): void;
  17948. }
  17949. }
  17950. declare module "babylonjs/Rendering/renderingGroup" {
  17951. import { SmartArray } from "babylonjs/Misc/smartArray";
  17952. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17953. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17954. import { Nullable } from "babylonjs/types";
  17955. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17956. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17957. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17958. import { Material } from "babylonjs/Materials/material";
  17959. import { Scene } from "babylonjs/scene";
  17960. /**
  17961. * This represents the object necessary to create a rendering group.
  17962. * This is exclusively used and created by the rendering manager.
  17963. * To modify the behavior, you use the available helpers in your scene or meshes.
  17964. * @hidden
  17965. */
  17966. export class RenderingGroup {
  17967. index: number;
  17968. private static _zeroVector;
  17969. private _scene;
  17970. private _opaqueSubMeshes;
  17971. private _transparentSubMeshes;
  17972. private _alphaTestSubMeshes;
  17973. private _depthOnlySubMeshes;
  17974. private _particleSystems;
  17975. private _spriteManagers;
  17976. private _opaqueSortCompareFn;
  17977. private _alphaTestSortCompareFn;
  17978. private _transparentSortCompareFn;
  17979. private _renderOpaque;
  17980. private _renderAlphaTest;
  17981. private _renderTransparent;
  17982. /** @hidden */
  17983. _edgesRenderers: SmartArray<IEdgesRenderer>;
  17984. onBeforeTransparentRendering: () => void;
  17985. /**
  17986. * Set the opaque sort comparison function.
  17987. * If null the sub meshes will be render in the order they were created
  17988. */
  17989. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17990. /**
  17991. * Set the alpha test sort comparison function.
  17992. * If null the sub meshes will be render in the order they were created
  17993. */
  17994. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17995. /**
  17996. * Set the transparent sort comparison function.
  17997. * If null the sub meshes will be render in the order they were created
  17998. */
  17999. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  18000. /**
  18001. * Creates a new rendering group.
  18002. * @param index The rendering group index
  18003. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  18004. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  18005. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  18006. */
  18007. 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>);
  18008. /**
  18009. * Render all the sub meshes contained in the group.
  18010. * @param customRenderFunction Used to override the default render behaviour of the group.
  18011. * @returns true if rendered some submeshes.
  18012. */
  18013. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  18014. /**
  18015. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  18016. * @param subMeshes The submeshes to render
  18017. */
  18018. private renderOpaqueSorted;
  18019. /**
  18020. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  18021. * @param subMeshes The submeshes to render
  18022. */
  18023. private renderAlphaTestSorted;
  18024. /**
  18025. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  18026. * @param subMeshes The submeshes to render
  18027. */
  18028. private renderTransparentSorted;
  18029. /**
  18030. * Renders the submeshes in a specified order.
  18031. * @param subMeshes The submeshes to sort before render
  18032. * @param sortCompareFn The comparison function use to sort
  18033. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  18034. * @param transparent Specifies to activate blending if true
  18035. */
  18036. private static renderSorted;
  18037. /**
  18038. * Renders the submeshes in the order they were dispatched (no sort applied).
  18039. * @param subMeshes The submeshes to render
  18040. */
  18041. private static renderUnsorted;
  18042. /**
  18043. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18044. * are rendered back to front if in the same alpha index.
  18045. *
  18046. * @param a The first submesh
  18047. * @param b The second submesh
  18048. * @returns The result of the comparison
  18049. */
  18050. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  18051. /**
  18052. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18053. * are rendered back to front.
  18054. *
  18055. * @param a The first submesh
  18056. * @param b The second submesh
  18057. * @returns The result of the comparison
  18058. */
  18059. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  18060. /**
  18061. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18062. * are rendered front to back (prevent overdraw).
  18063. *
  18064. * @param a The first submesh
  18065. * @param b The second submesh
  18066. * @returns The result of the comparison
  18067. */
  18068. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  18069. /**
  18070. * Resets the different lists of submeshes to prepare a new frame.
  18071. */
  18072. prepare(): void;
  18073. dispose(): void;
  18074. /**
  18075. * Inserts the submesh in its correct queue depending on its material.
  18076. * @param subMesh The submesh to dispatch
  18077. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  18078. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  18079. */
  18080. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  18081. dispatchSprites(spriteManager: ISpriteManager): void;
  18082. dispatchParticles(particleSystem: IParticleSystem): void;
  18083. private _renderParticles;
  18084. private _renderSprites;
  18085. }
  18086. }
  18087. declare module "babylonjs/Rendering/renderingManager" {
  18088. import { Nullable } from "babylonjs/types";
  18089. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18090. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18091. import { SmartArray } from "babylonjs/Misc/smartArray";
  18092. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18093. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  18094. import { Material } from "babylonjs/Materials/material";
  18095. import { Scene } from "babylonjs/scene";
  18096. import { Camera } from "babylonjs/Cameras/camera";
  18097. /**
  18098. * Interface describing the different options available in the rendering manager
  18099. * regarding Auto Clear between groups.
  18100. */
  18101. export interface IRenderingManagerAutoClearSetup {
  18102. /**
  18103. * Defines whether or not autoclear is enable.
  18104. */
  18105. autoClear: boolean;
  18106. /**
  18107. * Defines whether or not to autoclear the depth buffer.
  18108. */
  18109. depth: boolean;
  18110. /**
  18111. * Defines whether or not to autoclear the stencil buffer.
  18112. */
  18113. stencil: boolean;
  18114. }
  18115. /**
  18116. * This class is used by the onRenderingGroupObservable
  18117. */
  18118. export class RenderingGroupInfo {
  18119. /**
  18120. * The Scene that being rendered
  18121. */
  18122. scene: Scene;
  18123. /**
  18124. * The camera currently used for the rendering pass
  18125. */
  18126. camera: Nullable<Camera>;
  18127. /**
  18128. * The ID of the renderingGroup being processed
  18129. */
  18130. renderingGroupId: number;
  18131. }
  18132. /**
  18133. * This is the manager responsible of all the rendering for meshes sprites and particles.
  18134. * It is enable to manage the different groups as well as the different necessary sort functions.
  18135. * This should not be used directly aside of the few static configurations
  18136. */
  18137. export class RenderingManager {
  18138. /**
  18139. * The max id used for rendering groups (not included)
  18140. */
  18141. static MAX_RENDERINGGROUPS: number;
  18142. /**
  18143. * The min id used for rendering groups (included)
  18144. */
  18145. static MIN_RENDERINGGROUPS: number;
  18146. /**
  18147. * Used to globally prevent autoclearing scenes.
  18148. */
  18149. static AUTOCLEAR: boolean;
  18150. /**
  18151. * @hidden
  18152. */
  18153. _useSceneAutoClearSetup: boolean;
  18154. private _scene;
  18155. private _renderingGroups;
  18156. private _depthStencilBufferAlreadyCleaned;
  18157. private _autoClearDepthStencil;
  18158. private _customOpaqueSortCompareFn;
  18159. private _customAlphaTestSortCompareFn;
  18160. private _customTransparentSortCompareFn;
  18161. private _renderingGroupInfo;
  18162. /**
  18163. * Instantiates a new rendering group for a particular scene
  18164. * @param scene Defines the scene the groups belongs to
  18165. */
  18166. constructor(scene: Scene);
  18167. private _clearDepthStencilBuffer;
  18168. /**
  18169. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  18170. * @hidden
  18171. */
  18172. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  18173. /**
  18174. * Resets the different information of the group to prepare a new frame
  18175. * @hidden
  18176. */
  18177. reset(): void;
  18178. /**
  18179. * Dispose and release the group and its associated resources.
  18180. * @hidden
  18181. */
  18182. dispose(): void;
  18183. /**
  18184. * Clear the info related to rendering groups preventing retention points during dispose.
  18185. */
  18186. freeRenderingGroups(): void;
  18187. private _prepareRenderingGroup;
  18188. /**
  18189. * Add a sprite manager to the rendering manager in order to render it this frame.
  18190. * @param spriteManager Define the sprite manager to render
  18191. */
  18192. dispatchSprites(spriteManager: ISpriteManager): void;
  18193. /**
  18194. * Add a particle system to the rendering manager in order to render it this frame.
  18195. * @param particleSystem Define the particle system to render
  18196. */
  18197. dispatchParticles(particleSystem: IParticleSystem): void;
  18198. /**
  18199. * Add a submesh to the manager in order to render it this frame
  18200. * @param subMesh The submesh to dispatch
  18201. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  18202. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  18203. */
  18204. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  18205. /**
  18206. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18207. * This allowed control for front to back rendering or reversly depending of the special needs.
  18208. *
  18209. * @param renderingGroupId The rendering group id corresponding to its index
  18210. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18211. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18212. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18213. */
  18214. 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;
  18215. /**
  18216. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18217. *
  18218. * @param renderingGroupId The rendering group id corresponding to its index
  18219. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18220. * @param depth Automatically clears depth between groups if true and autoClear is true.
  18221. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  18222. */
  18223. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  18224. /**
  18225. * Gets the current auto clear configuration for one rendering group of the rendering
  18226. * manager.
  18227. * @param index the rendering group index to get the information for
  18228. * @returns The auto clear setup for the requested rendering group
  18229. */
  18230. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  18231. }
  18232. }
  18233. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  18234. import { Observable } from "babylonjs/Misc/observable";
  18235. import { SmartArray } from "babylonjs/Misc/smartArray";
  18236. import { Nullable } from "babylonjs/types";
  18237. import { Camera } from "babylonjs/Cameras/camera";
  18238. import { Scene } from "babylonjs/scene";
  18239. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  18240. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  18241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18242. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18243. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18244. import { Texture } from "babylonjs/Materials/Textures/texture";
  18245. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  18246. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  18247. import "babylonjs/Engines/Extensions/engine.renderTarget";
  18248. import { Engine } from "babylonjs/Engines/engine";
  18249. /**
  18250. * This Helps creating a texture that will be created from a camera in your scene.
  18251. * It is basically a dynamic texture that could be used to create special effects for instance.
  18252. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  18253. */
  18254. export class RenderTargetTexture extends Texture {
  18255. isCube: boolean;
  18256. /**
  18257. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  18258. */
  18259. static readonly REFRESHRATE_RENDER_ONCE: number;
  18260. /**
  18261. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  18262. */
  18263. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  18264. /**
  18265. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  18266. * the central point of your effect and can save a lot of performances.
  18267. */
  18268. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  18269. /**
  18270. * Use this predicate to dynamically define the list of mesh you want to render.
  18271. * If set, the renderList property will be overwritten.
  18272. */
  18273. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  18274. private _renderList;
  18275. /**
  18276. * Use this list to define the list of mesh you want to render.
  18277. */
  18278. renderList: Nullable<Array<AbstractMesh>>;
  18279. private _hookArray;
  18280. /**
  18281. * Define if particles should be rendered in your texture.
  18282. */
  18283. renderParticles: boolean;
  18284. /**
  18285. * Define if sprites should be rendered in your texture.
  18286. */
  18287. renderSprites: boolean;
  18288. /**
  18289. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  18290. */
  18291. coordinatesMode: number;
  18292. /**
  18293. * Define the camera used to render the texture.
  18294. */
  18295. activeCamera: Nullable<Camera>;
  18296. /**
  18297. * Override the render function of the texture with your own one.
  18298. */
  18299. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  18300. /**
  18301. * Define if camera post processes should be use while rendering the texture.
  18302. */
  18303. useCameraPostProcesses: boolean;
  18304. /**
  18305. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  18306. */
  18307. ignoreCameraViewport: boolean;
  18308. private _postProcessManager;
  18309. private _postProcesses;
  18310. private _resizeObserver;
  18311. /**
  18312. * An event triggered when the texture is unbind.
  18313. */
  18314. onBeforeBindObservable: Observable<RenderTargetTexture>;
  18315. /**
  18316. * An event triggered when the texture is unbind.
  18317. */
  18318. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  18319. private _onAfterUnbindObserver;
  18320. /**
  18321. * Set a after unbind callback in the texture.
  18322. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  18323. */
  18324. onAfterUnbind: () => void;
  18325. /**
  18326. * An event triggered before rendering the texture
  18327. */
  18328. onBeforeRenderObservable: Observable<number>;
  18329. private _onBeforeRenderObserver;
  18330. /**
  18331. * Set a before render callback in the texture.
  18332. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  18333. */
  18334. onBeforeRender: (faceIndex: number) => void;
  18335. /**
  18336. * An event triggered after rendering the texture
  18337. */
  18338. onAfterRenderObservable: Observable<number>;
  18339. private _onAfterRenderObserver;
  18340. /**
  18341. * Set a after render callback in the texture.
  18342. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  18343. */
  18344. onAfterRender: (faceIndex: number) => void;
  18345. /**
  18346. * An event triggered after the texture clear
  18347. */
  18348. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  18349. private _onClearObserver;
  18350. /**
  18351. * Set a clear callback in the texture.
  18352. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  18353. */
  18354. onClear: (Engine: Engine) => void;
  18355. /**
  18356. * Define the clear color of the Render Target if it should be different from the scene.
  18357. */
  18358. clearColor: Color4;
  18359. protected _size: number | {
  18360. width: number;
  18361. height: number;
  18362. };
  18363. protected _initialSizeParameter: number | {
  18364. width: number;
  18365. height: number;
  18366. } | {
  18367. ratio: number;
  18368. };
  18369. protected _sizeRatio: Nullable<number>;
  18370. /** @hidden */
  18371. _generateMipMaps: boolean;
  18372. protected _renderingManager: RenderingManager;
  18373. /** @hidden */
  18374. _waitingRenderList: string[];
  18375. protected _doNotChangeAspectRatio: boolean;
  18376. protected _currentRefreshId: number;
  18377. protected _refreshRate: number;
  18378. protected _textureMatrix: Matrix;
  18379. protected _samples: number;
  18380. protected _renderTargetOptions: RenderTargetCreationOptions;
  18381. /**
  18382. * Gets render target creation options that were used.
  18383. */
  18384. readonly renderTargetOptions: RenderTargetCreationOptions;
  18385. protected _engine: Engine;
  18386. protected _onRatioRescale(): void;
  18387. /**
  18388. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  18389. * It must define where the camera used to render the texture is set
  18390. */
  18391. boundingBoxPosition: Vector3;
  18392. private _boundingBoxSize;
  18393. /**
  18394. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  18395. * When defined, the cubemap will switch to local mode
  18396. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  18397. * @example https://www.babylonjs-playground.com/#RNASML
  18398. */
  18399. boundingBoxSize: Vector3;
  18400. /**
  18401. * In case the RTT has been created with a depth texture, get the associated
  18402. * depth texture.
  18403. * Otherwise, return null.
  18404. */
  18405. depthStencilTexture: Nullable<InternalTexture>;
  18406. /**
  18407. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  18408. * or used a shadow, depth texture...
  18409. * @param name The friendly name of the texture
  18410. * @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)
  18411. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  18412. * @param generateMipMaps True if mip maps need to be generated after render.
  18413. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  18414. * @param type The type of the buffer in the RTT (int, half float, float...)
  18415. * @param isCube True if a cube texture needs to be created
  18416. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  18417. * @param generateDepthBuffer True to generate a depth buffer
  18418. * @param generateStencilBuffer True to generate a stencil buffer
  18419. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  18420. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  18421. * @param delayAllocation if the texture allocation should be delayed (default: false)
  18422. */
  18423. constructor(name: string, size: number | {
  18424. width: number;
  18425. height: number;
  18426. } | {
  18427. ratio: number;
  18428. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  18429. /**
  18430. * Creates a depth stencil texture.
  18431. * This is only available in WebGL 2 or with the depth texture extension available.
  18432. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  18433. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  18434. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  18435. */
  18436. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  18437. private _processSizeParameter;
  18438. /**
  18439. * Define the number of samples to use in case of MSAA.
  18440. * It defaults to one meaning no MSAA has been enabled.
  18441. */
  18442. samples: number;
  18443. /**
  18444. * Resets the refresh counter of the texture and start bak from scratch.
  18445. * Could be useful to regenerate the texture if it is setup to render only once.
  18446. */
  18447. resetRefreshCounter(): void;
  18448. /**
  18449. * Define the refresh rate of the texture or the rendering frequency.
  18450. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  18451. */
  18452. refreshRate: number;
  18453. /**
  18454. * Adds a post process to the render target rendering passes.
  18455. * @param postProcess define the post process to add
  18456. */
  18457. addPostProcess(postProcess: PostProcess): void;
  18458. /**
  18459. * Clear all the post processes attached to the render target
  18460. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  18461. */
  18462. clearPostProcesses(dispose?: boolean): void;
  18463. /**
  18464. * Remove one of the post process from the list of attached post processes to the texture
  18465. * @param postProcess define the post process to remove from the list
  18466. */
  18467. removePostProcess(postProcess: PostProcess): void;
  18468. /** @hidden */
  18469. _shouldRender(): boolean;
  18470. /**
  18471. * Gets the actual render size of the texture.
  18472. * @returns the width of the render size
  18473. */
  18474. getRenderSize(): number;
  18475. /**
  18476. * Gets the actual render width of the texture.
  18477. * @returns the width of the render size
  18478. */
  18479. getRenderWidth(): number;
  18480. /**
  18481. * Gets the actual render height of the texture.
  18482. * @returns the height of the render size
  18483. */
  18484. getRenderHeight(): number;
  18485. /**
  18486. * Get if the texture can be rescaled or not.
  18487. */
  18488. readonly canRescale: boolean;
  18489. /**
  18490. * Resize the texture using a ratio.
  18491. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  18492. */
  18493. scale(ratio: number): void;
  18494. /**
  18495. * Get the texture reflection matrix used to rotate/transform the reflection.
  18496. * @returns the reflection matrix
  18497. */
  18498. getReflectionTextureMatrix(): Matrix;
  18499. /**
  18500. * Resize the texture to a new desired size.
  18501. * Be carrefull as it will recreate all the data in the new texture.
  18502. * @param size Define the new size. It can be:
  18503. * - a number for squared texture,
  18504. * - an object containing { width: number, height: number }
  18505. * - or an object containing a ratio { ratio: number }
  18506. */
  18507. resize(size: number | {
  18508. width: number;
  18509. height: number;
  18510. } | {
  18511. ratio: number;
  18512. }): void;
  18513. /**
  18514. * Renders all the objects from the render list into the texture.
  18515. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  18516. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  18517. */
  18518. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  18519. private _bestReflectionRenderTargetDimension;
  18520. /**
  18521. * @hidden
  18522. * @param faceIndex face index to bind to if this is a cubetexture
  18523. */
  18524. _bindFrameBuffer(faceIndex?: number): void;
  18525. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18526. private renderToTarget;
  18527. /**
  18528. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18529. * This allowed control for front to back rendering or reversly depending of the special needs.
  18530. *
  18531. * @param renderingGroupId The rendering group id corresponding to its index
  18532. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18533. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18534. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18535. */
  18536. 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;
  18537. /**
  18538. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18539. *
  18540. * @param renderingGroupId The rendering group id corresponding to its index
  18541. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18542. */
  18543. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18544. /**
  18545. * Clones the texture.
  18546. * @returns the cloned texture
  18547. */
  18548. clone(): RenderTargetTexture;
  18549. /**
  18550. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18551. * @returns The JSON representation of the texture
  18552. */
  18553. serialize(): any;
  18554. /**
  18555. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  18556. */
  18557. disposeFramebufferObjects(): void;
  18558. /**
  18559. * Dispose the texture and release its associated resources.
  18560. */
  18561. dispose(): void;
  18562. /** @hidden */
  18563. _rebuild(): void;
  18564. /**
  18565. * Clear the info related to rendering groups preventing retention point in material dispose.
  18566. */
  18567. freeRenderingGroups(): void;
  18568. /**
  18569. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  18570. * @returns the view count
  18571. */
  18572. getViewCount(): number;
  18573. }
  18574. }
  18575. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18576. import { Scene } from "babylonjs/scene";
  18577. import { Plane } from "babylonjs/Maths/math";
  18578. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18579. /**
  18580. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18581. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18582. * You can then easily use it as a reflectionTexture on a flat surface.
  18583. * In case the surface is not a plane, please consider relying on reflection probes.
  18584. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18585. */
  18586. export class MirrorTexture extends RenderTargetTexture {
  18587. private scene;
  18588. /**
  18589. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18590. * 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.
  18591. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18592. */
  18593. mirrorPlane: Plane;
  18594. /**
  18595. * Define the blur ratio used to blur the reflection if needed.
  18596. */
  18597. blurRatio: number;
  18598. /**
  18599. * Define the adaptive blur kernel used to blur the reflection if needed.
  18600. * This will autocompute the closest best match for the `blurKernel`
  18601. */
  18602. adaptiveBlurKernel: number;
  18603. /**
  18604. * Define the blur kernel used to blur the reflection if needed.
  18605. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18606. */
  18607. blurKernel: number;
  18608. /**
  18609. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18610. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18611. */
  18612. blurKernelX: number;
  18613. /**
  18614. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18615. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18616. */
  18617. blurKernelY: number;
  18618. private _autoComputeBlurKernel;
  18619. protected _onRatioRescale(): void;
  18620. private _updateGammaSpace;
  18621. private _imageProcessingConfigChangeObserver;
  18622. private _transformMatrix;
  18623. private _mirrorMatrix;
  18624. private _savedViewMatrix;
  18625. private _blurX;
  18626. private _blurY;
  18627. private _adaptiveBlurKernel;
  18628. private _blurKernelX;
  18629. private _blurKernelY;
  18630. private _blurRatio;
  18631. /**
  18632. * Instantiates a Mirror Texture.
  18633. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18634. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18635. * You can then easily use it as a reflectionTexture on a flat surface.
  18636. * In case the surface is not a plane, please consider relying on reflection probes.
  18637. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18638. * @param name
  18639. * @param size
  18640. * @param scene
  18641. * @param generateMipMaps
  18642. * @param type
  18643. * @param samplingMode
  18644. * @param generateDepthBuffer
  18645. */
  18646. constructor(name: string, size: number | {
  18647. width: number;
  18648. height: number;
  18649. } | {
  18650. ratio: number;
  18651. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18652. private _preparePostProcesses;
  18653. /**
  18654. * Clone the mirror texture.
  18655. * @returns the cloned texture
  18656. */
  18657. clone(): MirrorTexture;
  18658. /**
  18659. * Serialize the texture to a JSON representation you could use in Parse later on
  18660. * @returns the serialized JSON representation
  18661. */
  18662. serialize(): any;
  18663. /**
  18664. * Dispose the texture and release its associated resources.
  18665. */
  18666. dispose(): void;
  18667. }
  18668. }
  18669. declare module "babylonjs/Materials/Textures/texture" {
  18670. import { Observable } from "babylonjs/Misc/observable";
  18671. import { Nullable } from "babylonjs/types";
  18672. import { Scene } from "babylonjs/scene";
  18673. import { Matrix } from "babylonjs/Maths/math";
  18674. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18675. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18676. /**
  18677. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18678. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18679. */
  18680. export class Texture extends BaseTexture {
  18681. /** @hidden */
  18682. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18683. /** @hidden */
  18684. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18685. /** @hidden */
  18686. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18687. /** nearest is mag = nearest and min = nearest and mip = linear */
  18688. static readonly NEAREST_SAMPLINGMODE: number;
  18689. /** nearest is mag = nearest and min = nearest and mip = linear */
  18690. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18691. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18692. static readonly BILINEAR_SAMPLINGMODE: number;
  18693. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18694. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18695. /** Trilinear is mag = linear and min = linear and mip = linear */
  18696. static readonly TRILINEAR_SAMPLINGMODE: number;
  18697. /** Trilinear is mag = linear and min = linear and mip = linear */
  18698. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18699. /** mag = nearest and min = nearest and mip = nearest */
  18700. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18701. /** mag = nearest and min = linear and mip = nearest */
  18702. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18703. /** mag = nearest and min = linear and mip = linear */
  18704. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18705. /** mag = nearest and min = linear and mip = none */
  18706. static readonly NEAREST_LINEAR: number;
  18707. /** mag = nearest and min = nearest and mip = none */
  18708. static readonly NEAREST_NEAREST: number;
  18709. /** mag = linear and min = nearest and mip = nearest */
  18710. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18711. /** mag = linear and min = nearest and mip = linear */
  18712. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18713. /** mag = linear and min = linear and mip = none */
  18714. static readonly LINEAR_LINEAR: number;
  18715. /** mag = linear and min = nearest and mip = none */
  18716. static readonly LINEAR_NEAREST: number;
  18717. /** Explicit coordinates mode */
  18718. static readonly EXPLICIT_MODE: number;
  18719. /** Spherical coordinates mode */
  18720. static readonly SPHERICAL_MODE: number;
  18721. /** Planar coordinates mode */
  18722. static readonly PLANAR_MODE: number;
  18723. /** Cubic coordinates mode */
  18724. static readonly CUBIC_MODE: number;
  18725. /** Projection coordinates mode */
  18726. static readonly PROJECTION_MODE: number;
  18727. /** Inverse Cubic coordinates mode */
  18728. static readonly SKYBOX_MODE: number;
  18729. /** Inverse Cubic coordinates mode */
  18730. static readonly INVCUBIC_MODE: number;
  18731. /** Equirectangular coordinates mode */
  18732. static readonly EQUIRECTANGULAR_MODE: number;
  18733. /** Equirectangular Fixed coordinates mode */
  18734. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18735. /** Equirectangular Fixed Mirrored coordinates mode */
  18736. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18737. /** Texture is not repeating outside of 0..1 UVs */
  18738. static readonly CLAMP_ADDRESSMODE: number;
  18739. /** Texture is repeating outside of 0..1 UVs */
  18740. static readonly WRAP_ADDRESSMODE: number;
  18741. /** Texture is repeating and mirrored */
  18742. static readonly MIRROR_ADDRESSMODE: number;
  18743. /**
  18744. * 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
  18745. */
  18746. static UseSerializedUrlIfAny: boolean;
  18747. /**
  18748. * Define the url of the texture.
  18749. */
  18750. url: Nullable<string>;
  18751. /**
  18752. * Define an offset on the texture to offset the u coordinates of the UVs
  18753. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18754. */
  18755. uOffset: number;
  18756. /**
  18757. * Define an offset on the texture to offset the v coordinates of the UVs
  18758. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18759. */
  18760. vOffset: number;
  18761. /**
  18762. * Define an offset on the texture to scale the u coordinates of the UVs
  18763. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18764. */
  18765. uScale: number;
  18766. /**
  18767. * Define an offset on the texture to scale the v coordinates of the UVs
  18768. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18769. */
  18770. vScale: number;
  18771. /**
  18772. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18773. * @see http://doc.babylonjs.com/how_to/more_materials
  18774. */
  18775. uAng: number;
  18776. /**
  18777. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18778. * @see http://doc.babylonjs.com/how_to/more_materials
  18779. */
  18780. vAng: number;
  18781. /**
  18782. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18783. * @see http://doc.babylonjs.com/how_to/more_materials
  18784. */
  18785. wAng: number;
  18786. /**
  18787. * Defines the center of rotation (U)
  18788. */
  18789. uRotationCenter: number;
  18790. /**
  18791. * Defines the center of rotation (V)
  18792. */
  18793. vRotationCenter: number;
  18794. /**
  18795. * Defines the center of rotation (W)
  18796. */
  18797. wRotationCenter: number;
  18798. /**
  18799. * Are mip maps generated for this texture or not.
  18800. */
  18801. readonly noMipmap: boolean;
  18802. /**
  18803. * List of inspectable custom properties (used by the Inspector)
  18804. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18805. */
  18806. inspectableCustomProperties: Nullable<IInspectable[]>;
  18807. private _noMipmap;
  18808. /** @hidden */
  18809. _invertY: boolean;
  18810. private _rowGenerationMatrix;
  18811. private _cachedTextureMatrix;
  18812. private _projectionModeMatrix;
  18813. private _t0;
  18814. private _t1;
  18815. private _t2;
  18816. private _cachedUOffset;
  18817. private _cachedVOffset;
  18818. private _cachedUScale;
  18819. private _cachedVScale;
  18820. private _cachedUAng;
  18821. private _cachedVAng;
  18822. private _cachedWAng;
  18823. private _cachedProjectionMatrixId;
  18824. private _cachedCoordinatesMode;
  18825. /** @hidden */
  18826. protected _initialSamplingMode: number;
  18827. /** @hidden */
  18828. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18829. private _deleteBuffer;
  18830. protected _format: Nullable<number>;
  18831. private _delayedOnLoad;
  18832. private _delayedOnError;
  18833. /**
  18834. * Observable triggered once the texture has been loaded.
  18835. */
  18836. onLoadObservable: Observable<Texture>;
  18837. protected _isBlocking: boolean;
  18838. /**
  18839. * Is the texture preventing material to render while loading.
  18840. * If false, a default texture will be used instead of the loading one during the preparation step.
  18841. */
  18842. isBlocking: boolean;
  18843. /**
  18844. * Get the current sampling mode associated with the texture.
  18845. */
  18846. readonly samplingMode: number;
  18847. /**
  18848. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18849. */
  18850. readonly invertY: boolean;
  18851. /**
  18852. * Instantiates a new texture.
  18853. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18854. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18855. * @param url define the url of the picture to load as a texture
  18856. * @param scene define the scene the texture will belong to
  18857. * @param noMipmap define if the texture will require mip maps or not
  18858. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18859. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18860. * @param onLoad define a callback triggered when the texture has been loaded
  18861. * @param onError define a callback triggered when an error occurred during the loading session
  18862. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18863. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18864. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18865. */
  18866. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  18867. /**
  18868. * Update the url (and optional buffer) of this texture if url was null during construction.
  18869. * @param url the url of the texture
  18870. * @param buffer the buffer of the texture (defaults to null)
  18871. * @param onLoad callback called when the texture is loaded (defaults to null)
  18872. */
  18873. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18874. /**
  18875. * Finish the loading sequence of a texture flagged as delayed load.
  18876. * @hidden
  18877. */
  18878. delayLoad(): void;
  18879. private _prepareRowForTextureGeneration;
  18880. /**
  18881. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18882. * @returns the transform matrix of the texture.
  18883. */
  18884. getTextureMatrix(): Matrix;
  18885. /**
  18886. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18887. * @returns The reflection texture transform
  18888. */
  18889. getReflectionTextureMatrix(): Matrix;
  18890. /**
  18891. * Clones the texture.
  18892. * @returns the cloned texture
  18893. */
  18894. clone(): Texture;
  18895. /**
  18896. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18897. * @returns The JSON representation of the texture
  18898. */
  18899. serialize(): any;
  18900. /**
  18901. * Get the current class name of the texture useful for serialization or dynamic coding.
  18902. * @returns "Texture"
  18903. */
  18904. getClassName(): string;
  18905. /**
  18906. * Dispose the texture and release its associated resources.
  18907. */
  18908. dispose(): void;
  18909. /**
  18910. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18911. * @param parsedTexture Define the JSON representation of the texture
  18912. * @param scene Define the scene the parsed texture should be instantiated in
  18913. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18914. * @returns The parsed texture if successful
  18915. */
  18916. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18917. /**
  18918. * Creates a texture from its base 64 representation.
  18919. * @param data Define the base64 payload without the data: prefix
  18920. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18921. * @param scene Define the scene the texture should belong to
  18922. * @param noMipmap Forces the texture to not create mip map information if true
  18923. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18924. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18925. * @param onLoad define a callback triggered when the texture has been loaded
  18926. * @param onError define a callback triggered when an error occurred during the loading session
  18927. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18928. * @returns the created texture
  18929. */
  18930. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18931. /**
  18932. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18933. * @param data Define the base64 payload without the data: prefix
  18934. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18935. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18936. * @param scene Define the scene the texture should belong to
  18937. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18938. * @param noMipmap Forces the texture to not create mip map information if true
  18939. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18940. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18941. * @param onLoad define a callback triggered when the texture has been loaded
  18942. * @param onError define a callback triggered when an error occurred during the loading session
  18943. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18944. * @returns the created texture
  18945. */
  18946. 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;
  18947. }
  18948. }
  18949. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  18950. import { Nullable } from "babylonjs/types";
  18951. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18952. import { Scene } from "babylonjs/scene";
  18953. module "babylonjs/Engines/engine" {
  18954. interface Engine {
  18955. /**
  18956. * Creates a raw texture
  18957. * @param data defines the data to store in the texture
  18958. * @param width defines the width of the texture
  18959. * @param height defines the height of the texture
  18960. * @param format defines the format of the data
  18961. * @param generateMipMaps defines if the engine should generate the mip levels
  18962. * @param invertY defines if data must be stored with Y axis inverted
  18963. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  18964. * @param compression defines the compression used (null by default)
  18965. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18966. * @returns the raw texture inside an InternalTexture
  18967. */
  18968. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  18969. /**
  18970. * Update a raw texture
  18971. * @param texture defines the texture to update
  18972. * @param data defines the data to store in the texture
  18973. * @param format defines the format of the data
  18974. * @param invertY defines if data must be stored with Y axis inverted
  18975. */
  18976. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18977. /**
  18978. * Update a raw texture
  18979. * @param texture defines the texture to update
  18980. * @param data defines the data to store in the texture
  18981. * @param format defines the format of the data
  18982. * @param invertY defines if data must be stored with Y axis inverted
  18983. * @param compression defines the compression used (null by default)
  18984. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18985. */
  18986. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  18987. /**
  18988. * Creates a new raw cube texture
  18989. * @param data defines the array of data to use to create each face
  18990. * @param size defines the size of the textures
  18991. * @param format defines the format of the data
  18992. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18993. * @param generateMipMaps defines if the engine should generate the mip levels
  18994. * @param invertY defines if data must be stored with Y axis inverted
  18995. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18996. * @param compression defines the compression used (null by default)
  18997. * @returns the cube texture as an InternalTexture
  18998. */
  18999. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  19000. /**
  19001. * Update a raw cube texture
  19002. * @param texture defines the texture to udpdate
  19003. * @param data defines the data to store
  19004. * @param format defines the data format
  19005. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  19006. * @param invertY defines if data must be stored with Y axis inverted
  19007. */
  19008. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  19009. /**
  19010. * Update a raw cube texture
  19011. * @param texture defines the texture to udpdate
  19012. * @param data defines the data to store
  19013. * @param format defines the data format
  19014. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  19015. * @param invertY defines if data must be stored with Y axis inverted
  19016. * @param compression defines the compression used (null by default)
  19017. */
  19018. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  19019. /**
  19020. * Update a raw cube texture
  19021. * @param texture defines the texture to udpdate
  19022. * @param data defines the data to store
  19023. * @param format defines the data format
  19024. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  19025. * @param invertY defines if data must be stored with Y axis inverted
  19026. * @param compression defines the compression used (null by default)
  19027. * @param level defines which level of the texture to update
  19028. */
  19029. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  19030. /**
  19031. * Creates a new raw cube texture from a specified url
  19032. * @param url defines the url where the data is located
  19033. * @param scene defines the current scene
  19034. * @param size defines the size of the textures
  19035. * @param format defines the format of the data
  19036. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  19037. * @param noMipmap defines if the engine should avoid generating the mip levels
  19038. * @param callback defines a callback used to extract texture data from loaded data
  19039. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  19040. * @param onLoad defines a callback called when texture is loaded
  19041. * @param onError defines a callback called if there is an error
  19042. * @returns the cube texture as an InternalTexture
  19043. */
  19044. 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;
  19045. /**
  19046. * Creates a new raw cube texture from a specified url
  19047. * @param url defines the url where the data is located
  19048. * @param scene defines the current scene
  19049. * @param size defines the size of the textures
  19050. * @param format defines the format of the data
  19051. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  19052. * @param noMipmap defines if the engine should avoid generating the mip levels
  19053. * @param callback defines a callback used to extract texture data from loaded data
  19054. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  19055. * @param onLoad defines a callback called when texture is loaded
  19056. * @param onError defines a callback called if there is an error
  19057. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  19058. * @param invertY defines if data must be stored with Y axis inverted
  19059. * @returns the cube texture as an InternalTexture
  19060. */
  19061. 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;
  19062. /**
  19063. * Creates a new raw 3D texture
  19064. * @param data defines the data used to create the texture
  19065. * @param width defines the width of the texture
  19066. * @param height defines the height of the texture
  19067. * @param depth defines the depth of the texture
  19068. * @param format defines the format of the texture
  19069. * @param generateMipMaps defines if the engine must generate mip levels
  19070. * @param invertY defines if data must be stored with Y axis inverted
  19071. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  19072. * @param compression defines the compressed used (can be null)
  19073. * @param textureType defines the compressed used (can be null)
  19074. * @returns a new raw 3D texture (stored in an InternalTexture)
  19075. */
  19076. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  19077. /**
  19078. * Update a raw 3D texture
  19079. * @param texture defines the texture to update
  19080. * @param data defines the data to store
  19081. * @param format defines the data format
  19082. * @param invertY defines if data must be stored with Y axis inverted
  19083. */
  19084. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  19085. /**
  19086. * Update a raw 3D texture
  19087. * @param texture defines the texture to update
  19088. * @param data defines the data to store
  19089. * @param format defines the data format
  19090. * @param invertY defines if data must be stored with Y axis inverted
  19091. * @param compression defines the used compression (can be null)
  19092. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  19093. */
  19094. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  19095. }
  19096. }
  19097. }
  19098. declare module "babylonjs/Materials/Textures/rawTexture" {
  19099. import { Scene } from "babylonjs/scene";
  19100. import { Texture } from "babylonjs/Materials/Textures/texture";
  19101. import "babylonjs/Engines/Extensions/engine.rawTexture";
  19102. /**
  19103. * Raw texture can help creating a texture directly from an array of data.
  19104. * This can be super useful if you either get the data from an uncompressed source or
  19105. * if you wish to create your texture pixel by pixel.
  19106. */
  19107. export class RawTexture extends Texture {
  19108. /**
  19109. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19110. */
  19111. format: number;
  19112. private _engine;
  19113. /**
  19114. * Instantiates a new RawTexture.
  19115. * Raw texture can help creating a texture directly from an array of data.
  19116. * This can be super useful if you either get the data from an uncompressed source or
  19117. * if you wish to create your texture pixel by pixel.
  19118. * @param data define the array of data to use to create the texture
  19119. * @param width define the width of the texture
  19120. * @param height define the height of the texture
  19121. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19122. * @param scene define the scene the texture belongs to
  19123. * @param generateMipMaps define whether mip maps should be generated or not
  19124. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19125. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19126. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19127. */
  19128. constructor(data: ArrayBufferView, width: number, height: number,
  19129. /**
  19130. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19131. */
  19132. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  19133. /**
  19134. * Updates the texture underlying data.
  19135. * @param data Define the new data of the texture
  19136. */
  19137. update(data: ArrayBufferView): void;
  19138. /**
  19139. * Creates a luminance texture from some data.
  19140. * @param data Define the texture data
  19141. * @param width Define the width of the texture
  19142. * @param height Define the height of the texture
  19143. * @param scene Define the scene the texture belongs to
  19144. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19145. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19146. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19147. * @returns the luminance texture
  19148. */
  19149. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19150. /**
  19151. * Creates a luminance alpha texture from some data.
  19152. * @param data Define the texture data
  19153. * @param width Define the width of the texture
  19154. * @param height Define the height of the texture
  19155. * @param scene Define the scene the texture belongs to
  19156. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19157. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19158. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19159. * @returns the luminance alpha texture
  19160. */
  19161. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19162. /**
  19163. * Creates an alpha texture from some data.
  19164. * @param data Define the texture data
  19165. * @param width Define the width of the texture
  19166. * @param height Define the height of the texture
  19167. * @param scene Define the scene the texture belongs to
  19168. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19169. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19170. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19171. * @returns the alpha texture
  19172. */
  19173. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19174. /**
  19175. * Creates a RGB texture from some data.
  19176. * @param data Define the texture data
  19177. * @param width Define the width of the texture
  19178. * @param height Define the height of the texture
  19179. * @param scene Define the scene the texture belongs to
  19180. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19181. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19182. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19183. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19184. * @returns the RGB alpha texture
  19185. */
  19186. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19187. /**
  19188. * Creates a RGBA texture from some data.
  19189. * @param data Define the texture data
  19190. * @param width Define the width of the texture
  19191. * @param height Define the height of the texture
  19192. * @param scene Define the scene the texture belongs to
  19193. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19194. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19195. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19196. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19197. * @returns the RGBA texture
  19198. */
  19199. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19200. /**
  19201. * Creates a R texture from some data.
  19202. * @param data Define the texture data
  19203. * @param width Define the width of the texture
  19204. * @param height Define the height of the texture
  19205. * @param scene Define the scene the texture belongs to
  19206. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19207. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19208. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19209. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19210. * @returns the R texture
  19211. */
  19212. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19213. }
  19214. }
  19215. declare module "babylonjs/Animations/runtimeAnimation" {
  19216. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  19217. import { Animatable } from "babylonjs/Animations/animatable";
  19218. import { Scene } from "babylonjs/scene";
  19219. /**
  19220. * Defines a runtime animation
  19221. */
  19222. export class RuntimeAnimation {
  19223. private _events;
  19224. /**
  19225. * The current frame of the runtime animation
  19226. */
  19227. private _currentFrame;
  19228. /**
  19229. * The animation used by the runtime animation
  19230. */
  19231. private _animation;
  19232. /**
  19233. * The target of the runtime animation
  19234. */
  19235. private _target;
  19236. /**
  19237. * The initiating animatable
  19238. */
  19239. private _host;
  19240. /**
  19241. * The original value of the runtime animation
  19242. */
  19243. private _originalValue;
  19244. /**
  19245. * The original blend value of the runtime animation
  19246. */
  19247. private _originalBlendValue;
  19248. /**
  19249. * The offsets cache of the runtime animation
  19250. */
  19251. private _offsetsCache;
  19252. /**
  19253. * The high limits cache of the runtime animation
  19254. */
  19255. private _highLimitsCache;
  19256. /**
  19257. * Specifies if the runtime animation has been stopped
  19258. */
  19259. private _stopped;
  19260. /**
  19261. * The blending factor of the runtime animation
  19262. */
  19263. private _blendingFactor;
  19264. /**
  19265. * The BabylonJS scene
  19266. */
  19267. private _scene;
  19268. /**
  19269. * The current value of the runtime animation
  19270. */
  19271. private _currentValue;
  19272. /** @hidden */
  19273. _animationState: _IAnimationState;
  19274. /**
  19275. * The active target of the runtime animation
  19276. */
  19277. private _activeTargets;
  19278. private _currentActiveTarget;
  19279. private _directTarget;
  19280. /**
  19281. * The target path of the runtime animation
  19282. */
  19283. private _targetPath;
  19284. /**
  19285. * The weight of the runtime animation
  19286. */
  19287. private _weight;
  19288. /**
  19289. * The ratio offset of the runtime animation
  19290. */
  19291. private _ratioOffset;
  19292. /**
  19293. * The previous delay of the runtime animation
  19294. */
  19295. private _previousDelay;
  19296. /**
  19297. * The previous ratio of the runtime animation
  19298. */
  19299. private _previousRatio;
  19300. private _enableBlending;
  19301. private _keys;
  19302. private _minFrame;
  19303. private _maxFrame;
  19304. private _minValue;
  19305. private _maxValue;
  19306. private _targetIsArray;
  19307. /**
  19308. * Gets the current frame of the runtime animation
  19309. */
  19310. readonly currentFrame: number;
  19311. /**
  19312. * Gets the weight of the runtime animation
  19313. */
  19314. readonly weight: number;
  19315. /**
  19316. * Gets the current value of the runtime animation
  19317. */
  19318. readonly currentValue: any;
  19319. /**
  19320. * Gets the target path of the runtime animation
  19321. */
  19322. readonly targetPath: string;
  19323. /**
  19324. * Gets the actual target of the runtime animation
  19325. */
  19326. readonly target: any;
  19327. /** @hidden */
  19328. _onLoop: () => void;
  19329. /**
  19330. * Create a new RuntimeAnimation object
  19331. * @param target defines the target of the animation
  19332. * @param animation defines the source animation object
  19333. * @param scene defines the hosting scene
  19334. * @param host defines the initiating Animatable
  19335. */
  19336. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  19337. private _preparePath;
  19338. /**
  19339. * Gets the animation from the runtime animation
  19340. */
  19341. readonly animation: Animation;
  19342. /**
  19343. * Resets the runtime animation to the beginning
  19344. * @param restoreOriginal defines whether to restore the target property to the original value
  19345. */
  19346. reset(restoreOriginal?: boolean): void;
  19347. /**
  19348. * Specifies if the runtime animation is stopped
  19349. * @returns Boolean specifying if the runtime animation is stopped
  19350. */
  19351. isStopped(): boolean;
  19352. /**
  19353. * Disposes of the runtime animation
  19354. */
  19355. dispose(): void;
  19356. /**
  19357. * Apply the interpolated value to the target
  19358. * @param currentValue defines the value computed by the animation
  19359. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  19360. */
  19361. setValue(currentValue: any, weight: number): void;
  19362. private _getOriginalValues;
  19363. private _setValue;
  19364. /**
  19365. * Gets the loop pmode of the runtime animation
  19366. * @returns Loop Mode
  19367. */
  19368. private _getCorrectLoopMode;
  19369. /**
  19370. * Move the current animation to a given frame
  19371. * @param frame defines the frame to move to
  19372. */
  19373. goToFrame(frame: number): void;
  19374. /**
  19375. * @hidden Internal use only
  19376. */
  19377. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  19378. /**
  19379. * Execute the current animation
  19380. * @param delay defines the delay to add to the current frame
  19381. * @param from defines the lower bound of the animation range
  19382. * @param to defines the upper bound of the animation range
  19383. * @param loop defines if the current animation must loop
  19384. * @param speedRatio defines the current speed ratio
  19385. * @param weight defines the weight of the animation (default is -1 so no weight)
  19386. * @param onLoop optional callback called when animation loops
  19387. * @returns a boolean indicating if the animation is running
  19388. */
  19389. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  19390. }
  19391. }
  19392. declare module "babylonjs/Animations/animatable" {
  19393. import { Animation } from "babylonjs/Animations/animation";
  19394. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  19395. import { Nullable } from "babylonjs/types";
  19396. import { Observable } from "babylonjs/Misc/observable";
  19397. import { Scene } from "babylonjs/scene";
  19398. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  19399. import { Node } from "babylonjs/node";
  19400. /**
  19401. * Class used to store an actual running animation
  19402. */
  19403. export class Animatable {
  19404. /** defines the target object */
  19405. target: any;
  19406. /** defines the starting frame number (default is 0) */
  19407. fromFrame: number;
  19408. /** defines the ending frame number (default is 100) */
  19409. toFrame: number;
  19410. /** defines if the animation must loop (default is false) */
  19411. loopAnimation: boolean;
  19412. /** defines a callback to call when animation ends if it is not looping */
  19413. onAnimationEnd?: (() => void) | null | undefined;
  19414. /** defines a callback to call when animation loops */
  19415. onAnimationLoop?: (() => void) | null | undefined;
  19416. private _localDelayOffset;
  19417. private _pausedDelay;
  19418. private _runtimeAnimations;
  19419. private _paused;
  19420. private _scene;
  19421. private _speedRatio;
  19422. private _weight;
  19423. private _syncRoot;
  19424. /**
  19425. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  19426. * This will only apply for non looping animation (default is true)
  19427. */
  19428. disposeOnEnd: boolean;
  19429. /**
  19430. * Gets a boolean indicating if the animation has started
  19431. */
  19432. animationStarted: boolean;
  19433. /**
  19434. * Observer raised when the animation ends
  19435. */
  19436. onAnimationEndObservable: Observable<Animatable>;
  19437. /**
  19438. * Observer raised when the animation loops
  19439. */
  19440. onAnimationLoopObservable: Observable<Animatable>;
  19441. /**
  19442. * Gets the root Animatable used to synchronize and normalize animations
  19443. */
  19444. readonly syncRoot: Nullable<Animatable>;
  19445. /**
  19446. * Gets the current frame of the first RuntimeAnimation
  19447. * Used to synchronize Animatables
  19448. */
  19449. readonly masterFrame: number;
  19450. /**
  19451. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  19452. */
  19453. weight: number;
  19454. /**
  19455. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  19456. */
  19457. speedRatio: number;
  19458. /**
  19459. * Creates a new Animatable
  19460. * @param scene defines the hosting scene
  19461. * @param target defines the target object
  19462. * @param fromFrame defines the starting frame number (default is 0)
  19463. * @param toFrame defines the ending frame number (default is 100)
  19464. * @param loopAnimation defines if the animation must loop (default is false)
  19465. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  19466. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  19467. * @param animations defines a group of animation to add to the new Animatable
  19468. * @param onAnimationLoop defines a callback to call when animation loops
  19469. */
  19470. constructor(scene: Scene,
  19471. /** defines the target object */
  19472. target: any,
  19473. /** defines the starting frame number (default is 0) */
  19474. fromFrame?: number,
  19475. /** defines the ending frame number (default is 100) */
  19476. toFrame?: number,
  19477. /** defines if the animation must loop (default is false) */
  19478. loopAnimation?: boolean, speedRatio?: number,
  19479. /** defines a callback to call when animation ends if it is not looping */
  19480. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  19481. /** defines a callback to call when animation loops */
  19482. onAnimationLoop?: (() => void) | null | undefined);
  19483. /**
  19484. * Synchronize and normalize current Animatable with a source Animatable
  19485. * This is useful when using animation weights and when animations are not of the same length
  19486. * @param root defines the root Animatable to synchronize with
  19487. * @returns the current Animatable
  19488. */
  19489. syncWith(root: Animatable): Animatable;
  19490. /**
  19491. * Gets the list of runtime animations
  19492. * @returns an array of RuntimeAnimation
  19493. */
  19494. getAnimations(): RuntimeAnimation[];
  19495. /**
  19496. * Adds more animations to the current animatable
  19497. * @param target defines the target of the animations
  19498. * @param animations defines the new animations to add
  19499. */
  19500. appendAnimations(target: any, animations: Animation[]): void;
  19501. /**
  19502. * Gets the source animation for a specific property
  19503. * @param property defines the propertyu to look for
  19504. * @returns null or the source animation for the given property
  19505. */
  19506. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  19507. /**
  19508. * Gets the runtime animation for a specific property
  19509. * @param property defines the propertyu to look for
  19510. * @returns null or the runtime animation for the given property
  19511. */
  19512. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  19513. /**
  19514. * Resets the animatable to its original state
  19515. */
  19516. reset(): void;
  19517. /**
  19518. * Allows the animatable to blend with current running animations
  19519. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19520. * @param blendingSpeed defines the blending speed to use
  19521. */
  19522. enableBlending(blendingSpeed: number): void;
  19523. /**
  19524. * Disable animation blending
  19525. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19526. */
  19527. disableBlending(): void;
  19528. /**
  19529. * Jump directly to a given frame
  19530. * @param frame defines the frame to jump to
  19531. */
  19532. goToFrame(frame: number): void;
  19533. /**
  19534. * Pause the animation
  19535. */
  19536. pause(): void;
  19537. /**
  19538. * Restart the animation
  19539. */
  19540. restart(): void;
  19541. private _raiseOnAnimationEnd;
  19542. /**
  19543. * Stop and delete the current animation
  19544. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  19545. * @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)
  19546. */
  19547. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  19548. /**
  19549. * Wait asynchronously for the animation to end
  19550. * @returns a promise which will be fullfilled when the animation ends
  19551. */
  19552. waitAsync(): Promise<Animatable>;
  19553. /** @hidden */
  19554. _animate(delay: number): boolean;
  19555. }
  19556. module "babylonjs/scene" {
  19557. interface Scene {
  19558. /** @hidden */
  19559. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  19560. /** @hidden */
  19561. _processLateAnimationBindingsForMatrices(holder: {
  19562. totalWeight: number;
  19563. animations: RuntimeAnimation[];
  19564. originalValue: Matrix;
  19565. }): any;
  19566. /** @hidden */
  19567. _processLateAnimationBindingsForQuaternions(holder: {
  19568. totalWeight: number;
  19569. animations: RuntimeAnimation[];
  19570. originalValue: Quaternion;
  19571. }, refQuaternion: Quaternion): Quaternion;
  19572. /** @hidden */
  19573. _processLateAnimationBindings(): void;
  19574. /**
  19575. * Will start the animation sequence of a given target
  19576. * @param target defines the target
  19577. * @param from defines from which frame should animation start
  19578. * @param to defines until which frame should animation run.
  19579. * @param weight defines the weight to apply to the animation (1.0 by default)
  19580. * @param loop defines if the animation loops
  19581. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19582. * @param onAnimationEnd defines the function to be executed when the animation ends
  19583. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19584. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19585. * @param onAnimationLoop defines the callback to call when an animation loops
  19586. * @returns the animatable object created for this animation
  19587. */
  19588. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19589. /**
  19590. * Will start the animation sequence of a given target
  19591. * @param target defines the target
  19592. * @param from defines from which frame should animation start
  19593. * @param to defines until which frame should animation run.
  19594. * @param loop defines if the animation loops
  19595. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19596. * @param onAnimationEnd defines the function to be executed when the animation ends
  19597. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19598. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19599. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  19600. * @param onAnimationLoop defines the callback to call when an animation loops
  19601. * @returns the animatable object created for this animation
  19602. */
  19603. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19604. /**
  19605. * Will start the animation sequence of a given target and its hierarchy
  19606. * @param target defines the target
  19607. * @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.
  19608. * @param from defines from which frame should animation start
  19609. * @param to defines until which frame should animation run.
  19610. * @param loop defines if the animation loops
  19611. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19612. * @param onAnimationEnd defines the function to be executed when the animation ends
  19613. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19614. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19615. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19616. * @param onAnimationLoop defines the callback to call when an animation loops
  19617. * @returns the list of created animatables
  19618. */
  19619. 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[];
  19620. /**
  19621. * Begin a new animation on a given node
  19622. * @param target defines the target where the animation will take place
  19623. * @param animations defines the list of animations to start
  19624. * @param from defines the initial value
  19625. * @param to defines the final value
  19626. * @param loop defines if you want animation to loop (off by default)
  19627. * @param speedRatio defines the speed ratio to apply to all animations
  19628. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19629. * @param onAnimationLoop defines the callback to call when an animation loops
  19630. * @returns the list of created animatables
  19631. */
  19632. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  19633. /**
  19634. * Begin a new animation on a given node and its hierarchy
  19635. * @param target defines the root node where the animation will take place
  19636. * @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.
  19637. * @param animations defines the list of animations to start
  19638. * @param from defines the initial value
  19639. * @param to defines the final value
  19640. * @param loop defines if you want animation to loop (off by default)
  19641. * @param speedRatio defines the speed ratio to apply to all animations
  19642. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19643. * @param onAnimationLoop defines the callback to call when an animation loops
  19644. * @returns the list of animatables created for all nodes
  19645. */
  19646. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  19647. /**
  19648. * Gets the animatable associated with a specific target
  19649. * @param target defines the target of the animatable
  19650. * @returns the required animatable if found
  19651. */
  19652. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19653. /**
  19654. * Gets all animatables associated with a given target
  19655. * @param target defines the target to look animatables for
  19656. * @returns an array of Animatables
  19657. */
  19658. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19659. /**
  19660. * Stops and removes all animations that have been applied to the scene
  19661. */
  19662. stopAllAnimations(): void;
  19663. }
  19664. }
  19665. module "babylonjs/Bones/bone" {
  19666. interface Bone {
  19667. /**
  19668. * Copy an animation range from another bone
  19669. * @param source defines the source bone
  19670. * @param rangeName defines the range name to copy
  19671. * @param frameOffset defines the frame offset
  19672. * @param rescaleAsRequired defines if rescaling must be applied if required
  19673. * @param skelDimensionsRatio defines the scaling ratio
  19674. * @returns true if operation was successful
  19675. */
  19676. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19677. }
  19678. }
  19679. }
  19680. declare module "babylonjs/Bones/skeleton" {
  19681. import { Bone } from "babylonjs/Bones/bone";
  19682. import { IAnimatable } from "babylonjs/Misc/tools";
  19683. import { Observable } from "babylonjs/Misc/observable";
  19684. import { Vector3, Matrix } from "babylonjs/Maths/math";
  19685. import { Scene } from "babylonjs/scene";
  19686. import { Nullable } from "babylonjs/types";
  19687. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19688. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19689. import { Animatable } from "babylonjs/Animations/animatable";
  19690. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19691. import { Animation } from "babylonjs/Animations/animation";
  19692. import { AnimationRange } from "babylonjs/Animations/animationRange";
  19693. import { IInspectable } from "babylonjs/Misc/iInspectable";
  19694. /**
  19695. * Class used to handle skinning animations
  19696. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19697. */
  19698. export class Skeleton implements IAnimatable {
  19699. /** defines the skeleton name */
  19700. name: string;
  19701. /** defines the skeleton Id */
  19702. id: string;
  19703. /**
  19704. * Defines the list of child bones
  19705. */
  19706. bones: Bone[];
  19707. /**
  19708. * Defines an estimate of the dimension of the skeleton at rest
  19709. */
  19710. dimensionsAtRest: Vector3;
  19711. /**
  19712. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19713. */
  19714. needInitialSkinMatrix: boolean;
  19715. /**
  19716. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19717. */
  19718. overrideMesh: Nullable<AbstractMesh>;
  19719. /**
  19720. * Gets the list of animations attached to this skeleton
  19721. */
  19722. animations: Array<Animation>;
  19723. private _scene;
  19724. private _isDirty;
  19725. private _transformMatrices;
  19726. private _transformMatrixTexture;
  19727. private _meshesWithPoseMatrix;
  19728. private _animatables;
  19729. private _identity;
  19730. private _synchronizedWithMesh;
  19731. private _ranges;
  19732. private _lastAbsoluteTransformsUpdateId;
  19733. private _canUseTextureForBones;
  19734. private _uniqueId;
  19735. /** @hidden */
  19736. _numBonesWithLinkedTransformNode: number;
  19737. /** @hidden */
  19738. _hasWaitingData: Nullable<boolean>;
  19739. /**
  19740. * Specifies if the skeleton should be serialized
  19741. */
  19742. doNotSerialize: boolean;
  19743. private _useTextureToStoreBoneMatrices;
  19744. /**
  19745. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19746. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19747. */
  19748. useTextureToStoreBoneMatrices: boolean;
  19749. private _animationPropertiesOverride;
  19750. /**
  19751. * Gets or sets the animation properties override
  19752. */
  19753. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19754. /**
  19755. * List of inspectable custom properties (used by the Inspector)
  19756. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19757. */
  19758. inspectableCustomProperties: IInspectable[];
  19759. /**
  19760. * An observable triggered before computing the skeleton's matrices
  19761. */
  19762. onBeforeComputeObservable: Observable<Skeleton>;
  19763. /**
  19764. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19765. */
  19766. readonly isUsingTextureForMatrices: boolean;
  19767. /**
  19768. * Gets the unique ID of this skeleton
  19769. */
  19770. readonly uniqueId: number;
  19771. /**
  19772. * Creates a new skeleton
  19773. * @param name defines the skeleton name
  19774. * @param id defines the skeleton Id
  19775. * @param scene defines the hosting scene
  19776. */
  19777. constructor(
  19778. /** defines the skeleton name */
  19779. name: string,
  19780. /** defines the skeleton Id */
  19781. id: string, scene: Scene);
  19782. /**
  19783. * Gets the current object class name.
  19784. * @return the class name
  19785. */
  19786. getClassName(): string;
  19787. /**
  19788. * Returns an array containing the root bones
  19789. * @returns an array containing the root bones
  19790. */
  19791. getChildren(): Array<Bone>;
  19792. /**
  19793. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19794. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19795. * @returns a Float32Array containing matrices data
  19796. */
  19797. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19798. /**
  19799. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19800. * @returns a raw texture containing the data
  19801. */
  19802. getTransformMatrixTexture(): Nullable<RawTexture>;
  19803. /**
  19804. * Gets the current hosting scene
  19805. * @returns a scene object
  19806. */
  19807. getScene(): Scene;
  19808. /**
  19809. * Gets a string representing the current skeleton data
  19810. * @param fullDetails defines a boolean indicating if we want a verbose version
  19811. * @returns a string representing the current skeleton data
  19812. */
  19813. toString(fullDetails?: boolean): string;
  19814. /**
  19815. * Get bone's index searching by name
  19816. * @param name defines bone's name to search for
  19817. * @return the indice of the bone. Returns -1 if not found
  19818. */
  19819. getBoneIndexByName(name: string): number;
  19820. /**
  19821. * Creater a new animation range
  19822. * @param name defines the name of the range
  19823. * @param from defines the start key
  19824. * @param to defines the end key
  19825. */
  19826. createAnimationRange(name: string, from: number, to: number): void;
  19827. /**
  19828. * Delete a specific animation range
  19829. * @param name defines the name of the range
  19830. * @param deleteFrames defines if frames must be removed as well
  19831. */
  19832. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19833. /**
  19834. * Gets a specific animation range
  19835. * @param name defines the name of the range to look for
  19836. * @returns the requested animation range or null if not found
  19837. */
  19838. getAnimationRange(name: string): Nullable<AnimationRange>;
  19839. /**
  19840. * Gets the list of all animation ranges defined on this skeleton
  19841. * @returns an array
  19842. */
  19843. getAnimationRanges(): Nullable<AnimationRange>[];
  19844. /**
  19845. * Copy animation range from a source skeleton.
  19846. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19847. * @param source defines the source skeleton
  19848. * @param name defines the name of the range to copy
  19849. * @param rescaleAsRequired defines if rescaling must be applied if required
  19850. * @returns true if operation was successful
  19851. */
  19852. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19853. /**
  19854. * Forces the skeleton to go to rest pose
  19855. */
  19856. returnToRest(): void;
  19857. private _getHighestAnimationFrame;
  19858. /**
  19859. * Begin a specific animation range
  19860. * @param name defines the name of the range to start
  19861. * @param loop defines if looping must be turned on (false by default)
  19862. * @param speedRatio defines the speed ratio to apply (1 by default)
  19863. * @param onAnimationEnd defines a callback which will be called when animation will end
  19864. * @returns a new animatable
  19865. */
  19866. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19867. /** @hidden */
  19868. _markAsDirty(): void;
  19869. /** @hidden */
  19870. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19871. /** @hidden */
  19872. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19873. private _computeTransformMatrices;
  19874. /**
  19875. * Build all resources required to render a skeleton
  19876. */
  19877. prepare(): void;
  19878. /**
  19879. * Gets the list of animatables currently running for this skeleton
  19880. * @returns an array of animatables
  19881. */
  19882. getAnimatables(): IAnimatable[];
  19883. /**
  19884. * Clone the current skeleton
  19885. * @param name defines the name of the new skeleton
  19886. * @param id defines the id of the new skeleton
  19887. * @returns the new skeleton
  19888. */
  19889. clone(name: string, id: string): Skeleton;
  19890. /**
  19891. * Enable animation blending for this skeleton
  19892. * @param blendingSpeed defines the blending speed to apply
  19893. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19894. */
  19895. enableBlending(blendingSpeed?: number): void;
  19896. /**
  19897. * Releases all resources associated with the current skeleton
  19898. */
  19899. dispose(): void;
  19900. /**
  19901. * Serialize the skeleton in a JSON object
  19902. * @returns a JSON object
  19903. */
  19904. serialize(): any;
  19905. /**
  19906. * Creates a new skeleton from serialized data
  19907. * @param parsedSkeleton defines the serialized data
  19908. * @param scene defines the hosting scene
  19909. * @returns a new skeleton
  19910. */
  19911. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19912. /**
  19913. * Compute all node absolute transforms
  19914. * @param forceUpdate defines if computation must be done even if cache is up to date
  19915. */
  19916. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19917. /**
  19918. * Gets the root pose matrix
  19919. * @returns a matrix
  19920. */
  19921. getPoseMatrix(): Nullable<Matrix>;
  19922. /**
  19923. * Sorts bones per internal index
  19924. */
  19925. sortBones(): void;
  19926. private _sortBones;
  19927. }
  19928. }
  19929. declare module "babylonjs/Morph/morphTarget" {
  19930. import { IAnimatable } from "babylonjs/Misc/tools";
  19931. import { Observable } from "babylonjs/Misc/observable";
  19932. import { Nullable, FloatArray } from "babylonjs/types";
  19933. import { Scene } from "babylonjs/scene";
  19934. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19935. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19936. /**
  19937. * Defines a target to use with MorphTargetManager
  19938. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19939. */
  19940. export class MorphTarget implements IAnimatable {
  19941. /** defines the name of the target */
  19942. name: string;
  19943. /**
  19944. * Gets or sets the list of animations
  19945. */
  19946. animations: import("babylonjs/Animations/animation").Animation[];
  19947. private _scene;
  19948. private _positions;
  19949. private _normals;
  19950. private _tangents;
  19951. private _influence;
  19952. /**
  19953. * Observable raised when the influence changes
  19954. */
  19955. onInfluenceChanged: Observable<boolean>;
  19956. /** @hidden */
  19957. _onDataLayoutChanged: Observable<void>;
  19958. /**
  19959. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19960. */
  19961. influence: number;
  19962. /**
  19963. * Gets or sets the id of the morph Target
  19964. */
  19965. id: string;
  19966. private _animationPropertiesOverride;
  19967. /**
  19968. * Gets or sets the animation properties override
  19969. */
  19970. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19971. /**
  19972. * Creates a new MorphTarget
  19973. * @param name defines the name of the target
  19974. * @param influence defines the influence to use
  19975. * @param scene defines the scene the morphtarget belongs to
  19976. */
  19977. constructor(
  19978. /** defines the name of the target */
  19979. name: string, influence?: number, scene?: Nullable<Scene>);
  19980. /**
  19981. * Gets a boolean defining if the target contains position data
  19982. */
  19983. readonly hasPositions: boolean;
  19984. /**
  19985. * Gets a boolean defining if the target contains normal data
  19986. */
  19987. readonly hasNormals: boolean;
  19988. /**
  19989. * Gets a boolean defining if the target contains tangent data
  19990. */
  19991. readonly hasTangents: boolean;
  19992. /**
  19993. * Affects position data to this target
  19994. * @param data defines the position data to use
  19995. */
  19996. setPositions(data: Nullable<FloatArray>): void;
  19997. /**
  19998. * Gets the position data stored in this target
  19999. * @returns a FloatArray containing the position data (or null if not present)
  20000. */
  20001. getPositions(): Nullable<FloatArray>;
  20002. /**
  20003. * Affects normal data to this target
  20004. * @param data defines the normal data to use
  20005. */
  20006. setNormals(data: Nullable<FloatArray>): void;
  20007. /**
  20008. * Gets the normal data stored in this target
  20009. * @returns a FloatArray containing the normal data (or null if not present)
  20010. */
  20011. getNormals(): Nullable<FloatArray>;
  20012. /**
  20013. * Affects tangent data to this target
  20014. * @param data defines the tangent data to use
  20015. */
  20016. setTangents(data: Nullable<FloatArray>): void;
  20017. /**
  20018. * Gets the tangent data stored in this target
  20019. * @returns a FloatArray containing the tangent data (or null if not present)
  20020. */
  20021. getTangents(): Nullable<FloatArray>;
  20022. /**
  20023. * Serializes the current target into a Serialization object
  20024. * @returns the serialized object
  20025. */
  20026. serialize(): any;
  20027. /**
  20028. * Returns the string "MorphTarget"
  20029. * @returns "MorphTarget"
  20030. */
  20031. getClassName(): string;
  20032. /**
  20033. * Creates a new target from serialized data
  20034. * @param serializationObject defines the serialized data to use
  20035. * @returns a new MorphTarget
  20036. */
  20037. static Parse(serializationObject: any): MorphTarget;
  20038. /**
  20039. * Creates a MorphTarget from mesh data
  20040. * @param mesh defines the source mesh
  20041. * @param name defines the name to use for the new target
  20042. * @param influence defines the influence to attach to the target
  20043. * @returns a new MorphTarget
  20044. */
  20045. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  20046. }
  20047. }
  20048. declare module "babylonjs/Morph/morphTargetManager" {
  20049. import { Nullable } from "babylonjs/types";
  20050. import { Scene } from "babylonjs/scene";
  20051. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  20052. /**
  20053. * This class is used to deform meshes using morphing between different targets
  20054. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20055. */
  20056. export class MorphTargetManager {
  20057. private _targets;
  20058. private _targetInfluenceChangedObservers;
  20059. private _targetDataLayoutChangedObservers;
  20060. private _activeTargets;
  20061. private _scene;
  20062. private _influences;
  20063. private _supportsNormals;
  20064. private _supportsTangents;
  20065. private _vertexCount;
  20066. private _uniqueId;
  20067. private _tempInfluences;
  20068. /**
  20069. * Creates a new MorphTargetManager
  20070. * @param scene defines the current scene
  20071. */
  20072. constructor(scene?: Nullable<Scene>);
  20073. /**
  20074. * Gets the unique ID of this manager
  20075. */
  20076. readonly uniqueId: number;
  20077. /**
  20078. * Gets the number of vertices handled by this manager
  20079. */
  20080. readonly vertexCount: number;
  20081. /**
  20082. * Gets a boolean indicating if this manager supports morphing of normals
  20083. */
  20084. readonly supportsNormals: boolean;
  20085. /**
  20086. * Gets a boolean indicating if this manager supports morphing of tangents
  20087. */
  20088. readonly supportsTangents: boolean;
  20089. /**
  20090. * Gets the number of targets stored in this manager
  20091. */
  20092. readonly numTargets: number;
  20093. /**
  20094. * Gets the number of influencers (ie. the number of targets with influences > 0)
  20095. */
  20096. readonly numInfluencers: number;
  20097. /**
  20098. * Gets the list of influences (one per target)
  20099. */
  20100. readonly influences: Float32Array;
  20101. /**
  20102. * Gets the active target at specified index. An active target is a target with an influence > 0
  20103. * @param index defines the index to check
  20104. * @returns the requested target
  20105. */
  20106. getActiveTarget(index: number): MorphTarget;
  20107. /**
  20108. * Gets the target at specified index
  20109. * @param index defines the index to check
  20110. * @returns the requested target
  20111. */
  20112. getTarget(index: number): MorphTarget;
  20113. /**
  20114. * Add a new target to this manager
  20115. * @param target defines the target to add
  20116. */
  20117. addTarget(target: MorphTarget): void;
  20118. /**
  20119. * Removes a target from the manager
  20120. * @param target defines the target to remove
  20121. */
  20122. removeTarget(target: MorphTarget): void;
  20123. /**
  20124. * Serializes the current manager into a Serialization object
  20125. * @returns the serialized object
  20126. */
  20127. serialize(): any;
  20128. private _syncActiveTargets;
  20129. /**
  20130. * Syncrhonize the targets with all the meshes using this morph target manager
  20131. */
  20132. synchronize(): void;
  20133. /**
  20134. * Creates a new MorphTargetManager from serialized data
  20135. * @param serializationObject defines the serialized data
  20136. * @param scene defines the hosting scene
  20137. * @returns the new MorphTargetManager
  20138. */
  20139. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  20140. }
  20141. }
  20142. declare module "babylonjs/Meshes/meshLODLevel" {
  20143. import { Mesh } from "babylonjs/Meshes/mesh";
  20144. import { Nullable } from "babylonjs/types";
  20145. /**
  20146. * Class used to represent a specific level of detail of a mesh
  20147. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20148. */
  20149. export class MeshLODLevel {
  20150. /** Defines the distance where this level should star being displayed */
  20151. distance: number;
  20152. /** Defines the mesh to use to render this level */
  20153. mesh: Nullable<Mesh>;
  20154. /**
  20155. * Creates a new LOD level
  20156. * @param distance defines the distance where this level should star being displayed
  20157. * @param mesh defines the mesh to use to render this level
  20158. */
  20159. constructor(
  20160. /** Defines the distance where this level should star being displayed */
  20161. distance: number,
  20162. /** Defines the mesh to use to render this level */
  20163. mesh: Nullable<Mesh>);
  20164. }
  20165. }
  20166. declare module "babylonjs/Meshes/groundMesh" {
  20167. import { Scene } from "babylonjs/scene";
  20168. import { Vector3 } from "babylonjs/Maths/math";
  20169. import { Mesh } from "babylonjs/Meshes/mesh";
  20170. /**
  20171. * Mesh representing the gorund
  20172. */
  20173. export class GroundMesh extends Mesh {
  20174. /** If octree should be generated */
  20175. generateOctree: boolean;
  20176. private _heightQuads;
  20177. /** @hidden */
  20178. _subdivisionsX: number;
  20179. /** @hidden */
  20180. _subdivisionsY: number;
  20181. /** @hidden */
  20182. _width: number;
  20183. /** @hidden */
  20184. _height: number;
  20185. /** @hidden */
  20186. _minX: number;
  20187. /** @hidden */
  20188. _maxX: number;
  20189. /** @hidden */
  20190. _minZ: number;
  20191. /** @hidden */
  20192. _maxZ: number;
  20193. constructor(name: string, scene: Scene);
  20194. /**
  20195. * "GroundMesh"
  20196. * @returns "GroundMesh"
  20197. */
  20198. getClassName(): string;
  20199. /**
  20200. * The minimum of x and y subdivisions
  20201. */
  20202. readonly subdivisions: number;
  20203. /**
  20204. * X subdivisions
  20205. */
  20206. readonly subdivisionsX: number;
  20207. /**
  20208. * Y subdivisions
  20209. */
  20210. readonly subdivisionsY: number;
  20211. /**
  20212. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  20213. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  20214. * @param chunksCount the number of subdivisions for x and y
  20215. * @param octreeBlocksSize (Default: 32)
  20216. */
  20217. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  20218. /**
  20219. * Returns a height (y) value in the Worl system :
  20220. * the ground altitude at the coordinates (x, z) expressed in the World system.
  20221. * @param x x coordinate
  20222. * @param z z coordinate
  20223. * @returns the ground y position if (x, z) are outside the ground surface.
  20224. */
  20225. getHeightAtCoordinates(x: number, z: number): number;
  20226. /**
  20227. * Returns a normalized vector (Vector3) orthogonal to the ground
  20228. * at the ground coordinates (x, z) expressed in the World system.
  20229. * @param x x coordinate
  20230. * @param z z coordinate
  20231. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  20232. */
  20233. getNormalAtCoordinates(x: number, z: number): Vector3;
  20234. /**
  20235. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  20236. * at the ground coordinates (x, z) expressed in the World system.
  20237. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  20238. * @param x x coordinate
  20239. * @param z z coordinate
  20240. * @param ref vector to store the result
  20241. * @returns the GroundMesh.
  20242. */
  20243. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  20244. /**
  20245. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  20246. * if the ground has been updated.
  20247. * This can be used in the render loop.
  20248. * @returns the GroundMesh.
  20249. */
  20250. updateCoordinateHeights(): GroundMesh;
  20251. private _getFacetAt;
  20252. private _initHeightQuads;
  20253. private _computeHeightQuads;
  20254. /**
  20255. * Serializes this ground mesh
  20256. * @param serializationObject object to write serialization to
  20257. */
  20258. serialize(serializationObject: any): void;
  20259. /**
  20260. * Parses a serialized ground mesh
  20261. * @param parsedMesh the serialized mesh
  20262. * @param scene the scene to create the ground mesh in
  20263. * @returns the created ground mesh
  20264. */
  20265. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  20266. }
  20267. }
  20268. declare module "babylonjs/Physics/physicsJoint" {
  20269. import { Vector3 } from "babylonjs/Maths/math";
  20270. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  20271. /**
  20272. * Interface for Physics-Joint data
  20273. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20274. */
  20275. export interface PhysicsJointData {
  20276. /**
  20277. * The main pivot of the joint
  20278. */
  20279. mainPivot?: Vector3;
  20280. /**
  20281. * The connected pivot of the joint
  20282. */
  20283. connectedPivot?: Vector3;
  20284. /**
  20285. * The main axis of the joint
  20286. */
  20287. mainAxis?: Vector3;
  20288. /**
  20289. * The connected axis of the joint
  20290. */
  20291. connectedAxis?: Vector3;
  20292. /**
  20293. * The collision of the joint
  20294. */
  20295. collision?: boolean;
  20296. /**
  20297. * Native Oimo/Cannon/Energy data
  20298. */
  20299. nativeParams?: any;
  20300. }
  20301. /**
  20302. * This is a holder class for the physics joint created by the physics plugin
  20303. * It holds a set of functions to control the underlying joint
  20304. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20305. */
  20306. export class PhysicsJoint {
  20307. /**
  20308. * The type of the physics joint
  20309. */
  20310. type: number;
  20311. /**
  20312. * The data for the physics joint
  20313. */
  20314. jointData: PhysicsJointData;
  20315. private _physicsJoint;
  20316. protected _physicsPlugin: IPhysicsEnginePlugin;
  20317. /**
  20318. * Initializes the physics joint
  20319. * @param type The type of the physics joint
  20320. * @param jointData The data for the physics joint
  20321. */
  20322. constructor(
  20323. /**
  20324. * The type of the physics joint
  20325. */
  20326. type: number,
  20327. /**
  20328. * The data for the physics joint
  20329. */
  20330. jointData: PhysicsJointData);
  20331. /**
  20332. * Gets the physics joint
  20333. */
  20334. /**
  20335. * Sets the physics joint
  20336. */
  20337. physicsJoint: any;
  20338. /**
  20339. * Sets the physics plugin
  20340. */
  20341. physicsPlugin: IPhysicsEnginePlugin;
  20342. /**
  20343. * Execute a function that is physics-plugin specific.
  20344. * @param {Function} func the function that will be executed.
  20345. * It accepts two parameters: the physics world and the physics joint
  20346. */
  20347. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  20348. /**
  20349. * Distance-Joint type
  20350. */
  20351. static DistanceJoint: number;
  20352. /**
  20353. * Hinge-Joint type
  20354. */
  20355. static HingeJoint: number;
  20356. /**
  20357. * Ball-and-Socket joint type
  20358. */
  20359. static BallAndSocketJoint: number;
  20360. /**
  20361. * Wheel-Joint type
  20362. */
  20363. static WheelJoint: number;
  20364. /**
  20365. * Slider-Joint type
  20366. */
  20367. static SliderJoint: number;
  20368. /**
  20369. * Prismatic-Joint type
  20370. */
  20371. static PrismaticJoint: number;
  20372. /**
  20373. * Universal-Joint type
  20374. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  20375. */
  20376. static UniversalJoint: number;
  20377. /**
  20378. * Hinge-Joint 2 type
  20379. */
  20380. static Hinge2Joint: number;
  20381. /**
  20382. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  20383. */
  20384. static PointToPointJoint: number;
  20385. /**
  20386. * Spring-Joint type
  20387. */
  20388. static SpringJoint: number;
  20389. /**
  20390. * Lock-Joint type
  20391. */
  20392. static LockJoint: number;
  20393. }
  20394. /**
  20395. * A class representing a physics distance joint
  20396. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20397. */
  20398. export class DistanceJoint extends PhysicsJoint {
  20399. /**
  20400. *
  20401. * @param jointData The data for the Distance-Joint
  20402. */
  20403. constructor(jointData: DistanceJointData);
  20404. /**
  20405. * Update the predefined distance.
  20406. * @param maxDistance The maximum preferred distance
  20407. * @param minDistance The minimum preferred distance
  20408. */
  20409. updateDistance(maxDistance: number, minDistance?: number): void;
  20410. }
  20411. /**
  20412. * Represents a Motor-Enabled Joint
  20413. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20414. */
  20415. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  20416. /**
  20417. * Initializes the Motor-Enabled Joint
  20418. * @param type The type of the joint
  20419. * @param jointData The physica joint data for the joint
  20420. */
  20421. constructor(type: number, jointData: PhysicsJointData);
  20422. /**
  20423. * Set the motor values.
  20424. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20425. * @param force the force to apply
  20426. * @param maxForce max force for this motor.
  20427. */
  20428. setMotor(force?: number, maxForce?: number): void;
  20429. /**
  20430. * Set the motor's limits.
  20431. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20432. * @param upperLimit The upper limit of the motor
  20433. * @param lowerLimit The lower limit of the motor
  20434. */
  20435. setLimit(upperLimit: number, lowerLimit?: number): void;
  20436. }
  20437. /**
  20438. * This class represents a single physics Hinge-Joint
  20439. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20440. */
  20441. export class HingeJoint extends MotorEnabledJoint {
  20442. /**
  20443. * Initializes the Hinge-Joint
  20444. * @param jointData The joint data for the Hinge-Joint
  20445. */
  20446. constructor(jointData: PhysicsJointData);
  20447. /**
  20448. * Set the motor values.
  20449. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20450. * @param {number} force the force to apply
  20451. * @param {number} maxForce max force for this motor.
  20452. */
  20453. setMotor(force?: number, maxForce?: number): void;
  20454. /**
  20455. * Set the motor's limits.
  20456. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20457. * @param upperLimit The upper limit of the motor
  20458. * @param lowerLimit The lower limit of the motor
  20459. */
  20460. setLimit(upperLimit: number, lowerLimit?: number): void;
  20461. }
  20462. /**
  20463. * This class represents a dual hinge physics joint (same as wheel joint)
  20464. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20465. */
  20466. export class Hinge2Joint extends MotorEnabledJoint {
  20467. /**
  20468. * Initializes the Hinge2-Joint
  20469. * @param jointData The joint data for the Hinge2-Joint
  20470. */
  20471. constructor(jointData: PhysicsJointData);
  20472. /**
  20473. * Set the motor values.
  20474. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20475. * @param {number} targetSpeed the speed the motor is to reach
  20476. * @param {number} maxForce max force for this motor.
  20477. * @param {motorIndex} the motor's index, 0 or 1.
  20478. */
  20479. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  20480. /**
  20481. * Set the motor limits.
  20482. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20483. * @param {number} upperLimit the upper limit
  20484. * @param {number} lowerLimit lower limit
  20485. * @param {motorIndex} the motor's index, 0 or 1.
  20486. */
  20487. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20488. }
  20489. /**
  20490. * Interface for a motor enabled joint
  20491. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20492. */
  20493. export interface IMotorEnabledJoint {
  20494. /**
  20495. * Physics joint
  20496. */
  20497. physicsJoint: any;
  20498. /**
  20499. * Sets the motor of the motor-enabled joint
  20500. * @param force The force of the motor
  20501. * @param maxForce The maximum force of the motor
  20502. * @param motorIndex The index of the motor
  20503. */
  20504. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  20505. /**
  20506. * Sets the limit of the motor
  20507. * @param upperLimit The upper limit of the motor
  20508. * @param lowerLimit The lower limit of the motor
  20509. * @param motorIndex The index of the motor
  20510. */
  20511. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20512. }
  20513. /**
  20514. * Joint data for a Distance-Joint
  20515. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20516. */
  20517. export interface DistanceJointData extends PhysicsJointData {
  20518. /**
  20519. * Max distance the 2 joint objects can be apart
  20520. */
  20521. maxDistance: number;
  20522. }
  20523. /**
  20524. * Joint data from a spring joint
  20525. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20526. */
  20527. export interface SpringJointData extends PhysicsJointData {
  20528. /**
  20529. * Length of the spring
  20530. */
  20531. length: number;
  20532. /**
  20533. * Stiffness of the spring
  20534. */
  20535. stiffness: number;
  20536. /**
  20537. * Damping of the spring
  20538. */
  20539. damping: number;
  20540. /** this callback will be called when applying the force to the impostors. */
  20541. forceApplicationCallback: () => void;
  20542. }
  20543. }
  20544. declare module "babylonjs/Physics/physicsRaycastResult" {
  20545. import { Vector3 } from "babylonjs/Maths/math";
  20546. /**
  20547. * Holds the data for the raycast result
  20548. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20549. */
  20550. export class PhysicsRaycastResult {
  20551. private _hasHit;
  20552. private _hitDistance;
  20553. private _hitNormalWorld;
  20554. private _hitPointWorld;
  20555. private _rayFromWorld;
  20556. private _rayToWorld;
  20557. /**
  20558. * Gets if there was a hit
  20559. */
  20560. readonly hasHit: boolean;
  20561. /**
  20562. * Gets the distance from the hit
  20563. */
  20564. readonly hitDistance: number;
  20565. /**
  20566. * Gets the hit normal/direction in the world
  20567. */
  20568. readonly hitNormalWorld: Vector3;
  20569. /**
  20570. * Gets the hit point in the world
  20571. */
  20572. readonly hitPointWorld: Vector3;
  20573. /**
  20574. * Gets the ray "start point" of the ray in the world
  20575. */
  20576. readonly rayFromWorld: Vector3;
  20577. /**
  20578. * Gets the ray "end point" of the ray in the world
  20579. */
  20580. readonly rayToWorld: Vector3;
  20581. /**
  20582. * Sets the hit data (normal & point in world space)
  20583. * @param hitNormalWorld defines the normal in world space
  20584. * @param hitPointWorld defines the point in world space
  20585. */
  20586. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  20587. /**
  20588. * Sets the distance from the start point to the hit point
  20589. * @param distance
  20590. */
  20591. setHitDistance(distance: number): void;
  20592. /**
  20593. * Calculates the distance manually
  20594. */
  20595. calculateHitDistance(): void;
  20596. /**
  20597. * Resets all the values to default
  20598. * @param from The from point on world space
  20599. * @param to The to point on world space
  20600. */
  20601. reset(from?: Vector3, to?: Vector3): void;
  20602. }
  20603. /**
  20604. * Interface for the size containing width and height
  20605. */
  20606. interface IXYZ {
  20607. /**
  20608. * X
  20609. */
  20610. x: number;
  20611. /**
  20612. * Y
  20613. */
  20614. y: number;
  20615. /**
  20616. * Z
  20617. */
  20618. z: number;
  20619. }
  20620. }
  20621. declare module "babylonjs/Physics/IPhysicsEngine" {
  20622. import { Nullable } from "babylonjs/types";
  20623. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  20624. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20625. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20626. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  20627. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  20628. /**
  20629. * Interface used to describe a physics joint
  20630. */
  20631. export interface PhysicsImpostorJoint {
  20632. /** Defines the main impostor to which the joint is linked */
  20633. mainImpostor: PhysicsImpostor;
  20634. /** Defines the impostor that is connected to the main impostor using this joint */
  20635. connectedImpostor: PhysicsImpostor;
  20636. /** Defines the joint itself */
  20637. joint: PhysicsJoint;
  20638. }
  20639. /** @hidden */
  20640. export interface IPhysicsEnginePlugin {
  20641. world: any;
  20642. name: string;
  20643. setGravity(gravity: Vector3): void;
  20644. setTimeStep(timeStep: number): void;
  20645. getTimeStep(): number;
  20646. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  20647. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20648. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20649. generatePhysicsBody(impostor: PhysicsImpostor): void;
  20650. removePhysicsBody(impostor: PhysicsImpostor): void;
  20651. generateJoint(joint: PhysicsImpostorJoint): void;
  20652. removeJoint(joint: PhysicsImpostorJoint): void;
  20653. isSupported(): boolean;
  20654. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  20655. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  20656. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20657. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20658. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20659. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20660. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  20661. getBodyMass(impostor: PhysicsImpostor): number;
  20662. getBodyFriction(impostor: PhysicsImpostor): number;
  20663. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  20664. getBodyRestitution(impostor: PhysicsImpostor): number;
  20665. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  20666. getBodyPressure?(impostor: PhysicsImpostor): number;
  20667. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  20668. getBodyStiffness?(impostor: PhysicsImpostor): number;
  20669. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  20670. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  20671. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  20672. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  20673. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  20674. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20675. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20676. sleepBody(impostor: PhysicsImpostor): void;
  20677. wakeUpBody(impostor: PhysicsImpostor): void;
  20678. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20679. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  20680. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20681. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20682. getRadius(impostor: PhysicsImpostor): number;
  20683. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20684. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20685. dispose(): void;
  20686. }
  20687. /**
  20688. * Interface used to define a physics engine
  20689. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20690. */
  20691. export interface IPhysicsEngine {
  20692. /**
  20693. * Gets the gravity vector used by the simulation
  20694. */
  20695. gravity: Vector3;
  20696. /**
  20697. * Sets the gravity vector used by the simulation
  20698. * @param gravity defines the gravity vector to use
  20699. */
  20700. setGravity(gravity: Vector3): void;
  20701. /**
  20702. * Set the time step of the physics engine.
  20703. * Default is 1/60.
  20704. * To slow it down, enter 1/600 for example.
  20705. * To speed it up, 1/30
  20706. * @param newTimeStep the new timestep to apply to this world.
  20707. */
  20708. setTimeStep(newTimeStep: number): void;
  20709. /**
  20710. * Get the time step of the physics engine.
  20711. * @returns the current time step
  20712. */
  20713. getTimeStep(): number;
  20714. /**
  20715. * Release all resources
  20716. */
  20717. dispose(): void;
  20718. /**
  20719. * Gets the name of the current physics plugin
  20720. * @returns the name of the plugin
  20721. */
  20722. getPhysicsPluginName(): string;
  20723. /**
  20724. * Adding a new impostor for the impostor tracking.
  20725. * This will be done by the impostor itself.
  20726. * @param impostor the impostor to add
  20727. */
  20728. addImpostor(impostor: PhysicsImpostor): void;
  20729. /**
  20730. * Remove an impostor from the engine.
  20731. * This impostor and its mesh will not longer be updated by the physics engine.
  20732. * @param impostor the impostor to remove
  20733. */
  20734. removeImpostor(impostor: PhysicsImpostor): void;
  20735. /**
  20736. * Add a joint to the physics engine
  20737. * @param mainImpostor defines the main impostor to which the joint is added.
  20738. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20739. * @param joint defines the joint that will connect both impostors.
  20740. */
  20741. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20742. /**
  20743. * Removes a joint from the simulation
  20744. * @param mainImpostor defines the impostor used with the joint
  20745. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20746. * @param joint defines the joint to remove
  20747. */
  20748. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20749. /**
  20750. * Gets the current plugin used to run the simulation
  20751. * @returns current plugin
  20752. */
  20753. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20754. /**
  20755. * Gets the list of physic impostors
  20756. * @returns an array of PhysicsImpostor
  20757. */
  20758. getImpostors(): Array<PhysicsImpostor>;
  20759. /**
  20760. * Gets the impostor for a physics enabled object
  20761. * @param object defines the object impersonated by the impostor
  20762. * @returns the PhysicsImpostor or null if not found
  20763. */
  20764. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20765. /**
  20766. * Gets the impostor for a physics body object
  20767. * @param body defines physics body used by the impostor
  20768. * @returns the PhysicsImpostor or null if not found
  20769. */
  20770. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20771. /**
  20772. * Does a raycast in the physics world
  20773. * @param from when should the ray start?
  20774. * @param to when should the ray end?
  20775. * @returns PhysicsRaycastResult
  20776. */
  20777. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20778. /**
  20779. * Called by the scene. No need to call it.
  20780. * @param delta defines the timespam between frames
  20781. */
  20782. _step(delta: number): void;
  20783. }
  20784. }
  20785. declare module "babylonjs/Physics/physicsImpostor" {
  20786. import { Nullable, IndicesArray } from "babylonjs/types";
  20787. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  20788. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20789. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20790. import { Scene } from "babylonjs/scene";
  20791. import { Bone } from "babylonjs/Bones/bone";
  20792. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  20793. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  20794. /**
  20795. * The interface for the physics imposter parameters
  20796. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20797. */
  20798. export interface PhysicsImpostorParameters {
  20799. /**
  20800. * The mass of the physics imposter
  20801. */
  20802. mass: number;
  20803. /**
  20804. * The friction of the physics imposter
  20805. */
  20806. friction?: number;
  20807. /**
  20808. * The coefficient of restitution of the physics imposter
  20809. */
  20810. restitution?: number;
  20811. /**
  20812. * The native options of the physics imposter
  20813. */
  20814. nativeOptions?: any;
  20815. /**
  20816. * Specifies if the parent should be ignored
  20817. */
  20818. ignoreParent?: boolean;
  20819. /**
  20820. * Specifies if bi-directional transformations should be disabled
  20821. */
  20822. disableBidirectionalTransformation?: boolean;
  20823. /**
  20824. * The pressure inside the physics imposter, soft object only
  20825. */
  20826. pressure?: number;
  20827. /**
  20828. * The stiffness the physics imposter, soft object only
  20829. */
  20830. stiffness?: number;
  20831. /**
  20832. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20833. */
  20834. velocityIterations?: number;
  20835. /**
  20836. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20837. */
  20838. positionIterations?: number;
  20839. /**
  20840. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20841. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20842. * Add to fix multiple points
  20843. */
  20844. fixedPoints?: number;
  20845. /**
  20846. * The collision margin around a soft object
  20847. */
  20848. margin?: number;
  20849. /**
  20850. * The collision margin around a soft object
  20851. */
  20852. damping?: number;
  20853. /**
  20854. * The path for a rope based on an extrusion
  20855. */
  20856. path?: any;
  20857. /**
  20858. * The shape of an extrusion used for a rope based on an extrusion
  20859. */
  20860. shape?: any;
  20861. }
  20862. /**
  20863. * Interface for a physics-enabled object
  20864. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20865. */
  20866. export interface IPhysicsEnabledObject {
  20867. /**
  20868. * The position of the physics-enabled object
  20869. */
  20870. position: Vector3;
  20871. /**
  20872. * The rotation of the physics-enabled object
  20873. */
  20874. rotationQuaternion: Nullable<Quaternion>;
  20875. /**
  20876. * The scale of the physics-enabled object
  20877. */
  20878. scaling: Vector3;
  20879. /**
  20880. * The rotation of the physics-enabled object
  20881. */
  20882. rotation?: Vector3;
  20883. /**
  20884. * The parent of the physics-enabled object
  20885. */
  20886. parent?: any;
  20887. /**
  20888. * The bounding info of the physics-enabled object
  20889. * @returns The bounding info of the physics-enabled object
  20890. */
  20891. getBoundingInfo(): BoundingInfo;
  20892. /**
  20893. * Computes the world matrix
  20894. * @param force Specifies if the world matrix should be computed by force
  20895. * @returns A world matrix
  20896. */
  20897. computeWorldMatrix(force: boolean): Matrix;
  20898. /**
  20899. * Gets the world matrix
  20900. * @returns A world matrix
  20901. */
  20902. getWorldMatrix?(): Matrix;
  20903. /**
  20904. * Gets the child meshes
  20905. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20906. * @returns An array of abstract meshes
  20907. */
  20908. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20909. /**
  20910. * Gets the vertex data
  20911. * @param kind The type of vertex data
  20912. * @returns A nullable array of numbers, or a float32 array
  20913. */
  20914. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20915. /**
  20916. * Gets the indices from the mesh
  20917. * @returns A nullable array of index arrays
  20918. */
  20919. getIndices?(): Nullable<IndicesArray>;
  20920. /**
  20921. * Gets the scene from the mesh
  20922. * @returns the indices array or null
  20923. */
  20924. getScene?(): Scene;
  20925. /**
  20926. * Gets the absolute position from the mesh
  20927. * @returns the absolute position
  20928. */
  20929. getAbsolutePosition(): Vector3;
  20930. /**
  20931. * Gets the absolute pivot point from the mesh
  20932. * @returns the absolute pivot point
  20933. */
  20934. getAbsolutePivotPoint(): Vector3;
  20935. /**
  20936. * Rotates the mesh
  20937. * @param axis The axis of rotation
  20938. * @param amount The amount of rotation
  20939. * @param space The space of the rotation
  20940. * @returns The rotation transform node
  20941. */
  20942. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20943. /**
  20944. * Translates the mesh
  20945. * @param axis The axis of translation
  20946. * @param distance The distance of translation
  20947. * @param space The space of the translation
  20948. * @returns The transform node
  20949. */
  20950. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20951. /**
  20952. * Sets the absolute position of the mesh
  20953. * @param absolutePosition The absolute position of the mesh
  20954. * @returns The transform node
  20955. */
  20956. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20957. /**
  20958. * Gets the class name of the mesh
  20959. * @returns The class name
  20960. */
  20961. getClassName(): string;
  20962. }
  20963. /**
  20964. * Represents a physics imposter
  20965. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20966. */
  20967. export class PhysicsImpostor {
  20968. /**
  20969. * The physics-enabled object used as the physics imposter
  20970. */
  20971. object: IPhysicsEnabledObject;
  20972. /**
  20973. * The type of the physics imposter
  20974. */
  20975. type: number;
  20976. private _options;
  20977. private _scene?;
  20978. /**
  20979. * The default object size of the imposter
  20980. */
  20981. static DEFAULT_OBJECT_SIZE: Vector3;
  20982. /**
  20983. * The identity quaternion of the imposter
  20984. */
  20985. static IDENTITY_QUATERNION: Quaternion;
  20986. /** @hidden */
  20987. _pluginData: any;
  20988. private _physicsEngine;
  20989. private _physicsBody;
  20990. private _bodyUpdateRequired;
  20991. private _onBeforePhysicsStepCallbacks;
  20992. private _onAfterPhysicsStepCallbacks;
  20993. /** @hidden */
  20994. _onPhysicsCollideCallbacks: Array<{
  20995. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20996. otherImpostors: Array<PhysicsImpostor>;
  20997. }>;
  20998. private _deltaPosition;
  20999. private _deltaRotation;
  21000. private _deltaRotationConjugated;
  21001. /** @hidden */
  21002. _isFromLine: boolean;
  21003. private _parent;
  21004. private _isDisposed;
  21005. private static _tmpVecs;
  21006. private static _tmpQuat;
  21007. /**
  21008. * Specifies if the physics imposter is disposed
  21009. */
  21010. readonly isDisposed: boolean;
  21011. /**
  21012. * Gets the mass of the physics imposter
  21013. */
  21014. mass: number;
  21015. /**
  21016. * Gets the coefficient of friction
  21017. */
  21018. /**
  21019. * Sets the coefficient of friction
  21020. */
  21021. friction: number;
  21022. /**
  21023. * Gets the coefficient of restitution
  21024. */
  21025. /**
  21026. * Sets the coefficient of restitution
  21027. */
  21028. restitution: number;
  21029. /**
  21030. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  21031. */
  21032. /**
  21033. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  21034. */
  21035. pressure: number;
  21036. /**
  21037. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  21038. */
  21039. /**
  21040. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  21041. */
  21042. stiffness: number;
  21043. /**
  21044. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  21045. */
  21046. /**
  21047. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  21048. */
  21049. velocityIterations: number;
  21050. /**
  21051. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  21052. */
  21053. /**
  21054. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  21055. */
  21056. positionIterations: number;
  21057. /**
  21058. * The unique id of the physics imposter
  21059. * set by the physics engine when adding this impostor to the array
  21060. */
  21061. uniqueId: number;
  21062. /**
  21063. * @hidden
  21064. */
  21065. soft: boolean;
  21066. /**
  21067. * @hidden
  21068. */
  21069. segments: number;
  21070. private _joints;
  21071. /**
  21072. * Initializes the physics imposter
  21073. * @param object The physics-enabled object used as the physics imposter
  21074. * @param type The type of the physics imposter
  21075. * @param _options The options for the physics imposter
  21076. * @param _scene The Babylon scene
  21077. */
  21078. constructor(
  21079. /**
  21080. * The physics-enabled object used as the physics imposter
  21081. */
  21082. object: IPhysicsEnabledObject,
  21083. /**
  21084. * The type of the physics imposter
  21085. */
  21086. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  21087. /**
  21088. * This function will completly initialize this impostor.
  21089. * It will create a new body - but only if this mesh has no parent.
  21090. * If it has, this impostor will not be used other than to define the impostor
  21091. * of the child mesh.
  21092. * @hidden
  21093. */
  21094. _init(): void;
  21095. private _getPhysicsParent;
  21096. /**
  21097. * Should a new body be generated.
  21098. * @returns boolean specifying if body initialization is required
  21099. */
  21100. isBodyInitRequired(): boolean;
  21101. /**
  21102. * Sets the updated scaling
  21103. * @param updated Specifies if the scaling is updated
  21104. */
  21105. setScalingUpdated(): void;
  21106. /**
  21107. * Force a regeneration of this or the parent's impostor's body.
  21108. * Use under cautious - This will remove all joints already implemented.
  21109. */
  21110. forceUpdate(): void;
  21111. /**
  21112. * Gets the body that holds this impostor. Either its own, or its parent.
  21113. */
  21114. /**
  21115. * Set the physics body. Used mainly by the physics engine/plugin
  21116. */
  21117. physicsBody: any;
  21118. /**
  21119. * Get the parent of the physics imposter
  21120. * @returns Physics imposter or null
  21121. */
  21122. /**
  21123. * Sets the parent of the physics imposter
  21124. */
  21125. parent: Nullable<PhysicsImpostor>;
  21126. /**
  21127. * Resets the update flags
  21128. */
  21129. resetUpdateFlags(): void;
  21130. /**
  21131. * Gets the object extend size
  21132. * @returns the object extend size
  21133. */
  21134. getObjectExtendSize(): Vector3;
  21135. /**
  21136. * Gets the object center
  21137. * @returns The object center
  21138. */
  21139. getObjectCenter(): Vector3;
  21140. /**
  21141. * Get a specific parametes from the options parameter
  21142. * @param paramName The object parameter name
  21143. * @returns The object parameter
  21144. */
  21145. getParam(paramName: string): any;
  21146. /**
  21147. * Sets a specific parameter in the options given to the physics plugin
  21148. * @param paramName The parameter name
  21149. * @param value The value of the parameter
  21150. */
  21151. setParam(paramName: string, value: number): void;
  21152. /**
  21153. * Specifically change the body's mass option. Won't recreate the physics body object
  21154. * @param mass The mass of the physics imposter
  21155. */
  21156. setMass(mass: number): void;
  21157. /**
  21158. * Gets the linear velocity
  21159. * @returns linear velocity or null
  21160. */
  21161. getLinearVelocity(): Nullable<Vector3>;
  21162. /**
  21163. * Sets the linear velocity
  21164. * @param velocity linear velocity or null
  21165. */
  21166. setLinearVelocity(velocity: Nullable<Vector3>): void;
  21167. /**
  21168. * Gets the angular velocity
  21169. * @returns angular velocity or null
  21170. */
  21171. getAngularVelocity(): Nullable<Vector3>;
  21172. /**
  21173. * Sets the angular velocity
  21174. * @param velocity The velocity or null
  21175. */
  21176. setAngularVelocity(velocity: Nullable<Vector3>): void;
  21177. /**
  21178. * Execute a function with the physics plugin native code
  21179. * Provide a function the will have two variables - the world object and the physics body object
  21180. * @param func The function to execute with the physics plugin native code
  21181. */
  21182. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  21183. /**
  21184. * Register a function that will be executed before the physics world is stepping forward
  21185. * @param func The function to execute before the physics world is stepped forward
  21186. */
  21187. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21188. /**
  21189. * Unregister a function that will be executed before the physics world is stepping forward
  21190. * @param func The function to execute before the physics world is stepped forward
  21191. */
  21192. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21193. /**
  21194. * Register a function that will be executed after the physics step
  21195. * @param func The function to execute after physics step
  21196. */
  21197. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21198. /**
  21199. * Unregisters a function that will be executed after the physics step
  21200. * @param func The function to execute after physics step
  21201. */
  21202. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21203. /**
  21204. * register a function that will be executed when this impostor collides against a different body
  21205. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  21206. * @param func Callback that is executed on collision
  21207. */
  21208. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  21209. /**
  21210. * Unregisters the physics imposter on contact
  21211. * @param collideAgainst The physics object to collide against
  21212. * @param func Callback to execute on collision
  21213. */
  21214. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  21215. private _tmpQuat;
  21216. private _tmpQuat2;
  21217. /**
  21218. * Get the parent rotation
  21219. * @returns The parent rotation
  21220. */
  21221. getParentsRotation(): Quaternion;
  21222. /**
  21223. * this function is executed by the physics engine.
  21224. */
  21225. beforeStep: () => void;
  21226. /**
  21227. * this function is executed by the physics engine
  21228. */
  21229. afterStep: () => void;
  21230. /**
  21231. * Legacy collision detection event support
  21232. */
  21233. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  21234. /**
  21235. * event and body object due to cannon's event-based architecture.
  21236. */
  21237. onCollide: (e: {
  21238. body: any;
  21239. }) => void;
  21240. /**
  21241. * Apply a force
  21242. * @param force The force to apply
  21243. * @param contactPoint The contact point for the force
  21244. * @returns The physics imposter
  21245. */
  21246. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  21247. /**
  21248. * Apply an impulse
  21249. * @param force The impulse force
  21250. * @param contactPoint The contact point for the impulse force
  21251. * @returns The physics imposter
  21252. */
  21253. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  21254. /**
  21255. * A help function to create a joint
  21256. * @param otherImpostor A physics imposter used to create a joint
  21257. * @param jointType The type of joint
  21258. * @param jointData The data for the joint
  21259. * @returns The physics imposter
  21260. */
  21261. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  21262. /**
  21263. * Add a joint to this impostor with a different impostor
  21264. * @param otherImpostor A physics imposter used to add a joint
  21265. * @param joint The joint to add
  21266. * @returns The physics imposter
  21267. */
  21268. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  21269. /**
  21270. * Add an anchor to a cloth impostor
  21271. * @param otherImpostor rigid impostor to anchor to
  21272. * @param width ratio across width from 0 to 1
  21273. * @param height ratio up height from 0 to 1
  21274. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  21275. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  21276. * @returns impostor the soft imposter
  21277. */
  21278. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  21279. /**
  21280. * Add a hook to a rope impostor
  21281. * @param otherImpostor rigid impostor to anchor to
  21282. * @param length ratio across rope from 0 to 1
  21283. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  21284. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  21285. * @returns impostor the rope imposter
  21286. */
  21287. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  21288. /**
  21289. * Will keep this body still, in a sleep mode.
  21290. * @returns the physics imposter
  21291. */
  21292. sleep(): PhysicsImpostor;
  21293. /**
  21294. * Wake the body up.
  21295. * @returns The physics imposter
  21296. */
  21297. wakeUp(): PhysicsImpostor;
  21298. /**
  21299. * Clones the physics imposter
  21300. * @param newObject The physics imposter clones to this physics-enabled object
  21301. * @returns A nullable physics imposter
  21302. */
  21303. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  21304. /**
  21305. * Disposes the physics imposter
  21306. */
  21307. dispose(): void;
  21308. /**
  21309. * Sets the delta position
  21310. * @param position The delta position amount
  21311. */
  21312. setDeltaPosition(position: Vector3): void;
  21313. /**
  21314. * Sets the delta rotation
  21315. * @param rotation The delta rotation amount
  21316. */
  21317. setDeltaRotation(rotation: Quaternion): void;
  21318. /**
  21319. * Gets the box size of the physics imposter and stores the result in the input parameter
  21320. * @param result Stores the box size
  21321. * @returns The physics imposter
  21322. */
  21323. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  21324. /**
  21325. * Gets the radius of the physics imposter
  21326. * @returns Radius of the physics imposter
  21327. */
  21328. getRadius(): number;
  21329. /**
  21330. * Sync a bone with this impostor
  21331. * @param bone The bone to sync to the impostor.
  21332. * @param boneMesh The mesh that the bone is influencing.
  21333. * @param jointPivot The pivot of the joint / bone in local space.
  21334. * @param distToJoint Optional distance from the impostor to the joint.
  21335. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  21336. */
  21337. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  21338. /**
  21339. * Sync impostor to a bone
  21340. * @param bone The bone that the impostor will be synced to.
  21341. * @param boneMesh The mesh that the bone is influencing.
  21342. * @param jointPivot The pivot of the joint / bone in local space.
  21343. * @param distToJoint Optional distance from the impostor to the joint.
  21344. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  21345. * @param boneAxis Optional vector3 axis the bone is aligned with
  21346. */
  21347. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  21348. /**
  21349. * No-Imposter type
  21350. */
  21351. static NoImpostor: number;
  21352. /**
  21353. * Sphere-Imposter type
  21354. */
  21355. static SphereImpostor: number;
  21356. /**
  21357. * Box-Imposter type
  21358. */
  21359. static BoxImpostor: number;
  21360. /**
  21361. * Plane-Imposter type
  21362. */
  21363. static PlaneImpostor: number;
  21364. /**
  21365. * Mesh-imposter type
  21366. */
  21367. static MeshImpostor: number;
  21368. /**
  21369. * Cylinder-Imposter type
  21370. */
  21371. static CylinderImpostor: number;
  21372. /**
  21373. * Particle-Imposter type
  21374. */
  21375. static ParticleImpostor: number;
  21376. /**
  21377. * Heightmap-Imposter type
  21378. */
  21379. static HeightmapImpostor: number;
  21380. /**
  21381. * ConvexHull-Impostor type (Ammo.js plugin only)
  21382. */
  21383. static ConvexHullImpostor: number;
  21384. /**
  21385. * Rope-Imposter type
  21386. */
  21387. static RopeImpostor: number;
  21388. /**
  21389. * Cloth-Imposter type
  21390. */
  21391. static ClothImpostor: number;
  21392. /**
  21393. * Softbody-Imposter type
  21394. */
  21395. static SoftbodyImpostor: number;
  21396. }
  21397. }
  21398. declare module "babylonjs/Meshes/mesh" {
  21399. import { Observable } from "babylonjs/Misc/observable";
  21400. import { IAnimatable } from "babylonjs/Misc/tools";
  21401. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21402. import { Camera } from "babylonjs/Cameras/camera";
  21403. import { Scene } from "babylonjs/scene";
  21404. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  21405. import { Engine } from "babylonjs/Engines/engine";
  21406. import { Node } from "babylonjs/node";
  21407. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21408. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  21409. import { Buffer } from "babylonjs/Meshes/buffer";
  21410. import { Geometry } from "babylonjs/Meshes/geometry";
  21411. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21412. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21413. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  21414. import { Effect } from "babylonjs/Materials/effect";
  21415. import { Material } from "babylonjs/Materials/material";
  21416. import { Skeleton } from "babylonjs/Bones/skeleton";
  21417. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  21418. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  21419. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  21420. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  21421. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  21422. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  21423. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  21424. /**
  21425. * @hidden
  21426. **/
  21427. export class _CreationDataStorage {
  21428. closePath?: boolean;
  21429. closeArray?: boolean;
  21430. idx: number[];
  21431. dashSize: number;
  21432. gapSize: number;
  21433. path3D: Path3D;
  21434. pathArray: Vector3[][];
  21435. arc: number;
  21436. radius: number;
  21437. cap: number;
  21438. tessellation: number;
  21439. }
  21440. /**
  21441. * @hidden
  21442. **/
  21443. class _InstanceDataStorage {
  21444. visibleInstances: any;
  21445. batchCache: _InstancesBatch;
  21446. instancesBufferSize: number;
  21447. instancesBuffer: Nullable<Buffer>;
  21448. instancesData: Float32Array;
  21449. overridenInstanceCount: number;
  21450. isFrozen: boolean;
  21451. previousBatch: _InstancesBatch;
  21452. hardwareInstancedRendering: boolean;
  21453. sideOrientation: number;
  21454. }
  21455. /**
  21456. * @hidden
  21457. **/
  21458. export class _InstancesBatch {
  21459. mustReturn: boolean;
  21460. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  21461. renderSelf: boolean[];
  21462. hardwareInstancedRendering: boolean[];
  21463. }
  21464. /**
  21465. * Class used to represent renderable models
  21466. */
  21467. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  21468. /**
  21469. * Mesh side orientation : usually the external or front surface
  21470. */
  21471. static readonly FRONTSIDE: number;
  21472. /**
  21473. * Mesh side orientation : usually the internal or back surface
  21474. */
  21475. static readonly BACKSIDE: number;
  21476. /**
  21477. * Mesh side orientation : both internal and external or front and back surfaces
  21478. */
  21479. static readonly DOUBLESIDE: number;
  21480. /**
  21481. * Mesh side orientation : by default, `FRONTSIDE`
  21482. */
  21483. static readonly DEFAULTSIDE: number;
  21484. /**
  21485. * Mesh cap setting : no cap
  21486. */
  21487. static readonly NO_CAP: number;
  21488. /**
  21489. * Mesh cap setting : one cap at the beginning of the mesh
  21490. */
  21491. static readonly CAP_START: number;
  21492. /**
  21493. * Mesh cap setting : one cap at the end of the mesh
  21494. */
  21495. static readonly CAP_END: number;
  21496. /**
  21497. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21498. */
  21499. static readonly CAP_ALL: number;
  21500. /**
  21501. * Mesh pattern setting : no flip or rotate
  21502. */
  21503. static readonly NO_FLIP: number;
  21504. /**
  21505. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  21506. */
  21507. static readonly FLIP_TILE: number;
  21508. /**
  21509. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  21510. */
  21511. static readonly ROTATE_TILE: number;
  21512. /**
  21513. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  21514. */
  21515. static readonly FLIP_ROW: number;
  21516. /**
  21517. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  21518. */
  21519. static readonly ROTATE_ROW: number;
  21520. /**
  21521. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  21522. */
  21523. static readonly FLIP_N_ROTATE_TILE: number;
  21524. /**
  21525. * Mesh pattern setting : rotate pattern and rotate
  21526. */
  21527. static readonly FLIP_N_ROTATE_ROW: number;
  21528. /**
  21529. * Mesh tile positioning : part tiles same on left/right or top/bottom
  21530. */
  21531. static readonly CENTER: number;
  21532. /**
  21533. * Mesh tile positioning : part tiles on left
  21534. */
  21535. static readonly LEFT: number;
  21536. /**
  21537. * Mesh tile positioning : part tiles on right
  21538. */
  21539. static readonly RIGHT: number;
  21540. /**
  21541. * Mesh tile positioning : part tiles on top
  21542. */
  21543. static readonly TOP: number;
  21544. /**
  21545. * Mesh tile positioning : part tiles on bottom
  21546. */
  21547. static readonly BOTTOM: number;
  21548. /**
  21549. * Gets the default side orientation.
  21550. * @param orientation the orientation to value to attempt to get
  21551. * @returns the default orientation
  21552. * @hidden
  21553. */
  21554. static _GetDefaultSideOrientation(orientation?: number): number;
  21555. private _internalMeshDataInfo;
  21556. /**
  21557. * An event triggered before rendering the mesh
  21558. */
  21559. readonly onBeforeRenderObservable: Observable<Mesh>;
  21560. /**
  21561. * An event triggered before binding the mesh
  21562. */
  21563. readonly onBeforeBindObservable: Observable<Mesh>;
  21564. /**
  21565. * An event triggered after rendering the mesh
  21566. */
  21567. readonly onAfterRenderObservable: Observable<Mesh>;
  21568. /**
  21569. * An event triggered before drawing the mesh
  21570. */
  21571. readonly onBeforeDrawObservable: Observable<Mesh>;
  21572. private _onBeforeDrawObserver;
  21573. /**
  21574. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  21575. */
  21576. onBeforeDraw: () => void;
  21577. /**
  21578. * Gets the delay loading state of the mesh (when delay loading is turned on)
  21579. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  21580. */
  21581. delayLoadState: number;
  21582. /**
  21583. * Gets the list of instances created from this mesh
  21584. * it is not supposed to be modified manually.
  21585. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  21586. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21587. */
  21588. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  21589. /**
  21590. * Gets the file containing delay loading data for this mesh
  21591. */
  21592. delayLoadingFile: string;
  21593. /** @hidden */
  21594. _binaryInfo: any;
  21595. /**
  21596. * User defined function used to change how LOD level selection is done
  21597. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21598. */
  21599. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21600. /**
  21601. * Gets or sets the morph target manager
  21602. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21603. */
  21604. morphTargetManager: Nullable<MorphTargetManager>;
  21605. /** @hidden */
  21606. _creationDataStorage: Nullable<_CreationDataStorage>;
  21607. /** @hidden */
  21608. _geometry: Nullable<Geometry>;
  21609. /** @hidden */
  21610. _delayInfo: Array<string>;
  21611. /** @hidden */
  21612. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21613. /** @hidden */
  21614. _instanceDataStorage: _InstanceDataStorage;
  21615. private _effectiveMaterial;
  21616. /** @hidden */
  21617. _shouldGenerateFlatShading: boolean;
  21618. /** @hidden */
  21619. _originalBuilderSideOrientation: number;
  21620. /**
  21621. * Use this property to change the original side orientation defined at construction time
  21622. */
  21623. overrideMaterialSideOrientation: Nullable<number>;
  21624. /**
  21625. * Gets the source mesh (the one used to clone this one from)
  21626. */
  21627. readonly source: Nullable<Mesh>;
  21628. /**
  21629. * Gets or sets a boolean indicating that this mesh does not use index buffer
  21630. */
  21631. isUnIndexed: boolean;
  21632. /**
  21633. * @constructor
  21634. * @param name The value used by scene.getMeshByName() to do a lookup.
  21635. * @param scene The scene to add this mesh to.
  21636. * @param parent The parent of this mesh, if it has one
  21637. * @param source An optional Mesh from which geometry is shared, cloned.
  21638. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21639. * When false, achieved by calling a clone(), also passing False.
  21640. * This will make creation of children, recursive.
  21641. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21642. */
  21643. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21644. /**
  21645. * Gets the class name
  21646. * @returns the string "Mesh".
  21647. */
  21648. getClassName(): string;
  21649. /** @hidden */
  21650. readonly _isMesh: boolean;
  21651. /**
  21652. * Returns a description of this mesh
  21653. * @param fullDetails define if full details about this mesh must be used
  21654. * @returns a descriptive string representing this mesh
  21655. */
  21656. toString(fullDetails?: boolean): string;
  21657. /** @hidden */
  21658. _unBindEffect(): void;
  21659. /**
  21660. * Gets a boolean indicating if this mesh has LOD
  21661. */
  21662. readonly hasLODLevels: boolean;
  21663. /**
  21664. * Gets the list of MeshLODLevel associated with the current mesh
  21665. * @returns an array of MeshLODLevel
  21666. */
  21667. getLODLevels(): MeshLODLevel[];
  21668. private _sortLODLevels;
  21669. /**
  21670. * Add a mesh as LOD level triggered at the given distance.
  21671. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21672. * @param distance The distance from the center of the object to show this level
  21673. * @param mesh The mesh to be added as LOD level (can be null)
  21674. * @return This mesh (for chaining)
  21675. */
  21676. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21677. /**
  21678. * Returns the LOD level mesh at the passed distance or null if not found.
  21679. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21680. * @param distance The distance from the center of the object to show this level
  21681. * @returns a Mesh or `null`
  21682. */
  21683. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21684. /**
  21685. * Remove a mesh from the LOD array
  21686. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21687. * @param mesh defines the mesh to be removed
  21688. * @return This mesh (for chaining)
  21689. */
  21690. removeLODLevel(mesh: Mesh): Mesh;
  21691. /**
  21692. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21693. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21694. * @param camera defines the camera to use to compute distance
  21695. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  21696. * @return This mesh (for chaining)
  21697. */
  21698. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21699. /**
  21700. * Gets the mesh internal Geometry object
  21701. */
  21702. readonly geometry: Nullable<Geometry>;
  21703. /**
  21704. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21705. * @returns the total number of vertices
  21706. */
  21707. getTotalVertices(): number;
  21708. /**
  21709. * Returns the content of an associated vertex buffer
  21710. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21711. * - VertexBuffer.PositionKind
  21712. * - VertexBuffer.UVKind
  21713. * - VertexBuffer.UV2Kind
  21714. * - VertexBuffer.UV3Kind
  21715. * - VertexBuffer.UV4Kind
  21716. * - VertexBuffer.UV5Kind
  21717. * - VertexBuffer.UV6Kind
  21718. * - VertexBuffer.ColorKind
  21719. * - VertexBuffer.MatricesIndicesKind
  21720. * - VertexBuffer.MatricesIndicesExtraKind
  21721. * - VertexBuffer.MatricesWeightsKind
  21722. * - VertexBuffer.MatricesWeightsExtraKind
  21723. * @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
  21724. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  21725. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  21726. */
  21727. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21728. /**
  21729. * Returns the mesh VertexBuffer object from the requested `kind`
  21730. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21731. * - VertexBuffer.PositionKind
  21732. * - VertexBuffer.NormalKind
  21733. * - VertexBuffer.UVKind
  21734. * - VertexBuffer.UV2Kind
  21735. * - VertexBuffer.UV3Kind
  21736. * - VertexBuffer.UV4Kind
  21737. * - VertexBuffer.UV5Kind
  21738. * - VertexBuffer.UV6Kind
  21739. * - VertexBuffer.ColorKind
  21740. * - VertexBuffer.MatricesIndicesKind
  21741. * - VertexBuffer.MatricesIndicesExtraKind
  21742. * - VertexBuffer.MatricesWeightsKind
  21743. * - VertexBuffer.MatricesWeightsExtraKind
  21744. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21745. */
  21746. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21747. /**
  21748. * Tests if a specific vertex buffer is associated with this mesh
  21749. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21750. * - VertexBuffer.PositionKind
  21751. * - VertexBuffer.NormalKind
  21752. * - VertexBuffer.UVKind
  21753. * - VertexBuffer.UV2Kind
  21754. * - VertexBuffer.UV3Kind
  21755. * - VertexBuffer.UV4Kind
  21756. * - VertexBuffer.UV5Kind
  21757. * - VertexBuffer.UV6Kind
  21758. * - VertexBuffer.ColorKind
  21759. * - VertexBuffer.MatricesIndicesKind
  21760. * - VertexBuffer.MatricesIndicesExtraKind
  21761. * - VertexBuffer.MatricesWeightsKind
  21762. * - VertexBuffer.MatricesWeightsExtraKind
  21763. * @returns a boolean
  21764. */
  21765. isVerticesDataPresent(kind: string): boolean;
  21766. /**
  21767. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21768. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21769. * - VertexBuffer.PositionKind
  21770. * - VertexBuffer.UVKind
  21771. * - VertexBuffer.UV2Kind
  21772. * - VertexBuffer.UV3Kind
  21773. * - VertexBuffer.UV4Kind
  21774. * - VertexBuffer.UV5Kind
  21775. * - VertexBuffer.UV6Kind
  21776. * - VertexBuffer.ColorKind
  21777. * - VertexBuffer.MatricesIndicesKind
  21778. * - VertexBuffer.MatricesIndicesExtraKind
  21779. * - VertexBuffer.MatricesWeightsKind
  21780. * - VertexBuffer.MatricesWeightsExtraKind
  21781. * @returns a boolean
  21782. */
  21783. isVertexBufferUpdatable(kind: string): boolean;
  21784. /**
  21785. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21786. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21787. * - VertexBuffer.PositionKind
  21788. * - VertexBuffer.NormalKind
  21789. * - VertexBuffer.UVKind
  21790. * - VertexBuffer.UV2Kind
  21791. * - VertexBuffer.UV3Kind
  21792. * - VertexBuffer.UV4Kind
  21793. * - VertexBuffer.UV5Kind
  21794. * - VertexBuffer.UV6Kind
  21795. * - VertexBuffer.ColorKind
  21796. * - VertexBuffer.MatricesIndicesKind
  21797. * - VertexBuffer.MatricesIndicesExtraKind
  21798. * - VertexBuffer.MatricesWeightsKind
  21799. * - VertexBuffer.MatricesWeightsExtraKind
  21800. * @returns an array of strings
  21801. */
  21802. getVerticesDataKinds(): string[];
  21803. /**
  21804. * Returns a positive integer : the total number of indices in this mesh geometry.
  21805. * @returns the numner of indices or zero if the mesh has no geometry.
  21806. */
  21807. getTotalIndices(): number;
  21808. /**
  21809. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21810. * @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.
  21811. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21812. * @returns the indices array or an empty array if the mesh has no geometry
  21813. */
  21814. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21815. readonly isBlocked: boolean;
  21816. /**
  21817. * Determine if the current mesh is ready to be rendered
  21818. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21819. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21820. * @returns true if all associated assets are ready (material, textures, shaders)
  21821. */
  21822. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21823. /**
  21824. * 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.
  21825. */
  21826. readonly areNormalsFrozen: boolean;
  21827. /**
  21828. * 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.
  21829. * @returns the current mesh
  21830. */
  21831. freezeNormals(): Mesh;
  21832. /**
  21833. * 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
  21834. * @returns the current mesh
  21835. */
  21836. unfreezeNormals(): Mesh;
  21837. /**
  21838. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21839. */
  21840. overridenInstanceCount: number;
  21841. /** @hidden */
  21842. _preActivate(): Mesh;
  21843. /** @hidden */
  21844. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21845. /** @hidden */
  21846. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21847. /**
  21848. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21849. * This means the mesh underlying bounding box and sphere are recomputed.
  21850. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21851. * @returns the current mesh
  21852. */
  21853. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21854. /** @hidden */
  21855. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21856. /**
  21857. * This function will subdivide the mesh into multiple submeshes
  21858. * @param count defines the expected number of submeshes
  21859. */
  21860. subdivide(count: number): void;
  21861. /**
  21862. * Copy a FloatArray into a specific associated vertex buffer
  21863. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21864. * - VertexBuffer.PositionKind
  21865. * - VertexBuffer.UVKind
  21866. * - VertexBuffer.UV2Kind
  21867. * - VertexBuffer.UV3Kind
  21868. * - VertexBuffer.UV4Kind
  21869. * - VertexBuffer.UV5Kind
  21870. * - VertexBuffer.UV6Kind
  21871. * - VertexBuffer.ColorKind
  21872. * - VertexBuffer.MatricesIndicesKind
  21873. * - VertexBuffer.MatricesIndicesExtraKind
  21874. * - VertexBuffer.MatricesWeightsKind
  21875. * - VertexBuffer.MatricesWeightsExtraKind
  21876. * @param data defines the data source
  21877. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21878. * @param stride defines the data stride size (can be null)
  21879. * @returns the current mesh
  21880. */
  21881. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21882. /**
  21883. * Flags an associated vertex buffer as updatable
  21884. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21885. * - VertexBuffer.PositionKind
  21886. * - VertexBuffer.UVKind
  21887. * - VertexBuffer.UV2Kind
  21888. * - VertexBuffer.UV3Kind
  21889. * - VertexBuffer.UV4Kind
  21890. * - VertexBuffer.UV5Kind
  21891. * - VertexBuffer.UV6Kind
  21892. * - VertexBuffer.ColorKind
  21893. * - VertexBuffer.MatricesIndicesKind
  21894. * - VertexBuffer.MatricesIndicesExtraKind
  21895. * - VertexBuffer.MatricesWeightsKind
  21896. * - VertexBuffer.MatricesWeightsExtraKind
  21897. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21898. */
  21899. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21900. /**
  21901. * Sets the mesh global Vertex Buffer
  21902. * @param buffer defines the buffer to use
  21903. * @returns the current mesh
  21904. */
  21905. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21906. /**
  21907. * Update a specific associated vertex buffer
  21908. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21909. * - VertexBuffer.PositionKind
  21910. * - VertexBuffer.UVKind
  21911. * - VertexBuffer.UV2Kind
  21912. * - VertexBuffer.UV3Kind
  21913. * - VertexBuffer.UV4Kind
  21914. * - VertexBuffer.UV5Kind
  21915. * - VertexBuffer.UV6Kind
  21916. * - VertexBuffer.ColorKind
  21917. * - VertexBuffer.MatricesIndicesKind
  21918. * - VertexBuffer.MatricesIndicesExtraKind
  21919. * - VertexBuffer.MatricesWeightsKind
  21920. * - VertexBuffer.MatricesWeightsExtraKind
  21921. * @param data defines the data source
  21922. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21923. * @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)
  21924. * @returns the current mesh
  21925. */
  21926. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21927. /**
  21928. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21929. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21930. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21931. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21932. * @returns the current mesh
  21933. */
  21934. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21935. /**
  21936. * Creates a un-shared specific occurence of the geometry for the mesh.
  21937. * @returns the current mesh
  21938. */
  21939. makeGeometryUnique(): Mesh;
  21940. /**
  21941. * Set the index buffer of this mesh
  21942. * @param indices defines the source data
  21943. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21944. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21945. * @returns the current mesh
  21946. */
  21947. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21948. /**
  21949. * Update the current index buffer
  21950. * @param indices defines the source data
  21951. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21952. * @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)
  21953. * @returns the current mesh
  21954. */
  21955. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21956. /**
  21957. * Invert the geometry to move from a right handed system to a left handed one.
  21958. * @returns the current mesh
  21959. */
  21960. toLeftHanded(): Mesh;
  21961. /** @hidden */
  21962. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21963. /** @hidden */
  21964. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21965. /**
  21966. * Registers for this mesh a javascript function called just before the rendering process
  21967. * @param func defines the function to call before rendering this mesh
  21968. * @returns the current mesh
  21969. */
  21970. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21971. /**
  21972. * Disposes a previously registered javascript function called before the rendering
  21973. * @param func defines the function to remove
  21974. * @returns the current mesh
  21975. */
  21976. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21977. /**
  21978. * Registers for this mesh a javascript function called just after the rendering is complete
  21979. * @param func defines the function to call after rendering this mesh
  21980. * @returns the current mesh
  21981. */
  21982. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21983. /**
  21984. * Disposes a previously registered javascript function called after the rendering.
  21985. * @param func defines the function to remove
  21986. * @returns the current mesh
  21987. */
  21988. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21989. /** @hidden */
  21990. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21991. /** @hidden */
  21992. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21993. /** @hidden */
  21994. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21995. /** @hidden */
  21996. _freeze(): void;
  21997. /** @hidden */
  21998. _unFreeze(): void;
  21999. /**
  22000. * 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
  22001. * @param subMesh defines the subMesh to render
  22002. * @param enableAlphaMode defines if alpha mode can be changed
  22003. * @returns the current mesh
  22004. */
  22005. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  22006. private _onBeforeDraw;
  22007. /**
  22008. * Renormalize the mesh and patch it up if there are no weights
  22009. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  22010. * However in the case of zero weights then we set just a single influence to 1.
  22011. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  22012. */
  22013. cleanMatrixWeights(): void;
  22014. private normalizeSkinFourWeights;
  22015. private normalizeSkinWeightsAndExtra;
  22016. /**
  22017. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  22018. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  22019. * the user know there was an issue with importing the mesh
  22020. * @returns a validation object with skinned, valid and report string
  22021. */
  22022. validateSkinning(): {
  22023. skinned: boolean;
  22024. valid: boolean;
  22025. report: string;
  22026. };
  22027. /** @hidden */
  22028. _checkDelayState(): Mesh;
  22029. private _queueLoad;
  22030. /**
  22031. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  22032. * A mesh is in the frustum if its bounding box intersects the frustum
  22033. * @param frustumPlanes defines the frustum to test
  22034. * @returns true if the mesh is in the frustum planes
  22035. */
  22036. isInFrustum(frustumPlanes: Plane[]): boolean;
  22037. /**
  22038. * Sets the mesh material by the material or multiMaterial `id` property
  22039. * @param id is a string identifying the material or the multiMaterial
  22040. * @returns the current mesh
  22041. */
  22042. setMaterialByID(id: string): Mesh;
  22043. /**
  22044. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  22045. * @returns an array of IAnimatable
  22046. */
  22047. getAnimatables(): IAnimatable[];
  22048. /**
  22049. * Modifies the mesh geometry according to the passed transformation matrix.
  22050. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  22051. * The mesh normals are modified using the same transformation.
  22052. * Note that, under the hood, this method sets a new VertexBuffer each call.
  22053. * @param transform defines the transform matrix to use
  22054. * @see http://doc.babylonjs.com/resources/baking_transformations
  22055. * @returns the current mesh
  22056. */
  22057. bakeTransformIntoVertices(transform: Matrix): Mesh;
  22058. /**
  22059. * Modifies the mesh geometry according to its own current World Matrix.
  22060. * The mesh World Matrix is then reset.
  22061. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  22062. * Note that, under the hood, this method sets a new VertexBuffer each call.
  22063. * @see http://doc.babylonjs.com/resources/baking_transformations
  22064. * @returns the current mesh
  22065. */
  22066. bakeCurrentTransformIntoVertices(): Mesh;
  22067. /** @hidden */
  22068. readonly _positions: Nullable<Vector3[]>;
  22069. /** @hidden */
  22070. _resetPointsArrayCache(): Mesh;
  22071. /** @hidden */
  22072. _generatePointsArray(): boolean;
  22073. /**
  22074. * Returns a new Mesh object generated from the current mesh properties.
  22075. * This method must not get confused with createInstance()
  22076. * @param name is a string, the name given to the new mesh
  22077. * @param newParent can be any Node object (default `null`)
  22078. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  22079. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  22080. * @returns a new mesh
  22081. */
  22082. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  22083. /**
  22084. * Releases resources associated with this mesh.
  22085. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  22086. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  22087. */
  22088. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  22089. /**
  22090. * Modifies the mesh geometry according to a displacement map.
  22091. * 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.
  22092. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  22093. * @param url is a string, the URL from the image file is to be downloaded.
  22094. * @param minHeight is the lower limit of the displacement.
  22095. * @param maxHeight is the upper limit of the displacement.
  22096. * @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.
  22097. * @param uvOffset is an optional vector2 used to offset UV.
  22098. * @param uvScale is an optional vector2 used to scale UV.
  22099. * @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.
  22100. * @returns the Mesh.
  22101. */
  22102. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  22103. /**
  22104. * Modifies the mesh geometry according to a displacementMap buffer.
  22105. * 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.
  22106. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  22107. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  22108. * @param heightMapWidth is the width of the buffer image.
  22109. * @param heightMapHeight is the height of the buffer image.
  22110. * @param minHeight is the lower limit of the displacement.
  22111. * @param maxHeight is the upper limit of the displacement.
  22112. * @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.
  22113. * @param uvOffset is an optional vector2 used to offset UV.
  22114. * @param uvScale is an optional vector2 used to scale UV.
  22115. * @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.
  22116. * @returns the Mesh.
  22117. */
  22118. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  22119. /**
  22120. * Modify the mesh to get a flat shading rendering.
  22121. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  22122. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  22123. * @returns current mesh
  22124. */
  22125. convertToFlatShadedMesh(): Mesh;
  22126. /**
  22127. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  22128. * In other words, more vertices, no more indices and a single bigger VBO.
  22129. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  22130. * @returns current mesh
  22131. */
  22132. convertToUnIndexedMesh(): Mesh;
  22133. /**
  22134. * Inverses facet orientations.
  22135. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22136. * @param flipNormals will also inverts the normals
  22137. * @returns current mesh
  22138. */
  22139. flipFaces(flipNormals?: boolean): Mesh;
  22140. /**
  22141. * Increase the number of facets and hence vertices in a mesh
  22142. * Vertex normals are interpolated from existing vertex normals
  22143. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22144. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  22145. */
  22146. increaseVertices(numberPerEdge: number): void;
  22147. /**
  22148. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  22149. * This will undo any application of covertToFlatShadedMesh
  22150. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22151. */
  22152. forceSharedVertices(): void;
  22153. /** @hidden */
  22154. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  22155. /** @hidden */
  22156. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  22157. /**
  22158. * Creates a new InstancedMesh object from the mesh model.
  22159. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  22160. * @param name defines the name of the new instance
  22161. * @returns a new InstancedMesh
  22162. */
  22163. createInstance(name: string): InstancedMesh;
  22164. /**
  22165. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  22166. * After this call, all the mesh instances have the same submeshes than the current mesh.
  22167. * @returns the current mesh
  22168. */
  22169. synchronizeInstances(): Mesh;
  22170. /**
  22171. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  22172. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  22173. * This should be used together with the simplification to avoid disappearing triangles.
  22174. * @param successCallback an optional success callback to be called after the optimization finished.
  22175. * @returns the current mesh
  22176. */
  22177. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  22178. /**
  22179. * Serialize current mesh
  22180. * @param serializationObject defines the object which will receive the serialization data
  22181. */
  22182. serialize(serializationObject: any): void;
  22183. /** @hidden */
  22184. _syncGeometryWithMorphTargetManager(): void;
  22185. /** @hidden */
  22186. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  22187. /**
  22188. * Returns a new Mesh object parsed from the source provided.
  22189. * @param parsedMesh is the source
  22190. * @param scene defines the hosting scene
  22191. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  22192. * @returns a new Mesh
  22193. */
  22194. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  22195. /**
  22196. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  22197. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22198. * @param name defines the name of the mesh to create
  22199. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  22200. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  22201. * @param closePath creates a seam between the first and the last points of each path of the path array
  22202. * @param offset is taken in account only if the `pathArray` is containing a single path
  22203. * @param scene defines the hosting scene
  22204. * @param updatable defines if the mesh must be flagged as updatable
  22205. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22206. * @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)
  22207. * @returns a new Mesh
  22208. */
  22209. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22210. /**
  22211. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  22212. * @param name defines the name of the mesh to create
  22213. * @param radius sets the radius size (float) of the polygon (default 0.5)
  22214. * @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
  22215. * @param scene defines the hosting scene
  22216. * @param updatable defines if the mesh must be flagged as updatable
  22217. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22218. * @returns a new Mesh
  22219. */
  22220. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22221. /**
  22222. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  22223. * @param name defines the name of the mesh to create
  22224. * @param size sets the size (float) of each box side (default 1)
  22225. * @param scene defines the hosting scene
  22226. * @param updatable defines if the mesh must be flagged as updatable
  22227. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22228. * @returns a new Mesh
  22229. */
  22230. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22231. /**
  22232. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  22233. * @param name defines the name of the mesh to create
  22234. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  22235. * @param diameter sets the diameter size (float) of the sphere (default 1)
  22236. * @param scene defines the hosting scene
  22237. * @param updatable defines if the mesh must be flagged as updatable
  22238. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22239. * @returns a new Mesh
  22240. */
  22241. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22242. /**
  22243. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  22244. * @param name defines the name of the mesh to create
  22245. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  22246. * @param diameter sets the diameter size (float) of the sphere (default 1)
  22247. * @param scene defines the hosting scene
  22248. * @returns a new Mesh
  22249. */
  22250. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  22251. /**
  22252. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  22253. * @param name defines the name of the mesh to create
  22254. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  22255. * @param diameterTop set the top cap diameter (floats, default 1)
  22256. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  22257. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  22258. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  22259. * @param scene defines the hosting scene
  22260. * @param updatable defines if the mesh must be flagged as updatable
  22261. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22262. * @returns a new Mesh
  22263. */
  22264. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  22265. /**
  22266. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  22267. * @param name defines the name of the mesh to create
  22268. * @param diameter sets the diameter size (float) of the torus (default 1)
  22269. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  22270. * @param tessellation sets the number of torus sides (postive integer, default 16)
  22271. * @param scene defines the hosting scene
  22272. * @param updatable defines if the mesh must be flagged as updatable
  22273. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22274. * @returns a new Mesh
  22275. */
  22276. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22277. /**
  22278. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  22279. * @param name defines the name of the mesh to create
  22280. * @param radius sets the global radius size (float) of the torus knot (default 2)
  22281. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  22282. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  22283. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  22284. * @param p the number of windings on X axis (positive integers, default 2)
  22285. * @param q the number of windings on Y axis (positive integers, default 3)
  22286. * @param scene defines the hosting scene
  22287. * @param updatable defines if the mesh must be flagged as updatable
  22288. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22289. * @returns a new Mesh
  22290. */
  22291. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22292. /**
  22293. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  22294. * @param name defines the name of the mesh to create
  22295. * @param points is an array successive Vector3
  22296. * @param scene defines the hosting scene
  22297. * @param updatable defines if the mesh must be flagged as updatable
  22298. * @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).
  22299. * @returns a new Mesh
  22300. */
  22301. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  22302. /**
  22303. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  22304. * @param name defines the name of the mesh to create
  22305. * @param points is an array successive Vector3
  22306. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  22307. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  22308. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  22309. * @param scene defines the hosting scene
  22310. * @param updatable defines if the mesh must be flagged as updatable
  22311. * @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)
  22312. * @returns a new Mesh
  22313. */
  22314. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  22315. /**
  22316. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  22317. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  22318. * 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.
  22319. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22320. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22321. * Remember you can only change the shape positions, not their number when updating a polygon.
  22322. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  22323. * @param name defines the name of the mesh to create
  22324. * @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
  22325. * @param scene defines the hosting scene
  22326. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  22327. * @param updatable defines if the mesh must be flagged as updatable
  22328. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22329. * @param earcutInjection can be used to inject your own earcut reference
  22330. * @returns a new Mesh
  22331. */
  22332. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  22333. /**
  22334. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  22335. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  22336. * @param name defines the name of the mesh to create
  22337. * @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
  22338. * @param depth defines the height of extrusion
  22339. * @param scene defines the hosting scene
  22340. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  22341. * @param updatable defines if the mesh must be flagged as updatable
  22342. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22343. * @param earcutInjection can be used to inject your own earcut reference
  22344. * @returns a new Mesh
  22345. */
  22346. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  22347. /**
  22348. * Creates an extruded shape mesh.
  22349. * 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
  22350. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22351. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22352. * @param name defines the name of the mesh to create
  22353. * @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
  22354. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  22355. * @param scale is the value to scale the shape
  22356. * @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
  22357. * @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
  22358. * @param scene defines the hosting scene
  22359. * @param updatable defines if the mesh must be flagged as updatable
  22360. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22361. * @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)
  22362. * @returns a new Mesh
  22363. */
  22364. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22365. /**
  22366. * Creates an custom extruded shape mesh.
  22367. * The custom extrusion is a parametric shape.
  22368. * It has no predefined shape. Its final shape will depend on the input parameters.
  22369. * Please consider using the same method from the MeshBuilder class instead
  22370. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22371. * @param name defines the name of the mesh to create
  22372. * @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
  22373. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  22374. * @param scaleFunction is a custom Javascript function called on each path point
  22375. * @param rotationFunction is a custom Javascript function called on each path point
  22376. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  22377. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  22378. * @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
  22379. * @param scene defines the hosting scene
  22380. * @param updatable defines if the mesh must be flagged as updatable
  22381. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22382. * @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)
  22383. * @returns a new Mesh
  22384. */
  22385. 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;
  22386. /**
  22387. * Creates lathe mesh.
  22388. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  22389. * Please consider using the same method from the MeshBuilder class instead
  22390. * @param name defines the name of the mesh to create
  22391. * @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
  22392. * @param radius is the radius value of the lathe
  22393. * @param tessellation is the side number of the lathe.
  22394. * @param scene defines the hosting scene
  22395. * @param updatable defines if the mesh must be flagged as updatable
  22396. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22397. * @returns a new Mesh
  22398. */
  22399. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22400. /**
  22401. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  22402. * @param name defines the name of the mesh to create
  22403. * @param size sets the size (float) of both sides of the plane at once (default 1)
  22404. * @param scene defines the hosting scene
  22405. * @param updatable defines if the mesh must be flagged as updatable
  22406. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22407. * @returns a new Mesh
  22408. */
  22409. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22410. /**
  22411. * Creates a ground mesh.
  22412. * Please consider using the same method from the MeshBuilder class instead
  22413. * @param name defines the name of the mesh to create
  22414. * @param width set the width of the ground
  22415. * @param height set the height of the ground
  22416. * @param subdivisions sets the number of subdivisions per side
  22417. * @param scene defines the hosting scene
  22418. * @param updatable defines if the mesh must be flagged as updatable
  22419. * @returns a new Mesh
  22420. */
  22421. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  22422. /**
  22423. * Creates a tiled ground mesh.
  22424. * Please consider using the same method from the MeshBuilder class instead
  22425. * @param name defines the name of the mesh to create
  22426. * @param xmin set the ground minimum X coordinate
  22427. * @param zmin set the ground minimum Y coordinate
  22428. * @param xmax set the ground maximum X coordinate
  22429. * @param zmax set the ground maximum Z coordinate
  22430. * @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
  22431. * @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
  22432. * @param scene defines the hosting scene
  22433. * @param updatable defines if the mesh must be flagged as updatable
  22434. * @returns a new Mesh
  22435. */
  22436. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  22437. w: number;
  22438. h: number;
  22439. }, precision: {
  22440. w: number;
  22441. h: number;
  22442. }, scene: Scene, updatable?: boolean): Mesh;
  22443. /**
  22444. * Creates a ground mesh from a height map.
  22445. * Please consider using the same method from the MeshBuilder class instead
  22446. * @see http://doc.babylonjs.com/babylon101/height_map
  22447. * @param name defines the name of the mesh to create
  22448. * @param url sets the URL of the height map image resource
  22449. * @param width set the ground width size
  22450. * @param height set the ground height size
  22451. * @param subdivisions sets the number of subdivision per side
  22452. * @param minHeight is the minimum altitude on the ground
  22453. * @param maxHeight is the maximum altitude on the ground
  22454. * @param scene defines the hosting scene
  22455. * @param updatable defines if the mesh must be flagged as updatable
  22456. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  22457. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  22458. * @returns a new Mesh
  22459. */
  22460. 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;
  22461. /**
  22462. * Creates a tube mesh.
  22463. * The tube is a parametric shape.
  22464. * It has no predefined shape. Its final shape will depend on the input parameters.
  22465. * Please consider using the same method from the MeshBuilder class instead
  22466. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22467. * @param name defines the name of the mesh to create
  22468. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  22469. * @param radius sets the tube radius size
  22470. * @param tessellation is the number of sides on the tubular surface
  22471. * @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
  22472. * @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
  22473. * @param scene defines the hosting scene
  22474. * @param updatable defines if the mesh must be flagged as updatable
  22475. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22476. * @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)
  22477. * @returns a new Mesh
  22478. */
  22479. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  22480. (i: number, distance: number): number;
  22481. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22482. /**
  22483. * Creates a polyhedron mesh.
  22484. * Please consider using the same method from the MeshBuilder class instead.
  22485. * * 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
  22486. * * The parameter `size` (positive float, default 1) sets the polygon size
  22487. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  22488. * * 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`
  22489. * * 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
  22490. * * 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)`)
  22491. * * 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
  22492. * * 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
  22493. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22494. * * If you create a double-sided mesh, you can choose what parts of 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
  22495. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22496. * @param name defines the name of the mesh to create
  22497. * @param options defines the options used to create the mesh
  22498. * @param scene defines the hosting scene
  22499. * @returns a new Mesh
  22500. */
  22501. static CreatePolyhedron(name: string, options: {
  22502. type?: number;
  22503. size?: number;
  22504. sizeX?: number;
  22505. sizeY?: number;
  22506. sizeZ?: number;
  22507. custom?: any;
  22508. faceUV?: Vector4[];
  22509. faceColors?: Color4[];
  22510. updatable?: boolean;
  22511. sideOrientation?: number;
  22512. }, scene: Scene): Mesh;
  22513. /**
  22514. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22515. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22516. * * 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`)
  22517. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22518. * * 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
  22519. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22520. * * If you create a double-sided mesh, you can choose what parts of 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
  22521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22522. * @param name defines the name of the mesh
  22523. * @param options defines the options used to create the mesh
  22524. * @param scene defines the hosting scene
  22525. * @returns a new Mesh
  22526. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22527. */
  22528. static CreateIcoSphere(name: string, options: {
  22529. radius?: number;
  22530. flat?: boolean;
  22531. subdivisions?: number;
  22532. sideOrientation?: number;
  22533. updatable?: boolean;
  22534. }, scene: Scene): Mesh;
  22535. /**
  22536. * Creates a decal mesh.
  22537. * Please consider using the same method from the MeshBuilder class instead.
  22538. * A decal is a mesh usually applied as a model onto the surface of another mesh
  22539. * @param name defines the name of the mesh
  22540. * @param sourceMesh defines the mesh receiving the decal
  22541. * @param position sets the position of the decal in world coordinates
  22542. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  22543. * @param size sets the decal scaling
  22544. * @param angle sets the angle to rotate the decal
  22545. * @returns a new Mesh
  22546. */
  22547. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22548. /**
  22549. * Prepare internal position array for software CPU skinning
  22550. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  22551. */
  22552. setPositionsForCPUSkinning(): Float32Array;
  22553. /**
  22554. * Prepare internal normal array for software CPU skinning
  22555. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22556. */
  22557. setNormalsForCPUSkinning(): Float32Array;
  22558. /**
  22559. * Updates the vertex buffer by applying transformation from the bones
  22560. * @param skeleton defines the skeleton to apply to current mesh
  22561. * @returns the current mesh
  22562. */
  22563. applySkeleton(skeleton: Skeleton): Mesh;
  22564. /**
  22565. * 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
  22566. * @param meshes defines the list of meshes to scan
  22567. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  22568. */
  22569. static MinMax(meshes: AbstractMesh[]): {
  22570. min: Vector3;
  22571. max: Vector3;
  22572. };
  22573. /**
  22574. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  22575. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  22576. * @returns a vector3
  22577. */
  22578. static Center(meshesOrMinMaxVector: {
  22579. min: Vector3;
  22580. max: Vector3;
  22581. } | AbstractMesh[]): Vector3;
  22582. /**
  22583. * Merge the array of meshes into a single mesh for performance reasons.
  22584. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  22585. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  22586. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  22587. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22588. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  22589. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  22590. * @returns a new mesh
  22591. */
  22592. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  22593. /** @hidden */
  22594. addInstance(instance: InstancedMesh): void;
  22595. /** @hidden */
  22596. removeInstance(instance: InstancedMesh): void;
  22597. }
  22598. }
  22599. declare module "babylonjs/Materials/material" {
  22600. import { IAnimatable } from "babylonjs/Misc/tools";
  22601. import { SmartArray } from "babylonjs/Misc/smartArray";
  22602. import { Observable } from "babylonjs/Misc/observable";
  22603. import { Nullable } from "babylonjs/types";
  22604. import { Scene } from "babylonjs/scene";
  22605. import { Matrix } from "babylonjs/Maths/math";
  22606. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22607. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22608. import { Mesh } from "babylonjs/Meshes/mesh";
  22609. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22610. import { Effect } from "babylonjs/Materials/effect";
  22611. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22612. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22613. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22614. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22615. import { Animation } from "babylonjs/Animations/animation";
  22616. /**
  22617. * Base class for the main features of a material in Babylon.js
  22618. */
  22619. export class Material implements IAnimatable {
  22620. /**
  22621. * Returns the triangle fill mode
  22622. */
  22623. static readonly TriangleFillMode: number;
  22624. /**
  22625. * Returns the wireframe mode
  22626. */
  22627. static readonly WireFrameFillMode: number;
  22628. /**
  22629. * Returns the point fill mode
  22630. */
  22631. static readonly PointFillMode: number;
  22632. /**
  22633. * Returns the point list draw mode
  22634. */
  22635. static readonly PointListDrawMode: number;
  22636. /**
  22637. * Returns the line list draw mode
  22638. */
  22639. static readonly LineListDrawMode: number;
  22640. /**
  22641. * Returns the line loop draw mode
  22642. */
  22643. static readonly LineLoopDrawMode: number;
  22644. /**
  22645. * Returns the line strip draw mode
  22646. */
  22647. static readonly LineStripDrawMode: number;
  22648. /**
  22649. * Returns the triangle strip draw mode
  22650. */
  22651. static readonly TriangleStripDrawMode: number;
  22652. /**
  22653. * Returns the triangle fan draw mode
  22654. */
  22655. static readonly TriangleFanDrawMode: number;
  22656. /**
  22657. * Stores the clock-wise side orientation
  22658. */
  22659. static readonly ClockWiseSideOrientation: number;
  22660. /**
  22661. * Stores the counter clock-wise side orientation
  22662. */
  22663. static readonly CounterClockWiseSideOrientation: number;
  22664. /**
  22665. * The dirty texture flag value
  22666. */
  22667. static readonly TextureDirtyFlag: number;
  22668. /**
  22669. * The dirty light flag value
  22670. */
  22671. static readonly LightDirtyFlag: number;
  22672. /**
  22673. * The dirty fresnel flag value
  22674. */
  22675. static readonly FresnelDirtyFlag: number;
  22676. /**
  22677. * The dirty attribute flag value
  22678. */
  22679. static readonly AttributesDirtyFlag: number;
  22680. /**
  22681. * The dirty misc flag value
  22682. */
  22683. static readonly MiscDirtyFlag: number;
  22684. /**
  22685. * The all dirty flag value
  22686. */
  22687. static readonly AllDirtyFlag: number;
  22688. /**
  22689. * The ID of the material
  22690. */
  22691. id: string;
  22692. /**
  22693. * Gets or sets the unique id of the material
  22694. */
  22695. uniqueId: number;
  22696. /**
  22697. * The name of the material
  22698. */
  22699. name: string;
  22700. /**
  22701. * Gets or sets user defined metadata
  22702. */
  22703. metadata: any;
  22704. /**
  22705. * For internal use only. Please do not use.
  22706. */
  22707. reservedDataStore: any;
  22708. /**
  22709. * Specifies if the ready state should be checked on each call
  22710. */
  22711. checkReadyOnEveryCall: boolean;
  22712. /**
  22713. * Specifies if the ready state should be checked once
  22714. */
  22715. checkReadyOnlyOnce: boolean;
  22716. /**
  22717. * The state of the material
  22718. */
  22719. state: string;
  22720. /**
  22721. * The alpha value of the material
  22722. */
  22723. protected _alpha: number;
  22724. /**
  22725. * List of inspectable custom properties (used by the Inspector)
  22726. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22727. */
  22728. inspectableCustomProperties: IInspectable[];
  22729. /**
  22730. * Sets the alpha value of the material
  22731. */
  22732. /**
  22733. * Gets the alpha value of the material
  22734. */
  22735. alpha: number;
  22736. /**
  22737. * Specifies if back face culling is enabled
  22738. */
  22739. protected _backFaceCulling: boolean;
  22740. /**
  22741. * Sets the back-face culling state
  22742. */
  22743. /**
  22744. * Gets the back-face culling state
  22745. */
  22746. backFaceCulling: boolean;
  22747. /**
  22748. * Stores the value for side orientation
  22749. */
  22750. sideOrientation: number;
  22751. /**
  22752. * Callback triggered when the material is compiled
  22753. */
  22754. onCompiled: Nullable<(effect: Effect) => void>;
  22755. /**
  22756. * Callback triggered when an error occurs
  22757. */
  22758. onError: Nullable<(effect: Effect, errors: string) => void>;
  22759. /**
  22760. * Callback triggered to get the render target textures
  22761. */
  22762. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22763. /**
  22764. * Gets a boolean indicating that current material needs to register RTT
  22765. */
  22766. readonly hasRenderTargetTextures: boolean;
  22767. /**
  22768. * Specifies if the material should be serialized
  22769. */
  22770. doNotSerialize: boolean;
  22771. /**
  22772. * @hidden
  22773. */
  22774. _storeEffectOnSubMeshes: boolean;
  22775. /**
  22776. * Stores the animations for the material
  22777. */
  22778. animations: Nullable<Array<Animation>>;
  22779. /**
  22780. * An event triggered when the material is disposed
  22781. */
  22782. onDisposeObservable: Observable<Material>;
  22783. /**
  22784. * An observer which watches for dispose events
  22785. */
  22786. private _onDisposeObserver;
  22787. private _onUnBindObservable;
  22788. /**
  22789. * Called during a dispose event
  22790. */
  22791. onDispose: () => void;
  22792. private _onBindObservable;
  22793. /**
  22794. * An event triggered when the material is bound
  22795. */
  22796. readonly onBindObservable: Observable<AbstractMesh>;
  22797. /**
  22798. * An observer which watches for bind events
  22799. */
  22800. private _onBindObserver;
  22801. /**
  22802. * Called during a bind event
  22803. */
  22804. onBind: (Mesh: AbstractMesh) => void;
  22805. /**
  22806. * An event triggered when the material is unbound
  22807. */
  22808. readonly onUnBindObservable: Observable<Material>;
  22809. /**
  22810. * Stores the value of the alpha mode
  22811. */
  22812. private _alphaMode;
  22813. /**
  22814. * Sets the value of the alpha mode.
  22815. *
  22816. * | Value | Type | Description |
  22817. * | --- | --- | --- |
  22818. * | 0 | ALPHA_DISABLE | |
  22819. * | 1 | ALPHA_ADD | |
  22820. * | 2 | ALPHA_COMBINE | |
  22821. * | 3 | ALPHA_SUBTRACT | |
  22822. * | 4 | ALPHA_MULTIPLY | |
  22823. * | 5 | ALPHA_MAXIMIZED | |
  22824. * | 6 | ALPHA_ONEONE | |
  22825. * | 7 | ALPHA_PREMULTIPLIED | |
  22826. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22827. * | 9 | ALPHA_INTERPOLATE | |
  22828. * | 10 | ALPHA_SCREENMODE | |
  22829. *
  22830. */
  22831. /**
  22832. * Gets the value of the alpha mode
  22833. */
  22834. alphaMode: number;
  22835. /**
  22836. * Stores the state of the need depth pre-pass value
  22837. */
  22838. private _needDepthPrePass;
  22839. /**
  22840. * Sets the need depth pre-pass value
  22841. */
  22842. /**
  22843. * Gets the depth pre-pass value
  22844. */
  22845. needDepthPrePass: boolean;
  22846. /**
  22847. * Specifies if depth writing should be disabled
  22848. */
  22849. disableDepthWrite: boolean;
  22850. /**
  22851. * Specifies if depth writing should be forced
  22852. */
  22853. forceDepthWrite: boolean;
  22854. /**
  22855. * Specifies if there should be a separate pass for culling
  22856. */
  22857. separateCullingPass: boolean;
  22858. /**
  22859. * Stores the state specifing if fog should be enabled
  22860. */
  22861. private _fogEnabled;
  22862. /**
  22863. * Sets the state for enabling fog
  22864. */
  22865. /**
  22866. * Gets the value of the fog enabled state
  22867. */
  22868. fogEnabled: boolean;
  22869. /**
  22870. * Stores the size of points
  22871. */
  22872. pointSize: number;
  22873. /**
  22874. * Stores the z offset value
  22875. */
  22876. zOffset: number;
  22877. /**
  22878. * Gets a value specifying if wireframe mode is enabled
  22879. */
  22880. /**
  22881. * Sets the state of wireframe mode
  22882. */
  22883. wireframe: boolean;
  22884. /**
  22885. * Gets the value specifying if point clouds are enabled
  22886. */
  22887. /**
  22888. * Sets the state of point cloud mode
  22889. */
  22890. pointsCloud: boolean;
  22891. /**
  22892. * Gets the material fill mode
  22893. */
  22894. /**
  22895. * Sets the material fill mode
  22896. */
  22897. fillMode: number;
  22898. /**
  22899. * @hidden
  22900. * Stores the effects for the material
  22901. */
  22902. _effect: Nullable<Effect>;
  22903. /**
  22904. * @hidden
  22905. * Specifies if the material was previously ready
  22906. */
  22907. _wasPreviouslyReady: boolean;
  22908. /**
  22909. * Specifies if uniform buffers should be used
  22910. */
  22911. private _useUBO;
  22912. /**
  22913. * Stores a reference to the scene
  22914. */
  22915. private _scene;
  22916. /**
  22917. * Stores the fill mode state
  22918. */
  22919. private _fillMode;
  22920. /**
  22921. * Specifies if the depth write state should be cached
  22922. */
  22923. private _cachedDepthWriteState;
  22924. /**
  22925. * Stores the uniform buffer
  22926. */
  22927. protected _uniformBuffer: UniformBuffer;
  22928. /** @hidden */
  22929. _indexInSceneMaterialArray: number;
  22930. /** @hidden */
  22931. meshMap: Nullable<{
  22932. [id: string]: AbstractMesh | undefined;
  22933. }>;
  22934. /**
  22935. * Creates a material instance
  22936. * @param name defines the name of the material
  22937. * @param scene defines the scene to reference
  22938. * @param doNotAdd specifies if the material should be added to the scene
  22939. */
  22940. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22941. /**
  22942. * Returns a string representation of the current material
  22943. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22944. * @returns a string with material information
  22945. */
  22946. toString(fullDetails?: boolean): string;
  22947. /**
  22948. * Gets the class name of the material
  22949. * @returns a string with the class name of the material
  22950. */
  22951. getClassName(): string;
  22952. /**
  22953. * Specifies if updates for the material been locked
  22954. */
  22955. readonly isFrozen: boolean;
  22956. /**
  22957. * Locks updates for the material
  22958. */
  22959. freeze(): void;
  22960. /**
  22961. * Unlocks updates for the material
  22962. */
  22963. unfreeze(): void;
  22964. /**
  22965. * Specifies if the material is ready to be used
  22966. * @param mesh defines the mesh to check
  22967. * @param useInstances specifies if instances should be used
  22968. * @returns a boolean indicating if the material is ready to be used
  22969. */
  22970. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22971. /**
  22972. * Specifies that the submesh is ready to be used
  22973. * @param mesh defines the mesh to check
  22974. * @param subMesh defines which submesh to check
  22975. * @param useInstances specifies that instances should be used
  22976. * @returns a boolean indicating that the submesh is ready or not
  22977. */
  22978. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22979. /**
  22980. * Returns the material effect
  22981. * @returns the effect associated with the material
  22982. */
  22983. getEffect(): Nullable<Effect>;
  22984. /**
  22985. * Returns the current scene
  22986. * @returns a Scene
  22987. */
  22988. getScene(): Scene;
  22989. /**
  22990. * Specifies if the material will require alpha blending
  22991. * @returns a boolean specifying if alpha blending is needed
  22992. */
  22993. needAlphaBlending(): boolean;
  22994. /**
  22995. * Specifies if the mesh will require alpha blending
  22996. * @param mesh defines the mesh to check
  22997. * @returns a boolean specifying if alpha blending is needed for the mesh
  22998. */
  22999. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  23000. /**
  23001. * Specifies if this material should be rendered in alpha test mode
  23002. * @returns a boolean specifying if an alpha test is needed.
  23003. */
  23004. needAlphaTesting(): boolean;
  23005. /**
  23006. * Gets the texture used for the alpha test
  23007. * @returns the texture to use for alpha testing
  23008. */
  23009. getAlphaTestTexture(): Nullable<BaseTexture>;
  23010. /**
  23011. * Marks the material to indicate that it needs to be re-calculated
  23012. */
  23013. markDirty(): void;
  23014. /** @hidden */
  23015. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  23016. /**
  23017. * Binds the material to the mesh
  23018. * @param world defines the world transformation matrix
  23019. * @param mesh defines the mesh to bind the material to
  23020. */
  23021. bind(world: Matrix, mesh?: Mesh): void;
  23022. /**
  23023. * Binds the submesh to the material
  23024. * @param world defines the world transformation matrix
  23025. * @param mesh defines the mesh containing the submesh
  23026. * @param subMesh defines the submesh to bind the material to
  23027. */
  23028. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23029. /**
  23030. * Binds the world matrix to the material
  23031. * @param world defines the world transformation matrix
  23032. */
  23033. bindOnlyWorldMatrix(world: Matrix): void;
  23034. /**
  23035. * Binds the scene's uniform buffer to the effect.
  23036. * @param effect defines the effect to bind to the scene uniform buffer
  23037. * @param sceneUbo defines the uniform buffer storing scene data
  23038. */
  23039. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  23040. /**
  23041. * Binds the view matrix to the effect
  23042. * @param effect defines the effect to bind the view matrix to
  23043. */
  23044. bindView(effect: Effect): void;
  23045. /**
  23046. * Binds the view projection matrix to the effect
  23047. * @param effect defines the effect to bind the view projection matrix to
  23048. */
  23049. bindViewProjection(effect: Effect): void;
  23050. /**
  23051. * Specifies if material alpha testing should be turned on for the mesh
  23052. * @param mesh defines the mesh to check
  23053. */
  23054. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  23055. /**
  23056. * Processes to execute after binding the material to a mesh
  23057. * @param mesh defines the rendered mesh
  23058. */
  23059. protected _afterBind(mesh?: Mesh): void;
  23060. /**
  23061. * Unbinds the material from the mesh
  23062. */
  23063. unbind(): void;
  23064. /**
  23065. * Gets the active textures from the material
  23066. * @returns an array of textures
  23067. */
  23068. getActiveTextures(): BaseTexture[];
  23069. /**
  23070. * Specifies if the material uses a texture
  23071. * @param texture defines the texture to check against the material
  23072. * @returns a boolean specifying if the material uses the texture
  23073. */
  23074. hasTexture(texture: BaseTexture): boolean;
  23075. /**
  23076. * Makes a duplicate of the material, and gives it a new name
  23077. * @param name defines the new name for the duplicated material
  23078. * @returns the cloned material
  23079. */
  23080. clone(name: string): Nullable<Material>;
  23081. /**
  23082. * Gets the meshes bound to the material
  23083. * @returns an array of meshes bound to the material
  23084. */
  23085. getBindedMeshes(): AbstractMesh[];
  23086. /**
  23087. * Force shader compilation
  23088. * @param mesh defines the mesh associated with this material
  23089. * @param onCompiled defines a function to execute once the material is compiled
  23090. * @param options defines the options to configure the compilation
  23091. */
  23092. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  23093. clipPlane: boolean;
  23094. }>): void;
  23095. /**
  23096. * Force shader compilation
  23097. * @param mesh defines the mesh that will use this material
  23098. * @param options defines additional options for compiling the shaders
  23099. * @returns a promise that resolves when the compilation completes
  23100. */
  23101. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  23102. clipPlane: boolean;
  23103. }>): Promise<void>;
  23104. private static readonly _AllDirtyCallBack;
  23105. private static readonly _ImageProcessingDirtyCallBack;
  23106. private static readonly _TextureDirtyCallBack;
  23107. private static readonly _FresnelDirtyCallBack;
  23108. private static readonly _MiscDirtyCallBack;
  23109. private static readonly _LightsDirtyCallBack;
  23110. private static readonly _AttributeDirtyCallBack;
  23111. private static _FresnelAndMiscDirtyCallBack;
  23112. private static _TextureAndMiscDirtyCallBack;
  23113. private static readonly _DirtyCallbackArray;
  23114. private static readonly _RunDirtyCallBacks;
  23115. /**
  23116. * Marks a define in the material to indicate that it needs to be re-computed
  23117. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  23118. */
  23119. markAsDirty(flag: number): void;
  23120. /**
  23121. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  23122. * @param func defines a function which checks material defines against the submeshes
  23123. */
  23124. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  23125. /**
  23126. * Indicates that we need to re-calculated for all submeshes
  23127. */
  23128. protected _markAllSubMeshesAsAllDirty(): void;
  23129. /**
  23130. * Indicates that image processing needs to be re-calculated for all submeshes
  23131. */
  23132. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  23133. /**
  23134. * Indicates that textures need to be re-calculated for all submeshes
  23135. */
  23136. protected _markAllSubMeshesAsTexturesDirty(): void;
  23137. /**
  23138. * Indicates that fresnel needs to be re-calculated for all submeshes
  23139. */
  23140. protected _markAllSubMeshesAsFresnelDirty(): void;
  23141. /**
  23142. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  23143. */
  23144. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  23145. /**
  23146. * Indicates that lights need to be re-calculated for all submeshes
  23147. */
  23148. protected _markAllSubMeshesAsLightsDirty(): void;
  23149. /**
  23150. * Indicates that attributes need to be re-calculated for all submeshes
  23151. */
  23152. protected _markAllSubMeshesAsAttributesDirty(): void;
  23153. /**
  23154. * Indicates that misc needs to be re-calculated for all submeshes
  23155. */
  23156. protected _markAllSubMeshesAsMiscDirty(): void;
  23157. /**
  23158. * Indicates that textures and misc need to be re-calculated for all submeshes
  23159. */
  23160. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  23161. /**
  23162. * Disposes the material
  23163. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23164. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23165. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23166. */
  23167. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23168. /** @hidden */
  23169. private releaseVertexArrayObject;
  23170. /**
  23171. * Serializes this material
  23172. * @returns the serialized material object
  23173. */
  23174. serialize(): any;
  23175. /**
  23176. * Creates a material from parsed material data
  23177. * @param parsedMaterial defines parsed material data
  23178. * @param scene defines the hosting scene
  23179. * @param rootUrl defines the root URL to use to load textures
  23180. * @returns a new material
  23181. */
  23182. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  23183. }
  23184. }
  23185. declare module "babylonjs/Meshes/subMesh" {
  23186. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  23187. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  23188. import { Engine } from "babylonjs/Engines/engine";
  23189. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  23190. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23191. import { Effect } from "babylonjs/Materials/effect";
  23192. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23193. import { Collider } from "babylonjs/Collisions/collider";
  23194. import { Material } from "babylonjs/Materials/material";
  23195. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23196. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23197. import { Mesh } from "babylonjs/Meshes/mesh";
  23198. import { Ray } from "babylonjs/Culling/ray";
  23199. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23200. /**
  23201. * Base class for submeshes
  23202. */
  23203. export class BaseSubMesh {
  23204. /** @hidden */
  23205. _materialDefines: Nullable<MaterialDefines>;
  23206. /** @hidden */
  23207. _materialEffect: Nullable<Effect>;
  23208. /**
  23209. * Gets associated effect
  23210. */
  23211. readonly effect: Nullable<Effect>;
  23212. /**
  23213. * Sets associated effect (effect used to render this submesh)
  23214. * @param effect defines the effect to associate with
  23215. * @param defines defines the set of defines used to compile this effect
  23216. */
  23217. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23218. }
  23219. /**
  23220. * Defines a subdivision inside a mesh
  23221. */
  23222. export class SubMesh extends BaseSubMesh implements ICullable {
  23223. /** the material index to use */
  23224. materialIndex: number;
  23225. /** vertex index start */
  23226. verticesStart: number;
  23227. /** vertices count */
  23228. verticesCount: number;
  23229. /** index start */
  23230. indexStart: number;
  23231. /** indices count */
  23232. indexCount: number;
  23233. /** @hidden */
  23234. _linesIndexCount: number;
  23235. private _mesh;
  23236. private _renderingMesh;
  23237. private _boundingInfo;
  23238. private _linesIndexBuffer;
  23239. /** @hidden */
  23240. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23241. /** @hidden */
  23242. _trianglePlanes: Plane[];
  23243. /** @hidden */
  23244. _lastColliderTransformMatrix: Nullable<Matrix>;
  23245. /** @hidden */
  23246. _renderId: number;
  23247. /** @hidden */
  23248. _alphaIndex: number;
  23249. /** @hidden */
  23250. _distanceToCamera: number;
  23251. /** @hidden */
  23252. _id: number;
  23253. private _currentMaterial;
  23254. /**
  23255. * Add a new submesh to a mesh
  23256. * @param materialIndex defines the material index to use
  23257. * @param verticesStart defines vertex index start
  23258. * @param verticesCount defines vertices count
  23259. * @param indexStart defines index start
  23260. * @param indexCount defines indices count
  23261. * @param mesh defines the parent mesh
  23262. * @param renderingMesh defines an optional rendering mesh
  23263. * @param createBoundingBox defines if bounding box should be created for this submesh
  23264. * @returns the new submesh
  23265. */
  23266. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23267. /**
  23268. * Creates a new submesh
  23269. * @param materialIndex defines the material index to use
  23270. * @param verticesStart defines vertex index start
  23271. * @param verticesCount defines vertices count
  23272. * @param indexStart defines index start
  23273. * @param indexCount defines indices count
  23274. * @param mesh defines the parent mesh
  23275. * @param renderingMesh defines an optional rendering mesh
  23276. * @param createBoundingBox defines if bounding box should be created for this submesh
  23277. */
  23278. constructor(
  23279. /** the material index to use */
  23280. materialIndex: number,
  23281. /** vertex index start */
  23282. verticesStart: number,
  23283. /** vertices count */
  23284. verticesCount: number,
  23285. /** index start */
  23286. indexStart: number,
  23287. /** indices count */
  23288. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23289. /**
  23290. * Returns true if this submesh covers the entire parent mesh
  23291. * @ignorenaming
  23292. */
  23293. readonly IsGlobal: boolean;
  23294. /**
  23295. * Returns the submesh BoudingInfo object
  23296. * @returns current bounding info (or mesh's one if the submesh is global)
  23297. */
  23298. getBoundingInfo(): BoundingInfo;
  23299. /**
  23300. * Sets the submesh BoundingInfo
  23301. * @param boundingInfo defines the new bounding info to use
  23302. * @returns the SubMesh
  23303. */
  23304. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23305. /**
  23306. * Returns the mesh of the current submesh
  23307. * @return the parent mesh
  23308. */
  23309. getMesh(): AbstractMesh;
  23310. /**
  23311. * Returns the rendering mesh of the submesh
  23312. * @returns the rendering mesh (could be different from parent mesh)
  23313. */
  23314. getRenderingMesh(): Mesh;
  23315. /**
  23316. * Returns the submesh material
  23317. * @returns null or the current material
  23318. */
  23319. getMaterial(): Nullable<Material>;
  23320. /**
  23321. * Sets a new updated BoundingInfo object to the submesh
  23322. * @param data defines an optional position array to use to determine the bounding info
  23323. * @returns the SubMesh
  23324. */
  23325. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  23326. /** @hidden */
  23327. _checkCollision(collider: Collider): boolean;
  23328. /**
  23329. * Updates the submesh BoundingInfo
  23330. * @param world defines the world matrix to use to update the bounding info
  23331. * @returns the submesh
  23332. */
  23333. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  23334. /**
  23335. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23336. * @param frustumPlanes defines the frustum planes
  23337. * @returns true if the submesh is intersecting with the frustum
  23338. */
  23339. isInFrustum(frustumPlanes: Plane[]): boolean;
  23340. /**
  23341. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  23342. * @param frustumPlanes defines the frustum planes
  23343. * @returns true if the submesh is inside the frustum
  23344. */
  23345. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23346. /**
  23347. * Renders the submesh
  23348. * @param enableAlphaMode defines if alpha needs to be used
  23349. * @returns the submesh
  23350. */
  23351. render(enableAlphaMode: boolean): SubMesh;
  23352. /**
  23353. * @hidden
  23354. */
  23355. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  23356. /**
  23357. * Checks if the submesh intersects with a ray
  23358. * @param ray defines the ray to test
  23359. * @returns true is the passed ray intersects the submesh bounding box
  23360. */
  23361. canIntersects(ray: Ray): boolean;
  23362. /**
  23363. * Intersects current submesh with a ray
  23364. * @param ray defines the ray to test
  23365. * @param positions defines mesh's positions array
  23366. * @param indices defines mesh's indices array
  23367. * @param fastCheck defines if only bounding info should be used
  23368. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  23369. * @returns intersection info or null if no intersection
  23370. */
  23371. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  23372. /** @hidden */
  23373. private _intersectLines;
  23374. /** @hidden */
  23375. private _intersectUnIndexedLines;
  23376. /** @hidden */
  23377. private _intersectTriangles;
  23378. /** @hidden */
  23379. private _intersectUnIndexedTriangles;
  23380. /** @hidden */
  23381. _rebuild(): void;
  23382. /**
  23383. * Creates a new submesh from the passed mesh
  23384. * @param newMesh defines the new hosting mesh
  23385. * @param newRenderingMesh defines an optional rendering mesh
  23386. * @returns the new submesh
  23387. */
  23388. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23389. /**
  23390. * Release associated resources
  23391. */
  23392. dispose(): void;
  23393. /**
  23394. * Gets the class name
  23395. * @returns the string "SubMesh".
  23396. */
  23397. getClassName(): string;
  23398. /**
  23399. * Creates a new submesh from indices data
  23400. * @param materialIndex the index of the main mesh material
  23401. * @param startIndex the index where to start the copy in the mesh indices array
  23402. * @param indexCount the number of indices to copy then from the startIndex
  23403. * @param mesh the main mesh to create the submesh from
  23404. * @param renderingMesh the optional rendering mesh
  23405. * @returns a new submesh
  23406. */
  23407. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23408. }
  23409. }
  23410. declare module "babylonjs/Meshes/geometry" {
  23411. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  23412. import { Scene } from "babylonjs/scene";
  23413. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  23414. import { Engine } from "babylonjs/Engines/engine";
  23415. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  23416. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23417. import { Effect } from "babylonjs/Materials/effect";
  23418. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23419. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23420. import { Mesh } from "babylonjs/Meshes/mesh";
  23421. /**
  23422. * Class used to store geometry data (vertex buffers + index buffer)
  23423. */
  23424. export class Geometry implements IGetSetVerticesData {
  23425. /**
  23426. * Gets or sets the ID of the geometry
  23427. */
  23428. id: string;
  23429. /**
  23430. * Gets or sets the unique ID of the geometry
  23431. */
  23432. uniqueId: number;
  23433. /**
  23434. * Gets the delay loading state of the geometry (none by default which means not delayed)
  23435. */
  23436. delayLoadState: number;
  23437. /**
  23438. * Gets the file containing the data to load when running in delay load state
  23439. */
  23440. delayLoadingFile: Nullable<string>;
  23441. /**
  23442. * Callback called when the geometry is updated
  23443. */
  23444. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  23445. private _scene;
  23446. private _engine;
  23447. private _meshes;
  23448. private _totalVertices;
  23449. /** @hidden */
  23450. _indices: IndicesArray;
  23451. /** @hidden */
  23452. _vertexBuffers: {
  23453. [key: string]: VertexBuffer;
  23454. };
  23455. private _isDisposed;
  23456. private _extend;
  23457. private _boundingBias;
  23458. /** @hidden */
  23459. _delayInfo: Array<string>;
  23460. private _indexBuffer;
  23461. private _indexBufferIsUpdatable;
  23462. /** @hidden */
  23463. _boundingInfo: Nullable<BoundingInfo>;
  23464. /** @hidden */
  23465. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  23466. /** @hidden */
  23467. _softwareSkinningFrameId: number;
  23468. private _vertexArrayObjects;
  23469. private _updatable;
  23470. /** @hidden */
  23471. _positions: Nullable<Vector3[]>;
  23472. /**
  23473. * 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
  23474. */
  23475. /**
  23476. * 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
  23477. */
  23478. boundingBias: Vector2;
  23479. /**
  23480. * Static function used to attach a new empty geometry to a mesh
  23481. * @param mesh defines the mesh to attach the geometry to
  23482. * @returns the new Geometry
  23483. */
  23484. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  23485. /**
  23486. * Creates a new geometry
  23487. * @param id defines the unique ID
  23488. * @param scene defines the hosting scene
  23489. * @param vertexData defines the VertexData used to get geometry data
  23490. * @param updatable defines if geometry must be updatable (false by default)
  23491. * @param mesh defines the mesh that will be associated with the geometry
  23492. */
  23493. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  23494. /**
  23495. * Gets the current extend of the geometry
  23496. */
  23497. readonly extend: {
  23498. minimum: Vector3;
  23499. maximum: Vector3;
  23500. };
  23501. /**
  23502. * Gets the hosting scene
  23503. * @returns the hosting Scene
  23504. */
  23505. getScene(): Scene;
  23506. /**
  23507. * Gets the hosting engine
  23508. * @returns the hosting Engine
  23509. */
  23510. getEngine(): Engine;
  23511. /**
  23512. * Defines if the geometry is ready to use
  23513. * @returns true if the geometry is ready to be used
  23514. */
  23515. isReady(): boolean;
  23516. /**
  23517. * Gets a value indicating that the geometry should not be serialized
  23518. */
  23519. readonly doNotSerialize: boolean;
  23520. /** @hidden */
  23521. _rebuild(): void;
  23522. /**
  23523. * Affects all geometry data in one call
  23524. * @param vertexData defines the geometry data
  23525. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23526. */
  23527. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23528. /**
  23529. * Set specific vertex data
  23530. * @param kind defines the data kind (Position, normal, etc...)
  23531. * @param data defines the vertex data to use
  23532. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23533. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23534. */
  23535. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23536. /**
  23537. * Removes a specific vertex data
  23538. * @param kind defines the data kind (Position, normal, etc...)
  23539. */
  23540. removeVerticesData(kind: string): void;
  23541. /**
  23542. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23543. * @param buffer defines the vertex buffer to use
  23544. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23545. */
  23546. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23547. /**
  23548. * Update a specific vertex buffer
  23549. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  23550. * It will do nothing if the buffer is not updatable
  23551. * @param kind defines the data kind (Position, normal, etc...)
  23552. * @param data defines the data to use
  23553. * @param offset defines the offset in the target buffer where to store the data
  23554. * @param useBytes set to true if the offset is in bytes
  23555. */
  23556. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23557. /**
  23558. * Update a specific vertex buffer
  23559. * This function will create a new buffer if the current one is not updatable
  23560. * @param kind defines the data kind (Position, normal, etc...)
  23561. * @param data defines the data to use
  23562. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23563. */
  23564. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23565. private _updateBoundingInfo;
  23566. /** @hidden */
  23567. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  23568. /**
  23569. * Gets total number of vertices
  23570. * @returns the total number of vertices
  23571. */
  23572. getTotalVertices(): number;
  23573. /**
  23574. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23575. * @param kind defines the data kind (Position, normal, etc...)
  23576. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23577. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23578. * @returns a float array containing vertex data
  23579. */
  23580. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23581. /**
  23582. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23583. * @param kind defines the data kind (Position, normal, etc...)
  23584. * @returns true if the vertex buffer with the specified kind is updatable
  23585. */
  23586. isVertexBufferUpdatable(kind: string): boolean;
  23587. /**
  23588. * Gets a specific vertex buffer
  23589. * @param kind defines the data kind (Position, normal, etc...)
  23590. * @returns a VertexBuffer
  23591. */
  23592. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23593. /**
  23594. * Returns all vertex buffers
  23595. * @return an object holding all vertex buffers indexed by kind
  23596. */
  23597. getVertexBuffers(): Nullable<{
  23598. [key: string]: VertexBuffer;
  23599. }>;
  23600. /**
  23601. * Gets a boolean indicating if specific vertex buffer is present
  23602. * @param kind defines the data kind (Position, normal, etc...)
  23603. * @returns true if data is present
  23604. */
  23605. isVerticesDataPresent(kind: string): boolean;
  23606. /**
  23607. * Gets a list of all attached data kinds (Position, normal, etc...)
  23608. * @returns a list of string containing all kinds
  23609. */
  23610. getVerticesDataKinds(): string[];
  23611. /**
  23612. * Update index buffer
  23613. * @param indices defines the indices to store in the index buffer
  23614. * @param offset defines the offset in the target buffer where to store the data
  23615. * @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)
  23616. */
  23617. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23618. /**
  23619. * Creates a new index buffer
  23620. * @param indices defines the indices to store in the index buffer
  23621. * @param totalVertices defines the total number of vertices (could be null)
  23622. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23623. */
  23624. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23625. /**
  23626. * Return the total number of indices
  23627. * @returns the total number of indices
  23628. */
  23629. getTotalIndices(): number;
  23630. /**
  23631. * Gets the index buffer array
  23632. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23633. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23634. * @returns the index buffer array
  23635. */
  23636. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23637. /**
  23638. * Gets the index buffer
  23639. * @return the index buffer
  23640. */
  23641. getIndexBuffer(): Nullable<DataBuffer>;
  23642. /** @hidden */
  23643. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23644. /**
  23645. * Release the associated resources for a specific mesh
  23646. * @param mesh defines the source mesh
  23647. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23648. */
  23649. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23650. /**
  23651. * Apply current geometry to a given mesh
  23652. * @param mesh defines the mesh to apply geometry to
  23653. */
  23654. applyToMesh(mesh: Mesh): void;
  23655. private _updateExtend;
  23656. private _applyToMesh;
  23657. private notifyUpdate;
  23658. /**
  23659. * Load the geometry if it was flagged as delay loaded
  23660. * @param scene defines the hosting scene
  23661. * @param onLoaded defines a callback called when the geometry is loaded
  23662. */
  23663. load(scene: Scene, onLoaded?: () => void): void;
  23664. private _queueLoad;
  23665. /**
  23666. * Invert the geometry to move from a right handed system to a left handed one.
  23667. */
  23668. toLeftHanded(): void;
  23669. /** @hidden */
  23670. _resetPointsArrayCache(): void;
  23671. /** @hidden */
  23672. _generatePointsArray(): boolean;
  23673. /**
  23674. * Gets a value indicating if the geometry is disposed
  23675. * @returns true if the geometry was disposed
  23676. */
  23677. isDisposed(): boolean;
  23678. private _disposeVertexArrayObjects;
  23679. /**
  23680. * Free all associated resources
  23681. */
  23682. dispose(): void;
  23683. /**
  23684. * Clone the current geometry into a new geometry
  23685. * @param id defines the unique ID of the new geometry
  23686. * @returns a new geometry object
  23687. */
  23688. copy(id: string): Geometry;
  23689. /**
  23690. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23691. * @return a JSON representation of the current geometry data (without the vertices data)
  23692. */
  23693. serialize(): any;
  23694. private toNumberArray;
  23695. /**
  23696. * Serialize all vertices data into a JSON oject
  23697. * @returns a JSON representation of the current geometry data
  23698. */
  23699. serializeVerticeData(): any;
  23700. /**
  23701. * Extracts a clone of a mesh geometry
  23702. * @param mesh defines the source mesh
  23703. * @param id defines the unique ID of the new geometry object
  23704. * @returns the new geometry object
  23705. */
  23706. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23707. /**
  23708. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23709. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23710. * Be aware Math.random() could cause collisions, but:
  23711. * "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"
  23712. * @returns a string containing a new GUID
  23713. */
  23714. static RandomId(): string;
  23715. /** @hidden */
  23716. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23717. private static _CleanMatricesWeights;
  23718. /**
  23719. * Create a new geometry from persisted data (Using .babylon file format)
  23720. * @param parsedVertexData defines the persisted data
  23721. * @param scene defines the hosting scene
  23722. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23723. * @returns the new geometry object
  23724. */
  23725. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23726. }
  23727. }
  23728. declare module "babylonjs/Meshes/mesh.vertexData" {
  23729. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23730. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23731. import { Geometry } from "babylonjs/Meshes/geometry";
  23732. import { Mesh } from "babylonjs/Meshes/mesh";
  23733. /**
  23734. * Define an interface for all classes that will get and set the data on vertices
  23735. */
  23736. export interface IGetSetVerticesData {
  23737. /**
  23738. * Gets a boolean indicating if specific vertex data is present
  23739. * @param kind defines the vertex data kind to use
  23740. * @returns true is data kind is present
  23741. */
  23742. isVerticesDataPresent(kind: string): boolean;
  23743. /**
  23744. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23745. * @param kind defines the data kind (Position, normal, etc...)
  23746. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23747. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23748. * @returns a float array containing vertex data
  23749. */
  23750. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23751. /**
  23752. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23753. * @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.
  23754. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23755. * @returns the indices array or an empty array if the mesh has no geometry
  23756. */
  23757. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23758. /**
  23759. * Set specific vertex data
  23760. * @param kind defines the data kind (Position, normal, etc...)
  23761. * @param data defines the vertex data to use
  23762. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23763. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23764. */
  23765. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23766. /**
  23767. * Update a specific associated vertex buffer
  23768. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23769. * - VertexBuffer.PositionKind
  23770. * - VertexBuffer.UVKind
  23771. * - VertexBuffer.UV2Kind
  23772. * - VertexBuffer.UV3Kind
  23773. * - VertexBuffer.UV4Kind
  23774. * - VertexBuffer.UV5Kind
  23775. * - VertexBuffer.UV6Kind
  23776. * - VertexBuffer.ColorKind
  23777. * - VertexBuffer.MatricesIndicesKind
  23778. * - VertexBuffer.MatricesIndicesExtraKind
  23779. * - VertexBuffer.MatricesWeightsKind
  23780. * - VertexBuffer.MatricesWeightsExtraKind
  23781. * @param data defines the data source
  23782. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23783. * @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)
  23784. */
  23785. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23786. /**
  23787. * Creates a new index buffer
  23788. * @param indices defines the indices to store in the index buffer
  23789. * @param totalVertices defines the total number of vertices (could be null)
  23790. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23791. */
  23792. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23793. }
  23794. /**
  23795. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23796. */
  23797. export class VertexData {
  23798. /**
  23799. * Mesh side orientation : usually the external or front surface
  23800. */
  23801. static readonly FRONTSIDE: number;
  23802. /**
  23803. * Mesh side orientation : usually the internal or back surface
  23804. */
  23805. static readonly BACKSIDE: number;
  23806. /**
  23807. * Mesh side orientation : both internal and external or front and back surfaces
  23808. */
  23809. static readonly DOUBLESIDE: number;
  23810. /**
  23811. * Mesh side orientation : by default, `FRONTSIDE`
  23812. */
  23813. static readonly DEFAULTSIDE: number;
  23814. /**
  23815. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23816. */
  23817. positions: Nullable<FloatArray>;
  23818. /**
  23819. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23820. */
  23821. normals: Nullable<FloatArray>;
  23822. /**
  23823. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23824. */
  23825. tangents: Nullable<FloatArray>;
  23826. /**
  23827. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23828. */
  23829. uvs: Nullable<FloatArray>;
  23830. /**
  23831. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23832. */
  23833. uvs2: Nullable<FloatArray>;
  23834. /**
  23835. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23836. */
  23837. uvs3: Nullable<FloatArray>;
  23838. /**
  23839. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23840. */
  23841. uvs4: Nullable<FloatArray>;
  23842. /**
  23843. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23844. */
  23845. uvs5: Nullable<FloatArray>;
  23846. /**
  23847. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23848. */
  23849. uvs6: Nullable<FloatArray>;
  23850. /**
  23851. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23852. */
  23853. colors: Nullable<FloatArray>;
  23854. /**
  23855. * 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).
  23856. */
  23857. matricesIndices: Nullable<FloatArray>;
  23858. /**
  23859. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23860. */
  23861. matricesWeights: Nullable<FloatArray>;
  23862. /**
  23863. * An array extending the number of possible indices
  23864. */
  23865. matricesIndicesExtra: Nullable<FloatArray>;
  23866. /**
  23867. * An array extending the number of possible weights when the number of indices is extended
  23868. */
  23869. matricesWeightsExtra: Nullable<FloatArray>;
  23870. /**
  23871. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23872. */
  23873. indices: Nullable<IndicesArray>;
  23874. /**
  23875. * Uses the passed data array to set the set the values for the specified kind of data
  23876. * @param data a linear array of floating numbers
  23877. * @param kind the type of data that is being set, eg positions, colors etc
  23878. */
  23879. set(data: FloatArray, kind: string): void;
  23880. /**
  23881. * Associates the vertexData to the passed Mesh.
  23882. * Sets it as updatable or not (default `false`)
  23883. * @param mesh the mesh the vertexData is applied to
  23884. * @param updatable when used and having the value true allows new data to update the vertexData
  23885. * @returns the VertexData
  23886. */
  23887. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23888. /**
  23889. * Associates the vertexData to the passed Geometry.
  23890. * Sets it as updatable or not (default `false`)
  23891. * @param geometry the geometry the vertexData is applied to
  23892. * @param updatable when used and having the value true allows new data to update the vertexData
  23893. * @returns VertexData
  23894. */
  23895. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23896. /**
  23897. * Updates the associated mesh
  23898. * @param mesh the mesh to be updated
  23899. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23900. * @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
  23901. * @returns VertexData
  23902. */
  23903. updateMesh(mesh: Mesh): VertexData;
  23904. /**
  23905. * Updates the associated geometry
  23906. * @param geometry the geometry to be updated
  23907. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23908. * @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
  23909. * @returns VertexData.
  23910. */
  23911. updateGeometry(geometry: Geometry): VertexData;
  23912. private _applyTo;
  23913. private _update;
  23914. /**
  23915. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23916. * @param matrix the transforming matrix
  23917. * @returns the VertexData
  23918. */
  23919. transform(matrix: Matrix): VertexData;
  23920. /**
  23921. * Merges the passed VertexData into the current one
  23922. * @param other the VertexData to be merged into the current one
  23923. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23924. * @returns the modified VertexData
  23925. */
  23926. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23927. private _mergeElement;
  23928. private _validate;
  23929. /**
  23930. * Serializes the VertexData
  23931. * @returns a serialized object
  23932. */
  23933. serialize(): any;
  23934. /**
  23935. * Extracts the vertexData from a mesh
  23936. * @param mesh the mesh from which to extract the VertexData
  23937. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23938. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23939. * @returns the object VertexData associated to the passed mesh
  23940. */
  23941. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23942. /**
  23943. * Extracts the vertexData from the geometry
  23944. * @param geometry the geometry from which to extract the VertexData
  23945. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23946. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23947. * @returns the object VertexData associated to the passed mesh
  23948. */
  23949. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23950. private static _ExtractFrom;
  23951. /**
  23952. * Creates the VertexData for a Ribbon
  23953. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23954. * * pathArray array of paths, each of which an array of successive Vector3
  23955. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23956. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23957. * * 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
  23958. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23959. * * 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)
  23960. * * 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)
  23961. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23962. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23963. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23964. * @returns the VertexData of the ribbon
  23965. */
  23966. static CreateRibbon(options: {
  23967. pathArray: Vector3[][];
  23968. closeArray?: boolean;
  23969. closePath?: boolean;
  23970. offset?: number;
  23971. sideOrientation?: number;
  23972. frontUVs?: Vector4;
  23973. backUVs?: Vector4;
  23974. invertUV?: boolean;
  23975. uvs?: Vector2[];
  23976. colors?: Color4[];
  23977. }): VertexData;
  23978. /**
  23979. * Creates the VertexData for a box
  23980. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23981. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23982. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23983. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23984. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23985. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23986. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23987. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23988. * * 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)
  23989. * * 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)
  23990. * @returns the VertexData of the box
  23991. */
  23992. static CreateBox(options: {
  23993. size?: number;
  23994. width?: number;
  23995. height?: number;
  23996. depth?: number;
  23997. faceUV?: Vector4[];
  23998. faceColors?: Color4[];
  23999. sideOrientation?: number;
  24000. frontUVs?: Vector4;
  24001. backUVs?: Vector4;
  24002. }): VertexData;
  24003. /**
  24004. * Creates the VertexData for a tiled box
  24005. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24006. * * faceTiles sets the pattern, tile size and number of tiles for a face
  24007. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  24008. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  24009. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24010. * @returns the VertexData of the box
  24011. */
  24012. static CreateTiledBox(options: {
  24013. pattern?: number;
  24014. width?: number;
  24015. height?: number;
  24016. depth?: number;
  24017. tileSize?: number;
  24018. tileWidth?: number;
  24019. tileHeight?: number;
  24020. alignHorizontal?: number;
  24021. alignVertical?: number;
  24022. faceUV?: Vector4[];
  24023. faceColors?: Color4[];
  24024. sideOrientation?: number;
  24025. }): VertexData;
  24026. /**
  24027. * Creates the VertexData for a tiled plane
  24028. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24029. * * pattern a limited pattern arrangement depending on the number
  24030. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  24031. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  24032. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  24033. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24034. * * 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)
  24035. * * 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)
  24036. * @returns the VertexData of the tiled plane
  24037. */
  24038. static CreateTiledPlane(options: {
  24039. pattern?: number;
  24040. tileSize?: number;
  24041. tileWidth?: number;
  24042. tileHeight?: number;
  24043. size?: number;
  24044. width?: number;
  24045. height?: number;
  24046. alignHorizontal?: number;
  24047. alignVertical?: number;
  24048. sideOrientation?: number;
  24049. frontUVs?: Vector4;
  24050. backUVs?: Vector4;
  24051. }): VertexData;
  24052. /**
  24053. * Creates the VertexData for an ellipsoid, defaults to a sphere
  24054. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24055. * * segments sets the number of horizontal strips optional, default 32
  24056. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  24057. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  24058. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  24059. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  24060. * * 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
  24061. * * 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
  24062. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24063. * * 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)
  24064. * * 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)
  24065. * @returns the VertexData of the ellipsoid
  24066. */
  24067. static CreateSphere(options: {
  24068. segments?: number;
  24069. diameter?: number;
  24070. diameterX?: number;
  24071. diameterY?: number;
  24072. diameterZ?: number;
  24073. arc?: number;
  24074. slice?: number;
  24075. sideOrientation?: number;
  24076. frontUVs?: Vector4;
  24077. backUVs?: Vector4;
  24078. }): VertexData;
  24079. /**
  24080. * Creates the VertexData for a cylinder, cone or prism
  24081. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24082. * * height sets the height (y direction) of the cylinder, optional, default 2
  24083. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  24084. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  24085. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  24086. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24087. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  24088. * * 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
  24089. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24090. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24091. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  24092. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  24093. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24094. * * 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)
  24095. * * 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)
  24096. * @returns the VertexData of the cylinder, cone or prism
  24097. */
  24098. static CreateCylinder(options: {
  24099. height?: number;
  24100. diameterTop?: number;
  24101. diameterBottom?: number;
  24102. diameter?: number;
  24103. tessellation?: number;
  24104. subdivisions?: number;
  24105. arc?: number;
  24106. faceColors?: Color4[];
  24107. faceUV?: Vector4[];
  24108. hasRings?: boolean;
  24109. enclose?: boolean;
  24110. sideOrientation?: number;
  24111. frontUVs?: Vector4;
  24112. backUVs?: Vector4;
  24113. }): VertexData;
  24114. /**
  24115. * Creates the VertexData for a torus
  24116. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24117. * * diameter the diameter of the torus, optional default 1
  24118. * * thickness the diameter of the tube forming the torus, optional default 0.5
  24119. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24120. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24121. * * 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)
  24122. * * 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)
  24123. * @returns the VertexData of the torus
  24124. */
  24125. static CreateTorus(options: {
  24126. diameter?: number;
  24127. thickness?: number;
  24128. tessellation?: number;
  24129. sideOrientation?: number;
  24130. frontUVs?: Vector4;
  24131. backUVs?: Vector4;
  24132. }): VertexData;
  24133. /**
  24134. * Creates the VertexData of the LineSystem
  24135. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  24136. * - lines an array of lines, each line being an array of successive Vector3
  24137. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  24138. * @returns the VertexData of the LineSystem
  24139. */
  24140. static CreateLineSystem(options: {
  24141. lines: Vector3[][];
  24142. colors?: Nullable<Color4[][]>;
  24143. }): VertexData;
  24144. /**
  24145. * Create the VertexData for a DashedLines
  24146. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  24147. * - points an array successive Vector3
  24148. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  24149. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  24150. * - dashNb the intended total number of dashes, optional, default 200
  24151. * @returns the VertexData for the DashedLines
  24152. */
  24153. static CreateDashedLines(options: {
  24154. points: Vector3[];
  24155. dashSize?: number;
  24156. gapSize?: number;
  24157. dashNb?: number;
  24158. }): VertexData;
  24159. /**
  24160. * Creates the VertexData for a Ground
  24161. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24162. * - width the width (x direction) of the ground, optional, default 1
  24163. * - height the height (z direction) of the ground, optional, default 1
  24164. * - subdivisions the number of subdivisions per side, optional, default 1
  24165. * @returns the VertexData of the Ground
  24166. */
  24167. static CreateGround(options: {
  24168. width?: number;
  24169. height?: number;
  24170. subdivisions?: number;
  24171. subdivisionsX?: number;
  24172. subdivisionsY?: number;
  24173. }): VertexData;
  24174. /**
  24175. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  24176. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24177. * * xmin the ground minimum X coordinate, optional, default -1
  24178. * * zmin the ground minimum Z coordinate, optional, default -1
  24179. * * xmax the ground maximum X coordinate, optional, default 1
  24180. * * zmax the ground maximum Z coordinate, optional, default 1
  24181. * * 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}
  24182. * * 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}
  24183. * @returns the VertexData of the TiledGround
  24184. */
  24185. static CreateTiledGround(options: {
  24186. xmin: number;
  24187. zmin: number;
  24188. xmax: number;
  24189. zmax: number;
  24190. subdivisions?: {
  24191. w: number;
  24192. h: number;
  24193. };
  24194. precision?: {
  24195. w: number;
  24196. h: number;
  24197. };
  24198. }): VertexData;
  24199. /**
  24200. * Creates the VertexData of the Ground designed from a heightmap
  24201. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  24202. * * width the width (x direction) of the ground
  24203. * * height the height (z direction) of the ground
  24204. * * subdivisions the number of subdivisions per side
  24205. * * minHeight the minimum altitude on the ground, optional, default 0
  24206. * * maxHeight the maximum altitude on the ground, optional default 1
  24207. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  24208. * * buffer the array holding the image color data
  24209. * * bufferWidth the width of image
  24210. * * bufferHeight the height of image
  24211. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  24212. * @returns the VertexData of the Ground designed from a heightmap
  24213. */
  24214. static CreateGroundFromHeightMap(options: {
  24215. width: number;
  24216. height: number;
  24217. subdivisions: number;
  24218. minHeight: number;
  24219. maxHeight: number;
  24220. colorFilter: Color3;
  24221. buffer: Uint8Array;
  24222. bufferWidth: number;
  24223. bufferHeight: number;
  24224. alphaFilter: number;
  24225. }): VertexData;
  24226. /**
  24227. * Creates the VertexData for a Plane
  24228. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  24229. * * size sets the width and height of the plane to the value of size, optional default 1
  24230. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  24231. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  24232. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24233. * * 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)
  24234. * * 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)
  24235. * @returns the VertexData of the box
  24236. */
  24237. static CreatePlane(options: {
  24238. size?: number;
  24239. width?: number;
  24240. height?: number;
  24241. sideOrientation?: number;
  24242. frontUVs?: Vector4;
  24243. backUVs?: Vector4;
  24244. }): VertexData;
  24245. /**
  24246. * Creates the VertexData of the Disc or regular Polygon
  24247. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  24248. * * radius the radius of the disc, optional default 0.5
  24249. * * tessellation the number of polygon sides, optional, default 64
  24250. * * 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
  24251. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24252. * * 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)
  24253. * * 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)
  24254. * @returns the VertexData of the box
  24255. */
  24256. static CreateDisc(options: {
  24257. radius?: number;
  24258. tessellation?: number;
  24259. arc?: number;
  24260. sideOrientation?: number;
  24261. frontUVs?: Vector4;
  24262. backUVs?: Vector4;
  24263. }): VertexData;
  24264. /**
  24265. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  24266. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  24267. * @param polygon a mesh built from polygonTriangulation.build()
  24268. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24269. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24270. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24271. * @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)
  24272. * @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)
  24273. * @returns the VertexData of the Polygon
  24274. */
  24275. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  24276. /**
  24277. * Creates the VertexData of the IcoSphere
  24278. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  24279. * * radius the radius of the IcoSphere, optional default 1
  24280. * * radiusX allows stretching in the x direction, optional, default radius
  24281. * * radiusY allows stretching in the y direction, optional, default radius
  24282. * * radiusZ allows stretching in the z direction, optional, default radius
  24283. * * flat when true creates a flat shaded mesh, optional, default true
  24284. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24285. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24286. * * 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)
  24287. * * 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)
  24288. * @returns the VertexData of the IcoSphere
  24289. */
  24290. static CreateIcoSphere(options: {
  24291. radius?: number;
  24292. radiusX?: number;
  24293. radiusY?: number;
  24294. radiusZ?: number;
  24295. flat?: boolean;
  24296. subdivisions?: number;
  24297. sideOrientation?: number;
  24298. frontUVs?: Vector4;
  24299. backUVs?: Vector4;
  24300. }): VertexData;
  24301. /**
  24302. * Creates the VertexData for a Polyhedron
  24303. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  24304. * * type provided types are:
  24305. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  24306. * * 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)
  24307. * * size the size of the IcoSphere, optional default 1
  24308. * * sizeX allows stretching in the x direction, optional, default size
  24309. * * sizeY allows stretching in the y direction, optional, default size
  24310. * * sizeZ allows stretching in the z direction, optional, default size
  24311. * * 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
  24312. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24313. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24314. * * flat when true creates a flat shaded mesh, optional, default true
  24315. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24316. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24317. * * 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)
  24318. * * 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)
  24319. * @returns the VertexData of the Polyhedron
  24320. */
  24321. static CreatePolyhedron(options: {
  24322. type?: number;
  24323. size?: number;
  24324. sizeX?: number;
  24325. sizeY?: number;
  24326. sizeZ?: number;
  24327. custom?: any;
  24328. faceUV?: Vector4[];
  24329. faceColors?: Color4[];
  24330. flat?: boolean;
  24331. sideOrientation?: number;
  24332. frontUVs?: Vector4;
  24333. backUVs?: Vector4;
  24334. }): VertexData;
  24335. /**
  24336. * Creates the VertexData for a TorusKnot
  24337. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  24338. * * radius the radius of the torus knot, optional, default 2
  24339. * * tube the thickness of the tube, optional, default 0.5
  24340. * * radialSegments the number of sides on each tube segments, optional, default 32
  24341. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  24342. * * p the number of windings around the z axis, optional, default 2
  24343. * * q the number of windings around the x axis, optional, default 3
  24344. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24345. * * 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)
  24346. * * 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)
  24347. * @returns the VertexData of the Torus Knot
  24348. */
  24349. static CreateTorusKnot(options: {
  24350. radius?: number;
  24351. tube?: number;
  24352. radialSegments?: number;
  24353. tubularSegments?: number;
  24354. p?: number;
  24355. q?: number;
  24356. sideOrientation?: number;
  24357. frontUVs?: Vector4;
  24358. backUVs?: Vector4;
  24359. }): VertexData;
  24360. /**
  24361. * Compute normals for given positions and indices
  24362. * @param positions an array of vertex positions, [...., x, y, z, ......]
  24363. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  24364. * @param normals an array of vertex normals, [...., x, y, z, ......]
  24365. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  24366. * * facetNormals : optional array of facet normals (vector3)
  24367. * * facetPositions : optional array of facet positions (vector3)
  24368. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  24369. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  24370. * * bInfo : optional bounding info, required for facetPartitioning computation
  24371. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  24372. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  24373. * * useRightHandedSystem: optional boolean to for right handed system computation
  24374. * * depthSort : optional boolean to enable the facet depth sort computation
  24375. * * distanceTo : optional Vector3 to compute the facet depth from this location
  24376. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  24377. */
  24378. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  24379. facetNormals?: any;
  24380. facetPositions?: any;
  24381. facetPartitioning?: any;
  24382. ratio?: number;
  24383. bInfo?: any;
  24384. bbSize?: Vector3;
  24385. subDiv?: any;
  24386. useRightHandedSystem?: boolean;
  24387. depthSort?: boolean;
  24388. distanceTo?: Vector3;
  24389. depthSortedFacets?: any;
  24390. }): void;
  24391. /** @hidden */
  24392. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  24393. /**
  24394. * Applies VertexData created from the imported parameters to the geometry
  24395. * @param parsedVertexData the parsed data from an imported file
  24396. * @param geometry the geometry to apply the VertexData to
  24397. */
  24398. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  24399. }
  24400. }
  24401. declare module "babylonjs/Meshes/Builders/discBuilder" {
  24402. import { Nullable } from "babylonjs/types";
  24403. import { Scene } from "babylonjs/scene";
  24404. import { Vector4 } from "babylonjs/Maths/math";
  24405. import { Mesh } from "babylonjs/Meshes/mesh";
  24406. /**
  24407. * Class containing static functions to help procedurally build meshes
  24408. */
  24409. export class DiscBuilder {
  24410. /**
  24411. * Creates a plane polygonal mesh. By default, this is a disc
  24412. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24413. * * 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
  24414. * * 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
  24415. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24416. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24418. * @param name defines the name of the mesh
  24419. * @param options defines the options used to create the mesh
  24420. * @param scene defines the hosting scene
  24421. * @returns the plane polygonal mesh
  24422. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24423. */
  24424. static CreateDisc(name: string, options: {
  24425. radius?: number;
  24426. tessellation?: number;
  24427. arc?: number;
  24428. updatable?: boolean;
  24429. sideOrientation?: number;
  24430. frontUVs?: Vector4;
  24431. backUVs?: Vector4;
  24432. }, scene?: Nullable<Scene>): Mesh;
  24433. }
  24434. }
  24435. declare module "babylonjs/Particles/solidParticleSystem" {
  24436. import { Vector3 } from "babylonjs/Maths/math";
  24437. import { Mesh } from "babylonjs/Meshes/mesh";
  24438. import { Scene, IDisposable } from "babylonjs/scene";
  24439. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  24440. /**
  24441. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24442. *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.
  24443. * The SPS is also a particle system. It provides some methods to manage the particles.
  24444. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24445. *
  24446. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24447. */
  24448. export class SolidParticleSystem implements IDisposable {
  24449. /**
  24450. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24451. * Example : var p = SPS.particles[i];
  24452. */
  24453. particles: SolidParticle[];
  24454. /**
  24455. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24456. */
  24457. nbParticles: number;
  24458. /**
  24459. * If the particles must ever face the camera (default false). Useful for planar particles.
  24460. */
  24461. billboard: boolean;
  24462. /**
  24463. * Recompute normals when adding a shape
  24464. */
  24465. recomputeNormals: boolean;
  24466. /**
  24467. * This a counter ofr your own usage. It's not set by any SPS functions.
  24468. */
  24469. counter: number;
  24470. /**
  24471. * The SPS name. This name is also given to the underlying mesh.
  24472. */
  24473. name: string;
  24474. /**
  24475. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24476. */
  24477. mesh: Mesh;
  24478. /**
  24479. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24480. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24481. */
  24482. vars: any;
  24483. /**
  24484. * This array is populated when the SPS is set as 'pickable'.
  24485. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24486. * Each element of this array is an object `{idx: int, faceId: int}`.
  24487. * `idx` is the picked particle index in the `SPS.particles` array
  24488. * `faceId` is the picked face index counted within this particle.
  24489. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24490. */
  24491. pickedParticles: {
  24492. idx: number;
  24493. faceId: number;
  24494. }[];
  24495. /**
  24496. * This array is populated when `enableDepthSort` is set to true.
  24497. * Each element of this array is an instance of the class DepthSortedParticle.
  24498. */
  24499. depthSortedParticles: DepthSortedParticle[];
  24500. /**
  24501. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24502. * @hidden
  24503. */
  24504. _bSphereOnly: boolean;
  24505. /**
  24506. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24507. * @hidden
  24508. */
  24509. _bSphereRadiusFactor: number;
  24510. private _scene;
  24511. private _positions;
  24512. private _indices;
  24513. private _normals;
  24514. private _colors;
  24515. private _uvs;
  24516. private _indices32;
  24517. private _positions32;
  24518. private _normals32;
  24519. private _fixedNormal32;
  24520. private _colors32;
  24521. private _uvs32;
  24522. private _index;
  24523. private _updatable;
  24524. private _pickable;
  24525. private _isVisibilityBoxLocked;
  24526. private _alwaysVisible;
  24527. private _depthSort;
  24528. private _shapeCounter;
  24529. private _copy;
  24530. private _color;
  24531. private _computeParticleColor;
  24532. private _computeParticleTexture;
  24533. private _computeParticleRotation;
  24534. private _computeParticleVertex;
  24535. private _computeBoundingBox;
  24536. private _depthSortParticles;
  24537. private _camera;
  24538. private _mustUnrotateFixedNormals;
  24539. private _particlesIntersect;
  24540. private _needs32Bits;
  24541. /**
  24542. * Creates a SPS (Solid Particle System) object.
  24543. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24544. * @param scene (Scene) is the scene in which the SPS is added.
  24545. * @param options defines the options of the sps e.g.
  24546. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24547. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24548. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24549. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24550. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24551. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24552. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24553. */
  24554. constructor(name: string, scene: Scene, options?: {
  24555. updatable?: boolean;
  24556. isPickable?: boolean;
  24557. enableDepthSort?: boolean;
  24558. particleIntersection?: boolean;
  24559. boundingSphereOnly?: boolean;
  24560. bSphereRadiusFactor?: number;
  24561. });
  24562. /**
  24563. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24564. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24565. * @returns the created mesh
  24566. */
  24567. buildMesh(): Mesh;
  24568. /**
  24569. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24570. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24571. * Thus the particles generated from `digest()` have their property `position` set yet.
  24572. * @param mesh ( Mesh ) is the mesh to be digested
  24573. * @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
  24574. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24575. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24576. * @returns the current SPS
  24577. */
  24578. digest(mesh: Mesh, options?: {
  24579. facetNb?: number;
  24580. number?: number;
  24581. delta?: number;
  24582. }): SolidParticleSystem;
  24583. private _unrotateFixedNormals;
  24584. private _resetCopy;
  24585. private _meshBuilder;
  24586. private _posToShape;
  24587. private _uvsToShapeUV;
  24588. private _addParticle;
  24589. /**
  24590. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24591. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24592. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24593. * @param nb (positive integer) the number of particles to be created from this model
  24594. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24595. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24596. * @returns the number of shapes in the system
  24597. */
  24598. addShape(mesh: Mesh, nb: number, options?: {
  24599. positionFunction?: any;
  24600. vertexFunction?: any;
  24601. }): number;
  24602. private _rebuildParticle;
  24603. /**
  24604. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24605. * @returns the SPS.
  24606. */
  24607. rebuildMesh(): SolidParticleSystem;
  24608. /**
  24609. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24610. * This method calls `updateParticle()` for each particle of the SPS.
  24611. * For an animated SPS, it is usually called within the render loop.
  24612. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24613. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24614. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24615. * @returns the SPS.
  24616. */
  24617. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24618. /**
  24619. * Disposes the SPS.
  24620. */
  24621. dispose(): void;
  24622. /**
  24623. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24624. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24625. * @returns the SPS.
  24626. */
  24627. refreshVisibleSize(): SolidParticleSystem;
  24628. /**
  24629. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24630. * @param size the size (float) of the visibility box
  24631. * note : this doesn't lock the SPS mesh bounding box.
  24632. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24633. */
  24634. setVisibilityBox(size: number): void;
  24635. /**
  24636. * Gets whether the SPS as always visible or not
  24637. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24638. */
  24639. /**
  24640. * Sets the SPS as always visible or not
  24641. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24642. */
  24643. isAlwaysVisible: boolean;
  24644. /**
  24645. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24646. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24647. */
  24648. /**
  24649. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24650. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24651. */
  24652. isVisibilityBoxLocked: boolean;
  24653. /**
  24654. * Tells to `setParticles()` to compute the particle rotations or not.
  24655. * Default value : true. The SPS is faster when it's set to false.
  24656. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24657. */
  24658. /**
  24659. * Gets if `setParticles()` computes the particle rotations or not.
  24660. * Default value : true. The SPS is faster when it's set to false.
  24661. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24662. */
  24663. computeParticleRotation: boolean;
  24664. /**
  24665. * Tells to `setParticles()` to compute the particle colors or not.
  24666. * Default value : true. The SPS is faster when it's set to false.
  24667. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24668. */
  24669. /**
  24670. * Gets if `setParticles()` computes the particle colors or not.
  24671. * Default value : true. The SPS is faster when it's set to false.
  24672. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24673. */
  24674. computeParticleColor: boolean;
  24675. /**
  24676. * Gets if `setParticles()` computes the particle textures or not.
  24677. * Default value : true. The SPS is faster when it's set to false.
  24678. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24679. */
  24680. computeParticleTexture: boolean;
  24681. /**
  24682. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24683. * Default value : false. The SPS is faster when it's set to false.
  24684. * Note : the particle custom vertex positions aren't stored values.
  24685. */
  24686. /**
  24687. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24688. * Default value : false. The SPS is faster when it's set to false.
  24689. * Note : the particle custom vertex positions aren't stored values.
  24690. */
  24691. computeParticleVertex: boolean;
  24692. /**
  24693. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24694. */
  24695. /**
  24696. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24697. */
  24698. computeBoundingBox: boolean;
  24699. /**
  24700. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24701. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24702. * Default : `true`
  24703. */
  24704. /**
  24705. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24706. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24707. * Default : `true`
  24708. */
  24709. depthSortParticles: boolean;
  24710. /**
  24711. * This function does nothing. It may be overwritten to set all the particle first values.
  24712. * The SPS doesn't call this function, you may have to call it by your own.
  24713. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24714. */
  24715. initParticles(): void;
  24716. /**
  24717. * This function does nothing. It may be overwritten to recycle a particle.
  24718. * The SPS doesn't call this function, you may have to call it by your own.
  24719. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24720. * @param particle The particle to recycle
  24721. * @returns the recycled particle
  24722. */
  24723. recycleParticle(particle: SolidParticle): SolidParticle;
  24724. /**
  24725. * Updates a particle : this function should be overwritten by the user.
  24726. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24727. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24728. * @example : just set a particle position or velocity and recycle conditions
  24729. * @param particle The particle to update
  24730. * @returns the updated particle
  24731. */
  24732. updateParticle(particle: SolidParticle): SolidParticle;
  24733. /**
  24734. * Updates a vertex of a particle : it can be overwritten by the user.
  24735. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24736. * @param particle the current particle
  24737. * @param vertex the current index of the current particle
  24738. * @param pt the index of the current vertex in the particle shape
  24739. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24740. * @example : just set a vertex particle position
  24741. * @returns the updated vertex
  24742. */
  24743. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24744. /**
  24745. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24746. * This does nothing and may be overwritten by the user.
  24747. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24748. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24749. * @param update the boolean update value actually passed to setParticles()
  24750. */
  24751. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24752. /**
  24753. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24754. * This will be passed three parameters.
  24755. * This does nothing and may be overwritten by the user.
  24756. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24757. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24758. * @param update the boolean update value actually passed to setParticles()
  24759. */
  24760. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24761. }
  24762. }
  24763. declare module "babylonjs/Particles/solidParticle" {
  24764. import { Nullable } from "babylonjs/types";
  24765. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24766. import { Mesh } from "babylonjs/Meshes/mesh";
  24767. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24768. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24769. /**
  24770. * Represents one particle of a solid particle system.
  24771. */
  24772. export class SolidParticle {
  24773. /**
  24774. * particle global index
  24775. */
  24776. idx: number;
  24777. /**
  24778. * The color of the particle
  24779. */
  24780. color: Nullable<Color4>;
  24781. /**
  24782. * The world space position of the particle.
  24783. */
  24784. position: Vector3;
  24785. /**
  24786. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24787. */
  24788. rotation: Vector3;
  24789. /**
  24790. * The world space rotation quaternion of the particle.
  24791. */
  24792. rotationQuaternion: Nullable<Quaternion>;
  24793. /**
  24794. * The scaling of the particle.
  24795. */
  24796. scaling: Vector3;
  24797. /**
  24798. * The uvs of the particle.
  24799. */
  24800. uvs: Vector4;
  24801. /**
  24802. * The current speed of the particle.
  24803. */
  24804. velocity: Vector3;
  24805. /**
  24806. * The pivot point in the particle local space.
  24807. */
  24808. pivot: Vector3;
  24809. /**
  24810. * Must the particle be translated from its pivot point in its local space ?
  24811. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24812. * Default : false
  24813. */
  24814. translateFromPivot: boolean;
  24815. /**
  24816. * Is the particle active or not ?
  24817. */
  24818. alive: boolean;
  24819. /**
  24820. * Is the particle visible or not ?
  24821. */
  24822. isVisible: boolean;
  24823. /**
  24824. * Index of this particle in the global "positions" array (Internal use)
  24825. * @hidden
  24826. */
  24827. _pos: number;
  24828. /**
  24829. * @hidden Index of this particle in the global "indices" array (Internal use)
  24830. */
  24831. _ind: number;
  24832. /**
  24833. * @hidden ModelShape of this particle (Internal use)
  24834. */
  24835. _model: ModelShape;
  24836. /**
  24837. * ModelShape id of this particle
  24838. */
  24839. shapeId: number;
  24840. /**
  24841. * Index of the particle in its shape id (Internal use)
  24842. */
  24843. idxInShape: number;
  24844. /**
  24845. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24846. */
  24847. _modelBoundingInfo: BoundingInfo;
  24848. /**
  24849. * @hidden Particle BoundingInfo object (Internal use)
  24850. */
  24851. _boundingInfo: BoundingInfo;
  24852. /**
  24853. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24854. */
  24855. _sps: SolidParticleSystem;
  24856. /**
  24857. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24858. */
  24859. _stillInvisible: boolean;
  24860. /**
  24861. * @hidden Last computed particle rotation matrix
  24862. */
  24863. _rotationMatrix: number[];
  24864. /**
  24865. * Parent particle Id, if any.
  24866. * Default null.
  24867. */
  24868. parentId: Nullable<number>;
  24869. /**
  24870. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24871. * The possible values are :
  24872. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24873. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24874. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24875. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24876. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24877. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24878. * */
  24879. cullingStrategy: number;
  24880. /**
  24881. * @hidden Internal global position in the SPS.
  24882. */
  24883. _globalPosition: Vector3;
  24884. /**
  24885. * Creates a Solid Particle object.
  24886. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24887. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24888. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24889. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24890. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24891. * @param shapeId (integer) is the model shape identifier in the SPS.
  24892. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24893. * @param sps defines the sps it is associated to
  24894. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24895. */
  24896. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24897. /**
  24898. * Legacy support, changed scale to scaling
  24899. */
  24900. /**
  24901. * Legacy support, changed scale to scaling
  24902. */
  24903. scale: Vector3;
  24904. /**
  24905. * Legacy support, changed quaternion to rotationQuaternion
  24906. */
  24907. /**
  24908. * Legacy support, changed quaternion to rotationQuaternion
  24909. */
  24910. quaternion: Nullable<Quaternion>;
  24911. /**
  24912. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24913. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24914. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24915. * @returns true if it intersects
  24916. */
  24917. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24918. /**
  24919. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24920. * A particle is in the frustum if its bounding box intersects the frustum
  24921. * @param frustumPlanes defines the frustum to test
  24922. * @returns true if the particle is in the frustum planes
  24923. */
  24924. isInFrustum(frustumPlanes: Plane[]): boolean;
  24925. /**
  24926. * get the rotation matrix of the particle
  24927. * @hidden
  24928. */
  24929. getRotationMatrix(m: Matrix): void;
  24930. }
  24931. /**
  24932. * Represents the shape of the model used by one particle of a solid particle system.
  24933. * SPS internal tool, don't use it manually.
  24934. */
  24935. export class ModelShape {
  24936. /**
  24937. * The shape id
  24938. * @hidden
  24939. */
  24940. shapeID: number;
  24941. /**
  24942. * flat array of model positions (internal use)
  24943. * @hidden
  24944. */
  24945. _shape: Vector3[];
  24946. /**
  24947. * flat array of model UVs (internal use)
  24948. * @hidden
  24949. */
  24950. _shapeUV: number[];
  24951. /**
  24952. * length of the shape in the model indices array (internal use)
  24953. * @hidden
  24954. */
  24955. _indicesLength: number;
  24956. /**
  24957. * Custom position function (internal use)
  24958. * @hidden
  24959. */
  24960. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24961. /**
  24962. * Custom vertex function (internal use)
  24963. * @hidden
  24964. */
  24965. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24966. /**
  24967. * 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.
  24968. * SPS internal tool, don't use it manually.
  24969. * @hidden
  24970. */
  24971. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  24972. }
  24973. /**
  24974. * Represents a Depth Sorted Particle in the solid particle system.
  24975. */
  24976. export class DepthSortedParticle {
  24977. /**
  24978. * Index of the particle in the "indices" array
  24979. */
  24980. ind: number;
  24981. /**
  24982. * Length of the particle shape in the "indices" array
  24983. */
  24984. indicesLength: number;
  24985. /**
  24986. * Squared distance from the particle to the camera
  24987. */
  24988. sqDistance: number;
  24989. }
  24990. }
  24991. declare module "babylonjs/Collisions/meshCollisionData" {
  24992. import { Collider } from "babylonjs/Collisions/collider";
  24993. import { Vector3 } from "babylonjs/Maths/math";
  24994. import { Nullable } from "babylonjs/types";
  24995. import { Observer } from "babylonjs/Misc/observable";
  24996. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24997. /**
  24998. * @hidden
  24999. */
  25000. export class _MeshCollisionData {
  25001. _checkCollisions: boolean;
  25002. _collisionMask: number;
  25003. _collisionGroup: number;
  25004. _collider: Nullable<Collider>;
  25005. _oldPositionForCollisions: Vector3;
  25006. _diffPositionForCollisions: Vector3;
  25007. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25008. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25009. }
  25010. }
  25011. declare module "babylonjs/Meshes/abstractMesh" {
  25012. import { Observable } from "babylonjs/Misc/observable";
  25013. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  25014. import { Camera } from "babylonjs/Cameras/camera";
  25015. import { Scene, IDisposable } from "babylonjs/scene";
  25016. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  25017. import { Node } from "babylonjs/node";
  25018. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  25019. import { TransformNode } from "babylonjs/Meshes/transformNode";
  25020. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25021. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  25022. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25023. import { Material } from "babylonjs/Materials/material";
  25024. import { Light } from "babylonjs/Lights/light";
  25025. import { Skeleton } from "babylonjs/Bones/skeleton";
  25026. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  25027. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  25028. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25029. import { Ray } from "babylonjs/Culling/ray";
  25030. import { Collider } from "babylonjs/Collisions/collider";
  25031. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  25032. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  25033. /** @hidden */
  25034. class _FacetDataStorage {
  25035. facetPositions: Vector3[];
  25036. facetNormals: Vector3[];
  25037. facetPartitioning: number[][];
  25038. facetNb: number;
  25039. partitioningSubdivisions: number;
  25040. partitioningBBoxRatio: number;
  25041. facetDataEnabled: boolean;
  25042. facetParameters: any;
  25043. bbSize: Vector3;
  25044. subDiv: {
  25045. max: number;
  25046. X: number;
  25047. Y: number;
  25048. Z: number;
  25049. };
  25050. facetDepthSort: boolean;
  25051. facetDepthSortEnabled: boolean;
  25052. depthSortedIndices: IndicesArray;
  25053. depthSortedFacets: {
  25054. ind: number;
  25055. sqDistance: number;
  25056. }[];
  25057. facetDepthSortFunction: (f1: {
  25058. ind: number;
  25059. sqDistance: number;
  25060. }, f2: {
  25061. ind: number;
  25062. sqDistance: number;
  25063. }) => number;
  25064. facetDepthSortFrom: Vector3;
  25065. facetDepthSortOrigin: Vector3;
  25066. invertedMatrix: Matrix;
  25067. }
  25068. /**
  25069. * @hidden
  25070. **/
  25071. class _InternalAbstractMeshDataInfo {
  25072. _hasVertexAlpha: boolean;
  25073. _useVertexColors: boolean;
  25074. _numBoneInfluencers: number;
  25075. _applyFog: boolean;
  25076. _receiveShadows: boolean;
  25077. _facetData: _FacetDataStorage;
  25078. _visibility: number;
  25079. _skeleton: Nullable<Skeleton>;
  25080. _layerMask: number;
  25081. _computeBonesUsingShaders: boolean;
  25082. _isActive: boolean;
  25083. _onlyForInstances: boolean;
  25084. _isActiveIntermediate: boolean;
  25085. _onlyForInstancesIntermediate: boolean;
  25086. }
  25087. /**
  25088. * Class used to store all common mesh properties
  25089. */
  25090. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25091. /** No occlusion */
  25092. static OCCLUSION_TYPE_NONE: number;
  25093. /** Occlusion set to optimisitic */
  25094. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25095. /** Occlusion set to strict */
  25096. static OCCLUSION_TYPE_STRICT: number;
  25097. /** Use an accurante occlusion algorithm */
  25098. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25099. /** Use a conservative occlusion algorithm */
  25100. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25101. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25102. * Test order :
  25103. * Is the bounding sphere outside the frustum ?
  25104. * If not, are the bounding box vertices outside the frustum ?
  25105. * It not, then the cullable object is in the frustum.
  25106. */
  25107. static readonly CULLINGSTRATEGY_STANDARD: number;
  25108. /** Culling strategy : Bounding Sphere Only.
  25109. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25110. * It's also less accurate than the standard because some not visible objects can still be selected.
  25111. * Test : is the bounding sphere outside the frustum ?
  25112. * If not, then the cullable object is in the frustum.
  25113. */
  25114. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25115. /** Culling strategy : Optimistic Inclusion.
  25116. * This in an inclusion test first, then the standard exclusion test.
  25117. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25118. * 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.
  25119. * Anyway, it's as accurate as the standard strategy.
  25120. * Test :
  25121. * Is the cullable object bounding sphere center in the frustum ?
  25122. * If not, apply the default culling strategy.
  25123. */
  25124. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25125. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25126. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25127. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25128. * 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.
  25129. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25130. * Test :
  25131. * Is the cullable object bounding sphere center in the frustum ?
  25132. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25133. */
  25134. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25135. /**
  25136. * No billboard
  25137. */
  25138. static readonly BILLBOARDMODE_NONE: number;
  25139. /** Billboard on X axis */
  25140. static readonly BILLBOARDMODE_X: number;
  25141. /** Billboard on Y axis */
  25142. static readonly BILLBOARDMODE_Y: number;
  25143. /** Billboard on Z axis */
  25144. static readonly BILLBOARDMODE_Z: number;
  25145. /** Billboard on all axes */
  25146. static readonly BILLBOARDMODE_ALL: number;
  25147. /** @hidden */
  25148. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25149. /**
  25150. * The culling strategy to use to check whether the mesh must be rendered or not.
  25151. * This value can be changed at any time and will be used on the next render mesh selection.
  25152. * The possible values are :
  25153. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25154. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25155. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25156. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25157. * Please read each static variable documentation to get details about the culling process.
  25158. * */
  25159. cullingStrategy: number;
  25160. /**
  25161. * Gets the number of facets in the mesh
  25162. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25163. */
  25164. readonly facetNb: number;
  25165. /**
  25166. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25167. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25168. */
  25169. partitioningSubdivisions: number;
  25170. /**
  25171. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25172. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25173. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25174. */
  25175. partitioningBBoxRatio: number;
  25176. /**
  25177. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25178. * Works only for updatable meshes.
  25179. * Doesn't work with multi-materials
  25180. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25181. */
  25182. mustDepthSortFacets: boolean;
  25183. /**
  25184. * The location (Vector3) where the facet depth sort must be computed from.
  25185. * By default, the active camera position.
  25186. * Used only when facet depth sort is enabled
  25187. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25188. */
  25189. facetDepthSortFrom: Vector3;
  25190. /**
  25191. * gets a boolean indicating if facetData is enabled
  25192. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25193. */
  25194. readonly isFacetDataEnabled: boolean;
  25195. /** @hidden */
  25196. _updateNonUniformScalingState(value: boolean): boolean;
  25197. /**
  25198. * An event triggered when this mesh collides with another one
  25199. */
  25200. onCollideObservable: Observable<AbstractMesh>;
  25201. /** Set a function to call when this mesh collides with another one */
  25202. onCollide: () => void;
  25203. /**
  25204. * An event triggered when the collision's position changes
  25205. */
  25206. onCollisionPositionChangeObservable: Observable<Vector3>;
  25207. /** Set a function to call when the collision's position changes */
  25208. onCollisionPositionChange: () => void;
  25209. /**
  25210. * An event triggered when material is changed
  25211. */
  25212. onMaterialChangedObservable: Observable<AbstractMesh>;
  25213. /**
  25214. * Gets or sets the orientation for POV movement & rotation
  25215. */
  25216. definedFacingForward: boolean;
  25217. /** @hidden */
  25218. _occlusionQuery: Nullable<WebGLQuery>;
  25219. /** @hidden */
  25220. _renderingGroup: Nullable<RenderingGroup>;
  25221. /**
  25222. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25223. */
  25224. /**
  25225. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25226. */
  25227. visibility: number;
  25228. /** Gets or sets the alpha index used to sort transparent meshes
  25229. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25230. */
  25231. alphaIndex: number;
  25232. /**
  25233. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25234. */
  25235. isVisible: boolean;
  25236. /**
  25237. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25238. */
  25239. isPickable: boolean;
  25240. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25241. showSubMeshesBoundingBox: boolean;
  25242. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25243. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25244. */
  25245. isBlocker: boolean;
  25246. /**
  25247. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25248. */
  25249. enablePointerMoveEvents: boolean;
  25250. /**
  25251. * Specifies the rendering group id for this mesh (0 by default)
  25252. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25253. */
  25254. renderingGroupId: number;
  25255. private _material;
  25256. /** Gets or sets current material */
  25257. material: Nullable<Material>;
  25258. /**
  25259. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25260. * @see http://doc.babylonjs.com/babylon101/shadows
  25261. */
  25262. receiveShadows: boolean;
  25263. /** Defines color to use when rendering outline */
  25264. outlineColor: Color3;
  25265. /** Define width to use when rendering outline */
  25266. outlineWidth: number;
  25267. /** Defines color to use when rendering overlay */
  25268. overlayColor: Color3;
  25269. /** Defines alpha to use when rendering overlay */
  25270. overlayAlpha: number;
  25271. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25272. hasVertexAlpha: boolean;
  25273. /** 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) */
  25274. useVertexColors: boolean;
  25275. /**
  25276. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25277. */
  25278. computeBonesUsingShaders: boolean;
  25279. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25280. numBoneInfluencers: number;
  25281. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25282. applyFog: boolean;
  25283. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25284. useOctreeForRenderingSelection: boolean;
  25285. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25286. useOctreeForPicking: boolean;
  25287. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25288. useOctreeForCollisions: boolean;
  25289. /**
  25290. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25291. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25292. */
  25293. layerMask: number;
  25294. /**
  25295. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25296. */
  25297. alwaysSelectAsActiveMesh: boolean;
  25298. /**
  25299. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25300. */
  25301. doNotSyncBoundingInfo: boolean;
  25302. /**
  25303. * Gets or sets the current action manager
  25304. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25305. */
  25306. actionManager: Nullable<AbstractActionManager>;
  25307. private _meshCollisionData;
  25308. /**
  25309. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25310. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25311. */
  25312. ellipsoid: Vector3;
  25313. /**
  25314. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25315. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25316. */
  25317. ellipsoidOffset: Vector3;
  25318. /**
  25319. * Gets or sets a collision mask used to mask collisions (default is -1).
  25320. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25321. */
  25322. collisionMask: number;
  25323. /**
  25324. * Gets or sets the current collision group mask (-1 by default).
  25325. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25326. */
  25327. collisionGroup: number;
  25328. /**
  25329. * Defines edge width used when edgesRenderer is enabled
  25330. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25331. */
  25332. edgesWidth: number;
  25333. /**
  25334. * Defines edge color used when edgesRenderer is enabled
  25335. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25336. */
  25337. edgesColor: Color4;
  25338. /** @hidden */
  25339. _edgesRenderer: Nullable<IEdgesRenderer>;
  25340. /** @hidden */
  25341. _masterMesh: Nullable<AbstractMesh>;
  25342. /** @hidden */
  25343. _boundingInfo: Nullable<BoundingInfo>;
  25344. /** @hidden */
  25345. _renderId: number;
  25346. /**
  25347. * Gets or sets the list of subMeshes
  25348. * @see http://doc.babylonjs.com/how_to/multi_materials
  25349. */
  25350. subMeshes: SubMesh[];
  25351. /** @hidden */
  25352. _intersectionsInProgress: AbstractMesh[];
  25353. /** @hidden */
  25354. _unIndexed: boolean;
  25355. /** @hidden */
  25356. _lightSources: Light[];
  25357. /** Gets the list of lights affecting that mesh */
  25358. readonly lightSources: Light[];
  25359. /** @hidden */
  25360. readonly _positions: Nullable<Vector3[]>;
  25361. /** @hidden */
  25362. _waitingData: {
  25363. lods: Nullable<any>;
  25364. actions: Nullable<any>;
  25365. freezeWorldMatrix: Nullable<boolean>;
  25366. };
  25367. /** @hidden */
  25368. _bonesTransformMatrices: Nullable<Float32Array>;
  25369. /**
  25370. * Gets or sets a skeleton to apply skining transformations
  25371. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25372. */
  25373. skeleton: Nullable<Skeleton>;
  25374. /**
  25375. * An event triggered when the mesh is rebuilt.
  25376. */
  25377. onRebuildObservable: Observable<AbstractMesh>;
  25378. /**
  25379. * Creates a new AbstractMesh
  25380. * @param name defines the name of the mesh
  25381. * @param scene defines the hosting scene
  25382. */
  25383. constructor(name: string, scene?: Nullable<Scene>);
  25384. /**
  25385. * Returns the string "AbstractMesh"
  25386. * @returns "AbstractMesh"
  25387. */
  25388. getClassName(): string;
  25389. /**
  25390. * Gets a string representation of the current mesh
  25391. * @param fullDetails defines a boolean indicating if full details must be included
  25392. * @returns a string representation of the current mesh
  25393. */
  25394. toString(fullDetails?: boolean): string;
  25395. /**
  25396. * @hidden
  25397. */
  25398. protected _getEffectiveParent(): Nullable<Node>;
  25399. /** @hidden */
  25400. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25401. /** @hidden */
  25402. _rebuild(): void;
  25403. /** @hidden */
  25404. _resyncLightSources(): void;
  25405. /** @hidden */
  25406. _resyncLighSource(light: Light): void;
  25407. /** @hidden */
  25408. _unBindEffect(): void;
  25409. /** @hidden */
  25410. _removeLightSource(light: Light): void;
  25411. private _markSubMeshesAsDirty;
  25412. /** @hidden */
  25413. _markSubMeshesAsLightDirty(): void;
  25414. /** @hidden */
  25415. _markSubMeshesAsAttributesDirty(): void;
  25416. /** @hidden */
  25417. _markSubMeshesAsMiscDirty(): void;
  25418. /**
  25419. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25420. */
  25421. scaling: Vector3;
  25422. /**
  25423. * Returns true if the mesh is blocked. Implemented by child classes
  25424. */
  25425. readonly isBlocked: boolean;
  25426. /**
  25427. * Returns the mesh itself by default. Implemented by child classes
  25428. * @param camera defines the camera to use to pick the right LOD level
  25429. * @returns the currentAbstractMesh
  25430. */
  25431. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25432. /**
  25433. * Returns 0 by default. Implemented by child classes
  25434. * @returns an integer
  25435. */
  25436. getTotalVertices(): number;
  25437. /**
  25438. * Returns a positive integer : the total number of indices in this mesh geometry.
  25439. * @returns the numner of indices or zero if the mesh has no geometry.
  25440. */
  25441. getTotalIndices(): number;
  25442. /**
  25443. * Returns null by default. Implemented by child classes
  25444. * @returns null
  25445. */
  25446. getIndices(): Nullable<IndicesArray>;
  25447. /**
  25448. * Returns the array of the requested vertex data kind. Implemented by child classes
  25449. * @param kind defines the vertex data kind to use
  25450. * @returns null
  25451. */
  25452. getVerticesData(kind: string): Nullable<FloatArray>;
  25453. /**
  25454. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25455. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25456. * Note that a new underlying VertexBuffer object is created each call.
  25457. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25458. * @param kind defines vertex data kind:
  25459. * * VertexBuffer.PositionKind
  25460. * * VertexBuffer.UVKind
  25461. * * VertexBuffer.UV2Kind
  25462. * * VertexBuffer.UV3Kind
  25463. * * VertexBuffer.UV4Kind
  25464. * * VertexBuffer.UV5Kind
  25465. * * VertexBuffer.UV6Kind
  25466. * * VertexBuffer.ColorKind
  25467. * * VertexBuffer.MatricesIndicesKind
  25468. * * VertexBuffer.MatricesIndicesExtraKind
  25469. * * VertexBuffer.MatricesWeightsKind
  25470. * * VertexBuffer.MatricesWeightsExtraKind
  25471. * @param data defines the data source
  25472. * @param updatable defines if the data must be flagged as updatable (or static)
  25473. * @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
  25474. * @returns the current mesh
  25475. */
  25476. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25477. /**
  25478. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25479. * If the mesh has no geometry, it is simply returned as it is.
  25480. * @param kind defines vertex data kind:
  25481. * * VertexBuffer.PositionKind
  25482. * * VertexBuffer.UVKind
  25483. * * VertexBuffer.UV2Kind
  25484. * * VertexBuffer.UV3Kind
  25485. * * VertexBuffer.UV4Kind
  25486. * * VertexBuffer.UV5Kind
  25487. * * VertexBuffer.UV6Kind
  25488. * * VertexBuffer.ColorKind
  25489. * * VertexBuffer.MatricesIndicesKind
  25490. * * VertexBuffer.MatricesIndicesExtraKind
  25491. * * VertexBuffer.MatricesWeightsKind
  25492. * * VertexBuffer.MatricesWeightsExtraKind
  25493. * @param data defines the data source
  25494. * @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
  25495. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25496. * @returns the current mesh
  25497. */
  25498. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25499. /**
  25500. * Sets the mesh indices,
  25501. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25502. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25503. * @param totalVertices Defines the total number of vertices
  25504. * @returns the current mesh
  25505. */
  25506. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25507. /**
  25508. * Gets a boolean indicating if specific vertex data is present
  25509. * @param kind defines the vertex data kind to use
  25510. * @returns true is data kind is present
  25511. */
  25512. isVerticesDataPresent(kind: string): boolean;
  25513. /**
  25514. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  25515. * @returns a BoundingInfo
  25516. */
  25517. getBoundingInfo(): BoundingInfo;
  25518. /**
  25519. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25520. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25521. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25522. * @returns the current mesh
  25523. */
  25524. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  25525. /**
  25526. * Overwrite the current bounding info
  25527. * @param boundingInfo defines the new bounding info
  25528. * @returns the current mesh
  25529. */
  25530. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25531. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25532. readonly useBones: boolean;
  25533. /** @hidden */
  25534. _preActivate(): void;
  25535. /** @hidden */
  25536. _preActivateForIntermediateRendering(renderId: number): void;
  25537. /** @hidden */
  25538. _activate(renderId: number, intermediateRendering: boolean): boolean;
  25539. /** @hidden */
  25540. _postActivate(): void;
  25541. /** @hidden */
  25542. _freeze(): void;
  25543. /** @hidden */
  25544. _unFreeze(): void;
  25545. /**
  25546. * Gets the current world matrix
  25547. * @returns a Matrix
  25548. */
  25549. getWorldMatrix(): Matrix;
  25550. /** @hidden */
  25551. _getWorldMatrixDeterminant(): number;
  25552. /**
  25553. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25554. */
  25555. readonly isAnInstance: boolean;
  25556. /**
  25557. * Perform relative position change from the point of view of behind the front of the mesh.
  25558. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25559. * Supports definition of mesh facing forward or backward
  25560. * @param amountRight defines the distance on the right axis
  25561. * @param amountUp defines the distance on the up axis
  25562. * @param amountForward defines the distance on the forward axis
  25563. * @returns the current mesh
  25564. */
  25565. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25566. /**
  25567. * Calculate relative position change from the point of view of behind the front of the mesh.
  25568. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25569. * Supports definition of mesh facing forward or backward
  25570. * @param amountRight defines the distance on the right axis
  25571. * @param amountUp defines the distance on the up axis
  25572. * @param amountForward defines the distance on the forward axis
  25573. * @returns the new displacement vector
  25574. */
  25575. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25576. /**
  25577. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25578. * Supports definition of mesh facing forward or backward
  25579. * @param flipBack defines the flip
  25580. * @param twirlClockwise defines the twirl
  25581. * @param tiltRight defines the tilt
  25582. * @returns the current mesh
  25583. */
  25584. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25585. /**
  25586. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25587. * Supports definition of mesh facing forward or backward.
  25588. * @param flipBack defines the flip
  25589. * @param twirlClockwise defines the twirl
  25590. * @param tiltRight defines the tilt
  25591. * @returns the new rotation vector
  25592. */
  25593. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25594. /**
  25595. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25596. * This means the mesh underlying bounding box and sphere are recomputed.
  25597. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25598. * @returns the current mesh
  25599. */
  25600. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25601. /** @hidden */
  25602. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25603. /** @hidden */
  25604. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25605. /** @hidden */
  25606. _updateBoundingInfo(): AbstractMesh;
  25607. /** @hidden */
  25608. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25609. /** @hidden */
  25610. protected _afterComputeWorldMatrix(): void;
  25611. /** @hidden */
  25612. readonly _effectiveMesh: AbstractMesh;
  25613. /**
  25614. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25615. * A mesh is in the frustum if its bounding box intersects the frustum
  25616. * @param frustumPlanes defines the frustum to test
  25617. * @returns true if the mesh is in the frustum planes
  25618. */
  25619. isInFrustum(frustumPlanes: Plane[]): boolean;
  25620. /**
  25621. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25622. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25623. * @param frustumPlanes defines the frustum to test
  25624. * @returns true if the mesh is completely in the frustum planes
  25625. */
  25626. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25627. /**
  25628. * True if the mesh intersects another mesh or a SolidParticle object
  25629. * @param mesh defines a target mesh or SolidParticle to test
  25630. * @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)
  25631. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25632. * @returns true if there is an intersection
  25633. */
  25634. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25635. /**
  25636. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25637. * @param point defines the point to test
  25638. * @returns true if there is an intersection
  25639. */
  25640. intersectsPoint(point: Vector3): boolean;
  25641. /**
  25642. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25643. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25644. */
  25645. checkCollisions: boolean;
  25646. /**
  25647. * Gets Collider object used to compute collisions (not physics)
  25648. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25649. */
  25650. readonly collider: Nullable<Collider>;
  25651. /**
  25652. * Move the mesh using collision engine
  25653. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25654. * @param displacement defines the requested displacement vector
  25655. * @returns the current mesh
  25656. */
  25657. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25658. private _onCollisionPositionChange;
  25659. /** @hidden */
  25660. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25661. /** @hidden */
  25662. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25663. /** @hidden */
  25664. _checkCollision(collider: Collider): AbstractMesh;
  25665. /** @hidden */
  25666. _generatePointsArray(): boolean;
  25667. /**
  25668. * Checks if the passed Ray intersects with the mesh
  25669. * @param ray defines the ray to use
  25670. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25671. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25672. * @returns the picking info
  25673. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25674. */
  25675. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25676. /**
  25677. * Clones the current mesh
  25678. * @param name defines the mesh name
  25679. * @param newParent defines the new mesh parent
  25680. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25681. * @returns the new mesh
  25682. */
  25683. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25684. /**
  25685. * Disposes all the submeshes of the current meshnp
  25686. * @returns the current mesh
  25687. */
  25688. releaseSubMeshes(): AbstractMesh;
  25689. /**
  25690. * Releases resources associated with this abstract mesh.
  25691. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25692. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25693. */
  25694. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25695. /**
  25696. * Adds the passed mesh as a child to the current mesh
  25697. * @param mesh defines the child mesh
  25698. * @returns the current mesh
  25699. */
  25700. addChild(mesh: AbstractMesh): AbstractMesh;
  25701. /**
  25702. * Removes the passed mesh from the current mesh children list
  25703. * @param mesh defines the child mesh
  25704. * @returns the current mesh
  25705. */
  25706. removeChild(mesh: AbstractMesh): AbstractMesh;
  25707. /** @hidden */
  25708. private _initFacetData;
  25709. /**
  25710. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25711. * This method can be called within the render loop.
  25712. * 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
  25713. * @returns the current mesh
  25714. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25715. */
  25716. updateFacetData(): AbstractMesh;
  25717. /**
  25718. * Returns the facetLocalNormals array.
  25719. * The normals are expressed in the mesh local spac
  25720. * @returns an array of Vector3
  25721. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25722. */
  25723. getFacetLocalNormals(): Vector3[];
  25724. /**
  25725. * Returns the facetLocalPositions array.
  25726. * The facet positions are expressed in the mesh local space
  25727. * @returns an array of Vector3
  25728. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25729. */
  25730. getFacetLocalPositions(): Vector3[];
  25731. /**
  25732. * Returns the facetLocalPartioning array
  25733. * @returns an array of array of numbers
  25734. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25735. */
  25736. getFacetLocalPartitioning(): number[][];
  25737. /**
  25738. * Returns the i-th facet position in the world system.
  25739. * This method allocates a new Vector3 per call
  25740. * @param i defines the facet index
  25741. * @returns a new Vector3
  25742. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25743. */
  25744. getFacetPosition(i: number): Vector3;
  25745. /**
  25746. * Sets the reference Vector3 with the i-th facet position in the world system
  25747. * @param i defines the facet index
  25748. * @param ref defines the target vector
  25749. * @returns the current mesh
  25750. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25751. */
  25752. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25753. /**
  25754. * Returns the i-th facet normal in the world system.
  25755. * This method allocates a new Vector3 per call
  25756. * @param i defines the facet index
  25757. * @returns a new Vector3
  25758. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25759. */
  25760. getFacetNormal(i: number): Vector3;
  25761. /**
  25762. * Sets the reference Vector3 with the i-th facet normal in the world system
  25763. * @param i defines the facet index
  25764. * @param ref defines the target vector
  25765. * @returns the current mesh
  25766. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25767. */
  25768. getFacetNormalToRef(i: number, ref: Vector3): this;
  25769. /**
  25770. * 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)
  25771. * @param x defines x coordinate
  25772. * @param y defines y coordinate
  25773. * @param z defines z coordinate
  25774. * @returns the array of facet indexes
  25775. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25776. */
  25777. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25778. /**
  25779. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25780. * @param projected sets as the (x,y,z) world projection on the facet
  25781. * @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
  25782. * @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
  25783. * @param x defines x coordinate
  25784. * @param y defines y coordinate
  25785. * @param z defines z coordinate
  25786. * @returns the face index if found (or null instead)
  25787. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25788. */
  25789. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25790. /**
  25791. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25792. * @param projected sets as the (x,y,z) local projection on the facet
  25793. * @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
  25794. * @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
  25795. * @param x defines x coordinate
  25796. * @param y defines y coordinate
  25797. * @param z defines z coordinate
  25798. * @returns the face index if found (or null instead)
  25799. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25800. */
  25801. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25802. /**
  25803. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25804. * @returns the parameters
  25805. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25806. */
  25807. getFacetDataParameters(): any;
  25808. /**
  25809. * Disables the feature FacetData and frees the related memory
  25810. * @returns the current mesh
  25811. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25812. */
  25813. disableFacetData(): AbstractMesh;
  25814. /**
  25815. * Updates the AbstractMesh indices array
  25816. * @param indices defines the data source
  25817. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25818. * @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)
  25819. * @returns the current mesh
  25820. */
  25821. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25822. /**
  25823. * Creates new normals data for the mesh
  25824. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25825. * @returns the current mesh
  25826. */
  25827. createNormals(updatable: boolean): AbstractMesh;
  25828. /**
  25829. * Align the mesh with a normal
  25830. * @param normal defines the normal to use
  25831. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25832. * @returns the current mesh
  25833. */
  25834. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25835. /** @hidden */
  25836. _checkOcclusionQuery(): boolean;
  25837. /**
  25838. * Disables the mesh edge rendering mode
  25839. * @returns the currentAbstractMesh
  25840. */
  25841. disableEdgesRendering(): AbstractMesh;
  25842. /**
  25843. * Enables the edge rendering mode on the mesh.
  25844. * This mode makes the mesh edges visible
  25845. * @param epsilon defines the maximal distance between two angles to detect a face
  25846. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  25847. * @returns the currentAbstractMesh
  25848. * @see https://www.babylonjs-playground.com/#19O9TU#0
  25849. */
  25850. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  25851. }
  25852. }
  25853. declare module "babylonjs/Actions/actionEvent" {
  25854. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25855. import { Nullable } from "babylonjs/types";
  25856. import { Sprite } from "babylonjs/Sprites/sprite";
  25857. import { Scene } from "babylonjs/scene";
  25858. import { Vector2 } from "babylonjs/Maths/math";
  25859. /**
  25860. * Interface used to define ActionEvent
  25861. */
  25862. export interface IActionEvent {
  25863. /** The mesh or sprite that triggered the action */
  25864. source: any;
  25865. /** The X mouse cursor position at the time of the event */
  25866. pointerX: number;
  25867. /** The Y mouse cursor position at the time of the event */
  25868. pointerY: number;
  25869. /** The mesh that is currently pointed at (can be null) */
  25870. meshUnderPointer: Nullable<AbstractMesh>;
  25871. /** the original (browser) event that triggered the ActionEvent */
  25872. sourceEvent?: any;
  25873. /** additional data for the event */
  25874. additionalData?: any;
  25875. }
  25876. /**
  25877. * ActionEvent is the event being sent when an action is triggered.
  25878. */
  25879. export class ActionEvent implements IActionEvent {
  25880. /** The mesh or sprite that triggered the action */
  25881. source: any;
  25882. /** The X mouse cursor position at the time of the event */
  25883. pointerX: number;
  25884. /** The Y mouse cursor position at the time of the event */
  25885. pointerY: number;
  25886. /** The mesh that is currently pointed at (can be null) */
  25887. meshUnderPointer: Nullable<AbstractMesh>;
  25888. /** the original (browser) event that triggered the ActionEvent */
  25889. sourceEvent?: any;
  25890. /** additional data for the event */
  25891. additionalData?: any;
  25892. /**
  25893. * Creates a new ActionEvent
  25894. * @param source The mesh or sprite that triggered the action
  25895. * @param pointerX The X mouse cursor position at the time of the event
  25896. * @param pointerY The Y mouse cursor position at the time of the event
  25897. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25898. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25899. * @param additionalData additional data for the event
  25900. */
  25901. constructor(
  25902. /** The mesh or sprite that triggered the action */
  25903. source: any,
  25904. /** The X mouse cursor position at the time of the event */
  25905. pointerX: number,
  25906. /** The Y mouse cursor position at the time of the event */
  25907. pointerY: number,
  25908. /** The mesh that is currently pointed at (can be null) */
  25909. meshUnderPointer: Nullable<AbstractMesh>,
  25910. /** the original (browser) event that triggered the ActionEvent */
  25911. sourceEvent?: any,
  25912. /** additional data for the event */
  25913. additionalData?: any);
  25914. /**
  25915. * Helper function to auto-create an ActionEvent from a source mesh.
  25916. * @param source The source mesh that triggered the event
  25917. * @param evt The original (browser) event
  25918. * @param additionalData additional data for the event
  25919. * @returns the new ActionEvent
  25920. */
  25921. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25922. /**
  25923. * Helper function to auto-create an ActionEvent from a source sprite
  25924. * @param source The source sprite that triggered the event
  25925. * @param scene Scene associated with the sprite
  25926. * @param evt The original (browser) event
  25927. * @param additionalData additional data for the event
  25928. * @returns the new ActionEvent
  25929. */
  25930. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25931. /**
  25932. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25933. * @param scene the scene where the event occurred
  25934. * @param evt The original (browser) event
  25935. * @returns the new ActionEvent
  25936. */
  25937. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25938. /**
  25939. * Helper function to auto-create an ActionEvent from a primitive
  25940. * @param prim defines the target primitive
  25941. * @param pointerPos defines the pointer position
  25942. * @param evt The original (browser) event
  25943. * @param additionalData additional data for the event
  25944. * @returns the new ActionEvent
  25945. */
  25946. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25947. }
  25948. }
  25949. declare module "babylonjs/Actions/abstractActionManager" {
  25950. import { IDisposable } from "babylonjs/scene";
  25951. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  25952. import { IAction } from "babylonjs/Actions/action";
  25953. import { Nullable } from "babylonjs/types";
  25954. /**
  25955. * Abstract class used to decouple action Manager from scene and meshes.
  25956. * Do not instantiate.
  25957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25958. */
  25959. export abstract class AbstractActionManager implements IDisposable {
  25960. /** Gets the list of active triggers */
  25961. static Triggers: {
  25962. [key: string]: number;
  25963. };
  25964. /** Gets the cursor to use when hovering items */
  25965. hoverCursor: string;
  25966. /** Gets the list of actions */
  25967. actions: IAction[];
  25968. /**
  25969. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25970. */
  25971. isRecursive: boolean;
  25972. /**
  25973. * Releases all associated resources
  25974. */
  25975. abstract dispose(): void;
  25976. /**
  25977. * Does this action manager has pointer triggers
  25978. */
  25979. abstract readonly hasPointerTriggers: boolean;
  25980. /**
  25981. * Does this action manager has pick triggers
  25982. */
  25983. abstract readonly hasPickTriggers: boolean;
  25984. /**
  25985. * Process a specific trigger
  25986. * @param trigger defines the trigger to process
  25987. * @param evt defines the event details to be processed
  25988. */
  25989. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25990. /**
  25991. * Does this action manager handles actions of any of the given triggers
  25992. * @param triggers defines the triggers to be tested
  25993. * @return a boolean indicating whether one (or more) of the triggers is handled
  25994. */
  25995. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25996. /**
  25997. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25998. * speed.
  25999. * @param triggerA defines the trigger to be tested
  26000. * @param triggerB defines the trigger to be tested
  26001. * @return a boolean indicating whether one (or more) of the triggers is handled
  26002. */
  26003. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26004. /**
  26005. * Does this action manager handles actions of a given trigger
  26006. * @param trigger defines the trigger to be tested
  26007. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26008. * @return whether the trigger is handled
  26009. */
  26010. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26011. /**
  26012. * Serialize this manager to a JSON object
  26013. * @param name defines the property name to store this manager
  26014. * @returns a JSON representation of this manager
  26015. */
  26016. abstract serialize(name: string): any;
  26017. /**
  26018. * Registers an action to this action manager
  26019. * @param action defines the action to be registered
  26020. * @return the action amended (prepared) after registration
  26021. */
  26022. abstract registerAction(action: IAction): Nullable<IAction>;
  26023. /**
  26024. * Unregisters an action to this action manager
  26025. * @param action defines the action to be unregistered
  26026. * @return a boolean indicating whether the action has been unregistered
  26027. */
  26028. abstract unregisterAction(action: IAction): Boolean;
  26029. /**
  26030. * Does exist one action manager with at least one trigger
  26031. **/
  26032. static readonly HasTriggers: boolean;
  26033. /**
  26034. * Does exist one action manager with at least one pick trigger
  26035. **/
  26036. static readonly HasPickTriggers: boolean;
  26037. /**
  26038. * Does exist one action manager that handles actions of a given trigger
  26039. * @param trigger defines the trigger to be tested
  26040. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26041. **/
  26042. static HasSpecificTrigger(trigger: number): boolean;
  26043. }
  26044. }
  26045. declare module "babylonjs/node" {
  26046. import { Scene } from "babylonjs/scene";
  26047. import { Nullable } from "babylonjs/types";
  26048. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  26049. import { Engine } from "babylonjs/Engines/engine";
  26050. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  26051. import { Observable } from "babylonjs/Misc/observable";
  26052. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26053. import { IInspectable } from "babylonjs/Misc/iInspectable";
  26054. import { Animatable } from "babylonjs/Animations/animatable";
  26055. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26056. import { Animation } from "babylonjs/Animations/animation";
  26057. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26058. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26059. /**
  26060. * Defines how a node can be built from a string name.
  26061. */
  26062. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26063. /**
  26064. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26065. */
  26066. export class Node implements IBehaviorAware<Node> {
  26067. /** @hidden */
  26068. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  26069. private static _NodeConstructors;
  26070. /**
  26071. * Add a new node constructor
  26072. * @param type defines the type name of the node to construct
  26073. * @param constructorFunc defines the constructor function
  26074. */
  26075. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26076. /**
  26077. * Returns a node constructor based on type name
  26078. * @param type defines the type name
  26079. * @param name defines the new node name
  26080. * @param scene defines the hosting scene
  26081. * @param options defines optional options to transmit to constructors
  26082. * @returns the new constructor or null
  26083. */
  26084. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26085. /**
  26086. * Gets or sets the name of the node
  26087. */
  26088. name: string;
  26089. /**
  26090. * Gets or sets the id of the node
  26091. */
  26092. id: string;
  26093. /**
  26094. * Gets or sets the unique id of the node
  26095. */
  26096. uniqueId: number;
  26097. /**
  26098. * Gets or sets a string used to store user defined state for the node
  26099. */
  26100. state: string;
  26101. /**
  26102. * Gets or sets an object used to store user defined information for the node
  26103. */
  26104. metadata: any;
  26105. /**
  26106. * For internal use only. Please do not use.
  26107. */
  26108. reservedDataStore: any;
  26109. /**
  26110. * List of inspectable custom properties (used by the Inspector)
  26111. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26112. */
  26113. inspectableCustomProperties: IInspectable[];
  26114. /**
  26115. * Gets or sets a boolean used to define if the node must be serialized
  26116. */
  26117. doNotSerialize: boolean;
  26118. /** @hidden */
  26119. _isDisposed: boolean;
  26120. /**
  26121. * Gets a list of Animations associated with the node
  26122. */
  26123. animations: import("babylonjs/Animations/animation").Animation[];
  26124. protected _ranges: {
  26125. [name: string]: Nullable<AnimationRange>;
  26126. };
  26127. /**
  26128. * Callback raised when the node is ready to be used
  26129. */
  26130. onReady: Nullable<(node: Node) => void>;
  26131. private _isEnabled;
  26132. private _isParentEnabled;
  26133. private _isReady;
  26134. /** @hidden */
  26135. _currentRenderId: number;
  26136. private _parentUpdateId;
  26137. /** @hidden */
  26138. _childUpdateId: number;
  26139. /** @hidden */
  26140. _waitingParentId: Nullable<string>;
  26141. /** @hidden */
  26142. _scene: Scene;
  26143. /** @hidden */
  26144. _cache: any;
  26145. private _parentNode;
  26146. private _children;
  26147. /** @hidden */
  26148. _worldMatrix: Matrix;
  26149. /** @hidden */
  26150. _worldMatrixDeterminant: number;
  26151. /** @hidden */
  26152. _worldMatrixDeterminantIsDirty: boolean;
  26153. /** @hidden */
  26154. private _sceneRootNodesIndex;
  26155. /**
  26156. * Gets a boolean indicating if the node has been disposed
  26157. * @returns true if the node was disposed
  26158. */
  26159. isDisposed(): boolean;
  26160. /**
  26161. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26162. * @see https://doc.babylonjs.com/how_to/parenting
  26163. */
  26164. parent: Nullable<Node>;
  26165. private addToSceneRootNodes;
  26166. private removeFromSceneRootNodes;
  26167. private _animationPropertiesOverride;
  26168. /**
  26169. * Gets or sets the animation properties override
  26170. */
  26171. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26172. /**
  26173. * Gets a string idenfifying the name of the class
  26174. * @returns "Node" string
  26175. */
  26176. getClassName(): string;
  26177. /** @hidden */
  26178. readonly _isNode: boolean;
  26179. /**
  26180. * An event triggered when the mesh is disposed
  26181. */
  26182. onDisposeObservable: Observable<Node>;
  26183. private _onDisposeObserver;
  26184. /**
  26185. * Sets a callback that will be raised when the node will be disposed
  26186. */
  26187. onDispose: () => void;
  26188. /**
  26189. * Creates a new Node
  26190. * @param name the name and id to be given to this node
  26191. * @param scene the scene this node will be added to
  26192. * @param addToRootNodes the node will be added to scene.rootNodes
  26193. */
  26194. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26195. /**
  26196. * Gets the scene of the node
  26197. * @returns a scene
  26198. */
  26199. getScene(): Scene;
  26200. /**
  26201. * Gets the engine of the node
  26202. * @returns a Engine
  26203. */
  26204. getEngine(): Engine;
  26205. private _behaviors;
  26206. /**
  26207. * Attach a behavior to the node
  26208. * @see http://doc.babylonjs.com/features/behaviour
  26209. * @param behavior defines the behavior to attach
  26210. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26211. * @returns the current Node
  26212. */
  26213. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26214. /**
  26215. * Remove an attached behavior
  26216. * @see http://doc.babylonjs.com/features/behaviour
  26217. * @param behavior defines the behavior to attach
  26218. * @returns the current Node
  26219. */
  26220. removeBehavior(behavior: Behavior<Node>): Node;
  26221. /**
  26222. * Gets the list of attached behaviors
  26223. * @see http://doc.babylonjs.com/features/behaviour
  26224. */
  26225. readonly behaviors: Behavior<Node>[];
  26226. /**
  26227. * Gets an attached behavior by name
  26228. * @param name defines the name of the behavior to look for
  26229. * @see http://doc.babylonjs.com/features/behaviour
  26230. * @returns null if behavior was not found else the requested behavior
  26231. */
  26232. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26233. /**
  26234. * Returns the latest update of the World matrix
  26235. * @returns a Matrix
  26236. */
  26237. getWorldMatrix(): Matrix;
  26238. /** @hidden */
  26239. _getWorldMatrixDeterminant(): number;
  26240. /**
  26241. * Returns directly the latest state of the mesh World matrix.
  26242. * A Matrix is returned.
  26243. */
  26244. readonly worldMatrixFromCache: Matrix;
  26245. /** @hidden */
  26246. _initCache(): void;
  26247. /** @hidden */
  26248. updateCache(force?: boolean): void;
  26249. /** @hidden */
  26250. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26251. /** @hidden */
  26252. _updateCache(ignoreParentClass?: boolean): void;
  26253. /** @hidden */
  26254. _isSynchronized(): boolean;
  26255. /** @hidden */
  26256. _markSyncedWithParent(): void;
  26257. /** @hidden */
  26258. isSynchronizedWithParent(): boolean;
  26259. /** @hidden */
  26260. isSynchronized(): boolean;
  26261. /**
  26262. * Is this node ready to be used/rendered
  26263. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26264. * @return true if the node is ready
  26265. */
  26266. isReady(completeCheck?: boolean): boolean;
  26267. /**
  26268. * Is this node enabled?
  26269. * 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
  26270. * @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
  26271. * @return whether this node (and its parent) is enabled
  26272. */
  26273. isEnabled(checkAncestors?: boolean): boolean;
  26274. /** @hidden */
  26275. protected _syncParentEnabledState(): void;
  26276. /**
  26277. * Set the enabled state of this node
  26278. * @param value defines the new enabled state
  26279. */
  26280. setEnabled(value: boolean): void;
  26281. /**
  26282. * Is this node a descendant of the given node?
  26283. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26284. * @param ancestor defines the parent node to inspect
  26285. * @returns a boolean indicating if this node is a descendant of the given node
  26286. */
  26287. isDescendantOf(ancestor: Node): boolean;
  26288. /** @hidden */
  26289. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26290. /**
  26291. * Will return all nodes that have this node as ascendant
  26292. * @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
  26293. * @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
  26294. * @return all children nodes of all types
  26295. */
  26296. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26297. /**
  26298. * Get all child-meshes of this node
  26299. * @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)
  26300. * @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
  26301. * @returns an array of AbstractMesh
  26302. */
  26303. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26304. /**
  26305. * Get all direct children of this node
  26306. * @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
  26307. * @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)
  26308. * @returns an array of Node
  26309. */
  26310. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26311. /** @hidden */
  26312. _setReady(state: boolean): void;
  26313. /**
  26314. * Get an animation by name
  26315. * @param name defines the name of the animation to look for
  26316. * @returns null if not found else the requested animation
  26317. */
  26318. getAnimationByName(name: string): Nullable<Animation>;
  26319. /**
  26320. * Creates an animation range for this node
  26321. * @param name defines the name of the range
  26322. * @param from defines the starting key
  26323. * @param to defines the end key
  26324. */
  26325. createAnimationRange(name: string, from: number, to: number): void;
  26326. /**
  26327. * Delete a specific animation range
  26328. * @param name defines the name of the range to delete
  26329. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26330. */
  26331. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26332. /**
  26333. * Get an animation range by name
  26334. * @param name defines the name of the animation range to look for
  26335. * @returns null if not found else the requested animation range
  26336. */
  26337. getAnimationRange(name: string): Nullable<AnimationRange>;
  26338. /**
  26339. * Gets the list of all animation ranges defined on this node
  26340. * @returns an array
  26341. */
  26342. getAnimationRanges(): Nullable<AnimationRange>[];
  26343. /**
  26344. * Will start the animation sequence
  26345. * @param name defines the range frames for animation sequence
  26346. * @param loop defines if the animation should loop (false by default)
  26347. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26348. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26349. * @returns the object created for this animation. If range does not exist, it will return null
  26350. */
  26351. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26352. /**
  26353. * Serialize animation ranges into a JSON compatible object
  26354. * @returns serialization object
  26355. */
  26356. serializeAnimationRanges(): any;
  26357. /**
  26358. * Computes the world matrix of the node
  26359. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26360. * @returns the world matrix
  26361. */
  26362. computeWorldMatrix(force?: boolean): Matrix;
  26363. /**
  26364. * Releases resources associated with this node.
  26365. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26366. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26367. */
  26368. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26369. /**
  26370. * Parse animation range data from a serialization object and store them into a given node
  26371. * @param node defines where to store the animation ranges
  26372. * @param parsedNode defines the serialization object to read data from
  26373. * @param scene defines the hosting scene
  26374. */
  26375. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26376. /**
  26377. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26378. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26379. * @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
  26380. * @returns the new bounding vectors
  26381. */
  26382. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26383. min: Vector3;
  26384. max: Vector3;
  26385. };
  26386. }
  26387. }
  26388. declare module "babylonjs/Animations/animation" {
  26389. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  26390. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  26391. import { Nullable } from "babylonjs/types";
  26392. import { Scene } from "babylonjs/scene";
  26393. import { IAnimatable } from "babylonjs/Misc/tools";
  26394. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  26395. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26396. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  26397. import { Node } from "babylonjs/node";
  26398. import { Animatable } from "babylonjs/Animations/animatable";
  26399. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  26400. /**
  26401. * @hidden
  26402. */
  26403. export class _IAnimationState {
  26404. key: number;
  26405. repeatCount: number;
  26406. workValue?: any;
  26407. loopMode?: number;
  26408. offsetValue?: any;
  26409. highLimitValue?: any;
  26410. }
  26411. /**
  26412. * Class used to store any kind of animation
  26413. */
  26414. export class Animation {
  26415. /**Name of the animation */
  26416. name: string;
  26417. /**Property to animate */
  26418. targetProperty: string;
  26419. /**The frames per second of the animation */
  26420. framePerSecond: number;
  26421. /**The data type of the animation */
  26422. dataType: number;
  26423. /**The loop mode of the animation */
  26424. loopMode?: number | undefined;
  26425. /**Specifies if blending should be enabled */
  26426. enableBlending?: boolean | undefined;
  26427. /**
  26428. * Use matrix interpolation instead of using direct key value when animating matrices
  26429. */
  26430. static AllowMatricesInterpolation: boolean;
  26431. /**
  26432. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26433. */
  26434. static AllowMatrixDecomposeForInterpolation: boolean;
  26435. /**
  26436. * Stores the key frames of the animation
  26437. */
  26438. private _keys;
  26439. /**
  26440. * Stores the easing function of the animation
  26441. */
  26442. private _easingFunction;
  26443. /**
  26444. * @hidden Internal use only
  26445. */
  26446. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  26447. /**
  26448. * The set of event that will be linked to this animation
  26449. */
  26450. private _events;
  26451. /**
  26452. * Stores an array of target property paths
  26453. */
  26454. targetPropertyPath: string[];
  26455. /**
  26456. * Stores the blending speed of the animation
  26457. */
  26458. blendingSpeed: number;
  26459. /**
  26460. * Stores the animation ranges for the animation
  26461. */
  26462. private _ranges;
  26463. /**
  26464. * @hidden Internal use
  26465. */
  26466. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26467. /**
  26468. * Sets up an animation
  26469. * @param property The property to animate
  26470. * @param animationType The animation type to apply
  26471. * @param framePerSecond The frames per second of the animation
  26472. * @param easingFunction The easing function used in the animation
  26473. * @returns The created animation
  26474. */
  26475. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26476. /**
  26477. * Create and start an animation on a node
  26478. * @param name defines the name of the global animation that will be run on all nodes
  26479. * @param node defines the root node where the animation will take place
  26480. * @param targetProperty defines property to animate
  26481. * @param framePerSecond defines the number of frame per second yo use
  26482. * @param totalFrame defines the number of frames in total
  26483. * @param from defines the initial value
  26484. * @param to defines the final value
  26485. * @param loopMode defines which loop mode you want to use (off by default)
  26486. * @param easingFunction defines the easing function to use (linear by default)
  26487. * @param onAnimationEnd defines the callback to call when animation end
  26488. * @returns the animatable created for this animation
  26489. */
  26490. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26491. /**
  26492. * Create and start an animation on a node and its descendants
  26493. * @param name defines the name of the global animation that will be run on all nodes
  26494. * @param node defines the root node where the animation will take place
  26495. * @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
  26496. * @param targetProperty defines property to animate
  26497. * @param framePerSecond defines the number of frame per second to use
  26498. * @param totalFrame defines the number of frames in total
  26499. * @param from defines the initial value
  26500. * @param to defines the final value
  26501. * @param loopMode defines which loop mode you want to use (off by default)
  26502. * @param easingFunction defines the easing function to use (linear by default)
  26503. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26504. * @returns the list of animatables created for all nodes
  26505. * @example https://www.babylonjs-playground.com/#MH0VLI
  26506. */
  26507. 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[]>;
  26508. /**
  26509. * Creates a new animation, merges it with the existing animations and starts it
  26510. * @param name Name of the animation
  26511. * @param node Node which contains the scene that begins the animations
  26512. * @param targetProperty Specifies which property to animate
  26513. * @param framePerSecond The frames per second of the animation
  26514. * @param totalFrame The total number of frames
  26515. * @param from The frame at the beginning of the animation
  26516. * @param to The frame at the end of the animation
  26517. * @param loopMode Specifies the loop mode of the animation
  26518. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26519. * @param onAnimationEnd Callback to run once the animation is complete
  26520. * @returns Nullable animation
  26521. */
  26522. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26523. /**
  26524. * Transition property of an host to the target Value
  26525. * @param property The property to transition
  26526. * @param targetValue The target Value of the property
  26527. * @param host The object where the property to animate belongs
  26528. * @param scene Scene used to run the animation
  26529. * @param frameRate Framerate (in frame/s) to use
  26530. * @param transition The transition type we want to use
  26531. * @param duration The duration of the animation, in milliseconds
  26532. * @param onAnimationEnd Callback trigger at the end of the animation
  26533. * @returns Nullable animation
  26534. */
  26535. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26536. /**
  26537. * Return the array of runtime animations currently using this animation
  26538. */
  26539. readonly runtimeAnimations: RuntimeAnimation[];
  26540. /**
  26541. * Specifies if any of the runtime animations are currently running
  26542. */
  26543. readonly hasRunningRuntimeAnimations: boolean;
  26544. /**
  26545. * Initializes the animation
  26546. * @param name Name of the animation
  26547. * @param targetProperty Property to animate
  26548. * @param framePerSecond The frames per second of the animation
  26549. * @param dataType The data type of the animation
  26550. * @param loopMode The loop mode of the animation
  26551. * @param enableBlending Specifies if blending should be enabled
  26552. */
  26553. constructor(
  26554. /**Name of the animation */
  26555. name: string,
  26556. /**Property to animate */
  26557. targetProperty: string,
  26558. /**The frames per second of the animation */
  26559. framePerSecond: number,
  26560. /**The data type of the animation */
  26561. dataType: number,
  26562. /**The loop mode of the animation */
  26563. loopMode?: number | undefined,
  26564. /**Specifies if blending should be enabled */
  26565. enableBlending?: boolean | undefined);
  26566. /**
  26567. * Converts the animation to a string
  26568. * @param fullDetails support for multiple levels of logging within scene loading
  26569. * @returns String form of the animation
  26570. */
  26571. toString(fullDetails?: boolean): string;
  26572. /**
  26573. * Add an event to this animation
  26574. * @param event Event to add
  26575. */
  26576. addEvent(event: AnimationEvent): void;
  26577. /**
  26578. * Remove all events found at the given frame
  26579. * @param frame The frame to remove events from
  26580. */
  26581. removeEvents(frame: number): void;
  26582. /**
  26583. * Retrieves all the events from the animation
  26584. * @returns Events from the animation
  26585. */
  26586. getEvents(): AnimationEvent[];
  26587. /**
  26588. * Creates an animation range
  26589. * @param name Name of the animation range
  26590. * @param from Starting frame of the animation range
  26591. * @param to Ending frame of the animation
  26592. */
  26593. createRange(name: string, from: number, to: number): void;
  26594. /**
  26595. * Deletes an animation range by name
  26596. * @param name Name of the animation range to delete
  26597. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26598. */
  26599. deleteRange(name: string, deleteFrames?: boolean): void;
  26600. /**
  26601. * Gets the animation range by name, or null if not defined
  26602. * @param name Name of the animation range
  26603. * @returns Nullable animation range
  26604. */
  26605. getRange(name: string): Nullable<AnimationRange>;
  26606. /**
  26607. * Gets the key frames from the animation
  26608. * @returns The key frames of the animation
  26609. */
  26610. getKeys(): Array<IAnimationKey>;
  26611. /**
  26612. * Gets the highest frame rate of the animation
  26613. * @returns Highest frame rate of the animation
  26614. */
  26615. getHighestFrame(): number;
  26616. /**
  26617. * Gets the easing function of the animation
  26618. * @returns Easing function of the animation
  26619. */
  26620. getEasingFunction(): IEasingFunction;
  26621. /**
  26622. * Sets the easing function of the animation
  26623. * @param easingFunction A custom mathematical formula for animation
  26624. */
  26625. setEasingFunction(easingFunction: EasingFunction): void;
  26626. /**
  26627. * Interpolates a scalar linearly
  26628. * @param startValue Start value of the animation curve
  26629. * @param endValue End value of the animation curve
  26630. * @param gradient Scalar amount to interpolate
  26631. * @returns Interpolated scalar value
  26632. */
  26633. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26634. /**
  26635. * Interpolates a scalar cubically
  26636. * @param startValue Start value of the animation curve
  26637. * @param outTangent End tangent of the animation
  26638. * @param endValue End value of the animation curve
  26639. * @param inTangent Start tangent of the animation curve
  26640. * @param gradient Scalar amount to interpolate
  26641. * @returns Interpolated scalar value
  26642. */
  26643. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26644. /**
  26645. * Interpolates a quaternion using a spherical linear interpolation
  26646. * @param startValue Start value of the animation curve
  26647. * @param endValue End value of the animation curve
  26648. * @param gradient Scalar amount to interpolate
  26649. * @returns Interpolated quaternion value
  26650. */
  26651. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26652. /**
  26653. * Interpolates a quaternion cubically
  26654. * @param startValue Start value of the animation curve
  26655. * @param outTangent End tangent of the animation curve
  26656. * @param endValue End value of the animation curve
  26657. * @param inTangent Start tangent of the animation curve
  26658. * @param gradient Scalar amount to interpolate
  26659. * @returns Interpolated quaternion value
  26660. */
  26661. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26662. /**
  26663. * Interpolates a Vector3 linearl
  26664. * @param startValue Start value of the animation curve
  26665. * @param endValue End value of the animation curve
  26666. * @param gradient Scalar amount to interpolate
  26667. * @returns Interpolated scalar value
  26668. */
  26669. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26670. /**
  26671. * Interpolates a Vector3 cubically
  26672. * @param startValue Start value of the animation curve
  26673. * @param outTangent End tangent of the animation
  26674. * @param endValue End value of the animation curve
  26675. * @param inTangent Start tangent of the animation curve
  26676. * @param gradient Scalar amount to interpolate
  26677. * @returns InterpolatedVector3 value
  26678. */
  26679. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26680. /**
  26681. * Interpolates a Vector2 linearly
  26682. * @param startValue Start value of the animation curve
  26683. * @param endValue End value of the animation curve
  26684. * @param gradient Scalar amount to interpolate
  26685. * @returns Interpolated Vector2 value
  26686. */
  26687. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26688. /**
  26689. * Interpolates a Vector2 cubically
  26690. * @param startValue Start value of the animation curve
  26691. * @param outTangent End tangent of the animation
  26692. * @param endValue End value of the animation curve
  26693. * @param inTangent Start tangent of the animation curve
  26694. * @param gradient Scalar amount to interpolate
  26695. * @returns Interpolated Vector2 value
  26696. */
  26697. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26698. /**
  26699. * Interpolates a size linearly
  26700. * @param startValue Start value of the animation curve
  26701. * @param endValue End value of the animation curve
  26702. * @param gradient Scalar amount to interpolate
  26703. * @returns Interpolated Size value
  26704. */
  26705. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26706. /**
  26707. * Interpolates a Color3 linearly
  26708. * @param startValue Start value of the animation curve
  26709. * @param endValue End value of the animation curve
  26710. * @param gradient Scalar amount to interpolate
  26711. * @returns Interpolated Color3 value
  26712. */
  26713. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26714. /**
  26715. * @hidden Internal use only
  26716. */
  26717. _getKeyValue(value: any): any;
  26718. /**
  26719. * @hidden Internal use only
  26720. */
  26721. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26722. /**
  26723. * Defines the function to use to interpolate matrices
  26724. * @param startValue defines the start matrix
  26725. * @param endValue defines the end matrix
  26726. * @param gradient defines the gradient between both matrices
  26727. * @param result defines an optional target matrix where to store the interpolation
  26728. * @returns the interpolated matrix
  26729. */
  26730. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26731. /**
  26732. * Makes a copy of the animation
  26733. * @returns Cloned animation
  26734. */
  26735. clone(): Animation;
  26736. /**
  26737. * Sets the key frames of the animation
  26738. * @param values The animation key frames to set
  26739. */
  26740. setKeys(values: Array<IAnimationKey>): void;
  26741. /**
  26742. * Serializes the animation to an object
  26743. * @returns Serialized object
  26744. */
  26745. serialize(): any;
  26746. /**
  26747. * Float animation type
  26748. */
  26749. private static _ANIMATIONTYPE_FLOAT;
  26750. /**
  26751. * Vector3 animation type
  26752. */
  26753. private static _ANIMATIONTYPE_VECTOR3;
  26754. /**
  26755. * Quaternion animation type
  26756. */
  26757. private static _ANIMATIONTYPE_QUATERNION;
  26758. /**
  26759. * Matrix animation type
  26760. */
  26761. private static _ANIMATIONTYPE_MATRIX;
  26762. /**
  26763. * Color3 animation type
  26764. */
  26765. private static _ANIMATIONTYPE_COLOR3;
  26766. /**
  26767. * Vector2 animation type
  26768. */
  26769. private static _ANIMATIONTYPE_VECTOR2;
  26770. /**
  26771. * Size animation type
  26772. */
  26773. private static _ANIMATIONTYPE_SIZE;
  26774. /**
  26775. * Relative Loop Mode
  26776. */
  26777. private static _ANIMATIONLOOPMODE_RELATIVE;
  26778. /**
  26779. * Cycle Loop Mode
  26780. */
  26781. private static _ANIMATIONLOOPMODE_CYCLE;
  26782. /**
  26783. * Constant Loop Mode
  26784. */
  26785. private static _ANIMATIONLOOPMODE_CONSTANT;
  26786. /**
  26787. * Get the float animation type
  26788. */
  26789. static readonly ANIMATIONTYPE_FLOAT: number;
  26790. /**
  26791. * Get the Vector3 animation type
  26792. */
  26793. static readonly ANIMATIONTYPE_VECTOR3: number;
  26794. /**
  26795. * Get the Vector2 animation type
  26796. */
  26797. static readonly ANIMATIONTYPE_VECTOR2: number;
  26798. /**
  26799. * Get the Size animation type
  26800. */
  26801. static readonly ANIMATIONTYPE_SIZE: number;
  26802. /**
  26803. * Get the Quaternion animation type
  26804. */
  26805. static readonly ANIMATIONTYPE_QUATERNION: number;
  26806. /**
  26807. * Get the Matrix animation type
  26808. */
  26809. static readonly ANIMATIONTYPE_MATRIX: number;
  26810. /**
  26811. * Get the Color3 animation type
  26812. */
  26813. static readonly ANIMATIONTYPE_COLOR3: number;
  26814. /**
  26815. * Get the Relative Loop Mode
  26816. */
  26817. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26818. /**
  26819. * Get the Cycle Loop Mode
  26820. */
  26821. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26822. /**
  26823. * Get the Constant Loop Mode
  26824. */
  26825. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26826. /** @hidden */
  26827. static _UniversalLerp(left: any, right: any, amount: number): any;
  26828. /**
  26829. * Parses an animation object and creates an animation
  26830. * @param parsedAnimation Parsed animation object
  26831. * @returns Animation object
  26832. */
  26833. static Parse(parsedAnimation: any): Animation;
  26834. /**
  26835. * Appends the serialized animations from the source animations
  26836. * @param source Source containing the animations
  26837. * @param destination Target to store the animations
  26838. */
  26839. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26840. }
  26841. }
  26842. declare module "babylonjs/Materials/Textures/baseTexture" {
  26843. import { Observable } from "babylonjs/Misc/observable";
  26844. import { IAnimatable } from "babylonjs/Misc/tools";
  26845. import { Nullable } from "babylonjs/types";
  26846. import { Scene } from "babylonjs/scene";
  26847. import { Matrix, ISize } from "babylonjs/Maths/math";
  26848. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26849. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26850. /**
  26851. * Base class of all the textures in babylon.
  26852. * It groups all the common properties the materials, post process, lights... might need
  26853. * in order to make a correct use of the texture.
  26854. */
  26855. export class BaseTexture implements IAnimatable {
  26856. /**
  26857. * Default anisotropic filtering level for the application.
  26858. * It is set to 4 as a good tradeoff between perf and quality.
  26859. */
  26860. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26861. /**
  26862. * Gets or sets the unique id of the texture
  26863. */
  26864. uniqueId: number;
  26865. /**
  26866. * Define the name of the texture.
  26867. */
  26868. name: string;
  26869. /**
  26870. * Gets or sets an object used to store user defined information.
  26871. */
  26872. metadata: any;
  26873. /**
  26874. * For internal use only. Please do not use.
  26875. */
  26876. reservedDataStore: any;
  26877. private _hasAlpha;
  26878. /**
  26879. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26880. */
  26881. hasAlpha: boolean;
  26882. /**
  26883. * Defines if the alpha value should be determined via the rgb values.
  26884. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26885. */
  26886. getAlphaFromRGB: boolean;
  26887. /**
  26888. * Intensity or strength of the texture.
  26889. * It is commonly used by materials to fine tune the intensity of the texture
  26890. */
  26891. level: number;
  26892. /**
  26893. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26894. * This is part of the texture as textures usually maps to one uv set.
  26895. */
  26896. coordinatesIndex: number;
  26897. private _coordinatesMode;
  26898. /**
  26899. * How a texture is mapped.
  26900. *
  26901. * | Value | Type | Description |
  26902. * | ----- | ----------------------------------- | ----------- |
  26903. * | 0 | EXPLICIT_MODE | |
  26904. * | 1 | SPHERICAL_MODE | |
  26905. * | 2 | PLANAR_MODE | |
  26906. * | 3 | CUBIC_MODE | |
  26907. * | 4 | PROJECTION_MODE | |
  26908. * | 5 | SKYBOX_MODE | |
  26909. * | 6 | INVCUBIC_MODE | |
  26910. * | 7 | EQUIRECTANGULAR_MODE | |
  26911. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26912. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26913. */
  26914. coordinatesMode: number;
  26915. /**
  26916. * | Value | Type | Description |
  26917. * | ----- | ------------------ | ----------- |
  26918. * | 0 | CLAMP_ADDRESSMODE | |
  26919. * | 1 | WRAP_ADDRESSMODE | |
  26920. * | 2 | MIRROR_ADDRESSMODE | |
  26921. */
  26922. wrapU: number;
  26923. /**
  26924. * | Value | Type | Description |
  26925. * | ----- | ------------------ | ----------- |
  26926. * | 0 | CLAMP_ADDRESSMODE | |
  26927. * | 1 | WRAP_ADDRESSMODE | |
  26928. * | 2 | MIRROR_ADDRESSMODE | |
  26929. */
  26930. wrapV: number;
  26931. /**
  26932. * | Value | Type | Description |
  26933. * | ----- | ------------------ | ----------- |
  26934. * | 0 | CLAMP_ADDRESSMODE | |
  26935. * | 1 | WRAP_ADDRESSMODE | |
  26936. * | 2 | MIRROR_ADDRESSMODE | |
  26937. */
  26938. wrapR: number;
  26939. /**
  26940. * With compliant hardware and browser (supporting anisotropic filtering)
  26941. * this defines the level of anisotropic filtering in the texture.
  26942. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26943. */
  26944. anisotropicFilteringLevel: number;
  26945. /**
  26946. * Define if the texture is a cube texture or if false a 2d texture.
  26947. */
  26948. isCube: boolean;
  26949. /**
  26950. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26951. */
  26952. is3D: boolean;
  26953. /**
  26954. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26955. * HDR texture are usually stored in linear space.
  26956. * This only impacts the PBR and Background materials
  26957. */
  26958. gammaSpace: boolean;
  26959. /**
  26960. * Gets whether or not the texture contains RGBD data.
  26961. */
  26962. readonly isRGBD: boolean;
  26963. /**
  26964. * Is Z inverted in the texture (useful in a cube texture).
  26965. */
  26966. invertZ: boolean;
  26967. /**
  26968. * Are mip maps generated for this texture or not.
  26969. */
  26970. readonly noMipmap: boolean;
  26971. /**
  26972. * @hidden
  26973. */
  26974. lodLevelInAlpha: boolean;
  26975. /**
  26976. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26977. */
  26978. lodGenerationOffset: number;
  26979. /**
  26980. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26981. */
  26982. lodGenerationScale: number;
  26983. /**
  26984. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  26985. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  26986. * average roughness values.
  26987. */
  26988. linearSpecularLOD: boolean;
  26989. /**
  26990. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  26991. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  26992. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  26993. */
  26994. irradianceTexture: Nullable<BaseTexture>;
  26995. /**
  26996. * Define if the texture is a render target.
  26997. */
  26998. isRenderTarget: boolean;
  26999. /**
  27000. * Define the unique id of the texture in the scene.
  27001. */
  27002. readonly uid: string;
  27003. /**
  27004. * Return a string representation of the texture.
  27005. * @returns the texture as a string
  27006. */
  27007. toString(): string;
  27008. /**
  27009. * Get the class name of the texture.
  27010. * @returns "BaseTexture"
  27011. */
  27012. getClassName(): string;
  27013. /**
  27014. * Define the list of animation attached to the texture.
  27015. */
  27016. animations: import("babylonjs/Animations/animation").Animation[];
  27017. /**
  27018. * An event triggered when the texture is disposed.
  27019. */
  27020. onDisposeObservable: Observable<BaseTexture>;
  27021. private _onDisposeObserver;
  27022. /**
  27023. * Callback triggered when the texture has been disposed.
  27024. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27025. */
  27026. onDispose: () => void;
  27027. /**
  27028. * Define the current state of the loading sequence when in delayed load mode.
  27029. */
  27030. delayLoadState: number;
  27031. private _scene;
  27032. /** @hidden */
  27033. _texture: Nullable<InternalTexture>;
  27034. private _uid;
  27035. /**
  27036. * Define if the texture is preventinga material to render or not.
  27037. * If not and the texture is not ready, the engine will use a default black texture instead.
  27038. */
  27039. readonly isBlocking: boolean;
  27040. /**
  27041. * Instantiates a new BaseTexture.
  27042. * Base class of all the textures in babylon.
  27043. * It groups all the common properties the materials, post process, lights... might need
  27044. * in order to make a correct use of the texture.
  27045. * @param scene Define the scene the texture blongs to
  27046. */
  27047. constructor(scene: Nullable<Scene>);
  27048. /**
  27049. * Get the scene the texture belongs to.
  27050. * @returns the scene or null if undefined
  27051. */
  27052. getScene(): Nullable<Scene>;
  27053. /**
  27054. * Get the texture transform matrix used to offset tile the texture for istance.
  27055. * @returns the transformation matrix
  27056. */
  27057. getTextureMatrix(): Matrix;
  27058. /**
  27059. * Get the texture reflection matrix used to rotate/transform the reflection.
  27060. * @returns the reflection matrix
  27061. */
  27062. getReflectionTextureMatrix(): Matrix;
  27063. /**
  27064. * Get the underlying lower level texture from Babylon.
  27065. * @returns the insternal texture
  27066. */
  27067. getInternalTexture(): Nullable<InternalTexture>;
  27068. /**
  27069. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27070. * @returns true if ready or not blocking
  27071. */
  27072. isReadyOrNotBlocking(): boolean;
  27073. /**
  27074. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27075. * @returns true if fully ready
  27076. */
  27077. isReady(): boolean;
  27078. private _cachedSize;
  27079. /**
  27080. * Get the size of the texture.
  27081. * @returns the texture size.
  27082. */
  27083. getSize(): ISize;
  27084. /**
  27085. * Get the base size of the texture.
  27086. * It can be different from the size if the texture has been resized for POT for instance
  27087. * @returns the base size
  27088. */
  27089. getBaseSize(): ISize;
  27090. /**
  27091. * Update the sampling mode of the texture.
  27092. * Default is Trilinear mode.
  27093. *
  27094. * | Value | Type | Description |
  27095. * | ----- | ------------------ | ----------- |
  27096. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27097. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27098. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27099. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27100. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27101. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27102. * | 7 | NEAREST_LINEAR | |
  27103. * | 8 | NEAREST_NEAREST | |
  27104. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27105. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27106. * | 11 | LINEAR_LINEAR | |
  27107. * | 12 | LINEAR_NEAREST | |
  27108. *
  27109. * > _mag_: magnification filter (close to the viewer)
  27110. * > _min_: minification filter (far from the viewer)
  27111. * > _mip_: filter used between mip map levels
  27112. *@param samplingMode Define the new sampling mode of the texture
  27113. */
  27114. updateSamplingMode(samplingMode: number): void;
  27115. /**
  27116. * Scales the texture if is `canRescale()`
  27117. * @param ratio the resize factor we want to use to rescale
  27118. */
  27119. scale(ratio: number): void;
  27120. /**
  27121. * Get if the texture can rescale.
  27122. */
  27123. readonly canRescale: boolean;
  27124. /** @hidden */
  27125. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27126. /** @hidden */
  27127. _rebuild(): void;
  27128. /**
  27129. * Triggers the load sequence in delayed load mode.
  27130. */
  27131. delayLoad(): void;
  27132. /**
  27133. * Clones the texture.
  27134. * @returns the cloned texture
  27135. */
  27136. clone(): Nullable<BaseTexture>;
  27137. /**
  27138. * Get the texture underlying type (INT, FLOAT...)
  27139. */
  27140. readonly textureType: number;
  27141. /**
  27142. * Get the texture underlying format (RGB, RGBA...)
  27143. */
  27144. readonly textureFormat: number;
  27145. /**
  27146. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27147. * This will returns an RGBA array buffer containing either in values (0-255) or
  27148. * float values (0-1) depending of the underlying buffer type.
  27149. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27150. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27151. * @param buffer defines a user defined buffer to fill with data (can be null)
  27152. * @returns The Array buffer containing the pixels data.
  27153. */
  27154. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27155. /**
  27156. * Release and destroy the underlying lower level texture aka internalTexture.
  27157. */
  27158. releaseInternalTexture(): void;
  27159. /**
  27160. * Get the polynomial representation of the texture data.
  27161. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27162. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27163. */
  27164. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27165. /** @hidden */
  27166. readonly _lodTextureHigh: Nullable<BaseTexture>;
  27167. /** @hidden */
  27168. readonly _lodTextureMid: Nullable<BaseTexture>;
  27169. /** @hidden */
  27170. readonly _lodTextureLow: Nullable<BaseTexture>;
  27171. /**
  27172. * Dispose the texture and release its associated resources.
  27173. */
  27174. dispose(): void;
  27175. /**
  27176. * Serialize the texture into a JSON representation that can be parsed later on.
  27177. * @returns the JSON representation of the texture
  27178. */
  27179. serialize(): any;
  27180. /**
  27181. * Helper function to be called back once a list of texture contains only ready textures.
  27182. * @param textures Define the list of textures to wait for
  27183. * @param callback Define the callback triggered once the entire list will be ready
  27184. */
  27185. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27186. }
  27187. }
  27188. declare module "babylonjs/Materials/uniformBuffer" {
  27189. import { Nullable, FloatArray } from "babylonjs/types";
  27190. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  27191. import { Engine } from "babylonjs/Engines/engine";
  27192. import { Effect } from "babylonjs/Materials/effect";
  27193. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27194. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27195. /**
  27196. * Uniform buffer objects.
  27197. *
  27198. * Handles blocks of uniform on the GPU.
  27199. *
  27200. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27201. *
  27202. * For more information, please refer to :
  27203. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27204. */
  27205. export class UniformBuffer {
  27206. private _engine;
  27207. private _buffer;
  27208. private _data;
  27209. private _bufferData;
  27210. private _dynamic?;
  27211. private _uniformLocations;
  27212. private _uniformSizes;
  27213. private _uniformLocationPointer;
  27214. private _needSync;
  27215. private _noUBO;
  27216. private _currentEffect;
  27217. private static _MAX_UNIFORM_SIZE;
  27218. private static _tempBuffer;
  27219. /**
  27220. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  27221. * This is dynamic to allow compat with webgl 1 and 2.
  27222. * You will need to pass the name of the uniform as well as the value.
  27223. */
  27224. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  27225. /**
  27226. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  27227. * This is dynamic to allow compat with webgl 1 and 2.
  27228. * You will need to pass the name of the uniform as well as the value.
  27229. */
  27230. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  27231. /**
  27232. * Lambda to Update a single float in a uniform buffer.
  27233. * This is dynamic to allow compat with webgl 1 and 2.
  27234. * You will need to pass the name of the uniform as well as the value.
  27235. */
  27236. updateFloat: (name: string, x: number) => void;
  27237. /**
  27238. * Lambda to Update a vec2 of float in a uniform buffer.
  27239. * This is dynamic to allow compat with webgl 1 and 2.
  27240. * You will need to pass the name of the uniform as well as the value.
  27241. */
  27242. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  27243. /**
  27244. * Lambda to Update a vec3 of float in a uniform buffer.
  27245. * This is dynamic to allow compat with webgl 1 and 2.
  27246. * You will need to pass the name of the uniform as well as the value.
  27247. */
  27248. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  27249. /**
  27250. * Lambda to Update a vec4 of float in a uniform buffer.
  27251. * This is dynamic to allow compat with webgl 1 and 2.
  27252. * You will need to pass the name of the uniform as well as the value.
  27253. */
  27254. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  27255. /**
  27256. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  27257. * This is dynamic to allow compat with webgl 1 and 2.
  27258. * You will need to pass the name of the uniform as well as the value.
  27259. */
  27260. updateMatrix: (name: string, mat: Matrix) => void;
  27261. /**
  27262. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  27263. * This is dynamic to allow compat with webgl 1 and 2.
  27264. * You will need to pass the name of the uniform as well as the value.
  27265. */
  27266. updateVector3: (name: string, vector: Vector3) => void;
  27267. /**
  27268. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  27269. * This is dynamic to allow compat with webgl 1 and 2.
  27270. * You will need to pass the name of the uniform as well as the value.
  27271. */
  27272. updateVector4: (name: string, vector: Vector4) => void;
  27273. /**
  27274. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  27275. * This is dynamic to allow compat with webgl 1 and 2.
  27276. * You will need to pass the name of the uniform as well as the value.
  27277. */
  27278. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  27279. /**
  27280. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  27281. * This is dynamic to allow compat with webgl 1 and 2.
  27282. * You will need to pass the name of the uniform as well as the value.
  27283. */
  27284. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  27285. /**
  27286. * Instantiates a new Uniform buffer objects.
  27287. *
  27288. * Handles blocks of uniform on the GPU.
  27289. *
  27290. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27291. *
  27292. * For more information, please refer to :
  27293. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27294. * @param engine Define the engine the buffer is associated with
  27295. * @param data Define the data contained in the buffer
  27296. * @param dynamic Define if the buffer is updatable
  27297. */
  27298. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  27299. /**
  27300. * Indicates if the buffer is using the WebGL2 UBO implementation,
  27301. * or just falling back on setUniformXXX calls.
  27302. */
  27303. readonly useUbo: boolean;
  27304. /**
  27305. * Indicates if the WebGL underlying uniform buffer is in sync
  27306. * with the javascript cache data.
  27307. */
  27308. readonly isSync: boolean;
  27309. /**
  27310. * Indicates if the WebGL underlying uniform buffer is dynamic.
  27311. * Also, a dynamic UniformBuffer will disable cache verification and always
  27312. * update the underlying WebGL uniform buffer to the GPU.
  27313. * @returns if Dynamic, otherwise false
  27314. */
  27315. isDynamic(): boolean;
  27316. /**
  27317. * The data cache on JS side.
  27318. * @returns the underlying data as a float array
  27319. */
  27320. getData(): Float32Array;
  27321. /**
  27322. * The underlying WebGL Uniform buffer.
  27323. * @returns the webgl buffer
  27324. */
  27325. getBuffer(): Nullable<DataBuffer>;
  27326. /**
  27327. * std140 layout specifies how to align data within an UBO structure.
  27328. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  27329. * for specs.
  27330. */
  27331. private _fillAlignment;
  27332. /**
  27333. * Adds an uniform in the buffer.
  27334. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  27335. * for the layout to be correct !
  27336. * @param name Name of the uniform, as used in the uniform block in the shader.
  27337. * @param size Data size, or data directly.
  27338. */
  27339. addUniform(name: string, size: number | number[]): void;
  27340. /**
  27341. * Adds a Matrix 4x4 to the uniform buffer.
  27342. * @param name Name of the uniform, as used in the uniform block in the shader.
  27343. * @param mat A 4x4 matrix.
  27344. */
  27345. addMatrix(name: string, mat: Matrix): void;
  27346. /**
  27347. * Adds a vec2 to the uniform buffer.
  27348. * @param name Name of the uniform, as used in the uniform block in the shader.
  27349. * @param x Define the x component value of the vec2
  27350. * @param y Define the y component value of the vec2
  27351. */
  27352. addFloat2(name: string, x: number, y: number): void;
  27353. /**
  27354. * Adds a vec3 to the uniform buffer.
  27355. * @param name Name of the uniform, as used in the uniform block in the shader.
  27356. * @param x Define the x component value of the vec3
  27357. * @param y Define the y component value of the vec3
  27358. * @param z Define the z component value of the vec3
  27359. */
  27360. addFloat3(name: string, x: number, y: number, z: number): void;
  27361. /**
  27362. * Adds a vec3 to the uniform buffer.
  27363. * @param name Name of the uniform, as used in the uniform block in the shader.
  27364. * @param color Define the vec3 from a Color
  27365. */
  27366. addColor3(name: string, color: Color3): void;
  27367. /**
  27368. * Adds a vec4 to the uniform buffer.
  27369. * @param name Name of the uniform, as used in the uniform block in the shader.
  27370. * @param color Define the rgb components from a Color
  27371. * @param alpha Define the a component of the vec4
  27372. */
  27373. addColor4(name: string, color: Color3, alpha: number): void;
  27374. /**
  27375. * Adds a vec3 to the uniform buffer.
  27376. * @param name Name of the uniform, as used in the uniform block in the shader.
  27377. * @param vector Define the vec3 components from a Vector
  27378. */
  27379. addVector3(name: string, vector: Vector3): void;
  27380. /**
  27381. * Adds a Matrix 3x3 to the uniform buffer.
  27382. * @param name Name of the uniform, as used in the uniform block in the shader.
  27383. */
  27384. addMatrix3x3(name: string): void;
  27385. /**
  27386. * Adds a Matrix 2x2 to the uniform buffer.
  27387. * @param name Name of the uniform, as used in the uniform block in the shader.
  27388. */
  27389. addMatrix2x2(name: string): void;
  27390. /**
  27391. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  27392. */
  27393. create(): void;
  27394. /** @hidden */
  27395. _rebuild(): void;
  27396. /**
  27397. * Updates the WebGL Uniform Buffer on the GPU.
  27398. * If the `dynamic` flag is set to true, no cache comparison is done.
  27399. * Otherwise, the buffer will be updated only if the cache differs.
  27400. */
  27401. update(): void;
  27402. /**
  27403. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  27404. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27405. * @param data Define the flattened data
  27406. * @param size Define the size of the data.
  27407. */
  27408. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  27409. private _updateMatrix3x3ForUniform;
  27410. private _updateMatrix3x3ForEffect;
  27411. private _updateMatrix2x2ForEffect;
  27412. private _updateMatrix2x2ForUniform;
  27413. private _updateFloatForEffect;
  27414. private _updateFloatForUniform;
  27415. private _updateFloat2ForEffect;
  27416. private _updateFloat2ForUniform;
  27417. private _updateFloat3ForEffect;
  27418. private _updateFloat3ForUniform;
  27419. private _updateFloat4ForEffect;
  27420. private _updateFloat4ForUniform;
  27421. private _updateMatrixForEffect;
  27422. private _updateMatrixForUniform;
  27423. private _updateVector3ForEffect;
  27424. private _updateVector3ForUniform;
  27425. private _updateVector4ForEffect;
  27426. private _updateVector4ForUniform;
  27427. private _updateColor3ForEffect;
  27428. private _updateColor3ForUniform;
  27429. private _updateColor4ForEffect;
  27430. private _updateColor4ForUniform;
  27431. /**
  27432. * Sets a sampler uniform on the effect.
  27433. * @param name Define the name of the sampler.
  27434. * @param texture Define the texture to set in the sampler
  27435. */
  27436. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  27437. /**
  27438. * Directly updates the value of the uniform in the cache AND on the GPU.
  27439. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27440. * @param data Define the flattened data
  27441. */
  27442. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  27443. /**
  27444. * Binds this uniform buffer to an effect.
  27445. * @param effect Define the effect to bind the buffer to
  27446. * @param name Name of the uniform block in the shader.
  27447. */
  27448. bindToEffect(effect: Effect, name: string): void;
  27449. /**
  27450. * Disposes the uniform buffer.
  27451. */
  27452. dispose(): void;
  27453. }
  27454. }
  27455. declare module "babylonjs/Audio/analyser" {
  27456. import { Scene } from "babylonjs/scene";
  27457. /**
  27458. * Class used to work with sound analyzer using fast fourier transform (FFT)
  27459. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27460. */
  27461. export class Analyser {
  27462. /**
  27463. * Gets or sets the smoothing
  27464. * @ignorenaming
  27465. */
  27466. SMOOTHING: number;
  27467. /**
  27468. * Gets or sets the FFT table size
  27469. * @ignorenaming
  27470. */
  27471. FFT_SIZE: number;
  27472. /**
  27473. * Gets or sets the bar graph amplitude
  27474. * @ignorenaming
  27475. */
  27476. BARGRAPHAMPLITUDE: number;
  27477. /**
  27478. * Gets or sets the position of the debug canvas
  27479. * @ignorenaming
  27480. */
  27481. DEBUGCANVASPOS: {
  27482. x: number;
  27483. y: number;
  27484. };
  27485. /**
  27486. * Gets or sets the debug canvas size
  27487. * @ignorenaming
  27488. */
  27489. DEBUGCANVASSIZE: {
  27490. width: number;
  27491. height: number;
  27492. };
  27493. private _byteFreqs;
  27494. private _byteTime;
  27495. private _floatFreqs;
  27496. private _webAudioAnalyser;
  27497. private _debugCanvas;
  27498. private _debugCanvasContext;
  27499. private _scene;
  27500. private _registerFunc;
  27501. private _audioEngine;
  27502. /**
  27503. * Creates a new analyser
  27504. * @param scene defines hosting scene
  27505. */
  27506. constructor(scene: Scene);
  27507. /**
  27508. * Get the number of data values you will have to play with for the visualization
  27509. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  27510. * @returns a number
  27511. */
  27512. getFrequencyBinCount(): number;
  27513. /**
  27514. * Gets the current frequency data as a byte array
  27515. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27516. * @returns a Uint8Array
  27517. */
  27518. getByteFrequencyData(): Uint8Array;
  27519. /**
  27520. * Gets the current waveform as a byte array
  27521. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27522. * @returns a Uint8Array
  27523. */
  27524. getByteTimeDomainData(): Uint8Array;
  27525. /**
  27526. * Gets the current frequency data as a float array
  27527. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27528. * @returns a Float32Array
  27529. */
  27530. getFloatFrequencyData(): Float32Array;
  27531. /**
  27532. * Renders the debug canvas
  27533. */
  27534. drawDebugCanvas(): void;
  27535. /**
  27536. * Stops rendering the debug canvas and removes it
  27537. */
  27538. stopDebugCanvas(): void;
  27539. /**
  27540. * Connects two audio nodes
  27541. * @param inputAudioNode defines first node to connect
  27542. * @param outputAudioNode defines second node to connect
  27543. */
  27544. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27545. /**
  27546. * Releases all associated resources
  27547. */
  27548. dispose(): void;
  27549. }
  27550. }
  27551. declare module "babylonjs/Audio/audioEngine" {
  27552. import { IDisposable } from "babylonjs/scene";
  27553. import { Analyser } from "babylonjs/Audio/analyser";
  27554. import { Nullable } from "babylonjs/types";
  27555. import { Observable } from "babylonjs/Misc/observable";
  27556. /**
  27557. * This represents an audio engine and it is responsible
  27558. * to play, synchronize and analyse sounds throughout the application.
  27559. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27560. */
  27561. export interface IAudioEngine extends IDisposable {
  27562. /**
  27563. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27564. */
  27565. readonly canUseWebAudio: boolean;
  27566. /**
  27567. * Gets the current AudioContext if available.
  27568. */
  27569. readonly audioContext: Nullable<AudioContext>;
  27570. /**
  27571. * The master gain node defines the global audio volume of your audio engine.
  27572. */
  27573. readonly masterGain: GainNode;
  27574. /**
  27575. * Gets whether or not mp3 are supported by your browser.
  27576. */
  27577. readonly isMP3supported: boolean;
  27578. /**
  27579. * Gets whether or not ogg are supported by your browser.
  27580. */
  27581. readonly isOGGsupported: boolean;
  27582. /**
  27583. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27584. * @ignoreNaming
  27585. */
  27586. WarnedWebAudioUnsupported: boolean;
  27587. /**
  27588. * Defines if the audio engine relies on a custom unlocked button.
  27589. * In this case, the embedded button will not be displayed.
  27590. */
  27591. useCustomUnlockedButton: boolean;
  27592. /**
  27593. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27594. */
  27595. readonly unlocked: boolean;
  27596. /**
  27597. * Event raised when audio has been unlocked on the browser.
  27598. */
  27599. onAudioUnlockedObservable: Observable<AudioEngine>;
  27600. /**
  27601. * Event raised when audio has been locked on the browser.
  27602. */
  27603. onAudioLockedObservable: Observable<AudioEngine>;
  27604. /**
  27605. * Flags the audio engine in Locked state.
  27606. * This happens due to new browser policies preventing audio to autoplay.
  27607. */
  27608. lock(): void;
  27609. /**
  27610. * Unlocks the audio engine once a user action has been done on the dom.
  27611. * This is helpful to resume play once browser policies have been satisfied.
  27612. */
  27613. unlock(): void;
  27614. }
  27615. /**
  27616. * This represents the default audio engine used in babylon.
  27617. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27618. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27619. */
  27620. export class AudioEngine implements IAudioEngine {
  27621. private _audioContext;
  27622. private _audioContextInitialized;
  27623. private _muteButton;
  27624. private _hostElement;
  27625. /**
  27626. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27627. */
  27628. canUseWebAudio: boolean;
  27629. /**
  27630. * The master gain node defines the global audio volume of your audio engine.
  27631. */
  27632. masterGain: GainNode;
  27633. /**
  27634. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27635. * @ignoreNaming
  27636. */
  27637. WarnedWebAudioUnsupported: boolean;
  27638. /**
  27639. * Gets whether or not mp3 are supported by your browser.
  27640. */
  27641. isMP3supported: boolean;
  27642. /**
  27643. * Gets whether or not ogg are supported by your browser.
  27644. */
  27645. isOGGsupported: boolean;
  27646. /**
  27647. * Gets whether audio has been unlocked on the device.
  27648. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27649. * a user interaction has happened.
  27650. */
  27651. unlocked: boolean;
  27652. /**
  27653. * Defines if the audio engine relies on a custom unlocked button.
  27654. * In this case, the embedded button will not be displayed.
  27655. */
  27656. useCustomUnlockedButton: boolean;
  27657. /**
  27658. * Event raised when audio has been unlocked on the browser.
  27659. */
  27660. onAudioUnlockedObservable: Observable<AudioEngine>;
  27661. /**
  27662. * Event raised when audio has been locked on the browser.
  27663. */
  27664. onAudioLockedObservable: Observable<AudioEngine>;
  27665. /**
  27666. * Gets the current AudioContext if available.
  27667. */
  27668. readonly audioContext: Nullable<AudioContext>;
  27669. private _connectedAnalyser;
  27670. /**
  27671. * Instantiates a new audio engine.
  27672. *
  27673. * There should be only one per page as some browsers restrict the number
  27674. * of audio contexts you can create.
  27675. * @param hostElement defines the host element where to display the mute icon if necessary
  27676. */
  27677. constructor(hostElement?: Nullable<HTMLElement>);
  27678. /**
  27679. * Flags the audio engine in Locked state.
  27680. * This happens due to new browser policies preventing audio to autoplay.
  27681. */
  27682. lock(): void;
  27683. /**
  27684. * Unlocks the audio engine once a user action has been done on the dom.
  27685. * This is helpful to resume play once browser policies have been satisfied.
  27686. */
  27687. unlock(): void;
  27688. private _resumeAudioContext;
  27689. private _initializeAudioContext;
  27690. private _tryToRun;
  27691. private _triggerRunningState;
  27692. private _triggerSuspendedState;
  27693. private _displayMuteButton;
  27694. private _moveButtonToTopLeft;
  27695. private _onResize;
  27696. private _hideMuteButton;
  27697. /**
  27698. * Destroy and release the resources associated with the audio ccontext.
  27699. */
  27700. dispose(): void;
  27701. /**
  27702. * Gets the global volume sets on the master gain.
  27703. * @returns the global volume if set or -1 otherwise
  27704. */
  27705. getGlobalVolume(): number;
  27706. /**
  27707. * Sets the global volume of your experience (sets on the master gain).
  27708. * @param newVolume Defines the new global volume of the application
  27709. */
  27710. setGlobalVolume(newVolume: number): void;
  27711. /**
  27712. * Connect the audio engine to an audio analyser allowing some amazing
  27713. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27714. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27715. * @param analyser The analyser to connect to the engine
  27716. */
  27717. connectToAnalyser(analyser: Analyser): void;
  27718. }
  27719. }
  27720. declare module "babylonjs/Loading/loadingScreen" {
  27721. /**
  27722. * Interface used to present a loading screen while loading a scene
  27723. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27724. */
  27725. export interface ILoadingScreen {
  27726. /**
  27727. * Function called to display the loading screen
  27728. */
  27729. displayLoadingUI: () => void;
  27730. /**
  27731. * Function called to hide the loading screen
  27732. */
  27733. hideLoadingUI: () => void;
  27734. /**
  27735. * Gets or sets the color to use for the background
  27736. */
  27737. loadingUIBackgroundColor: string;
  27738. /**
  27739. * Gets or sets the text to display while loading
  27740. */
  27741. loadingUIText: string;
  27742. }
  27743. /**
  27744. * Class used for the default loading screen
  27745. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27746. */
  27747. export class DefaultLoadingScreen implements ILoadingScreen {
  27748. private _renderingCanvas;
  27749. private _loadingText;
  27750. private _loadingDivBackgroundColor;
  27751. private _loadingDiv;
  27752. private _loadingTextDiv;
  27753. /** Gets or sets the logo url to use for the default loading screen */
  27754. static DefaultLogoUrl: string;
  27755. /** Gets or sets the spinner url to use for the default loading screen */
  27756. static DefaultSpinnerUrl: string;
  27757. /**
  27758. * Creates a new default loading screen
  27759. * @param _renderingCanvas defines the canvas used to render the scene
  27760. * @param _loadingText defines the default text to display
  27761. * @param _loadingDivBackgroundColor defines the default background color
  27762. */
  27763. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27764. /**
  27765. * Function called to display the loading screen
  27766. */
  27767. displayLoadingUI(): void;
  27768. /**
  27769. * Function called to hide the loading screen
  27770. */
  27771. hideLoadingUI(): void;
  27772. /**
  27773. * Gets or sets the text to display while loading
  27774. */
  27775. loadingUIText: string;
  27776. /**
  27777. * Gets or sets the color to use for the background
  27778. */
  27779. loadingUIBackgroundColor: string;
  27780. private _resizeLoadingUI;
  27781. }
  27782. }
  27783. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  27784. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27785. import { Engine } from "babylonjs/Engines/engine";
  27786. import { Nullable } from "babylonjs/types";
  27787. /** @hidden */
  27788. export class WebGLPipelineContext implements IPipelineContext {
  27789. engine: Engine;
  27790. program: Nullable<WebGLProgram>;
  27791. context?: WebGLRenderingContext;
  27792. vertexShader?: WebGLShader;
  27793. fragmentShader?: WebGLShader;
  27794. isParallelCompiled: boolean;
  27795. onCompiled?: () => void;
  27796. transformFeedback?: WebGLTransformFeedback | null;
  27797. readonly isAsync: boolean;
  27798. readonly isReady: boolean;
  27799. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  27800. }
  27801. }
  27802. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  27803. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27804. /** @hidden */
  27805. export class WebGLDataBuffer extends DataBuffer {
  27806. private _buffer;
  27807. constructor(resource: WebGLBuffer);
  27808. readonly underlyingResource: any;
  27809. }
  27810. }
  27811. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  27812. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  27813. /** @hidden */
  27814. export class WebGL2ShaderProcessor implements IShaderProcessor {
  27815. attributeProcessor(attribute: string): string;
  27816. varyingProcessor(varying: string, isFragment: boolean): string;
  27817. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  27818. }
  27819. }
  27820. declare module "babylonjs/Materials/Textures/videoTexture" {
  27821. import { Observable } from "babylonjs/Misc/observable";
  27822. import { Nullable } from "babylonjs/types";
  27823. import { Scene } from "babylonjs/scene";
  27824. import { Texture } from "babylonjs/Materials/Textures/texture";
  27825. /**
  27826. * Settings for finer control over video usage
  27827. */
  27828. export interface VideoTextureSettings {
  27829. /**
  27830. * Applies `autoplay` to video, if specified
  27831. */
  27832. autoPlay?: boolean;
  27833. /**
  27834. * Applies `loop` to video, if specified
  27835. */
  27836. loop?: boolean;
  27837. /**
  27838. * Automatically updates internal texture from video at every frame in the render loop
  27839. */
  27840. autoUpdateTexture: boolean;
  27841. /**
  27842. * Image src displayed during the video loading or until the user interacts with the video.
  27843. */
  27844. poster?: string;
  27845. }
  27846. /**
  27847. * If you want to display a video in your scene, this is the special texture for that.
  27848. * This special texture works similar to other textures, with the exception of a few parameters.
  27849. * @see https://doc.babylonjs.com/how_to/video_texture
  27850. */
  27851. export class VideoTexture extends Texture {
  27852. /**
  27853. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27854. */
  27855. readonly autoUpdateTexture: boolean;
  27856. /**
  27857. * The video instance used by the texture internally
  27858. */
  27859. readonly video: HTMLVideoElement;
  27860. private _onUserActionRequestedObservable;
  27861. /**
  27862. * Event triggerd when a dom action is required by the user to play the video.
  27863. * This happens due to recent changes in browser policies preventing video to auto start.
  27864. */
  27865. readonly onUserActionRequestedObservable: Observable<Texture>;
  27866. private _generateMipMaps;
  27867. private _engine;
  27868. private _stillImageCaptured;
  27869. private _displayingPosterTexture;
  27870. private _settings;
  27871. private _createInternalTextureOnEvent;
  27872. /**
  27873. * Creates a video texture.
  27874. * If you want to display a video in your scene, this is the special texture for that.
  27875. * This special texture works similar to other textures, with the exception of a few parameters.
  27876. * @see https://doc.babylonjs.com/how_to/video_texture
  27877. * @param name optional name, will detect from video source, if not defined
  27878. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27879. * @param scene is obviously the current scene.
  27880. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27881. * @param invertY is false by default but can be used to invert video on Y axis
  27882. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27883. * @param settings allows finer control over video usage
  27884. */
  27885. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27886. private _getName;
  27887. private _getVideo;
  27888. private _createInternalTexture;
  27889. private reset;
  27890. /**
  27891. * @hidden Internal method to initiate `update`.
  27892. */
  27893. _rebuild(): void;
  27894. /**
  27895. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27896. */
  27897. update(): void;
  27898. /**
  27899. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27900. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27901. */
  27902. updateTexture(isVisible: boolean): void;
  27903. protected _updateInternalTexture: () => void;
  27904. /**
  27905. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27906. * @param url New url.
  27907. */
  27908. updateURL(url: string): void;
  27909. /**
  27910. * Dispose the texture and release its associated resources.
  27911. */
  27912. dispose(): void;
  27913. /**
  27914. * Creates a video texture straight from a stream.
  27915. * @param scene Define the scene the texture should be created in
  27916. * @param stream Define the stream the texture should be created from
  27917. * @returns The created video texture as a promise
  27918. */
  27919. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27920. /**
  27921. * Creates a video texture straight from your WebCam video feed.
  27922. * @param scene Define the scene the texture should be created in
  27923. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27924. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27925. * @returns The created video texture as a promise
  27926. */
  27927. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27928. minWidth: number;
  27929. maxWidth: number;
  27930. minHeight: number;
  27931. maxHeight: number;
  27932. deviceId: string;
  27933. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27934. /**
  27935. * Creates a video texture straight from your WebCam video feed.
  27936. * @param scene Define the scene the texture should be created in
  27937. * @param onReady Define a callback to triggered once the texture will be ready
  27938. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27939. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27940. */
  27941. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27942. minWidth: number;
  27943. maxWidth: number;
  27944. minHeight: number;
  27945. maxHeight: number;
  27946. deviceId: string;
  27947. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27948. }
  27949. }
  27950. declare module "babylonjs/Engines/engine" {
  27951. import { Observable } from "babylonjs/Misc/observable";
  27952. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27953. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27954. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27955. import { Camera } from "babylonjs/Cameras/camera";
  27956. import { Scene } from "babylonjs/scene";
  27957. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27958. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27959. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27960. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27961. import { Material } from "babylonjs/Materials/material";
  27962. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27963. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27964. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27965. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27966. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27967. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27968. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27969. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27970. import { WebRequest } from "babylonjs/Misc/webRequest";
  27971. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  27972. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27973. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27974. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  27975. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27976. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27977. /**
  27978. * Interface for attribute information associated with buffer instanciation
  27979. */
  27980. export class InstancingAttributeInfo {
  27981. /**
  27982. * Index/offset of the attribute in the vertex shader
  27983. */
  27984. index: number;
  27985. /**
  27986. * size of the attribute, 1, 2, 3 or 4
  27987. */
  27988. attributeSize: number;
  27989. /**
  27990. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27991. * default is FLOAT
  27992. */
  27993. attribyteType: number;
  27994. /**
  27995. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27996. */
  27997. normalized: boolean;
  27998. /**
  27999. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  28000. */
  28001. offset: number;
  28002. /**
  28003. * Name of the GLSL attribute, for debugging purpose only
  28004. */
  28005. attributeName: string;
  28006. }
  28007. /**
  28008. * Define options used to create a depth texture
  28009. */
  28010. export class DepthTextureCreationOptions {
  28011. /** Specifies whether or not a stencil should be allocated in the texture */
  28012. generateStencil?: boolean;
  28013. /** Specifies whether or not bilinear filtering is enable on the texture */
  28014. bilinearFiltering?: boolean;
  28015. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  28016. comparisonFunction?: number;
  28017. /** Specifies if the created texture is a cube texture */
  28018. isCube?: boolean;
  28019. }
  28020. /**
  28021. * Class used to describe the capabilities of the engine relatively to the current browser
  28022. */
  28023. export class EngineCapabilities {
  28024. /** Maximum textures units per fragment shader */
  28025. maxTexturesImageUnits: number;
  28026. /** Maximum texture units per vertex shader */
  28027. maxVertexTextureImageUnits: number;
  28028. /** Maximum textures units in the entire pipeline */
  28029. maxCombinedTexturesImageUnits: number;
  28030. /** Maximum texture size */
  28031. maxTextureSize: number;
  28032. /** Maximum cube texture size */
  28033. maxCubemapTextureSize: number;
  28034. /** Maximum render texture size */
  28035. maxRenderTextureSize: number;
  28036. /** Maximum number of vertex attributes */
  28037. maxVertexAttribs: number;
  28038. /** Maximum number of varyings */
  28039. maxVaryingVectors: number;
  28040. /** Maximum number of uniforms per vertex shader */
  28041. maxVertexUniformVectors: number;
  28042. /** Maximum number of uniforms per fragment shader */
  28043. maxFragmentUniformVectors: number;
  28044. /** Defines if standard derivates (dx/dy) are supported */
  28045. standardDerivatives: boolean;
  28046. /** Defines if s3tc texture compression is supported */
  28047. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  28048. /** Defines if pvrtc texture compression is supported */
  28049. pvrtc: any;
  28050. /** Defines if etc1 texture compression is supported */
  28051. etc1: any;
  28052. /** Defines if etc2 texture compression is supported */
  28053. etc2: any;
  28054. /** Defines if astc texture compression is supported */
  28055. astc: any;
  28056. /** Defines if float textures are supported */
  28057. textureFloat: boolean;
  28058. /** Defines if vertex array objects are supported */
  28059. vertexArrayObject: boolean;
  28060. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28061. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  28062. /** Gets the maximum level of anisotropy supported */
  28063. maxAnisotropy: number;
  28064. /** Defines if instancing is supported */
  28065. instancedArrays: boolean;
  28066. /** Defines if 32 bits indices are supported */
  28067. uintIndices: boolean;
  28068. /** Defines if high precision shaders are supported */
  28069. highPrecisionShaderSupported: boolean;
  28070. /** Defines if depth reading in the fragment shader is supported */
  28071. fragmentDepthSupported: boolean;
  28072. /** Defines if float texture linear filtering is supported*/
  28073. textureFloatLinearFiltering: boolean;
  28074. /** Defines if rendering to float textures is supported */
  28075. textureFloatRender: boolean;
  28076. /** Defines if half float textures are supported*/
  28077. textureHalfFloat: boolean;
  28078. /** Defines if half float texture linear filtering is supported*/
  28079. textureHalfFloatLinearFiltering: boolean;
  28080. /** Defines if rendering to half float textures is supported */
  28081. textureHalfFloatRender: boolean;
  28082. /** Defines if textureLOD shader command is supported */
  28083. textureLOD: boolean;
  28084. /** Defines if draw buffers extension is supported */
  28085. drawBuffersExtension: boolean;
  28086. /** Defines if depth textures are supported */
  28087. depthTextureExtension: boolean;
  28088. /** Defines if float color buffer are supported */
  28089. colorBufferFloat: boolean;
  28090. /** Gets disjoint timer query extension (null if not supported) */
  28091. timerQuery: EXT_disjoint_timer_query;
  28092. /** Defines if timestamp can be used with timer query */
  28093. canUseTimestampForTimerQuery: boolean;
  28094. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  28095. multiview: any;
  28096. /** Function used to let the system compiles shaders in background */
  28097. parallelShaderCompile: {
  28098. COMPLETION_STATUS_KHR: number;
  28099. };
  28100. }
  28101. /** Interface defining initialization parameters for Engine class */
  28102. export interface EngineOptions extends WebGLContextAttributes {
  28103. /**
  28104. * Defines if the engine should no exceed a specified device ratio
  28105. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  28106. */
  28107. limitDeviceRatio?: number;
  28108. /**
  28109. * Defines if webvr should be enabled automatically
  28110. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28111. */
  28112. autoEnableWebVR?: boolean;
  28113. /**
  28114. * Defines if webgl2 should be turned off even if supported
  28115. * @see http://doc.babylonjs.com/features/webgl2
  28116. */
  28117. disableWebGL2Support?: boolean;
  28118. /**
  28119. * Defines if webaudio should be initialized as well
  28120. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28121. */
  28122. audioEngine?: boolean;
  28123. /**
  28124. * Defines if animations should run using a deterministic lock step
  28125. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28126. */
  28127. deterministicLockstep?: boolean;
  28128. /** Defines the maximum steps to use with deterministic lock step mode */
  28129. lockstepMaxSteps?: number;
  28130. /**
  28131. * Defines that engine should ignore context lost events
  28132. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  28133. */
  28134. doNotHandleContextLost?: boolean;
  28135. /**
  28136. * Defines that engine should ignore modifying touch action attribute and style
  28137. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  28138. */
  28139. doNotHandleTouchAction?: boolean;
  28140. /**
  28141. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  28142. */
  28143. useHighPrecisionFloats?: boolean;
  28144. }
  28145. /**
  28146. * Defines the interface used by display changed events
  28147. */
  28148. export interface IDisplayChangedEventArgs {
  28149. /** Gets the vrDisplay object (if any) */
  28150. vrDisplay: Nullable<any>;
  28151. /** Gets a boolean indicating if webVR is supported */
  28152. vrSupported: boolean;
  28153. }
  28154. /**
  28155. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  28156. */
  28157. export class Engine {
  28158. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  28159. static ExceptionList: ({
  28160. key: string;
  28161. capture: string;
  28162. captureConstraint: number;
  28163. targets: string[];
  28164. } | {
  28165. key: string;
  28166. capture: null;
  28167. captureConstraint: null;
  28168. targets: string[];
  28169. })[];
  28170. /** Gets the list of created engines */
  28171. static readonly Instances: Engine[];
  28172. /**
  28173. * Gets the latest created engine
  28174. */
  28175. static readonly LastCreatedEngine: Nullable<Engine>;
  28176. /**
  28177. * Gets the latest created scene
  28178. */
  28179. static readonly LastCreatedScene: Nullable<Scene>;
  28180. /**
  28181. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  28182. * @param flag defines which part of the materials must be marked as dirty
  28183. * @param predicate defines a predicate used to filter which materials should be affected
  28184. */
  28185. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  28186. /** @hidden */
  28187. static _TextureLoaders: IInternalTextureLoader[];
  28188. /** Defines that alpha blending is disabled */
  28189. static readonly ALPHA_DISABLE: number;
  28190. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  28191. static readonly ALPHA_ADD: number;
  28192. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  28193. static readonly ALPHA_COMBINE: number;
  28194. /** Defines that alpha blending to DEST - SRC * DEST */
  28195. static readonly ALPHA_SUBTRACT: number;
  28196. /** Defines that alpha blending to SRC * DEST */
  28197. static readonly ALPHA_MULTIPLY: number;
  28198. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  28199. static readonly ALPHA_MAXIMIZED: number;
  28200. /** Defines that alpha blending to SRC + DEST */
  28201. static readonly ALPHA_ONEONE: number;
  28202. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  28203. static readonly ALPHA_PREMULTIPLIED: number;
  28204. /**
  28205. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  28206. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  28207. */
  28208. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  28209. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  28210. static readonly ALPHA_INTERPOLATE: number;
  28211. /**
  28212. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  28213. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  28214. */
  28215. static readonly ALPHA_SCREENMODE: number;
  28216. /** Defines that the ressource is not delayed*/
  28217. static readonly DELAYLOADSTATE_NONE: number;
  28218. /** Defines that the ressource was successfully delay loaded */
  28219. static readonly DELAYLOADSTATE_LOADED: number;
  28220. /** Defines that the ressource is currently delay loading */
  28221. static readonly DELAYLOADSTATE_LOADING: number;
  28222. /** Defines that the ressource is delayed and has not started loading */
  28223. static readonly DELAYLOADSTATE_NOTLOADED: number;
  28224. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  28225. static readonly NEVER: number;
  28226. /** 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 */
  28227. static readonly ALWAYS: number;
  28228. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  28229. static readonly LESS: number;
  28230. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  28231. static readonly EQUAL: number;
  28232. /** 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 */
  28233. static readonly LEQUAL: number;
  28234. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  28235. static readonly GREATER: number;
  28236. /** 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 */
  28237. static readonly GEQUAL: number;
  28238. /** 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 */
  28239. static readonly NOTEQUAL: number;
  28240. /** Passed to stencilOperation to specify that stencil value must be kept */
  28241. static readonly KEEP: number;
  28242. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28243. static readonly REPLACE: number;
  28244. /** Passed to stencilOperation to specify that stencil value must be incremented */
  28245. static readonly INCR: number;
  28246. /** Passed to stencilOperation to specify that stencil value must be decremented */
  28247. static readonly DECR: number;
  28248. /** Passed to stencilOperation to specify that stencil value must be inverted */
  28249. static readonly INVERT: number;
  28250. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  28251. static readonly INCR_WRAP: number;
  28252. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  28253. static readonly DECR_WRAP: number;
  28254. /** Texture is not repeating outside of 0..1 UVs */
  28255. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  28256. /** Texture is repeating outside of 0..1 UVs */
  28257. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  28258. /** Texture is repeating and mirrored */
  28259. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  28260. /** ALPHA */
  28261. static readonly TEXTUREFORMAT_ALPHA: number;
  28262. /** LUMINANCE */
  28263. static readonly TEXTUREFORMAT_LUMINANCE: number;
  28264. /** LUMINANCE_ALPHA */
  28265. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  28266. /** RGB */
  28267. static readonly TEXTUREFORMAT_RGB: number;
  28268. /** RGBA */
  28269. static readonly TEXTUREFORMAT_RGBA: number;
  28270. /** RED */
  28271. static readonly TEXTUREFORMAT_RED: number;
  28272. /** RED (2nd reference) */
  28273. static readonly TEXTUREFORMAT_R: number;
  28274. /** RG */
  28275. static readonly TEXTUREFORMAT_RG: number;
  28276. /** RED_INTEGER */
  28277. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  28278. /** RED_INTEGER (2nd reference) */
  28279. static readonly TEXTUREFORMAT_R_INTEGER: number;
  28280. /** RG_INTEGER */
  28281. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  28282. /** RGB_INTEGER */
  28283. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  28284. /** RGBA_INTEGER */
  28285. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  28286. /** UNSIGNED_BYTE */
  28287. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  28288. /** UNSIGNED_BYTE (2nd reference) */
  28289. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  28290. /** FLOAT */
  28291. static readonly TEXTURETYPE_FLOAT: number;
  28292. /** HALF_FLOAT */
  28293. static readonly TEXTURETYPE_HALF_FLOAT: number;
  28294. /** BYTE */
  28295. static readonly TEXTURETYPE_BYTE: number;
  28296. /** SHORT */
  28297. static readonly TEXTURETYPE_SHORT: number;
  28298. /** UNSIGNED_SHORT */
  28299. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  28300. /** INT */
  28301. static readonly TEXTURETYPE_INT: number;
  28302. /** UNSIGNED_INT */
  28303. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  28304. /** UNSIGNED_SHORT_4_4_4_4 */
  28305. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  28306. /** UNSIGNED_SHORT_5_5_5_1 */
  28307. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  28308. /** UNSIGNED_SHORT_5_6_5 */
  28309. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  28310. /** UNSIGNED_INT_2_10_10_10_REV */
  28311. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  28312. /** UNSIGNED_INT_24_8 */
  28313. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  28314. /** UNSIGNED_INT_10F_11F_11F_REV */
  28315. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  28316. /** UNSIGNED_INT_5_9_9_9_REV */
  28317. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  28318. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  28319. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  28320. /** nearest is mag = nearest and min = nearest and mip = linear */
  28321. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  28322. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28323. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  28324. /** Trilinear is mag = linear and min = linear and mip = linear */
  28325. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  28326. /** nearest is mag = nearest and min = nearest and mip = linear */
  28327. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  28328. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28329. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  28330. /** Trilinear is mag = linear and min = linear and mip = linear */
  28331. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  28332. /** mag = nearest and min = nearest and mip = nearest */
  28333. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  28334. /** mag = nearest and min = linear and mip = nearest */
  28335. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  28336. /** mag = nearest and min = linear and mip = linear */
  28337. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  28338. /** mag = nearest and min = linear and mip = none */
  28339. static readonly TEXTURE_NEAREST_LINEAR: number;
  28340. /** mag = nearest and min = nearest and mip = none */
  28341. static readonly TEXTURE_NEAREST_NEAREST: number;
  28342. /** mag = linear and min = nearest and mip = nearest */
  28343. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  28344. /** mag = linear and min = nearest and mip = linear */
  28345. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  28346. /** mag = linear and min = linear and mip = none */
  28347. static readonly TEXTURE_LINEAR_LINEAR: number;
  28348. /** mag = linear and min = nearest and mip = none */
  28349. static readonly TEXTURE_LINEAR_NEAREST: number;
  28350. /** Explicit coordinates mode */
  28351. static readonly TEXTURE_EXPLICIT_MODE: number;
  28352. /** Spherical coordinates mode */
  28353. static readonly TEXTURE_SPHERICAL_MODE: number;
  28354. /** Planar coordinates mode */
  28355. static readonly TEXTURE_PLANAR_MODE: number;
  28356. /** Cubic coordinates mode */
  28357. static readonly TEXTURE_CUBIC_MODE: number;
  28358. /** Projection coordinates mode */
  28359. static readonly TEXTURE_PROJECTION_MODE: number;
  28360. /** Skybox coordinates mode */
  28361. static readonly TEXTURE_SKYBOX_MODE: number;
  28362. /** Inverse Cubic coordinates mode */
  28363. static readonly TEXTURE_INVCUBIC_MODE: number;
  28364. /** Equirectangular coordinates mode */
  28365. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  28366. /** Equirectangular Fixed coordinates mode */
  28367. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  28368. /** Equirectangular Fixed Mirrored coordinates mode */
  28369. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28370. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  28371. static readonly SCALEMODE_FLOOR: number;
  28372. /** Defines that texture rescaling will look for the nearest power of 2 size */
  28373. static readonly SCALEMODE_NEAREST: number;
  28374. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  28375. static readonly SCALEMODE_CEILING: number;
  28376. /**
  28377. * Returns the current npm package of the sdk
  28378. */
  28379. static readonly NpmPackage: string;
  28380. /**
  28381. * Returns the current version of the framework
  28382. */
  28383. static readonly Version: string;
  28384. /**
  28385. * Returns a string describing the current engine
  28386. */
  28387. readonly description: string;
  28388. /**
  28389. * Gets or sets the epsilon value used by collision engine
  28390. */
  28391. static CollisionsEpsilon: number;
  28392. /**
  28393. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28394. */
  28395. static ShadersRepository: string;
  28396. /**
  28397. * Method called to create the default loading screen.
  28398. * This can be overriden in your own app.
  28399. * @param canvas The rendering canvas element
  28400. * @returns The loading screen
  28401. */
  28402. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  28403. /**
  28404. * Method called to create the default rescale post process on each engine.
  28405. */
  28406. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  28407. /** @hidden */
  28408. _shaderProcessor: IShaderProcessor;
  28409. /**
  28410. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28411. */
  28412. forcePOTTextures: boolean;
  28413. /**
  28414. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28415. */
  28416. isFullscreen: boolean;
  28417. /**
  28418. * Gets a boolean indicating if the pointer is currently locked
  28419. */
  28420. isPointerLock: boolean;
  28421. /**
  28422. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28423. */
  28424. cullBackFaces: boolean;
  28425. /**
  28426. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28427. */
  28428. renderEvenInBackground: boolean;
  28429. /**
  28430. * Gets or sets a boolean indicating that cache can be kept between frames
  28431. */
  28432. preventCacheWipeBetweenFrames: boolean;
  28433. /**
  28434. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28435. **/
  28436. enableOfflineSupport: boolean;
  28437. /**
  28438. * 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)
  28439. **/
  28440. disableManifestCheck: boolean;
  28441. /**
  28442. * Gets the list of created scenes
  28443. */
  28444. scenes: Scene[];
  28445. /**
  28446. * Event raised when a new scene is created
  28447. */
  28448. onNewSceneAddedObservable: Observable<Scene>;
  28449. /**
  28450. * Gets the list of created postprocesses
  28451. */
  28452. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  28453. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28454. validateShaderPrograms: boolean;
  28455. /**
  28456. * Observable event triggered each time the rendering canvas is resized
  28457. */
  28458. onResizeObservable: Observable<Engine>;
  28459. /**
  28460. * Observable event triggered each time the canvas loses focus
  28461. */
  28462. onCanvasBlurObservable: Observable<Engine>;
  28463. /**
  28464. * Observable event triggered each time the canvas gains focus
  28465. */
  28466. onCanvasFocusObservable: Observable<Engine>;
  28467. /**
  28468. * Observable event triggered each time the canvas receives pointerout event
  28469. */
  28470. onCanvasPointerOutObservable: Observable<PointerEvent>;
  28471. /**
  28472. * Observable event triggered before each texture is initialized
  28473. */
  28474. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  28475. /**
  28476. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28477. */
  28478. disableUniformBuffers: boolean;
  28479. /** @hidden */
  28480. _uniformBuffers: UniformBuffer[];
  28481. /**
  28482. * Gets a boolean indicating that the engine supports uniform buffers
  28483. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28484. */
  28485. readonly supportsUniformBuffers: boolean;
  28486. /**
  28487. * Observable raised when the engine begins a new frame
  28488. */
  28489. onBeginFrameObservable: Observable<Engine>;
  28490. /**
  28491. * If set, will be used to request the next animation frame for the render loop
  28492. */
  28493. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  28494. /**
  28495. * Observable raised when the engine ends the current frame
  28496. */
  28497. onEndFrameObservable: Observable<Engine>;
  28498. /**
  28499. * Observable raised when the engine is about to compile a shader
  28500. */
  28501. onBeforeShaderCompilationObservable: Observable<Engine>;
  28502. /**
  28503. * Observable raised when the engine has jsut compiled a shader
  28504. */
  28505. onAfterShaderCompilationObservable: Observable<Engine>;
  28506. /** @hidden */
  28507. _gl: WebGLRenderingContext;
  28508. private _renderingCanvas;
  28509. private _windowIsBackground;
  28510. private _webGLVersion;
  28511. protected _highPrecisionShadersAllowed: boolean;
  28512. /** @hidden */
  28513. readonly _shouldUseHighPrecisionShader: boolean;
  28514. /**
  28515. * Gets a boolean indicating that only power of 2 textures are supported
  28516. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28517. */
  28518. readonly needPOTTextures: boolean;
  28519. /** @hidden */
  28520. _badOS: boolean;
  28521. /** @hidden */
  28522. _badDesktopOS: boolean;
  28523. /**
  28524. * Gets the audio engine
  28525. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28526. * @ignorenaming
  28527. */
  28528. static audioEngine: IAudioEngine;
  28529. /**
  28530. * Default AudioEngine factory responsible of creating the Audio Engine.
  28531. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  28532. */
  28533. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  28534. /**
  28535. * Default offline support factory responsible of creating a tool used to store data locally.
  28536. * By default, this will create a Database object if the workload has been embedded.
  28537. */
  28538. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  28539. private _onFocus;
  28540. private _onBlur;
  28541. private _onCanvasPointerOut;
  28542. private _onCanvasBlur;
  28543. private _onCanvasFocus;
  28544. private _onFullscreenChange;
  28545. private _onPointerLockChange;
  28546. private _hardwareScalingLevel;
  28547. /** @hidden */
  28548. _caps: EngineCapabilities;
  28549. private _pointerLockRequested;
  28550. private _isStencilEnable;
  28551. private _colorWrite;
  28552. private _loadingScreen;
  28553. /** @hidden */
  28554. _drawCalls: PerfCounter;
  28555. private _glVersion;
  28556. private _glRenderer;
  28557. private _glVendor;
  28558. private _videoTextureSupported;
  28559. private _renderingQueueLaunched;
  28560. private _activeRenderLoops;
  28561. private _deterministicLockstep;
  28562. private _lockstepMaxSteps;
  28563. /**
  28564. * Observable signaled when a context lost event is raised
  28565. */
  28566. onContextLostObservable: Observable<Engine>;
  28567. /**
  28568. * Observable signaled when a context restored event is raised
  28569. */
  28570. onContextRestoredObservable: Observable<Engine>;
  28571. private _onContextLost;
  28572. private _onContextRestored;
  28573. private _contextWasLost;
  28574. /** @hidden */
  28575. _doNotHandleContextLost: boolean;
  28576. /**
  28577. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28578. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28579. */
  28580. doNotHandleContextLost: boolean;
  28581. private _performanceMonitor;
  28582. private _fps;
  28583. private _deltaTime;
  28584. /**
  28585. * Turn this value on if you want to pause FPS computation when in background
  28586. */
  28587. disablePerformanceMonitorInBackground: boolean;
  28588. /**
  28589. * Gets the performance monitor attached to this engine
  28590. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28591. */
  28592. readonly performanceMonitor: PerformanceMonitor;
  28593. /**
  28594. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28595. */
  28596. disableVertexArrayObjects: boolean;
  28597. /** @hidden */
  28598. protected _depthCullingState: _DepthCullingState;
  28599. /** @hidden */
  28600. protected _stencilState: _StencilState;
  28601. /** @hidden */
  28602. protected _alphaState: _AlphaState;
  28603. /** @hidden */
  28604. protected _alphaMode: number;
  28605. /** @hidden */
  28606. _internalTexturesCache: InternalTexture[];
  28607. /** @hidden */
  28608. protected _activeChannel: number;
  28609. private _currentTextureChannel;
  28610. /** @hidden */
  28611. protected _boundTexturesCache: {
  28612. [key: string]: Nullable<InternalTexture>;
  28613. };
  28614. /** @hidden */
  28615. protected _currentEffect: Nullable<Effect>;
  28616. /** @hidden */
  28617. protected _currentProgram: Nullable<WebGLProgram>;
  28618. private _compiledEffects;
  28619. private _vertexAttribArraysEnabled;
  28620. /** @hidden */
  28621. protected _cachedViewport: Nullable<Viewport>;
  28622. private _cachedVertexArrayObject;
  28623. /** @hidden */
  28624. protected _cachedVertexBuffers: any;
  28625. /** @hidden */
  28626. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  28627. /** @hidden */
  28628. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28629. /** @hidden */
  28630. _currentRenderTarget: Nullable<InternalTexture>;
  28631. private _uintIndicesCurrentlySet;
  28632. private _currentBoundBuffer;
  28633. /** @hidden */
  28634. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28635. private _currentBufferPointers;
  28636. private _currentInstanceLocations;
  28637. private _currentInstanceBuffers;
  28638. private _textureUnits;
  28639. /** @hidden */
  28640. _workingCanvas: Nullable<HTMLCanvasElement>;
  28641. /** @hidden */
  28642. _workingContext: Nullable<CanvasRenderingContext2D>;
  28643. private _rescalePostProcess;
  28644. private _dummyFramebuffer;
  28645. private _externalData;
  28646. /** @hidden */
  28647. _bindedRenderFunction: any;
  28648. private _vaoRecordInProgress;
  28649. private _mustWipeVertexAttributes;
  28650. private _emptyTexture;
  28651. private _emptyCubeTexture;
  28652. private _emptyTexture3D;
  28653. /** @hidden */
  28654. _frameHandler: number;
  28655. private _nextFreeTextureSlots;
  28656. private _maxSimultaneousTextures;
  28657. private _activeRequests;
  28658. private _texturesSupported;
  28659. /** @hidden */
  28660. _textureFormatInUse: Nullable<string>;
  28661. /**
  28662. * Gets the list of texture formats supported
  28663. */
  28664. readonly texturesSupported: Array<string>;
  28665. /**
  28666. * Gets the list of texture formats in use
  28667. */
  28668. readonly textureFormatInUse: Nullable<string>;
  28669. /**
  28670. * Gets the current viewport
  28671. */
  28672. readonly currentViewport: Nullable<Viewport>;
  28673. /**
  28674. * Gets the default empty texture
  28675. */
  28676. readonly emptyTexture: InternalTexture;
  28677. /**
  28678. * Gets the default empty 3D texture
  28679. */
  28680. readonly emptyTexture3D: InternalTexture;
  28681. /**
  28682. * Gets the default empty cube texture
  28683. */
  28684. readonly emptyCubeTexture: InternalTexture;
  28685. /**
  28686. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28687. */
  28688. readonly premultipliedAlpha: boolean;
  28689. /**
  28690. * Creates a new engine
  28691. * @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
  28692. * @param antialias defines enable antialiasing (default: false)
  28693. * @param options defines further options to be sent to the getContext() function
  28694. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28695. */
  28696. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28697. /**
  28698. * Initializes a webVR display and starts listening to display change events
  28699. * The onVRDisplayChangedObservable will be notified upon these changes
  28700. * @returns The onVRDisplayChangedObservable
  28701. */
  28702. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28703. /** @hidden */
  28704. _prepareVRComponent(): void;
  28705. /** @hidden */
  28706. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  28707. /** @hidden */
  28708. _submitVRFrame(): void;
  28709. /**
  28710. * Call this function to leave webVR mode
  28711. * Will do nothing if webVR is not supported or if there is no webVR device
  28712. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28713. */
  28714. disableVR(): void;
  28715. /**
  28716. * Gets a boolean indicating that the system is in VR mode and is presenting
  28717. * @returns true if VR mode is engaged
  28718. */
  28719. isVRPresenting(): boolean;
  28720. /** @hidden */
  28721. _requestVRFrame(): void;
  28722. private _disableTouchAction;
  28723. private _rebuildInternalTextures;
  28724. private _rebuildEffects;
  28725. /**
  28726. * Gets a boolean indicating if all created effects are ready
  28727. * @returns true if all effects are ready
  28728. */
  28729. areAllEffectsReady(): boolean;
  28730. private _rebuildBuffers;
  28731. private _initGLContext;
  28732. /**
  28733. * Gets version of the current webGL context
  28734. */
  28735. readonly webGLVersion: number;
  28736. /**
  28737. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28738. */
  28739. readonly isStencilEnable: boolean;
  28740. /** @hidden */
  28741. _prepareWorkingCanvas(): void;
  28742. /**
  28743. * Reset the texture cache to empty state
  28744. */
  28745. resetTextureCache(): void;
  28746. /**
  28747. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28748. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28749. * @returns true if engine is in deterministic lock step mode
  28750. */
  28751. isDeterministicLockStep(): boolean;
  28752. /**
  28753. * Gets the max steps when engine is running in deterministic lock step
  28754. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28755. * @returns the max steps
  28756. */
  28757. getLockstepMaxSteps(): number;
  28758. /**
  28759. * Gets an object containing information about the current webGL context
  28760. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28761. */
  28762. getGlInfo(): {
  28763. vendor: string;
  28764. renderer: string;
  28765. version: string;
  28766. };
  28767. /**
  28768. * Gets current aspect ratio
  28769. * @param camera defines the camera to use to get the aspect ratio
  28770. * @param useScreen defines if screen size must be used (or the current render target if any)
  28771. * @returns a number defining the aspect ratio
  28772. */
  28773. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28774. /**
  28775. * Gets current screen aspect ratio
  28776. * @returns a number defining the aspect ratio
  28777. */
  28778. getScreenAspectRatio(): number;
  28779. /**
  28780. * Gets the current render width
  28781. * @param useScreen defines if screen size must be used (or the current render target if any)
  28782. * @returns a number defining the current render width
  28783. */
  28784. getRenderWidth(useScreen?: boolean): number;
  28785. /**
  28786. * Gets the current render height
  28787. * @param useScreen defines if screen size must be used (or the current render target if any)
  28788. * @returns a number defining the current render height
  28789. */
  28790. getRenderHeight(useScreen?: boolean): number;
  28791. /**
  28792. * Gets the HTML canvas attached with the current webGL context
  28793. * @returns a HTML canvas
  28794. */
  28795. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28796. /**
  28797. * Gets the client rect of the HTML canvas attached with the current webGL context
  28798. * @returns a client rectanglee
  28799. */
  28800. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28801. /**
  28802. * Defines the hardware scaling level.
  28803. * By default the hardware scaling level is computed from the window device ratio.
  28804. * 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.
  28805. * @param level defines the level to use
  28806. */
  28807. setHardwareScalingLevel(level: number): void;
  28808. /**
  28809. * Gets the current hardware scaling level.
  28810. * By default the hardware scaling level is computed from the window device ratio.
  28811. * 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.
  28812. * @returns a number indicating the current hardware scaling level
  28813. */
  28814. getHardwareScalingLevel(): number;
  28815. /**
  28816. * Gets the list of loaded textures
  28817. * @returns an array containing all loaded textures
  28818. */
  28819. getLoadedTexturesCache(): InternalTexture[];
  28820. /**
  28821. * Gets the object containing all engine capabilities
  28822. * @returns the EngineCapabilities object
  28823. */
  28824. getCaps(): EngineCapabilities;
  28825. /**
  28826. * Gets the current depth function
  28827. * @returns a number defining the depth function
  28828. */
  28829. getDepthFunction(): Nullable<number>;
  28830. /**
  28831. * Sets the current depth function
  28832. * @param depthFunc defines the function to use
  28833. */
  28834. setDepthFunction(depthFunc: number): void;
  28835. /**
  28836. * Sets the current depth function to GREATER
  28837. */
  28838. setDepthFunctionToGreater(): void;
  28839. /**
  28840. * Sets the current depth function to GEQUAL
  28841. */
  28842. setDepthFunctionToGreaterOrEqual(): void;
  28843. /**
  28844. * Sets the current depth function to LESS
  28845. */
  28846. setDepthFunctionToLess(): void;
  28847. private _cachedStencilBuffer;
  28848. private _cachedStencilFunction;
  28849. private _cachedStencilMask;
  28850. private _cachedStencilOperationPass;
  28851. private _cachedStencilOperationFail;
  28852. private _cachedStencilOperationDepthFail;
  28853. private _cachedStencilReference;
  28854. /**
  28855. * Caches the the state of the stencil buffer
  28856. */
  28857. cacheStencilState(): void;
  28858. /**
  28859. * Restores the state of the stencil buffer
  28860. */
  28861. restoreStencilState(): void;
  28862. /**
  28863. * Sets the current depth function to LEQUAL
  28864. */
  28865. setDepthFunctionToLessOrEqual(): void;
  28866. /**
  28867. * Gets a boolean indicating if stencil buffer is enabled
  28868. * @returns the current stencil buffer state
  28869. */
  28870. getStencilBuffer(): boolean;
  28871. /**
  28872. * Enable or disable the stencil buffer
  28873. * @param enable defines if the stencil buffer must be enabled or disabled
  28874. */
  28875. setStencilBuffer(enable: boolean): void;
  28876. /**
  28877. * Gets the current stencil mask
  28878. * @returns a number defining the new stencil mask to use
  28879. */
  28880. getStencilMask(): number;
  28881. /**
  28882. * Sets the current stencil mask
  28883. * @param mask defines the new stencil mask to use
  28884. */
  28885. setStencilMask(mask: number): void;
  28886. /**
  28887. * Gets the current stencil function
  28888. * @returns a number defining the stencil function to use
  28889. */
  28890. getStencilFunction(): number;
  28891. /**
  28892. * Gets the current stencil reference value
  28893. * @returns a number defining the stencil reference value to use
  28894. */
  28895. getStencilFunctionReference(): number;
  28896. /**
  28897. * Gets the current stencil mask
  28898. * @returns a number defining the stencil mask to use
  28899. */
  28900. getStencilFunctionMask(): number;
  28901. /**
  28902. * Sets the current stencil function
  28903. * @param stencilFunc defines the new stencil function to use
  28904. */
  28905. setStencilFunction(stencilFunc: number): void;
  28906. /**
  28907. * Sets the current stencil reference
  28908. * @param reference defines the new stencil reference to use
  28909. */
  28910. setStencilFunctionReference(reference: number): void;
  28911. /**
  28912. * Sets the current stencil mask
  28913. * @param mask defines the new stencil mask to use
  28914. */
  28915. setStencilFunctionMask(mask: number): void;
  28916. /**
  28917. * Gets the current stencil operation when stencil fails
  28918. * @returns a number defining stencil operation to use when stencil fails
  28919. */
  28920. getStencilOperationFail(): number;
  28921. /**
  28922. * Gets the current stencil operation when depth fails
  28923. * @returns a number defining stencil operation to use when depth fails
  28924. */
  28925. getStencilOperationDepthFail(): number;
  28926. /**
  28927. * Gets the current stencil operation when stencil passes
  28928. * @returns a number defining stencil operation to use when stencil passes
  28929. */
  28930. getStencilOperationPass(): number;
  28931. /**
  28932. * Sets the stencil operation to use when stencil fails
  28933. * @param operation defines the stencil operation to use when stencil fails
  28934. */
  28935. setStencilOperationFail(operation: number): void;
  28936. /**
  28937. * Sets the stencil operation to use when depth fails
  28938. * @param operation defines the stencil operation to use when depth fails
  28939. */
  28940. setStencilOperationDepthFail(operation: number): void;
  28941. /**
  28942. * Sets the stencil operation to use when stencil passes
  28943. * @param operation defines the stencil operation to use when stencil passes
  28944. */
  28945. setStencilOperationPass(operation: number): void;
  28946. /**
  28947. * Sets a boolean indicating if the dithering state is enabled or disabled
  28948. * @param value defines the dithering state
  28949. */
  28950. setDitheringState(value: boolean): void;
  28951. /**
  28952. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28953. * @param value defines the rasterizer state
  28954. */
  28955. setRasterizerState(value: boolean): void;
  28956. /**
  28957. * stop executing a render loop function and remove it from the execution array
  28958. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28959. */
  28960. stopRenderLoop(renderFunction?: () => void): void;
  28961. /** @hidden */
  28962. _renderLoop(): void;
  28963. /**
  28964. * Register and execute a render loop. The engine can have more than one render function
  28965. * @param renderFunction defines the function to continuously execute
  28966. */
  28967. runRenderLoop(renderFunction: () => void): void;
  28968. /**
  28969. * Toggle full screen mode
  28970. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28971. */
  28972. switchFullscreen(requestPointerLock: boolean): void;
  28973. /**
  28974. * Enters full screen mode
  28975. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28976. */
  28977. enterFullscreen(requestPointerLock: boolean): void;
  28978. /**
  28979. * Exits full screen mode
  28980. */
  28981. exitFullscreen(): void;
  28982. /**
  28983. * Clear the current render buffer or the current render target (if any is set up)
  28984. * @param color defines the color to use
  28985. * @param backBuffer defines if the back buffer must be cleared
  28986. * @param depth defines if the depth buffer must be cleared
  28987. * @param stencil defines if the stencil buffer must be cleared
  28988. */
  28989. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28990. /**
  28991. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28992. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28993. * @param y defines the y-coordinate of the corner of the clear rectangle
  28994. * @param width defines the width of the clear rectangle
  28995. * @param height defines the height of the clear rectangle
  28996. * @param clearColor defines the clear color
  28997. */
  28998. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28999. /**
  29000. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  29001. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29002. * @param y defines the y-coordinate of the corner of the clear rectangle
  29003. * @param width defines the width of the clear rectangle
  29004. * @param height defines the height of the clear rectangle
  29005. */
  29006. enableScissor(x: number, y: number, width: number, height: number): void;
  29007. /**
  29008. * Disable previously set scissor test rectangle
  29009. */
  29010. disableScissor(): void;
  29011. private _viewportCached;
  29012. /** @hidden */
  29013. _viewport(x: number, y: number, width: number, height: number): void;
  29014. /**
  29015. * Set the WebGL's viewport
  29016. * @param viewport defines the viewport element to be used
  29017. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29018. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29019. */
  29020. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  29021. /**
  29022. * Directly set the WebGL Viewport
  29023. * @param x defines the x coordinate of the viewport (in screen space)
  29024. * @param y defines the y coordinate of the viewport (in screen space)
  29025. * @param width defines the width of the viewport (in screen space)
  29026. * @param height defines the height of the viewport (in screen space)
  29027. * @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
  29028. */
  29029. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  29030. /**
  29031. * Begin a new frame
  29032. */
  29033. beginFrame(): void;
  29034. /**
  29035. * Enf the current frame
  29036. */
  29037. endFrame(): void;
  29038. /**
  29039. * Resize the view according to the canvas' size
  29040. */
  29041. resize(): void;
  29042. /**
  29043. * Force a specific size of the canvas
  29044. * @param width defines the new canvas' width
  29045. * @param height defines the new canvas' height
  29046. */
  29047. setSize(width: number, height: number): void;
  29048. /**
  29049. * Binds the frame buffer to the specified texture.
  29050. * @param texture The texture to render to or null for the default canvas
  29051. * @param faceIndex The face of the texture to render to in case of cube texture
  29052. * @param requiredWidth The width of the target to render to
  29053. * @param requiredHeight The height of the target to render to
  29054. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29055. * @param depthStencilTexture The depth stencil texture to use to render
  29056. * @param lodLevel defines le lod level to bind to the frame buffer
  29057. */
  29058. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29059. /** @hidden */
  29060. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  29061. /**
  29062. * Unbind the current render target texture from the webGL context
  29063. * @param texture defines the render target texture to unbind
  29064. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29065. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29066. */
  29067. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29068. /**
  29069. * Force the mipmap generation for the given render target texture
  29070. * @param texture defines the render target texture to use
  29071. */
  29072. generateMipMapsForCubemap(texture: InternalTexture): void;
  29073. /**
  29074. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29075. */
  29076. flushFramebuffer(): void;
  29077. /**
  29078. * Unbind the current render target and bind the default framebuffer
  29079. */
  29080. restoreDefaultFramebuffer(): void;
  29081. /**
  29082. * Create an uniform buffer
  29083. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29084. * @param elements defines the content of the uniform buffer
  29085. * @returns the webGL uniform buffer
  29086. */
  29087. createUniformBuffer(elements: FloatArray): DataBuffer;
  29088. /**
  29089. * Create a dynamic uniform buffer
  29090. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29091. * @param elements defines the content of the uniform buffer
  29092. * @returns the webGL uniform buffer
  29093. */
  29094. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  29095. /**
  29096. * Update an existing uniform buffer
  29097. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29098. * @param uniformBuffer defines the target uniform buffer
  29099. * @param elements defines the content to update
  29100. * @param offset defines the offset in the uniform buffer where update should start
  29101. * @param count defines the size of the data to update
  29102. */
  29103. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  29104. private _resetVertexBufferBinding;
  29105. /**
  29106. * Creates a vertex buffer
  29107. * @param data the data for the vertex buffer
  29108. * @returns the new WebGL static buffer
  29109. */
  29110. createVertexBuffer(data: DataArray): DataBuffer;
  29111. /**
  29112. * Creates a dynamic vertex buffer
  29113. * @param data the data for the dynamic vertex buffer
  29114. * @returns the new WebGL dynamic buffer
  29115. */
  29116. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  29117. /**
  29118. * Update a dynamic index buffer
  29119. * @param indexBuffer defines the target index buffer
  29120. * @param indices defines the data to update
  29121. * @param offset defines the offset in the target index buffer where update should start
  29122. */
  29123. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  29124. /**
  29125. * Updates a dynamic vertex buffer.
  29126. * @param vertexBuffer the vertex buffer to update
  29127. * @param data the data used to update the vertex buffer
  29128. * @param byteOffset the byte offset of the data
  29129. * @param byteLength the byte length of the data
  29130. */
  29131. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  29132. private _resetIndexBufferBinding;
  29133. /**
  29134. * Creates a new index buffer
  29135. * @param indices defines the content of the index buffer
  29136. * @param updatable defines if the index buffer must be updatable
  29137. * @returns a new webGL buffer
  29138. */
  29139. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  29140. /**
  29141. * Bind a webGL buffer to the webGL context
  29142. * @param buffer defines the buffer to bind
  29143. */
  29144. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  29145. /**
  29146. * Bind an uniform buffer to the current webGL context
  29147. * @param buffer defines the buffer to bind
  29148. */
  29149. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  29150. /**
  29151. * Bind a buffer to the current webGL context at a given location
  29152. * @param buffer defines the buffer to bind
  29153. * @param location defines the index where to bind the buffer
  29154. */
  29155. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  29156. /**
  29157. * Bind a specific block at a given index in a specific shader program
  29158. * @param pipelineContext defines the pipeline context to use
  29159. * @param blockName defines the block name
  29160. * @param index defines the index where to bind the block
  29161. */
  29162. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  29163. private bindIndexBuffer;
  29164. private bindBuffer;
  29165. /**
  29166. * update the bound buffer with the given data
  29167. * @param data defines the data to update
  29168. */
  29169. updateArrayBuffer(data: Float32Array): void;
  29170. private _vertexAttribPointer;
  29171. private _bindIndexBufferWithCache;
  29172. private _bindVertexBuffersAttributes;
  29173. /**
  29174. * Records a vertex array object
  29175. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29176. * @param vertexBuffers defines the list of vertex buffers to store
  29177. * @param indexBuffer defines the index buffer to store
  29178. * @param effect defines the effect to store
  29179. * @returns the new vertex array object
  29180. */
  29181. recordVertexArrayObject(vertexBuffers: {
  29182. [key: string]: VertexBuffer;
  29183. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29184. /**
  29185. * Bind a specific vertex array object
  29186. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29187. * @param vertexArrayObject defines the vertex array object to bind
  29188. * @param indexBuffer defines the index buffer to bind
  29189. */
  29190. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29191. /**
  29192. * Bind webGl buffers directly to the webGL context
  29193. * @param vertexBuffer defines the vertex buffer to bind
  29194. * @param indexBuffer defines the index buffer to bind
  29195. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29196. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29197. * @param effect defines the effect associated with the vertex buffer
  29198. */
  29199. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29200. private _unbindVertexArrayObject;
  29201. /**
  29202. * Bind a list of vertex buffers to the webGL context
  29203. * @param vertexBuffers defines the list of vertex buffers to bind
  29204. * @param indexBuffer defines the index buffer to bind
  29205. * @param effect defines the effect associated with the vertex buffers
  29206. */
  29207. bindBuffers(vertexBuffers: {
  29208. [key: string]: Nullable<VertexBuffer>;
  29209. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29210. /**
  29211. * Unbind all instance attributes
  29212. */
  29213. unbindInstanceAttributes(): void;
  29214. /**
  29215. * Release and free the memory of a vertex array object
  29216. * @param vao defines the vertex array object to delete
  29217. */
  29218. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29219. /** @hidden */
  29220. _releaseBuffer(buffer: DataBuffer): boolean;
  29221. /**
  29222. * Creates a webGL buffer to use with instanciation
  29223. * @param capacity defines the size of the buffer
  29224. * @returns the webGL buffer
  29225. */
  29226. createInstancesBuffer(capacity: number): DataBuffer;
  29227. /**
  29228. * Delete a webGL buffer used with instanciation
  29229. * @param buffer defines the webGL buffer to delete
  29230. */
  29231. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29232. /**
  29233. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29234. * @param instancesBuffer defines the webGL buffer to update and bind
  29235. * @param data defines the data to store in the buffer
  29236. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29237. */
  29238. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29239. /**
  29240. * Apply all cached states (depth, culling, stencil and alpha)
  29241. */
  29242. applyStates(): void;
  29243. /**
  29244. * Send a draw order
  29245. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29246. * @param indexStart defines the starting index
  29247. * @param indexCount defines the number of index to draw
  29248. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29249. */
  29250. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29251. /**
  29252. * Draw a list of points
  29253. * @param verticesStart defines the index of first vertex to draw
  29254. * @param verticesCount defines the count of vertices to draw
  29255. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29256. */
  29257. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29258. /**
  29259. * Draw a list of unindexed primitives
  29260. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29261. * @param verticesStart defines the index of first vertex to draw
  29262. * @param verticesCount defines the count of vertices to draw
  29263. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29264. */
  29265. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29266. /**
  29267. * Draw a list of indexed primitives
  29268. * @param fillMode defines the primitive to use
  29269. * @param indexStart defines the starting index
  29270. * @param indexCount defines the number of index to draw
  29271. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29272. */
  29273. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29274. /**
  29275. * Draw a list of unindexed primitives
  29276. * @param fillMode defines the primitive to use
  29277. * @param verticesStart defines the index of first vertex to draw
  29278. * @param verticesCount defines the count of vertices to draw
  29279. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29280. */
  29281. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29282. private _drawMode;
  29283. /** @hidden */
  29284. _releaseEffect(effect: Effect): void;
  29285. /** @hidden */
  29286. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29287. /**
  29288. * Create a new effect (used to store vertex/fragment shaders)
  29289. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29290. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29291. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29292. * @param samplers defines an array of string used to represent textures
  29293. * @param defines defines the string containing the defines to use to compile the shaders
  29294. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29295. * @param onCompiled defines a function to call when the effect creation is successful
  29296. * @param onError defines a function to call when the effect creation has failed
  29297. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29298. * @returns the new Effect
  29299. */
  29300. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  29301. private _compileShader;
  29302. private _compileRawShader;
  29303. /**
  29304. * Directly creates a webGL program
  29305. * @param pipelineContext defines the pipeline context to attach to
  29306. * @param vertexCode defines the vertex shader code to use
  29307. * @param fragmentCode defines the fragment shader code to use
  29308. * @param context defines the webGL context to use (if not set, the current one will be used)
  29309. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29310. * @returns the new webGL program
  29311. */
  29312. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29313. /**
  29314. * Creates a webGL program
  29315. * @param pipelineContext defines the pipeline context to attach to
  29316. * @param vertexCode defines the vertex shader code to use
  29317. * @param fragmentCode defines the fragment shader code to use
  29318. * @param defines defines the string containing the defines to use to compile the shaders
  29319. * @param context defines the webGL context to use (if not set, the current one will be used)
  29320. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29321. * @returns the new webGL program
  29322. */
  29323. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29324. /**
  29325. * Creates a new pipeline context
  29326. * @returns the new pipeline
  29327. */
  29328. createPipelineContext(): WebGLPipelineContext;
  29329. private _createShaderProgram;
  29330. private _finalizePipelineContext;
  29331. /** @hidden */
  29332. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29333. /** @hidden */
  29334. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29335. /** @hidden */
  29336. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29337. /**
  29338. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29339. * @param pipelineContext defines the pipeline context to use
  29340. * @param uniformsNames defines the list of uniform names
  29341. * @returns an array of webGL uniform locations
  29342. */
  29343. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29344. /**
  29345. * Gets the lsit of active attributes for a given webGL program
  29346. * @param pipelineContext defines the pipeline context to use
  29347. * @param attributesNames defines the list of attribute names to get
  29348. * @returns an array of indices indicating the offset of each attribute
  29349. */
  29350. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29351. /**
  29352. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29353. * @param effect defines the effect to activate
  29354. */
  29355. enableEffect(effect: Nullable<Effect>): void;
  29356. /**
  29357. * Set the value of an uniform to an array of int32
  29358. * @param uniform defines the webGL uniform location where to store the value
  29359. * @param array defines the array of int32 to store
  29360. */
  29361. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29362. /**
  29363. * Set the value of an uniform to an array of int32 (stored as vec2)
  29364. * @param uniform defines the webGL uniform location where to store the value
  29365. * @param array defines the array of int32 to store
  29366. */
  29367. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29368. /**
  29369. * Set the value of an uniform to an array of int32 (stored as vec3)
  29370. * @param uniform defines the webGL uniform location where to store the value
  29371. * @param array defines the array of int32 to store
  29372. */
  29373. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29374. /**
  29375. * Set the value of an uniform to an array of int32 (stored as vec4)
  29376. * @param uniform defines the webGL uniform location where to store the value
  29377. * @param array defines the array of int32 to store
  29378. */
  29379. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29380. /**
  29381. * Set the value of an uniform to an array of float32
  29382. * @param uniform defines the webGL uniform location where to store the value
  29383. * @param array defines the array of float32 to store
  29384. */
  29385. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29386. /**
  29387. * Set the value of an uniform to an array of float32 (stored as vec2)
  29388. * @param uniform defines the webGL uniform location where to store the value
  29389. * @param array defines the array of float32 to store
  29390. */
  29391. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29392. /**
  29393. * Set the value of an uniform to an array of float32 (stored as vec3)
  29394. * @param uniform defines the webGL uniform location where to store the value
  29395. * @param array defines the array of float32 to store
  29396. */
  29397. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29398. /**
  29399. * Set the value of an uniform to an array of float32 (stored as vec4)
  29400. * @param uniform defines the webGL uniform location where to store the value
  29401. * @param array defines the array of float32 to store
  29402. */
  29403. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29404. /**
  29405. * Set the value of an uniform to an array of number
  29406. * @param uniform defines the webGL uniform location where to store the value
  29407. * @param array defines the array of number to store
  29408. */
  29409. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29410. /**
  29411. * Set the value of an uniform to an array of number (stored as vec2)
  29412. * @param uniform defines the webGL uniform location where to store the value
  29413. * @param array defines the array of number to store
  29414. */
  29415. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29416. /**
  29417. * Set the value of an uniform to an array of number (stored as vec3)
  29418. * @param uniform defines the webGL uniform location where to store the value
  29419. * @param array defines the array of number to store
  29420. */
  29421. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29422. /**
  29423. * Set the value of an uniform to an array of number (stored as vec4)
  29424. * @param uniform defines the webGL uniform location where to store the value
  29425. * @param array defines the array of number to store
  29426. */
  29427. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29428. /**
  29429. * Set the value of an uniform to an array of float32 (stored as matrices)
  29430. * @param uniform defines the webGL uniform location where to store the value
  29431. * @param matrices defines the array of float32 to store
  29432. */
  29433. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29434. /**
  29435. * Set the value of an uniform to a matrix
  29436. * @param uniform defines the webGL uniform location where to store the value
  29437. * @param matrix defines the matrix to store
  29438. */
  29439. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  29440. /**
  29441. * Set the value of an uniform to a matrix (3x3)
  29442. * @param uniform defines the webGL uniform location where to store the value
  29443. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29444. */
  29445. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29446. /**
  29447. * Set the value of an uniform to a matrix (2x2)
  29448. * @param uniform defines the webGL uniform location where to store the value
  29449. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29450. */
  29451. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29452. /**
  29453. * Set the value of an uniform to a number (int)
  29454. * @param uniform defines the webGL uniform location where to store the value
  29455. * @param value defines the int number to store
  29456. */
  29457. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29458. /**
  29459. * Set the value of an uniform to a number (float)
  29460. * @param uniform defines the webGL uniform location where to store the value
  29461. * @param value defines the float number to store
  29462. */
  29463. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29464. /**
  29465. * Set the value of an uniform to a vec2
  29466. * @param uniform defines the webGL uniform location where to store the value
  29467. * @param x defines the 1st component of the value
  29468. * @param y defines the 2nd component of the value
  29469. */
  29470. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29471. /**
  29472. * Set the value of an uniform to a vec3
  29473. * @param uniform defines the webGL uniform location where to store the value
  29474. * @param x defines the 1st component of the value
  29475. * @param y defines the 2nd component of the value
  29476. * @param z defines the 3rd component of the value
  29477. */
  29478. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29479. /**
  29480. * Set the value of an uniform to a boolean
  29481. * @param uniform defines the webGL uniform location where to store the value
  29482. * @param bool defines the boolean to store
  29483. */
  29484. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29485. /**
  29486. * Set the value of an uniform to a vec4
  29487. * @param uniform defines the webGL uniform location where to store the value
  29488. * @param x defines the 1st component of the value
  29489. * @param y defines the 2nd component of the value
  29490. * @param z defines the 3rd component of the value
  29491. * @param w defines the 4th component of the value
  29492. */
  29493. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29494. /**
  29495. * Set the value of an uniform to a Color3
  29496. * @param uniform defines the webGL uniform location where to store the value
  29497. * @param color3 defines the color to store
  29498. */
  29499. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  29500. /**
  29501. * Set the value of an uniform to a Color3 and an alpha value
  29502. * @param uniform defines the webGL uniform location where to store the value
  29503. * @param color3 defines the color to store
  29504. * @param alpha defines the alpha component to store
  29505. */
  29506. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  29507. /**
  29508. * Sets a Color4 on a uniform variable
  29509. * @param uniform defines the uniform location
  29510. * @param color4 defines the value to be set
  29511. */
  29512. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  29513. /**
  29514. * Set various states to the webGL context
  29515. * @param culling defines backface culling state
  29516. * @param zOffset defines the value to apply to zOffset (0 by default)
  29517. * @param force defines if states must be applied even if cache is up to date
  29518. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29519. */
  29520. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  29521. /**
  29522. * Set the z offset to apply to current rendering
  29523. * @param value defines the offset to apply
  29524. */
  29525. setZOffset(value: number): void;
  29526. /**
  29527. * Gets the current value of the zOffset
  29528. * @returns the current zOffset state
  29529. */
  29530. getZOffset(): number;
  29531. /**
  29532. * Enable or disable depth buffering
  29533. * @param enable defines the state to set
  29534. */
  29535. setDepthBuffer(enable: boolean): void;
  29536. /**
  29537. * Gets a boolean indicating if depth writing is enabled
  29538. * @returns the current depth writing state
  29539. */
  29540. getDepthWrite(): boolean;
  29541. /**
  29542. * Enable or disable depth writing
  29543. * @param enable defines the state to set
  29544. */
  29545. setDepthWrite(enable: boolean): void;
  29546. /**
  29547. * Enable or disable color writing
  29548. * @param enable defines the state to set
  29549. */
  29550. setColorWrite(enable: boolean): void;
  29551. /**
  29552. * Gets a boolean indicating if color writing is enabled
  29553. * @returns the current color writing state
  29554. */
  29555. getColorWrite(): boolean;
  29556. /**
  29557. * Sets alpha constants used by some alpha blending modes
  29558. * @param r defines the red component
  29559. * @param g defines the green component
  29560. * @param b defines the blue component
  29561. * @param a defines the alpha component
  29562. */
  29563. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29564. /**
  29565. * Sets the current alpha mode
  29566. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29567. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29568. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29569. */
  29570. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29571. /**
  29572. * Gets the current alpha mode
  29573. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29574. * @returns the current alpha mode
  29575. */
  29576. getAlphaMode(): number;
  29577. /**
  29578. * Clears the list of texture accessible through engine.
  29579. * This can help preventing texture load conflict due to name collision.
  29580. */
  29581. clearInternalTexturesCache(): void;
  29582. /**
  29583. * Force the entire cache to be cleared
  29584. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29585. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29586. */
  29587. wipeCaches(bruteForce?: boolean): void;
  29588. /**
  29589. * Set the compressed texture format to use, based on the formats you have, and the formats
  29590. * supported by the hardware / browser.
  29591. *
  29592. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29593. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29594. * to API arguments needed to compressed textures. This puts the burden on the container
  29595. * generator to house the arcane code for determining these for current & future formats.
  29596. *
  29597. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29598. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29599. *
  29600. * Note: The result of this call is not taken into account when a texture is base64.
  29601. *
  29602. * @param formatsAvailable defines the list of those format families you have created
  29603. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29604. *
  29605. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29606. * @returns The extension selected.
  29607. */
  29608. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29609. /** @hidden */
  29610. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29611. min: number;
  29612. mag: number;
  29613. };
  29614. /** @hidden */
  29615. _createTexture(): WebGLTexture;
  29616. /**
  29617. * Usually called from Texture.ts.
  29618. * Passed information to create a WebGLTexture
  29619. * @param urlArg defines a value which contains one of the following:
  29620. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29621. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29622. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29623. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29624. * @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)
  29625. * @param scene needed for loading to the correct scene
  29626. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29627. * @param onLoad optional callback to be called upon successful completion
  29628. * @param onError optional callback to be called upon failure
  29629. * @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
  29630. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29631. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29632. * @param forcedExtension defines the extension to use to pick the right loader
  29633. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29634. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29635. */
  29636. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  29637. private _rescaleTexture;
  29638. private _unpackFlipYCached;
  29639. /**
  29640. * In case you are sharing the context with other applications, it might
  29641. * be interested to not cache the unpack flip y state to ensure a consistent
  29642. * value would be set.
  29643. */
  29644. enableUnpackFlipYCached: boolean;
  29645. /** @hidden */
  29646. _unpackFlipY(value: boolean): void;
  29647. /** @hidden */
  29648. _getUnpackAlignement(): number;
  29649. /**
  29650. * Creates a dynamic texture
  29651. * @param width defines the width of the texture
  29652. * @param height defines the height of the texture
  29653. * @param generateMipMaps defines if the engine should generate the mip levels
  29654. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29655. * @returns the dynamic texture inside an InternalTexture
  29656. */
  29657. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29658. /**
  29659. * Update the sampling mode of a given texture
  29660. * @param samplingMode defines the required sampling mode
  29661. * @param texture defines the texture to update
  29662. */
  29663. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29664. /**
  29665. * Update the content of a dynamic texture
  29666. * @param texture defines the texture to update
  29667. * @param canvas defines the canvas containing the source
  29668. * @param invertY defines if data must be stored with Y axis inverted
  29669. * @param premulAlpha defines if alpha is stored as premultiplied
  29670. * @param format defines the format of the data
  29671. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29672. */
  29673. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29674. /**
  29675. * Update a video texture
  29676. * @param texture defines the texture to update
  29677. * @param video defines the video element to use
  29678. * @param invertY defines if data must be stored with Y axis inverted
  29679. */
  29680. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29681. /**
  29682. * Updates a depth texture Comparison Mode and Function.
  29683. * If the comparison Function is equal to 0, the mode will be set to none.
  29684. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29685. * @param texture The texture to set the comparison function for
  29686. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29687. */
  29688. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29689. /** @hidden */
  29690. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29691. width: number;
  29692. height: number;
  29693. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29694. /**
  29695. * Creates a depth stencil texture.
  29696. * This is only available in WebGL 2 or with the depth texture extension available.
  29697. * @param size The size of face edge in the texture.
  29698. * @param options The options defining the texture.
  29699. * @returns The texture
  29700. */
  29701. createDepthStencilTexture(size: number | {
  29702. width: number;
  29703. height: number;
  29704. }, options: DepthTextureCreationOptions): InternalTexture;
  29705. /**
  29706. * Creates a depth stencil texture.
  29707. * This is only available in WebGL 2 or with the depth texture extension available.
  29708. * @param size The size of face edge in the texture.
  29709. * @param options The options defining the texture.
  29710. * @returns The texture
  29711. */
  29712. private _createDepthStencilTexture;
  29713. /**
  29714. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29715. * @param renderTarget The render target to set the frame buffer for
  29716. */
  29717. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29718. /**
  29719. * Creates a new render target texture
  29720. * @param size defines the size of the texture
  29721. * @param options defines the options used to create the texture
  29722. * @returns a new render target texture stored in an InternalTexture
  29723. */
  29724. createRenderTargetTexture(size: number | {
  29725. width: number;
  29726. height: number;
  29727. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29728. /** @hidden */
  29729. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29730. /**
  29731. * Updates the sample count of a render target texture
  29732. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29733. * @param texture defines the texture to update
  29734. * @param samples defines the sample count to set
  29735. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29736. */
  29737. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29738. /** @hidden */
  29739. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29740. /** @hidden */
  29741. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29742. /** @hidden */
  29743. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29744. /** @hidden */
  29745. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29746. /**
  29747. * @hidden
  29748. */
  29749. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29750. private _prepareWebGLTextureContinuation;
  29751. private _prepareWebGLTexture;
  29752. /** @hidden */
  29753. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29754. /** @hidden */
  29755. _releaseFramebufferObjects(texture: InternalTexture): void;
  29756. /** @hidden */
  29757. _releaseTexture(texture: InternalTexture): void;
  29758. private setProgram;
  29759. private _boundUniforms;
  29760. /**
  29761. * Binds an effect to the webGL context
  29762. * @param effect defines the effect to bind
  29763. */
  29764. bindSamplers(effect: Effect): void;
  29765. private _activateCurrentTexture;
  29766. /** @hidden */
  29767. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29768. /** @hidden */
  29769. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29770. /**
  29771. * Sets a texture to the webGL context from a postprocess
  29772. * @param channel defines the channel to use
  29773. * @param postProcess defines the source postprocess
  29774. */
  29775. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29776. /**
  29777. * Binds the output of the passed in post process to the texture channel specified
  29778. * @param channel The channel the texture should be bound to
  29779. * @param postProcess The post process which's output should be bound
  29780. */
  29781. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29782. /**
  29783. * Unbind all textures from the webGL context
  29784. */
  29785. unbindAllTextures(): void;
  29786. /**
  29787. * Sets a texture to the according uniform.
  29788. * @param channel The texture channel
  29789. * @param uniform The uniform to set
  29790. * @param texture The texture to apply
  29791. */
  29792. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29793. /**
  29794. * Sets a depth stencil texture from a render target to the according uniform.
  29795. * @param channel The texture channel
  29796. * @param uniform The uniform to set
  29797. * @param texture The render target texture containing the depth stencil texture to apply
  29798. */
  29799. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29800. private _bindSamplerUniformToChannel;
  29801. private _getTextureWrapMode;
  29802. private _setTexture;
  29803. /**
  29804. * Sets an array of texture to the webGL context
  29805. * @param channel defines the channel where the texture array must be set
  29806. * @param uniform defines the associated uniform location
  29807. * @param textures defines the array of textures to bind
  29808. */
  29809. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29810. /** @hidden */
  29811. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29812. private _setTextureParameterFloat;
  29813. private _setTextureParameterInteger;
  29814. /**
  29815. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29816. * @param x defines the x coordinate of the rectangle where pixels must be read
  29817. * @param y defines the y coordinate of the rectangle where pixels must be read
  29818. * @param width defines the width of the rectangle where pixels must be read
  29819. * @param height defines the height of the rectangle where pixels must be read
  29820. * @returns a Uint8Array containing RGBA colors
  29821. */
  29822. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29823. /**
  29824. * Add an externaly attached data from its key.
  29825. * This method call will fail and return false, if such key already exists.
  29826. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29827. * @param key the unique key that identifies the data
  29828. * @param data the data object to associate to the key for this Engine instance
  29829. * @return true if no such key were already present and the data was added successfully, false otherwise
  29830. */
  29831. addExternalData<T>(key: string, data: T): boolean;
  29832. /**
  29833. * Get an externaly attached data from its key
  29834. * @param key the unique key that identifies the data
  29835. * @return the associated data, if present (can be null), or undefined if not present
  29836. */
  29837. getExternalData<T>(key: string): T;
  29838. /**
  29839. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29840. * @param key the unique key that identifies the data
  29841. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29842. * @return the associated data, can be null if the factory returned null.
  29843. */
  29844. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29845. /**
  29846. * Remove an externaly attached data from the Engine instance
  29847. * @param key the unique key that identifies the data
  29848. * @return true if the data was successfully removed, false if it doesn't exist
  29849. */
  29850. removeExternalData(key: string): boolean;
  29851. /**
  29852. * Unbind all vertex attributes from the webGL context
  29853. */
  29854. unbindAllAttributes(): void;
  29855. /**
  29856. * 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
  29857. */
  29858. releaseEffects(): void;
  29859. /**
  29860. * Dispose and release all associated resources
  29861. */
  29862. dispose(): void;
  29863. /**
  29864. * Display the loading screen
  29865. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29866. */
  29867. displayLoadingUI(): void;
  29868. /**
  29869. * Hide the loading screen
  29870. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29871. */
  29872. hideLoadingUI(): void;
  29873. /**
  29874. * Gets the current loading screen object
  29875. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29876. */
  29877. /**
  29878. * Sets the current loading screen object
  29879. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29880. */
  29881. loadingScreen: ILoadingScreen;
  29882. /**
  29883. * Sets the current loading screen text
  29884. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29885. */
  29886. loadingUIText: string;
  29887. /**
  29888. * Sets the current loading screen background color
  29889. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29890. */
  29891. loadingUIBackgroundColor: string;
  29892. /**
  29893. * Attach a new callback raised when context lost event is fired
  29894. * @param callback defines the callback to call
  29895. */
  29896. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29897. /**
  29898. * Attach a new callback raised when context restored event is fired
  29899. * @param callback defines the callback to call
  29900. */
  29901. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29902. /**
  29903. * Gets the source code of the vertex shader associated with a specific webGL program
  29904. * @param program defines the program to use
  29905. * @returns a string containing the source code of the vertex shader associated with the program
  29906. */
  29907. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29908. /**
  29909. * Gets the source code of the fragment shader associated with a specific webGL program
  29910. * @param program defines the program to use
  29911. * @returns a string containing the source code of the fragment shader associated with the program
  29912. */
  29913. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29914. /**
  29915. * Get the current error code of the webGL context
  29916. * @returns the error code
  29917. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29918. */
  29919. getError(): number;
  29920. /**
  29921. * Gets the current framerate
  29922. * @returns a number representing the framerate
  29923. */
  29924. getFps(): number;
  29925. /**
  29926. * Gets the time spent between current and previous frame
  29927. * @returns a number representing the delta time in ms
  29928. */
  29929. getDeltaTime(): number;
  29930. private _measureFps;
  29931. /** @hidden */
  29932. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29933. private _canRenderToFloatFramebuffer;
  29934. private _canRenderToHalfFloatFramebuffer;
  29935. private _canRenderToFramebuffer;
  29936. /** @hidden */
  29937. _getWebGLTextureType(type: number): number;
  29938. /** @hidden */
  29939. _getInternalFormat(format: number): number;
  29940. /** @hidden */
  29941. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29942. /** @hidden */
  29943. _getRGBAMultiSampleBufferFormat(type: number): number;
  29944. /** @hidden */
  29945. _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;
  29946. /** @hidden */
  29947. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29948. /**
  29949. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29950. * @returns true if the engine can be created
  29951. * @ignorenaming
  29952. */
  29953. static isSupported(): boolean;
  29954. }
  29955. }
  29956. declare module "babylonjs/Materials/effect" {
  29957. import { Observable } from "babylonjs/Misc/observable";
  29958. import { Nullable } from "babylonjs/types";
  29959. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29960. import { IDisposable } from "babylonjs/scene";
  29961. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29962. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29963. import { Engine } from "babylonjs/Engines/engine";
  29964. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29965. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29966. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29967. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29968. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29969. /**
  29970. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29971. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29972. */
  29973. export class EffectFallbacks {
  29974. private _defines;
  29975. private _currentRank;
  29976. private _maxRank;
  29977. private _mesh;
  29978. /**
  29979. * Removes the fallback from the bound mesh.
  29980. */
  29981. unBindMesh(): void;
  29982. /**
  29983. * Adds a fallback on the specified property.
  29984. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29985. * @param define The name of the define in the shader
  29986. */
  29987. addFallback(rank: number, define: string): void;
  29988. /**
  29989. * Sets the mesh to use CPU skinning when needing to fallback.
  29990. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29991. * @param mesh The mesh to use the fallbacks.
  29992. */
  29993. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29994. /**
  29995. * Checks to see if more fallbacks are still availible.
  29996. */
  29997. readonly isMoreFallbacks: boolean;
  29998. /**
  29999. * Removes the defines that should be removed when falling back.
  30000. * @param currentDefines defines the current define statements for the shader.
  30001. * @param effect defines the current effect we try to compile
  30002. * @returns The resulting defines with defines of the current rank removed.
  30003. */
  30004. reduce(currentDefines: string, effect: Effect): string;
  30005. }
  30006. /**
  30007. * Options to be used when creating an effect.
  30008. */
  30009. export class EffectCreationOptions {
  30010. /**
  30011. * Atrributes that will be used in the shader.
  30012. */
  30013. attributes: string[];
  30014. /**
  30015. * Uniform varible names that will be set in the shader.
  30016. */
  30017. uniformsNames: string[];
  30018. /**
  30019. * Uniform buffer varible names that will be set in the shader.
  30020. */
  30021. uniformBuffersNames: string[];
  30022. /**
  30023. * Sampler texture variable names that will be set in the shader.
  30024. */
  30025. samplers: string[];
  30026. /**
  30027. * Define statements that will be set in the shader.
  30028. */
  30029. defines: any;
  30030. /**
  30031. * Possible fallbacks for this effect to improve performance when needed.
  30032. */
  30033. fallbacks: Nullable<EffectFallbacks>;
  30034. /**
  30035. * Callback that will be called when the shader is compiled.
  30036. */
  30037. onCompiled: Nullable<(effect: Effect) => void>;
  30038. /**
  30039. * Callback that will be called if an error occurs during shader compilation.
  30040. */
  30041. onError: Nullable<(effect: Effect, errors: string) => void>;
  30042. /**
  30043. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30044. */
  30045. indexParameters: any;
  30046. /**
  30047. * Max number of lights that can be used in the shader.
  30048. */
  30049. maxSimultaneousLights: number;
  30050. /**
  30051. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30052. */
  30053. transformFeedbackVaryings: Nullable<string[]>;
  30054. }
  30055. /**
  30056. * Effect containing vertex and fragment shader that can be executed on an object.
  30057. */
  30058. export class Effect implements IDisposable {
  30059. /**
  30060. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30061. */
  30062. static ShadersRepository: string;
  30063. /**
  30064. * Name of the effect.
  30065. */
  30066. name: any;
  30067. /**
  30068. * String container all the define statements that should be set on the shader.
  30069. */
  30070. defines: string;
  30071. /**
  30072. * Callback that will be called when the shader is compiled.
  30073. */
  30074. onCompiled: Nullable<(effect: Effect) => void>;
  30075. /**
  30076. * Callback that will be called if an error occurs during shader compilation.
  30077. */
  30078. onError: Nullable<(effect: Effect, errors: string) => void>;
  30079. /**
  30080. * Callback that will be called when effect is bound.
  30081. */
  30082. onBind: Nullable<(effect: Effect) => void>;
  30083. /**
  30084. * Unique ID of the effect.
  30085. */
  30086. uniqueId: number;
  30087. /**
  30088. * Observable that will be called when the shader is compiled.
  30089. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30090. */
  30091. onCompileObservable: Observable<Effect>;
  30092. /**
  30093. * Observable that will be called if an error occurs during shader compilation.
  30094. */
  30095. onErrorObservable: Observable<Effect>;
  30096. /** @hidden */
  30097. _onBindObservable: Nullable<Observable<Effect>>;
  30098. /**
  30099. * Observable that will be called when effect is bound.
  30100. */
  30101. readonly onBindObservable: Observable<Effect>;
  30102. /** @hidden */
  30103. _bonesComputationForcedToCPU: boolean;
  30104. private static _uniqueIdSeed;
  30105. private _engine;
  30106. private _uniformBuffersNames;
  30107. private _uniformsNames;
  30108. private _samplerList;
  30109. private _samplers;
  30110. private _isReady;
  30111. private _compilationError;
  30112. private _attributesNames;
  30113. private _attributes;
  30114. private _uniforms;
  30115. /**
  30116. * Key for the effect.
  30117. * @hidden
  30118. */
  30119. _key: string;
  30120. private _indexParameters;
  30121. private _fallbacks;
  30122. private _vertexSourceCode;
  30123. private _fragmentSourceCode;
  30124. private _vertexSourceCodeOverride;
  30125. private _fragmentSourceCodeOverride;
  30126. private _transformFeedbackVaryings;
  30127. /**
  30128. * Compiled shader to webGL program.
  30129. * @hidden
  30130. */
  30131. _pipelineContext: Nullable<IPipelineContext>;
  30132. private _valueCache;
  30133. private static _baseCache;
  30134. /**
  30135. * Instantiates an effect.
  30136. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30137. * @param baseName Name of the effect.
  30138. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30139. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30140. * @param samplers List of sampler variables that will be passed to the shader.
  30141. * @param engine Engine to be used to render the effect
  30142. * @param defines Define statements to be added to the shader.
  30143. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30144. * @param onCompiled Callback that will be called when the shader is compiled.
  30145. * @param onError Callback that will be called if an error occurs during shader compilation.
  30146. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30147. */
  30148. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  30149. private _useFinalCode;
  30150. /**
  30151. * Unique key for this effect
  30152. */
  30153. readonly key: string;
  30154. /**
  30155. * If the effect has been compiled and prepared.
  30156. * @returns if the effect is compiled and prepared.
  30157. */
  30158. isReady(): boolean;
  30159. /**
  30160. * The engine the effect was initialized with.
  30161. * @returns the engine.
  30162. */
  30163. getEngine(): Engine;
  30164. /**
  30165. * The pipeline context for this effect
  30166. * @returns the associated pipeline context
  30167. */
  30168. getPipelineContext(): Nullable<IPipelineContext>;
  30169. /**
  30170. * The set of names of attribute variables for the shader.
  30171. * @returns An array of attribute names.
  30172. */
  30173. getAttributesNames(): string[];
  30174. /**
  30175. * Returns the attribute at the given index.
  30176. * @param index The index of the attribute.
  30177. * @returns The location of the attribute.
  30178. */
  30179. getAttributeLocation(index: number): number;
  30180. /**
  30181. * Returns the attribute based on the name of the variable.
  30182. * @param name of the attribute to look up.
  30183. * @returns the attribute location.
  30184. */
  30185. getAttributeLocationByName(name: string): number;
  30186. /**
  30187. * The number of attributes.
  30188. * @returns the numnber of attributes.
  30189. */
  30190. getAttributesCount(): number;
  30191. /**
  30192. * Gets the index of a uniform variable.
  30193. * @param uniformName of the uniform to look up.
  30194. * @returns the index.
  30195. */
  30196. getUniformIndex(uniformName: string): number;
  30197. /**
  30198. * Returns the attribute based on the name of the variable.
  30199. * @param uniformName of the uniform to look up.
  30200. * @returns the location of the uniform.
  30201. */
  30202. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30203. /**
  30204. * Returns an array of sampler variable names
  30205. * @returns The array of sampler variable neames.
  30206. */
  30207. getSamplers(): string[];
  30208. /**
  30209. * The error from the last compilation.
  30210. * @returns the error string.
  30211. */
  30212. getCompilationError(): string;
  30213. /**
  30214. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30215. * @param func The callback to be used.
  30216. */
  30217. executeWhenCompiled(func: (effect: Effect) => void): void;
  30218. private _checkIsReady;
  30219. /** @hidden */
  30220. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  30221. /** @hidden */
  30222. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  30223. /** @hidden */
  30224. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  30225. /**
  30226. * Recompiles the webGL program
  30227. * @param vertexSourceCode The source code for the vertex shader.
  30228. * @param fragmentSourceCode The source code for the fragment shader.
  30229. * @param onCompiled Callback called when completed.
  30230. * @param onError Callback called on error.
  30231. * @hidden
  30232. */
  30233. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30234. /**
  30235. * Prepares the effect
  30236. * @hidden
  30237. */
  30238. _prepareEffect(): void;
  30239. /**
  30240. * Checks if the effect is supported. (Must be called after compilation)
  30241. */
  30242. readonly isSupported: boolean;
  30243. /**
  30244. * Binds a texture to the engine to be used as output of the shader.
  30245. * @param channel Name of the output variable.
  30246. * @param texture Texture to bind.
  30247. * @hidden
  30248. */
  30249. _bindTexture(channel: string, texture: InternalTexture): void;
  30250. /**
  30251. * Sets a texture on the engine to be used in the shader.
  30252. * @param channel Name of the sampler variable.
  30253. * @param texture Texture to set.
  30254. */
  30255. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30256. /**
  30257. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30258. * @param channel Name of the sampler variable.
  30259. * @param texture Texture to set.
  30260. */
  30261. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30262. /**
  30263. * Sets an array of textures on the engine to be used in the shader.
  30264. * @param channel Name of the variable.
  30265. * @param textures Textures to set.
  30266. */
  30267. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30268. /**
  30269. * 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)
  30270. * @param channel Name of the sampler variable.
  30271. * @param postProcess Post process to get the input texture from.
  30272. */
  30273. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30274. /**
  30275. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30276. * 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)
  30277. * @param channel Name of the sampler variable.
  30278. * @param postProcess Post process to get the output texture from.
  30279. */
  30280. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30281. /** @hidden */
  30282. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  30283. /** @hidden */
  30284. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30285. /** @hidden */
  30286. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30287. /** @hidden */
  30288. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30289. /**
  30290. * Binds a buffer to a uniform.
  30291. * @param buffer Buffer to bind.
  30292. * @param name Name of the uniform variable to bind to.
  30293. */
  30294. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30295. /**
  30296. * Binds block to a uniform.
  30297. * @param blockName Name of the block to bind.
  30298. * @param index Index to bind.
  30299. */
  30300. bindUniformBlock(blockName: string, index: number): void;
  30301. /**
  30302. * Sets an interger value on a uniform variable.
  30303. * @param uniformName Name of the variable.
  30304. * @param value Value to be set.
  30305. * @returns this effect.
  30306. */
  30307. setInt(uniformName: string, value: number): Effect;
  30308. /**
  30309. * Sets an int array on a uniform variable.
  30310. * @param uniformName Name of the variable.
  30311. * @param array array to be set.
  30312. * @returns this effect.
  30313. */
  30314. setIntArray(uniformName: string, array: Int32Array): Effect;
  30315. /**
  30316. * 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)
  30317. * @param uniformName Name of the variable.
  30318. * @param array array to be set.
  30319. * @returns this effect.
  30320. */
  30321. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30322. /**
  30323. * 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)
  30324. * @param uniformName Name of the variable.
  30325. * @param array array to be set.
  30326. * @returns this effect.
  30327. */
  30328. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30329. /**
  30330. * 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)
  30331. * @param uniformName Name of the variable.
  30332. * @param array array to be set.
  30333. * @returns this effect.
  30334. */
  30335. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30336. /**
  30337. * Sets an float array on a uniform variable.
  30338. * @param uniformName Name of the variable.
  30339. * @param array array to be set.
  30340. * @returns this effect.
  30341. */
  30342. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30343. /**
  30344. * 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)
  30345. * @param uniformName Name of the variable.
  30346. * @param array array to be set.
  30347. * @returns this effect.
  30348. */
  30349. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30350. /**
  30351. * 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)
  30352. * @param uniformName Name of the variable.
  30353. * @param array array to be set.
  30354. * @returns this effect.
  30355. */
  30356. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30357. /**
  30358. * 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)
  30359. * @param uniformName Name of the variable.
  30360. * @param array array to be set.
  30361. * @returns this effect.
  30362. */
  30363. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30364. /**
  30365. * Sets an array on a uniform variable.
  30366. * @param uniformName Name of the variable.
  30367. * @param array array to be set.
  30368. * @returns this effect.
  30369. */
  30370. setArray(uniformName: string, array: number[]): Effect;
  30371. /**
  30372. * 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)
  30373. * @param uniformName Name of the variable.
  30374. * @param array array to be set.
  30375. * @returns this effect.
  30376. */
  30377. setArray2(uniformName: string, array: number[]): Effect;
  30378. /**
  30379. * 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)
  30380. * @param uniformName Name of the variable.
  30381. * @param array array to be set.
  30382. * @returns this effect.
  30383. */
  30384. setArray3(uniformName: string, array: number[]): Effect;
  30385. /**
  30386. * 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)
  30387. * @param uniformName Name of the variable.
  30388. * @param array array to be set.
  30389. * @returns this effect.
  30390. */
  30391. setArray4(uniformName: string, array: number[]): Effect;
  30392. /**
  30393. * Sets matrices on a uniform variable.
  30394. * @param uniformName Name of the variable.
  30395. * @param matrices matrices to be set.
  30396. * @returns this effect.
  30397. */
  30398. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30399. /**
  30400. * Sets matrix on a uniform variable.
  30401. * @param uniformName Name of the variable.
  30402. * @param matrix matrix to be set.
  30403. * @returns this effect.
  30404. */
  30405. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30406. /**
  30407. * 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)
  30408. * @param uniformName Name of the variable.
  30409. * @param matrix matrix to be set.
  30410. * @returns this effect.
  30411. */
  30412. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30413. /**
  30414. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30415. * @param uniformName Name of the variable.
  30416. * @param matrix matrix to be set.
  30417. * @returns this effect.
  30418. */
  30419. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30420. /**
  30421. * Sets a float on a uniform variable.
  30422. * @param uniformName Name of the variable.
  30423. * @param value value to be set.
  30424. * @returns this effect.
  30425. */
  30426. setFloat(uniformName: string, value: number): Effect;
  30427. /**
  30428. * Sets a boolean on a uniform variable.
  30429. * @param uniformName Name of the variable.
  30430. * @param bool value to be set.
  30431. * @returns this effect.
  30432. */
  30433. setBool(uniformName: string, bool: boolean): Effect;
  30434. /**
  30435. * Sets a Vector2 on a uniform variable.
  30436. * @param uniformName Name of the variable.
  30437. * @param vector2 vector2 to be set.
  30438. * @returns this effect.
  30439. */
  30440. setVector2(uniformName: string, vector2: Vector2): Effect;
  30441. /**
  30442. * Sets a float2 on a uniform variable.
  30443. * @param uniformName Name of the variable.
  30444. * @param x First float in float2.
  30445. * @param y Second float in float2.
  30446. * @returns this effect.
  30447. */
  30448. setFloat2(uniformName: string, x: number, y: number): Effect;
  30449. /**
  30450. * Sets a Vector3 on a uniform variable.
  30451. * @param uniformName Name of the variable.
  30452. * @param vector3 Value to be set.
  30453. * @returns this effect.
  30454. */
  30455. setVector3(uniformName: string, vector3: Vector3): Effect;
  30456. /**
  30457. * Sets a float3 on a uniform variable.
  30458. * @param uniformName Name of the variable.
  30459. * @param x First float in float3.
  30460. * @param y Second float in float3.
  30461. * @param z Third float in float3.
  30462. * @returns this effect.
  30463. */
  30464. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30465. /**
  30466. * Sets a Vector4 on a uniform variable.
  30467. * @param uniformName Name of the variable.
  30468. * @param vector4 Value to be set.
  30469. * @returns this effect.
  30470. */
  30471. setVector4(uniformName: string, vector4: Vector4): Effect;
  30472. /**
  30473. * Sets a float4 on a uniform variable.
  30474. * @param uniformName Name of the variable.
  30475. * @param x First float in float4.
  30476. * @param y Second float in float4.
  30477. * @param z Third float in float4.
  30478. * @param w Fourth float in float4.
  30479. * @returns this effect.
  30480. */
  30481. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30482. /**
  30483. * Sets a Color3 on a uniform variable.
  30484. * @param uniformName Name of the variable.
  30485. * @param color3 Value to be set.
  30486. * @returns this effect.
  30487. */
  30488. setColor3(uniformName: string, color3: Color3): Effect;
  30489. /**
  30490. * Sets a Color4 on a uniform variable.
  30491. * @param uniformName Name of the variable.
  30492. * @param color3 Value to be set.
  30493. * @param alpha Alpha value to be set.
  30494. * @returns this effect.
  30495. */
  30496. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30497. /**
  30498. * Sets a Color4 on a uniform variable
  30499. * @param uniformName defines the name of the variable
  30500. * @param color4 defines the value to be set
  30501. * @returns this effect.
  30502. */
  30503. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30504. /** Release all associated resources */
  30505. dispose(): void;
  30506. /**
  30507. * This function will add a new shader to the shader store
  30508. * @param name the name of the shader
  30509. * @param pixelShader optional pixel shader content
  30510. * @param vertexShader optional vertex shader content
  30511. */
  30512. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30513. /**
  30514. * Store of each shader (The can be looked up using effect.key)
  30515. */
  30516. static ShadersStore: {
  30517. [key: string]: string;
  30518. };
  30519. /**
  30520. * Store of each included file for a shader (The can be looked up using effect.key)
  30521. */
  30522. static IncludesShadersStore: {
  30523. [key: string]: string;
  30524. };
  30525. /**
  30526. * Resets the cache of effects.
  30527. */
  30528. static ResetCache(): void;
  30529. }
  30530. }
  30531. declare module "babylonjs/Materials/colorCurves" {
  30532. import { Effect } from "babylonjs/Materials/effect";
  30533. /**
  30534. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30535. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30536. * 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;
  30537. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30538. */
  30539. export class ColorCurves {
  30540. private _dirty;
  30541. private _tempColor;
  30542. private _globalCurve;
  30543. private _highlightsCurve;
  30544. private _midtonesCurve;
  30545. private _shadowsCurve;
  30546. private _positiveCurve;
  30547. private _negativeCurve;
  30548. private _globalHue;
  30549. private _globalDensity;
  30550. private _globalSaturation;
  30551. private _globalExposure;
  30552. /**
  30553. * Gets the global Hue value.
  30554. * 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).
  30555. */
  30556. /**
  30557. * Sets the global Hue value.
  30558. * 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).
  30559. */
  30560. globalHue: number;
  30561. /**
  30562. * Gets the global Density value.
  30563. * 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.
  30564. * Values less than zero provide a filter of opposite hue.
  30565. */
  30566. /**
  30567. * Sets the global Density value.
  30568. * 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.
  30569. * Values less than zero provide a filter of opposite hue.
  30570. */
  30571. globalDensity: number;
  30572. /**
  30573. * Gets the global Saturation value.
  30574. * 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.
  30575. */
  30576. /**
  30577. * Sets the global Saturation value.
  30578. * 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.
  30579. */
  30580. globalSaturation: number;
  30581. /**
  30582. * Gets the global Exposure value.
  30583. * 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.
  30584. */
  30585. /**
  30586. * Sets the global Exposure value.
  30587. * 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.
  30588. */
  30589. globalExposure: number;
  30590. private _highlightsHue;
  30591. private _highlightsDensity;
  30592. private _highlightsSaturation;
  30593. private _highlightsExposure;
  30594. /**
  30595. * Gets the highlights Hue value.
  30596. * 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).
  30597. */
  30598. /**
  30599. * Sets the highlights Hue value.
  30600. * 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).
  30601. */
  30602. highlightsHue: number;
  30603. /**
  30604. * Gets the highlights Density value.
  30605. * 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.
  30606. * Values less than zero provide a filter of opposite hue.
  30607. */
  30608. /**
  30609. * Sets the highlights Density value.
  30610. * 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.
  30611. * Values less than zero provide a filter of opposite hue.
  30612. */
  30613. highlightsDensity: number;
  30614. /**
  30615. * Gets the highlights Saturation value.
  30616. * 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.
  30617. */
  30618. /**
  30619. * Sets the highlights Saturation value.
  30620. * 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.
  30621. */
  30622. highlightsSaturation: number;
  30623. /**
  30624. * Gets the highlights Exposure value.
  30625. * 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.
  30626. */
  30627. /**
  30628. * Sets the highlights Exposure value.
  30629. * 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.
  30630. */
  30631. highlightsExposure: number;
  30632. private _midtonesHue;
  30633. private _midtonesDensity;
  30634. private _midtonesSaturation;
  30635. private _midtonesExposure;
  30636. /**
  30637. * Gets the midtones Hue value.
  30638. * 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).
  30639. */
  30640. /**
  30641. * Sets the midtones Hue value.
  30642. * 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).
  30643. */
  30644. midtonesHue: number;
  30645. /**
  30646. * Gets the midtones Density value.
  30647. * 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.
  30648. * Values less than zero provide a filter of opposite hue.
  30649. */
  30650. /**
  30651. * Sets the midtones Density value.
  30652. * 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.
  30653. * Values less than zero provide a filter of opposite hue.
  30654. */
  30655. midtonesDensity: number;
  30656. /**
  30657. * Gets the midtones Saturation value.
  30658. * 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.
  30659. */
  30660. /**
  30661. * Sets the midtones Saturation value.
  30662. * 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.
  30663. */
  30664. midtonesSaturation: number;
  30665. /**
  30666. * Gets the midtones Exposure value.
  30667. * 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.
  30668. */
  30669. /**
  30670. * Sets the midtones Exposure value.
  30671. * 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.
  30672. */
  30673. midtonesExposure: number;
  30674. private _shadowsHue;
  30675. private _shadowsDensity;
  30676. private _shadowsSaturation;
  30677. private _shadowsExposure;
  30678. /**
  30679. * Gets the shadows Hue value.
  30680. * 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).
  30681. */
  30682. /**
  30683. * Sets the shadows Hue value.
  30684. * 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).
  30685. */
  30686. shadowsHue: number;
  30687. /**
  30688. * Gets the shadows Density value.
  30689. * 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.
  30690. * Values less than zero provide a filter of opposite hue.
  30691. */
  30692. /**
  30693. * Sets the shadows Density value.
  30694. * 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.
  30695. * Values less than zero provide a filter of opposite hue.
  30696. */
  30697. shadowsDensity: number;
  30698. /**
  30699. * Gets the shadows Saturation value.
  30700. * 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.
  30701. */
  30702. /**
  30703. * Sets the shadows Saturation value.
  30704. * 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.
  30705. */
  30706. shadowsSaturation: number;
  30707. /**
  30708. * Gets the shadows Exposure value.
  30709. * 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.
  30710. */
  30711. /**
  30712. * Sets the shadows Exposure value.
  30713. * 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.
  30714. */
  30715. shadowsExposure: number;
  30716. /**
  30717. * Returns the class name
  30718. * @returns The class name
  30719. */
  30720. getClassName(): string;
  30721. /**
  30722. * Binds the color curves to the shader.
  30723. * @param colorCurves The color curve to bind
  30724. * @param effect The effect to bind to
  30725. * @param positiveUniform The positive uniform shader parameter
  30726. * @param neutralUniform The neutral uniform shader parameter
  30727. * @param negativeUniform The negative uniform shader parameter
  30728. */
  30729. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30730. /**
  30731. * Prepare the list of uniforms associated with the ColorCurves effects.
  30732. * @param uniformsList The list of uniforms used in the effect
  30733. */
  30734. static PrepareUniforms(uniformsList: string[]): void;
  30735. /**
  30736. * Returns color grading data based on a hue, density, saturation and exposure value.
  30737. * @param filterHue The hue of the color filter.
  30738. * @param filterDensity The density of the color filter.
  30739. * @param saturation The saturation.
  30740. * @param exposure The exposure.
  30741. * @param result The result data container.
  30742. */
  30743. private getColorGradingDataToRef;
  30744. /**
  30745. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30746. * @param value The input slider value in range [-100,100].
  30747. * @returns Adjusted value.
  30748. */
  30749. private static applyColorGradingSliderNonlinear;
  30750. /**
  30751. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30752. * @param hue The hue (H) input.
  30753. * @param saturation The saturation (S) input.
  30754. * @param brightness The brightness (B) input.
  30755. * @result An RGBA color represented as Vector4.
  30756. */
  30757. private static fromHSBToRef;
  30758. /**
  30759. * Returns a value clamped between min and max
  30760. * @param value The value to clamp
  30761. * @param min The minimum of value
  30762. * @param max The maximum of value
  30763. * @returns The clamped value.
  30764. */
  30765. private static clamp;
  30766. /**
  30767. * Clones the current color curve instance.
  30768. * @return The cloned curves
  30769. */
  30770. clone(): ColorCurves;
  30771. /**
  30772. * Serializes the current color curve instance to a json representation.
  30773. * @return a JSON representation
  30774. */
  30775. serialize(): any;
  30776. /**
  30777. * Parses the color curve from a json representation.
  30778. * @param source the JSON source to parse
  30779. * @return The parsed curves
  30780. */
  30781. static Parse(source: any): ColorCurves;
  30782. }
  30783. }
  30784. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30785. import { Observable } from "babylonjs/Misc/observable";
  30786. import { Nullable } from "babylonjs/types";
  30787. import { Color4 } from "babylonjs/Maths/math";
  30788. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30789. import { Effect } from "babylonjs/Materials/effect";
  30790. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30791. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30792. /**
  30793. * Interface to follow in your material defines to integrate easily the
  30794. * Image proccessing functions.
  30795. * @hidden
  30796. */
  30797. export interface IImageProcessingConfigurationDefines {
  30798. IMAGEPROCESSING: boolean;
  30799. VIGNETTE: boolean;
  30800. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30801. VIGNETTEBLENDMODEOPAQUE: boolean;
  30802. TONEMAPPING: boolean;
  30803. TONEMAPPING_ACES: boolean;
  30804. CONTRAST: boolean;
  30805. EXPOSURE: boolean;
  30806. COLORCURVES: boolean;
  30807. COLORGRADING: boolean;
  30808. COLORGRADING3D: boolean;
  30809. SAMPLER3DGREENDEPTH: boolean;
  30810. SAMPLER3DBGRMAP: boolean;
  30811. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30812. }
  30813. /**
  30814. * @hidden
  30815. */
  30816. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30817. IMAGEPROCESSING: boolean;
  30818. VIGNETTE: boolean;
  30819. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30820. VIGNETTEBLENDMODEOPAQUE: boolean;
  30821. TONEMAPPING: boolean;
  30822. TONEMAPPING_ACES: boolean;
  30823. CONTRAST: boolean;
  30824. COLORCURVES: boolean;
  30825. COLORGRADING: boolean;
  30826. COLORGRADING3D: boolean;
  30827. SAMPLER3DGREENDEPTH: boolean;
  30828. SAMPLER3DBGRMAP: boolean;
  30829. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30830. EXPOSURE: boolean;
  30831. constructor();
  30832. }
  30833. /**
  30834. * This groups together the common properties used for image processing either in direct forward pass
  30835. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30836. * or not.
  30837. */
  30838. export class ImageProcessingConfiguration {
  30839. /**
  30840. * Default tone mapping applied in BabylonJS.
  30841. */
  30842. static readonly TONEMAPPING_STANDARD: number;
  30843. /**
  30844. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30845. * to other engines rendering to increase portability.
  30846. */
  30847. static readonly TONEMAPPING_ACES: number;
  30848. /**
  30849. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30850. */
  30851. colorCurves: Nullable<ColorCurves>;
  30852. private _colorCurvesEnabled;
  30853. /**
  30854. * Gets wether the color curves effect is enabled.
  30855. */
  30856. /**
  30857. * Sets wether the color curves effect is enabled.
  30858. */
  30859. colorCurvesEnabled: boolean;
  30860. private _colorGradingTexture;
  30861. /**
  30862. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30863. */
  30864. /**
  30865. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30866. */
  30867. colorGradingTexture: Nullable<BaseTexture>;
  30868. private _colorGradingEnabled;
  30869. /**
  30870. * Gets wether the color grading effect is enabled.
  30871. */
  30872. /**
  30873. * Sets wether the color grading effect is enabled.
  30874. */
  30875. colorGradingEnabled: boolean;
  30876. private _colorGradingWithGreenDepth;
  30877. /**
  30878. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30879. */
  30880. /**
  30881. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30882. */
  30883. colorGradingWithGreenDepth: boolean;
  30884. private _colorGradingBGR;
  30885. /**
  30886. * Gets wether the color grading texture contains BGR values.
  30887. */
  30888. /**
  30889. * Sets wether the color grading texture contains BGR values.
  30890. */
  30891. colorGradingBGR: boolean;
  30892. /** @hidden */
  30893. _exposure: number;
  30894. /**
  30895. * Gets the Exposure used in the effect.
  30896. */
  30897. /**
  30898. * Sets the Exposure used in the effect.
  30899. */
  30900. exposure: number;
  30901. private _toneMappingEnabled;
  30902. /**
  30903. * Gets wether the tone mapping effect is enabled.
  30904. */
  30905. /**
  30906. * Sets wether the tone mapping effect is enabled.
  30907. */
  30908. toneMappingEnabled: boolean;
  30909. private _toneMappingType;
  30910. /**
  30911. * Gets the type of tone mapping effect.
  30912. */
  30913. /**
  30914. * Sets the type of tone mapping effect used in BabylonJS.
  30915. */
  30916. toneMappingType: number;
  30917. protected _contrast: number;
  30918. /**
  30919. * Gets the contrast used in the effect.
  30920. */
  30921. /**
  30922. * Sets the contrast used in the effect.
  30923. */
  30924. contrast: number;
  30925. /**
  30926. * Vignette stretch size.
  30927. */
  30928. vignetteStretch: number;
  30929. /**
  30930. * Vignette centre X Offset.
  30931. */
  30932. vignetteCentreX: number;
  30933. /**
  30934. * Vignette centre Y Offset.
  30935. */
  30936. vignetteCentreY: number;
  30937. /**
  30938. * Vignette weight or intensity of the vignette effect.
  30939. */
  30940. vignetteWeight: number;
  30941. /**
  30942. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30943. * if vignetteEnabled is set to true.
  30944. */
  30945. vignetteColor: Color4;
  30946. /**
  30947. * Camera field of view used by the Vignette effect.
  30948. */
  30949. vignetteCameraFov: number;
  30950. private _vignetteBlendMode;
  30951. /**
  30952. * Gets the vignette blend mode allowing different kind of effect.
  30953. */
  30954. /**
  30955. * Sets the vignette blend mode allowing different kind of effect.
  30956. */
  30957. vignetteBlendMode: number;
  30958. private _vignetteEnabled;
  30959. /**
  30960. * Gets wether the vignette effect is enabled.
  30961. */
  30962. /**
  30963. * Sets wether the vignette effect is enabled.
  30964. */
  30965. vignetteEnabled: boolean;
  30966. private _applyByPostProcess;
  30967. /**
  30968. * Gets wether the image processing is applied through a post process or not.
  30969. */
  30970. /**
  30971. * Sets wether the image processing is applied through a post process or not.
  30972. */
  30973. applyByPostProcess: boolean;
  30974. private _isEnabled;
  30975. /**
  30976. * Gets wether the image processing is enabled or not.
  30977. */
  30978. /**
  30979. * Sets wether the image processing is enabled or not.
  30980. */
  30981. isEnabled: boolean;
  30982. /**
  30983. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30984. */
  30985. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30986. /**
  30987. * Method called each time the image processing information changes requires to recompile the effect.
  30988. */
  30989. protected _updateParameters(): void;
  30990. /**
  30991. * Gets the current class name.
  30992. * @return "ImageProcessingConfiguration"
  30993. */
  30994. getClassName(): string;
  30995. /**
  30996. * Prepare the list of uniforms associated with the Image Processing effects.
  30997. * @param uniforms The list of uniforms used in the effect
  30998. * @param defines the list of defines currently in use
  30999. */
  31000. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  31001. /**
  31002. * Prepare the list of samplers associated with the Image Processing effects.
  31003. * @param samplersList The list of uniforms used in the effect
  31004. * @param defines the list of defines currently in use
  31005. */
  31006. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  31007. /**
  31008. * Prepare the list of defines associated to the shader.
  31009. * @param defines the list of defines to complete
  31010. * @param forPostProcess Define if we are currently in post process mode or not
  31011. */
  31012. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  31013. /**
  31014. * Returns true if all the image processing information are ready.
  31015. * @returns True if ready, otherwise, false
  31016. */
  31017. isReady(): boolean;
  31018. /**
  31019. * Binds the image processing to the shader.
  31020. * @param effect The effect to bind to
  31021. * @param aspectRatio Define the current aspect ratio of the effect
  31022. */
  31023. bind(effect: Effect, aspectRatio?: number): void;
  31024. /**
  31025. * Clones the current image processing instance.
  31026. * @return The cloned image processing
  31027. */
  31028. clone(): ImageProcessingConfiguration;
  31029. /**
  31030. * Serializes the current image processing instance to a json representation.
  31031. * @return a JSON representation
  31032. */
  31033. serialize(): any;
  31034. /**
  31035. * Parses the image processing from a json representation.
  31036. * @param source the JSON source to parse
  31037. * @return The parsed image processing
  31038. */
  31039. static Parse(source: any): ImageProcessingConfiguration;
  31040. private static _VIGNETTEMODE_MULTIPLY;
  31041. private static _VIGNETTEMODE_OPAQUE;
  31042. /**
  31043. * Used to apply the vignette as a mix with the pixel color.
  31044. */
  31045. static readonly VIGNETTEMODE_MULTIPLY: number;
  31046. /**
  31047. * Used to apply the vignette as a replacement of the pixel color.
  31048. */
  31049. static readonly VIGNETTEMODE_OPAQUE: number;
  31050. }
  31051. }
  31052. declare module "babylonjs/Materials/fresnelParameters" {
  31053. import { Color3 } from "babylonjs/Maths/math";
  31054. /**
  31055. * This represents all the required information to add a fresnel effect on a material:
  31056. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31057. */
  31058. export class FresnelParameters {
  31059. private _isEnabled;
  31060. /**
  31061. * Define if the fresnel effect is enable or not.
  31062. */
  31063. isEnabled: boolean;
  31064. /**
  31065. * Define the color used on edges (grazing angle)
  31066. */
  31067. leftColor: Color3;
  31068. /**
  31069. * Define the color used on center
  31070. */
  31071. rightColor: Color3;
  31072. /**
  31073. * Define bias applied to computed fresnel term
  31074. */
  31075. bias: number;
  31076. /**
  31077. * Defined the power exponent applied to fresnel term
  31078. */
  31079. power: number;
  31080. /**
  31081. * Clones the current fresnel and its valuues
  31082. * @returns a clone fresnel configuration
  31083. */
  31084. clone(): FresnelParameters;
  31085. /**
  31086. * Serializes the current fresnel parameters to a JSON representation.
  31087. * @return the JSON serialization
  31088. */
  31089. serialize(): any;
  31090. /**
  31091. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  31092. * @param parsedFresnelParameters Define the JSON representation
  31093. * @returns the parsed parameters
  31094. */
  31095. static Parse(parsedFresnelParameters: any): FresnelParameters;
  31096. }
  31097. }
  31098. declare module "babylonjs/Misc/decorators" {
  31099. import { Nullable } from "babylonjs/types";
  31100. import { Scene } from "babylonjs/scene";
  31101. import { IAnimatable } from "babylonjs/Misc/tools";
  31102. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  31103. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31104. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31105. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31106. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31107. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31108. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31109. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31110. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31111. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31112. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31113. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31114. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31115. /**
  31116. * Decorator used to define property that can be serialized as reference to a camera
  31117. * @param sourceName defines the name of the property to decorate
  31118. */
  31119. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31120. /**
  31121. * Class used to help serialization objects
  31122. */
  31123. export class SerializationHelper {
  31124. /** @hidden */
  31125. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  31126. /** @hidden */
  31127. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  31128. /** @hidden */
  31129. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  31130. /** @hidden */
  31131. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  31132. /**
  31133. * Appends the serialized animations from the source animations
  31134. * @param source Source containing the animations
  31135. * @param destination Target to store the animations
  31136. */
  31137. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  31138. /**
  31139. * Static function used to serialized a specific entity
  31140. * @param entity defines the entity to serialize
  31141. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  31142. * @returns a JSON compatible object representing the serialization of the entity
  31143. */
  31144. static Serialize<T>(entity: T, serializationObject?: any): any;
  31145. /**
  31146. * Creates a new entity from a serialization data object
  31147. * @param creationFunction defines a function used to instanciated the new entity
  31148. * @param source defines the source serialization data
  31149. * @param scene defines the hosting scene
  31150. * @param rootUrl defines the root url for resources
  31151. * @returns a new entity
  31152. */
  31153. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  31154. /**
  31155. * Clones an object
  31156. * @param creationFunction defines the function used to instanciate the new object
  31157. * @param source defines the source object
  31158. * @returns the cloned object
  31159. */
  31160. static Clone<T>(creationFunction: () => T, source: T): T;
  31161. /**
  31162. * Instanciates a new object based on a source one (some data will be shared between both object)
  31163. * @param creationFunction defines the function used to instanciate the new object
  31164. * @param source defines the source object
  31165. * @returns the new object
  31166. */
  31167. static Instanciate<T>(creationFunction: () => T, source: T): T;
  31168. }
  31169. }
  31170. declare module "babylonjs/Cameras/camera" {
  31171. import { SmartArray } from "babylonjs/Misc/smartArray";
  31172. import { Observable } from "babylonjs/Misc/observable";
  31173. import { Nullable } from "babylonjs/types";
  31174. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  31175. import { Scene } from "babylonjs/scene";
  31176. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  31177. import { Node } from "babylonjs/node";
  31178. import { Mesh } from "babylonjs/Meshes/mesh";
  31179. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31180. import { ICullable } from "babylonjs/Culling/boundingInfo";
  31181. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31182. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31183. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  31184. import { Ray } from "babylonjs/Culling/ray";
  31185. /**
  31186. * This is the base class of all the camera used in the application.
  31187. * @see http://doc.babylonjs.com/features/cameras
  31188. */
  31189. export class Camera extends Node {
  31190. /** @hidden */
  31191. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  31192. /**
  31193. * This is the default projection mode used by the cameras.
  31194. * It helps recreating a feeling of perspective and better appreciate depth.
  31195. * This is the best way to simulate real life cameras.
  31196. */
  31197. static readonly PERSPECTIVE_CAMERA: number;
  31198. /**
  31199. * This helps creating camera with an orthographic mode.
  31200. * 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.
  31201. */
  31202. static readonly ORTHOGRAPHIC_CAMERA: number;
  31203. /**
  31204. * This is the default FOV mode for perspective cameras.
  31205. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  31206. */
  31207. static readonly FOVMODE_VERTICAL_FIXED: number;
  31208. /**
  31209. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  31210. */
  31211. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  31212. /**
  31213. * This specifies ther is no need for a camera rig.
  31214. * Basically only one eye is rendered corresponding to the camera.
  31215. */
  31216. static readonly RIG_MODE_NONE: number;
  31217. /**
  31218. * Simulates a camera Rig with one blue eye and one red eye.
  31219. * This can be use with 3d blue and red glasses.
  31220. */
  31221. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  31222. /**
  31223. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  31224. */
  31225. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  31226. /**
  31227. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  31228. */
  31229. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  31230. /**
  31231. * Defines that both eyes of the camera will be rendered over under each other.
  31232. */
  31233. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  31234. /**
  31235. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  31236. */
  31237. static readonly RIG_MODE_VR: number;
  31238. /**
  31239. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  31240. */
  31241. static readonly RIG_MODE_WEBVR: number;
  31242. /**
  31243. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  31244. */
  31245. static readonly RIG_MODE_CUSTOM: number;
  31246. /**
  31247. * Defines if by default attaching controls should prevent the default javascript event to continue.
  31248. */
  31249. static ForceAttachControlToAlwaysPreventDefault: boolean;
  31250. /**
  31251. * Define the input manager associated with the camera.
  31252. */
  31253. inputs: CameraInputsManager<Camera>;
  31254. /** @hidden */
  31255. _position: Vector3;
  31256. /**
  31257. * Define the current local position of the camera in the scene
  31258. */
  31259. position: Vector3;
  31260. /**
  31261. * The vector the camera should consider as up.
  31262. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  31263. */
  31264. upVector: Vector3;
  31265. /**
  31266. * Define the current limit on the left side for an orthographic camera
  31267. * In scene unit
  31268. */
  31269. orthoLeft: Nullable<number>;
  31270. /**
  31271. * Define the current limit on the right side for an orthographic camera
  31272. * In scene unit
  31273. */
  31274. orthoRight: Nullable<number>;
  31275. /**
  31276. * Define the current limit on the bottom side for an orthographic camera
  31277. * In scene unit
  31278. */
  31279. orthoBottom: Nullable<number>;
  31280. /**
  31281. * Define the current limit on the top side for an orthographic camera
  31282. * In scene unit
  31283. */
  31284. orthoTop: Nullable<number>;
  31285. /**
  31286. * Field Of View is set in Radians. (default is 0.8)
  31287. */
  31288. fov: number;
  31289. /**
  31290. * Define the minimum distance the camera can see from.
  31291. * This is important to note that the depth buffer are not infinite and the closer it starts
  31292. * the more your scene might encounter depth fighting issue.
  31293. */
  31294. minZ: number;
  31295. /**
  31296. * Define the maximum distance the camera can see to.
  31297. * This is important to note that the depth buffer are not infinite and the further it end
  31298. * the more your scene might encounter depth fighting issue.
  31299. */
  31300. maxZ: number;
  31301. /**
  31302. * Define the default inertia of the camera.
  31303. * This helps giving a smooth feeling to the camera movement.
  31304. */
  31305. inertia: number;
  31306. /**
  31307. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  31308. */
  31309. mode: number;
  31310. /**
  31311. * Define wether the camera is intermediate.
  31312. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  31313. */
  31314. isIntermediate: boolean;
  31315. /**
  31316. * Define the viewport of the camera.
  31317. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  31318. */
  31319. viewport: Viewport;
  31320. /**
  31321. * Restricts the camera to viewing objects with the same layerMask.
  31322. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  31323. */
  31324. layerMask: number;
  31325. /**
  31326. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  31327. */
  31328. fovMode: number;
  31329. /**
  31330. * Rig mode of the camera.
  31331. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  31332. * This is normally controlled byt the camera themselves as internal use.
  31333. */
  31334. cameraRigMode: number;
  31335. /**
  31336. * Defines the distance between both "eyes" in case of a RIG
  31337. */
  31338. interaxialDistance: number;
  31339. /**
  31340. * Defines if stereoscopic rendering is done side by side or over under.
  31341. */
  31342. isStereoscopicSideBySide: boolean;
  31343. /**
  31344. * 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
  31345. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  31346. * else in the scene.
  31347. */
  31348. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  31349. /**
  31350. * When set, the camera will render to this render target instead of the default canvas
  31351. */
  31352. outputRenderTarget: Nullable<RenderTargetTexture>;
  31353. /**
  31354. * Observable triggered when the camera view matrix has changed.
  31355. */
  31356. onViewMatrixChangedObservable: Observable<Camera>;
  31357. /**
  31358. * Observable triggered when the camera Projection matrix has changed.
  31359. */
  31360. onProjectionMatrixChangedObservable: Observable<Camera>;
  31361. /**
  31362. * Observable triggered when the inputs have been processed.
  31363. */
  31364. onAfterCheckInputsObservable: Observable<Camera>;
  31365. /**
  31366. * Observable triggered when reset has been called and applied to the camera.
  31367. */
  31368. onRestoreStateObservable: Observable<Camera>;
  31369. /** @hidden */
  31370. _cameraRigParams: any;
  31371. /** @hidden */
  31372. _rigCameras: Camera[];
  31373. /** @hidden */
  31374. _rigPostProcess: Nullable<PostProcess>;
  31375. protected _webvrViewMatrix: Matrix;
  31376. /** @hidden */
  31377. _skipRendering: boolean;
  31378. /** @hidden */
  31379. _projectionMatrix: Matrix;
  31380. /** @hidden */
  31381. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  31382. /** @hidden */
  31383. _activeMeshes: SmartArray<AbstractMesh>;
  31384. protected _globalPosition: Vector3;
  31385. /** @hidden */
  31386. _computedViewMatrix: Matrix;
  31387. private _doNotComputeProjectionMatrix;
  31388. private _transformMatrix;
  31389. private _frustumPlanes;
  31390. private _refreshFrustumPlanes;
  31391. private _storedFov;
  31392. private _stateStored;
  31393. /**
  31394. * Instantiates a new camera object.
  31395. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31396. * @see http://doc.babylonjs.com/features/cameras
  31397. * @param name Defines the name of the camera in the scene
  31398. * @param position Defines the position of the camera
  31399. * @param scene Defines the scene the camera belongs too
  31400. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31401. */
  31402. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31403. /**
  31404. * Store current camera state (fov, position, etc..)
  31405. * @returns the camera
  31406. */
  31407. storeState(): Camera;
  31408. /**
  31409. * Restores the camera state values if it has been stored. You must call storeState() first
  31410. */
  31411. protected _restoreStateValues(): boolean;
  31412. /**
  31413. * Restored camera state. You must call storeState() first.
  31414. * @returns true if restored and false otherwise
  31415. */
  31416. restoreState(): boolean;
  31417. /**
  31418. * Gets the class name of the camera.
  31419. * @returns the class name
  31420. */
  31421. getClassName(): string;
  31422. /** @hidden */
  31423. readonly _isCamera: boolean;
  31424. /**
  31425. * Gets a string representation of the camera useful for debug purpose.
  31426. * @param fullDetails Defines that a more verboe level of logging is required
  31427. * @returns the string representation
  31428. */
  31429. toString(fullDetails?: boolean): string;
  31430. /**
  31431. * Gets the current world space position of the camera.
  31432. */
  31433. readonly globalPosition: Vector3;
  31434. /**
  31435. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31436. * @returns the active meshe list
  31437. */
  31438. getActiveMeshes(): SmartArray<AbstractMesh>;
  31439. /**
  31440. * Check wether a mesh is part of the current active mesh list of the camera
  31441. * @param mesh Defines the mesh to check
  31442. * @returns true if active, false otherwise
  31443. */
  31444. isActiveMesh(mesh: Mesh): boolean;
  31445. /**
  31446. * Is this camera ready to be used/rendered
  31447. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31448. * @return true if the camera is ready
  31449. */
  31450. isReady(completeCheck?: boolean): boolean;
  31451. /** @hidden */
  31452. _initCache(): void;
  31453. /** @hidden */
  31454. _updateCache(ignoreParentClass?: boolean): void;
  31455. /** @hidden */
  31456. _isSynchronized(): boolean;
  31457. /** @hidden */
  31458. _isSynchronizedViewMatrix(): boolean;
  31459. /** @hidden */
  31460. _isSynchronizedProjectionMatrix(): boolean;
  31461. /**
  31462. * Attach the input controls to a specific dom element to get the input from.
  31463. * @param element Defines the element the controls should be listened from
  31464. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31465. */
  31466. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31467. /**
  31468. * Detach the current controls from the specified dom element.
  31469. * @param element Defines the element to stop listening the inputs from
  31470. */
  31471. detachControl(element: HTMLElement): void;
  31472. /**
  31473. * Update the camera state according to the different inputs gathered during the frame.
  31474. */
  31475. update(): void;
  31476. /** @hidden */
  31477. _checkInputs(): void;
  31478. /** @hidden */
  31479. readonly rigCameras: Camera[];
  31480. /**
  31481. * Gets the post process used by the rig cameras
  31482. */
  31483. readonly rigPostProcess: Nullable<PostProcess>;
  31484. /**
  31485. * Internal, gets the first post proces.
  31486. * @returns the first post process to be run on this camera.
  31487. */
  31488. _getFirstPostProcess(): Nullable<PostProcess>;
  31489. private _cascadePostProcessesToRigCams;
  31490. /**
  31491. * Attach a post process to the camera.
  31492. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31493. * @param postProcess The post process to attach to the camera
  31494. * @param insertAt The position of the post process in case several of them are in use in the scene
  31495. * @returns the position the post process has been inserted at
  31496. */
  31497. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31498. /**
  31499. * Detach a post process to the camera.
  31500. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31501. * @param postProcess The post process to detach from the camera
  31502. */
  31503. detachPostProcess(postProcess: PostProcess): void;
  31504. /**
  31505. * Gets the current world matrix of the camera
  31506. */
  31507. getWorldMatrix(): Matrix;
  31508. /** @hidden */
  31509. _getViewMatrix(): Matrix;
  31510. /**
  31511. * Gets the current view matrix of the camera.
  31512. * @param force forces the camera to recompute the matrix without looking at the cached state
  31513. * @returns the view matrix
  31514. */
  31515. getViewMatrix(force?: boolean): Matrix;
  31516. /**
  31517. * Freeze the projection matrix.
  31518. * It will prevent the cache check of the camera projection compute and can speed up perf
  31519. * if no parameter of the camera are meant to change
  31520. * @param projection Defines manually a projection if necessary
  31521. */
  31522. freezeProjectionMatrix(projection?: Matrix): void;
  31523. /**
  31524. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31525. */
  31526. unfreezeProjectionMatrix(): void;
  31527. /**
  31528. * Gets the current projection matrix of the camera.
  31529. * @param force forces the camera to recompute the matrix without looking at the cached state
  31530. * @returns the projection matrix
  31531. */
  31532. getProjectionMatrix(force?: boolean): Matrix;
  31533. /**
  31534. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31535. * @returns a Matrix
  31536. */
  31537. getTransformationMatrix(): Matrix;
  31538. private _updateFrustumPlanes;
  31539. /**
  31540. * Checks if a cullable object (mesh...) is in the camera frustum
  31541. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31542. * @param target The object to check
  31543. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  31544. * @returns true if the object is in frustum otherwise false
  31545. */
  31546. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  31547. /**
  31548. * Checks if a cullable object (mesh...) is in the camera frustum
  31549. * Unlike isInFrustum this cheks the full bounding box
  31550. * @param target The object to check
  31551. * @returns true if the object is in frustum otherwise false
  31552. */
  31553. isCompletelyInFrustum(target: ICullable): boolean;
  31554. /**
  31555. * Gets a ray in the forward direction from the camera.
  31556. * @param length Defines the length of the ray to create
  31557. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31558. * @param origin Defines the start point of the ray which defaults to the camera position
  31559. * @returns the forward ray
  31560. */
  31561. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31562. /**
  31563. * Releases resources associated with this node.
  31564. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31565. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31566. */
  31567. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31568. /** @hidden */
  31569. _isLeftCamera: boolean;
  31570. /**
  31571. * Gets the left camera of a rig setup in case of Rigged Camera
  31572. */
  31573. readonly isLeftCamera: boolean;
  31574. /** @hidden */
  31575. _isRightCamera: boolean;
  31576. /**
  31577. * Gets the right camera of a rig setup in case of Rigged Camera
  31578. */
  31579. readonly isRightCamera: boolean;
  31580. /**
  31581. * Gets the left camera of a rig setup in case of Rigged Camera
  31582. */
  31583. readonly leftCamera: Nullable<FreeCamera>;
  31584. /**
  31585. * Gets the right camera of a rig setup in case of Rigged Camera
  31586. */
  31587. readonly rightCamera: Nullable<FreeCamera>;
  31588. /**
  31589. * Gets the left camera target of a rig setup in case of Rigged Camera
  31590. * @returns the target position
  31591. */
  31592. getLeftTarget(): Nullable<Vector3>;
  31593. /**
  31594. * Gets the right camera target of a rig setup in case of Rigged Camera
  31595. * @returns the target position
  31596. */
  31597. getRightTarget(): Nullable<Vector3>;
  31598. /**
  31599. * @hidden
  31600. */
  31601. setCameraRigMode(mode: number, rigParams: any): void;
  31602. /** @hidden */
  31603. static _setStereoscopicRigMode(camera: Camera): void;
  31604. /** @hidden */
  31605. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31606. /** @hidden */
  31607. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31608. /** @hidden */
  31609. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31610. /** @hidden */
  31611. _getVRProjectionMatrix(): Matrix;
  31612. protected _updateCameraRotationMatrix(): void;
  31613. protected _updateWebVRCameraRotationMatrix(): void;
  31614. /**
  31615. * This function MUST be overwritten by the different WebVR cameras available.
  31616. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31617. * @hidden
  31618. */
  31619. _getWebVRProjectionMatrix(): Matrix;
  31620. /**
  31621. * This function MUST be overwritten by the different WebVR cameras available.
  31622. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31623. * @hidden
  31624. */
  31625. _getWebVRViewMatrix(): Matrix;
  31626. /** @hidden */
  31627. setCameraRigParameter(name: string, value: any): void;
  31628. /**
  31629. * needs to be overridden by children so sub has required properties to be copied
  31630. * @hidden
  31631. */
  31632. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31633. /**
  31634. * May need to be overridden by children
  31635. * @hidden
  31636. */
  31637. _updateRigCameras(): void;
  31638. /** @hidden */
  31639. _setupInputs(): void;
  31640. /**
  31641. * Serialiaze the camera setup to a json represention
  31642. * @returns the JSON representation
  31643. */
  31644. serialize(): any;
  31645. /**
  31646. * Clones the current camera.
  31647. * @param name The cloned camera name
  31648. * @returns the cloned camera
  31649. */
  31650. clone(name: string): Camera;
  31651. /**
  31652. * Gets the direction of the camera relative to a given local axis.
  31653. * @param localAxis Defines the reference axis to provide a relative direction.
  31654. * @return the direction
  31655. */
  31656. getDirection(localAxis: Vector3): Vector3;
  31657. /**
  31658. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31659. * @param localAxis Defines the reference axis to provide a relative direction.
  31660. * @param result Defines the vector to store the result in
  31661. */
  31662. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31663. /**
  31664. * Gets a camera constructor for a given camera type
  31665. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31666. * @param name The name of the camera the result will be able to instantiate
  31667. * @param scene The scene the result will construct the camera in
  31668. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31669. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31670. * @returns a factory method to construc the camera
  31671. */
  31672. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31673. /**
  31674. * Compute the world matrix of the camera.
  31675. * @returns the camera workd matrix
  31676. */
  31677. computeWorldMatrix(): Matrix;
  31678. /**
  31679. * Parse a JSON and creates the camera from the parsed information
  31680. * @param parsedCamera The JSON to parse
  31681. * @param scene The scene to instantiate the camera in
  31682. * @returns the newly constructed camera
  31683. */
  31684. static Parse(parsedCamera: any, scene: Scene): Camera;
  31685. }
  31686. }
  31687. declare module "babylonjs/Misc/tools" {
  31688. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31689. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31690. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31691. import { Observable } from "babylonjs/Misc/observable";
  31692. import { DomManagement } from "babylonjs/Misc/domManagement";
  31693. import { WebRequest } from "babylonjs/Misc/webRequest";
  31694. import { Camera } from "babylonjs/Cameras/camera";
  31695. import { Engine } from "babylonjs/Engines/engine";
  31696. import { Animation } from "babylonjs/Animations/animation";
  31697. /**
  31698. * Interface for any object that can request an animation frame
  31699. */
  31700. export interface ICustomAnimationFrameRequester {
  31701. /**
  31702. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31703. */
  31704. renderFunction?: Function;
  31705. /**
  31706. * Called to request the next frame to render to
  31707. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31708. */
  31709. requestAnimationFrame: Function;
  31710. /**
  31711. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31712. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31713. */
  31714. requestID?: number;
  31715. }
  31716. /**
  31717. * Interface containing an array of animations
  31718. */
  31719. export interface IAnimatable {
  31720. /**
  31721. * Array of animations
  31722. */
  31723. animations: Nullable<Array<Animation>>;
  31724. }
  31725. /** Interface used by value gradients (color, factor, ...) */
  31726. export interface IValueGradient {
  31727. /**
  31728. * Gets or sets the gradient value (between 0 and 1)
  31729. */
  31730. gradient: number;
  31731. }
  31732. /** Class used to store color4 gradient */
  31733. export class ColorGradient implements IValueGradient {
  31734. /**
  31735. * Gets or sets the gradient value (between 0 and 1)
  31736. */
  31737. gradient: number;
  31738. /**
  31739. * Gets or sets first associated color
  31740. */
  31741. color1: Color4;
  31742. /**
  31743. * Gets or sets second associated color
  31744. */
  31745. color2?: Color4;
  31746. /**
  31747. * Will get a color picked randomly between color1 and color2.
  31748. * If color2 is undefined then color1 will be used
  31749. * @param result defines the target Color4 to store the result in
  31750. */
  31751. getColorToRef(result: Color4): void;
  31752. }
  31753. /** Class used to store color 3 gradient */
  31754. export class Color3Gradient implements IValueGradient {
  31755. /**
  31756. * Gets or sets the gradient value (between 0 and 1)
  31757. */
  31758. gradient: number;
  31759. /**
  31760. * Gets or sets the associated color
  31761. */
  31762. color: Color3;
  31763. }
  31764. /** Class used to store factor gradient */
  31765. export class FactorGradient implements IValueGradient {
  31766. /**
  31767. * Gets or sets the gradient value (between 0 and 1)
  31768. */
  31769. gradient: number;
  31770. /**
  31771. * Gets or sets first associated factor
  31772. */
  31773. factor1: number;
  31774. /**
  31775. * Gets or sets second associated factor
  31776. */
  31777. factor2?: number;
  31778. /**
  31779. * Will get a number picked randomly between factor1 and factor2.
  31780. * If factor2 is undefined then factor1 will be used
  31781. * @returns the picked number
  31782. */
  31783. getFactor(): number;
  31784. }
  31785. /**
  31786. * @ignore
  31787. * Application error to support additional information when loading a file
  31788. */
  31789. export class LoadFileError extends Error {
  31790. /** defines the optional web request */
  31791. request?: WebRequest | undefined;
  31792. private static _setPrototypeOf;
  31793. /**
  31794. * Creates a new LoadFileError
  31795. * @param message defines the message of the error
  31796. * @param request defines the optional web request
  31797. */
  31798. constructor(message: string,
  31799. /** defines the optional web request */
  31800. request?: WebRequest | undefined);
  31801. }
  31802. /**
  31803. * Class used to define a retry strategy when error happens while loading assets
  31804. */
  31805. export class RetryStrategy {
  31806. /**
  31807. * Function used to defines an exponential back off strategy
  31808. * @param maxRetries defines the maximum number of retries (3 by default)
  31809. * @param baseInterval defines the interval between retries
  31810. * @returns the strategy function to use
  31811. */
  31812. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31813. }
  31814. /**
  31815. * File request interface
  31816. */
  31817. export interface IFileRequest {
  31818. /**
  31819. * Raised when the request is complete (success or error).
  31820. */
  31821. onCompleteObservable: Observable<IFileRequest>;
  31822. /**
  31823. * Aborts the request for a file.
  31824. */
  31825. abort: () => void;
  31826. }
  31827. /**
  31828. * Class containing a set of static utilities functions
  31829. */
  31830. export class Tools {
  31831. /**
  31832. * Gets or sets the base URL to use to load assets
  31833. */
  31834. static BaseUrl: string;
  31835. /**
  31836. * Enable/Disable Custom HTTP Request Headers globally.
  31837. * default = false
  31838. * @see CustomRequestHeaders
  31839. */
  31840. static UseCustomRequestHeaders: boolean;
  31841. /**
  31842. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31843. * i.e. when loading files, where the server/service expects an Authorization header
  31844. */
  31845. static CustomRequestHeaders: {
  31846. [key: string]: string;
  31847. };
  31848. /**
  31849. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31850. */
  31851. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31852. /**
  31853. * Default behaviour for cors in the application.
  31854. * It can be a string if the expected behavior is identical in the entire app.
  31855. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31856. */
  31857. static CorsBehavior: string | ((url: string | string[]) => string);
  31858. /**
  31859. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31860. * @ignorenaming
  31861. */
  31862. static UseFallbackTexture: boolean;
  31863. /**
  31864. * Use this object to register external classes like custom textures or material
  31865. * to allow the laoders to instantiate them
  31866. */
  31867. static RegisteredExternalClasses: {
  31868. [key: string]: Object;
  31869. };
  31870. /**
  31871. * Texture content used if a texture cannot loaded
  31872. * @ignorenaming
  31873. */
  31874. static fallbackTexture: string;
  31875. /**
  31876. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31877. * @param u defines the coordinate on X axis
  31878. * @param v defines the coordinate on Y axis
  31879. * @param width defines the width of the source data
  31880. * @param height defines the height of the source data
  31881. * @param pixels defines the source byte array
  31882. * @param color defines the output color
  31883. */
  31884. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31885. /**
  31886. * Interpolates between a and b via alpha
  31887. * @param a The lower value (returned when alpha = 0)
  31888. * @param b The upper value (returned when alpha = 1)
  31889. * @param alpha The interpolation-factor
  31890. * @return The mixed value
  31891. */
  31892. static Mix(a: number, b: number, alpha: number): number;
  31893. /**
  31894. * Tries to instantiate a new object from a given class name
  31895. * @param className defines the class name to instantiate
  31896. * @returns the new object or null if the system was not able to do the instantiation
  31897. */
  31898. static Instantiate(className: string): any;
  31899. /**
  31900. * Provides a slice function that will work even on IE
  31901. * @param data defines the array to slice
  31902. * @param start defines the start of the data (optional)
  31903. * @param end defines the end of the data (optional)
  31904. * @returns the new sliced array
  31905. */
  31906. static Slice<T>(data: T, start?: number, end?: number): T;
  31907. /**
  31908. * Polyfill for setImmediate
  31909. * @param action defines the action to execute after the current execution block
  31910. */
  31911. static SetImmediate(action: () => void): void;
  31912. /**
  31913. * Function indicating if a number is an exponent of 2
  31914. * @param value defines the value to test
  31915. * @returns true if the value is an exponent of 2
  31916. */
  31917. static IsExponentOfTwo(value: number): boolean;
  31918. private static _tmpFloatArray;
  31919. /**
  31920. * Returns the nearest 32-bit single precision float representation of a Number
  31921. * @param value A Number. If the parameter is of a different type, it will get converted
  31922. * to a number or to NaN if it cannot be converted
  31923. * @returns number
  31924. */
  31925. static FloatRound(value: number): number;
  31926. /**
  31927. * Find the next highest power of two.
  31928. * @param x Number to start search from.
  31929. * @return Next highest power of two.
  31930. */
  31931. static CeilingPOT(x: number): number;
  31932. /**
  31933. * Find the next lowest power of two.
  31934. * @param x Number to start search from.
  31935. * @return Next lowest power of two.
  31936. */
  31937. static FloorPOT(x: number): number;
  31938. /**
  31939. * Find the nearest power of two.
  31940. * @param x Number to start search from.
  31941. * @return Next nearest power of two.
  31942. */
  31943. static NearestPOT(x: number): number;
  31944. /**
  31945. * Get the closest exponent of two
  31946. * @param value defines the value to approximate
  31947. * @param max defines the maximum value to return
  31948. * @param mode defines how to define the closest value
  31949. * @returns closest exponent of two of the given value
  31950. */
  31951. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31952. /**
  31953. * Extracts the filename from a path
  31954. * @param path defines the path to use
  31955. * @returns the filename
  31956. */
  31957. static GetFilename(path: string): string;
  31958. /**
  31959. * Extracts the "folder" part of a path (everything before the filename).
  31960. * @param uri The URI to extract the info from
  31961. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31962. * @returns The "folder" part of the path
  31963. */
  31964. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31965. /**
  31966. * Extracts text content from a DOM element hierarchy
  31967. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31968. */
  31969. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31970. /**
  31971. * Convert an angle in radians to degrees
  31972. * @param angle defines the angle to convert
  31973. * @returns the angle in degrees
  31974. */
  31975. static ToDegrees(angle: number): number;
  31976. /**
  31977. * Convert an angle in degrees to radians
  31978. * @param angle defines the angle to convert
  31979. * @returns the angle in radians
  31980. */
  31981. static ToRadians(angle: number): number;
  31982. /**
  31983. * Encode a buffer to a base64 string
  31984. * @param buffer defines the buffer to encode
  31985. * @returns the encoded string
  31986. */
  31987. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31988. /**
  31989. * Extracts minimum and maximum values from a list of indexed positions
  31990. * @param positions defines the positions to use
  31991. * @param indices defines the indices to the positions
  31992. * @param indexStart defines the start index
  31993. * @param indexCount defines the end index
  31994. * @param bias defines bias value to add to the result
  31995. * @return minimum and maximum values
  31996. */
  31997. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31998. minimum: Vector3;
  31999. maximum: Vector3;
  32000. };
  32001. /**
  32002. * Extracts minimum and maximum values from a list of positions
  32003. * @param positions defines the positions to use
  32004. * @param start defines the start index in the positions array
  32005. * @param count defines the number of positions to handle
  32006. * @param bias defines bias value to add to the result
  32007. * @param stride defines the stride size to use (distance between two positions in the positions array)
  32008. * @return minimum and maximum values
  32009. */
  32010. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  32011. minimum: Vector3;
  32012. maximum: Vector3;
  32013. };
  32014. /**
  32015. * Returns an array if obj is not an array
  32016. * @param obj defines the object to evaluate as an array
  32017. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32018. * @returns either obj directly if obj is an array or a new array containing obj
  32019. */
  32020. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32021. /**
  32022. * Gets the pointer prefix to use
  32023. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32024. */
  32025. static GetPointerPrefix(): string;
  32026. /**
  32027. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32028. * @param func - the function to be called
  32029. * @param requester - the object that will request the next frame. Falls back to window.
  32030. * @returns frame number
  32031. */
  32032. static QueueNewFrame(func: () => void, requester?: any): number;
  32033. /**
  32034. * Ask the browser to promote the current element to fullscreen rendering mode
  32035. * @param element defines the DOM element to promote
  32036. */
  32037. static RequestFullscreen(element: HTMLElement): void;
  32038. /**
  32039. * Asks the browser to exit fullscreen mode
  32040. */
  32041. static ExitFullscreen(): void;
  32042. /**
  32043. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32044. * @param url define the url we are trying
  32045. * @param element define the dom element where to configure the cors policy
  32046. */
  32047. static SetCorsBehavior(url: string | string[], element: {
  32048. crossOrigin: string | null;
  32049. }): void;
  32050. /**
  32051. * Removes unwanted characters from an url
  32052. * @param url defines the url to clean
  32053. * @returns the cleaned url
  32054. */
  32055. static CleanUrl(url: string): string;
  32056. /**
  32057. * Gets or sets a function used to pre-process url before using them to load assets
  32058. */
  32059. static PreprocessUrl: (url: string) => string;
  32060. /**
  32061. * Loads an image as an HTMLImageElement.
  32062. * @param input url string, ArrayBuffer, or Blob to load
  32063. * @param onLoad callback called when the image successfully loads
  32064. * @param onError callback called when the image fails to load
  32065. * @param offlineProvider offline provider for caching
  32066. * @returns the HTMLImageElement of the loaded image
  32067. */
  32068. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32069. /**
  32070. * Loads a file
  32071. * @param url url string, ArrayBuffer, or Blob to load
  32072. * @param onSuccess callback called when the file successfully loads
  32073. * @param onProgress callback called while file is loading (if the server supports this mode)
  32074. * @param offlineProvider defines the offline provider for caching
  32075. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32076. * @param onError callback called when the file fails to load
  32077. * @returns a file request object
  32078. */
  32079. 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;
  32080. /**
  32081. * Load a script (identified by an url). When the url returns, the
  32082. * content of this file is added into a new script element, attached to the DOM (body element)
  32083. * @param scriptUrl defines the url of the script to laod
  32084. * @param onSuccess defines the callback called when the script is loaded
  32085. * @param onError defines the callback to call if an error occurs
  32086. * @param scriptId defines the id of the script element
  32087. */
  32088. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32089. /**
  32090. * Load an asynchronous script (identified by an url). When the url returns, the
  32091. * content of this file is added into a new script element, attached to the DOM (body element)
  32092. * @param scriptUrl defines the url of the script to laod
  32093. * @param scriptId defines the id of the script element
  32094. * @returns a promise request object
  32095. */
  32096. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  32097. /**
  32098. * Loads a file from a blob
  32099. * @param fileToLoad defines the blob to use
  32100. * @param callback defines the callback to call when data is loaded
  32101. * @param progressCallback defines the callback to call during loading process
  32102. * @returns a file request object
  32103. */
  32104. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32105. /**
  32106. * Loads a file
  32107. * @param fileToLoad defines the file to load
  32108. * @param callback defines the callback to call when data is loaded
  32109. * @param progressCallBack defines the callback to call during loading process
  32110. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32111. * @returns a file request object
  32112. */
  32113. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32114. /**
  32115. * Creates a data url from a given string content
  32116. * @param content defines the content to convert
  32117. * @returns the new data url link
  32118. */
  32119. static FileAsURL(content: string): string;
  32120. /**
  32121. * Format the given number to a specific decimal format
  32122. * @param value defines the number to format
  32123. * @param decimals defines the number of decimals to use
  32124. * @returns the formatted string
  32125. */
  32126. static Format(value: number, decimals?: number): string;
  32127. /**
  32128. * Checks if a given vector is inside a specific range
  32129. * @param v defines the vector to test
  32130. * @param min defines the minimum range
  32131. * @param max defines the maximum range
  32132. */
  32133. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  32134. /**
  32135. * Tries to copy an object by duplicating every property
  32136. * @param source defines the source object
  32137. * @param destination defines the target object
  32138. * @param doNotCopyList defines a list of properties to avoid
  32139. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32140. */
  32141. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32142. /**
  32143. * Gets a boolean indicating if the given object has no own property
  32144. * @param obj defines the object to test
  32145. * @returns true if object has no own property
  32146. */
  32147. static IsEmpty(obj: any): boolean;
  32148. /**
  32149. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  32150. * @param str Source string
  32151. * @param suffix Suffix to search for in the source string
  32152. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  32153. */
  32154. static EndsWith(str: string, suffix: string): boolean;
  32155. /**
  32156. * Function used to register events at window level
  32157. * @param events defines the events to register
  32158. */
  32159. static RegisterTopRootEvents(events: {
  32160. name: string;
  32161. handler: Nullable<(e: FocusEvent) => any>;
  32162. }[]): void;
  32163. /**
  32164. * Function used to unregister events from window level
  32165. * @param events defines the events to unregister
  32166. */
  32167. static UnregisterTopRootEvents(events: {
  32168. name: string;
  32169. handler: Nullable<(e: FocusEvent) => any>;
  32170. }[]): void;
  32171. /**
  32172. * @ignore
  32173. */
  32174. static _ScreenshotCanvas: HTMLCanvasElement;
  32175. /**
  32176. * Dumps the current bound framebuffer
  32177. * @param width defines the rendering width
  32178. * @param height defines the rendering height
  32179. * @param engine defines the hosting engine
  32180. * @param successCallback defines the callback triggered once the data are available
  32181. * @param mimeType defines the mime type of the result
  32182. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32183. */
  32184. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32185. /**
  32186. * Converts the canvas data to blob.
  32187. * This acts as a polyfill for browsers not supporting the to blob function.
  32188. * @param canvas Defines the canvas to extract the data from
  32189. * @param successCallback Defines the callback triggered once the data are available
  32190. * @param mimeType Defines the mime type of the result
  32191. */
  32192. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32193. /**
  32194. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32195. * @param successCallback defines the callback triggered once the data are available
  32196. * @param mimeType defines the mime type of the result
  32197. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32198. */
  32199. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32200. /**
  32201. * Downloads a blob in the browser
  32202. * @param blob defines the blob to download
  32203. * @param fileName defines the name of the downloaded file
  32204. */
  32205. static Download(blob: Blob, fileName: string): void;
  32206. /**
  32207. * Captures a screenshot of the current rendering
  32208. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32209. * @param engine defines the rendering engine
  32210. * @param camera defines the source camera
  32211. * @param size This parameter can be set to a single number or to an object with the
  32212. * following (optional) properties: precision, width, height. If a single number is passed,
  32213. * it will be used for both width and height. If an object is passed, the screenshot size
  32214. * will be derived from the parameters. The precision property is a multiplier allowing
  32215. * rendering at a higher or lower resolution
  32216. * @param successCallback defines the callback receives a single parameter which contains the
  32217. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32218. * src parameter of an <img> to display it
  32219. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32220. * Check your browser for supported MIME types
  32221. */
  32222. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  32223. /**
  32224. * Generates an image screenshot from the specified camera.
  32225. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32226. * @param engine The engine to use for rendering
  32227. * @param camera The camera to use for rendering
  32228. * @param size This parameter can be set to a single number or to an object with the
  32229. * following (optional) properties: precision, width, height. If a single number is passed,
  32230. * it will be used for both width and height. If an object is passed, the screenshot size
  32231. * will be derived from the parameters. The precision property is a multiplier allowing
  32232. * rendering at a higher or lower resolution
  32233. * @param successCallback The callback receives a single parameter which contains the
  32234. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32235. * src parameter of an <img> to display it
  32236. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32237. * Check your browser for supported MIME types
  32238. * @param samples Texture samples (default: 1)
  32239. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32240. * @param fileName A name for for the downloaded file.
  32241. */
  32242. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32243. /**
  32244. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32245. * Be aware Math.random() could cause collisions, but:
  32246. * "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"
  32247. * @returns a pseudo random id
  32248. */
  32249. static RandomId(): string;
  32250. /**
  32251. * Test if the given uri is a base64 string
  32252. * @param uri The uri to test
  32253. * @return True if the uri is a base64 string or false otherwise
  32254. */
  32255. static IsBase64(uri: string): boolean;
  32256. /**
  32257. * Decode the given base64 uri.
  32258. * @param uri The uri to decode
  32259. * @return The decoded base64 data.
  32260. */
  32261. static DecodeBase64(uri: string): ArrayBuffer;
  32262. /**
  32263. * Gets the absolute url.
  32264. * @param url the input url
  32265. * @return the absolute url
  32266. */
  32267. static GetAbsoluteUrl(url: string): string;
  32268. /**
  32269. * No log
  32270. */
  32271. static readonly NoneLogLevel: number;
  32272. /**
  32273. * Only message logs
  32274. */
  32275. static readonly MessageLogLevel: number;
  32276. /**
  32277. * Only warning logs
  32278. */
  32279. static readonly WarningLogLevel: number;
  32280. /**
  32281. * Only error logs
  32282. */
  32283. static readonly ErrorLogLevel: number;
  32284. /**
  32285. * All logs
  32286. */
  32287. static readonly AllLogLevel: number;
  32288. /**
  32289. * Gets a value indicating the number of loading errors
  32290. * @ignorenaming
  32291. */
  32292. static readonly errorsCount: number;
  32293. /**
  32294. * Callback called when a new log is added
  32295. */
  32296. static OnNewCacheEntry: (entry: string) => void;
  32297. /**
  32298. * Log a message to the console
  32299. * @param message defines the message to log
  32300. */
  32301. static Log(message: string): void;
  32302. /**
  32303. * Write a warning message to the console
  32304. * @param message defines the message to log
  32305. */
  32306. static Warn(message: string): void;
  32307. /**
  32308. * Write an error message to the console
  32309. * @param message defines the message to log
  32310. */
  32311. static Error(message: string): void;
  32312. /**
  32313. * Gets current log cache (list of logs)
  32314. */
  32315. static readonly LogCache: string;
  32316. /**
  32317. * Clears the log cache
  32318. */
  32319. static ClearLogCache(): void;
  32320. /**
  32321. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32322. */
  32323. static LogLevels: number;
  32324. /**
  32325. * Checks if the loaded document was accessed via `file:`-Protocol.
  32326. * @returns boolean
  32327. */
  32328. static IsFileURL(): boolean;
  32329. /**
  32330. * Checks if the window object exists
  32331. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32332. */
  32333. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32334. /**
  32335. * No performance log
  32336. */
  32337. static readonly PerformanceNoneLogLevel: number;
  32338. /**
  32339. * Use user marks to log performance
  32340. */
  32341. static readonly PerformanceUserMarkLogLevel: number;
  32342. /**
  32343. * Log performance to the console
  32344. */
  32345. static readonly PerformanceConsoleLogLevel: number;
  32346. private static _performance;
  32347. /**
  32348. * Sets the current performance log level
  32349. */
  32350. static PerformanceLogLevel: number;
  32351. private static _StartPerformanceCounterDisabled;
  32352. private static _EndPerformanceCounterDisabled;
  32353. private static _StartUserMark;
  32354. private static _EndUserMark;
  32355. private static _StartPerformanceConsole;
  32356. private static _EndPerformanceConsole;
  32357. /**
  32358. * Starts a performance counter
  32359. */
  32360. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32361. /**
  32362. * Ends a specific performance coutner
  32363. */
  32364. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32365. /**
  32366. * Gets either window.performance.now() if supported or Date.now() else
  32367. */
  32368. static readonly Now: number;
  32369. /**
  32370. * This method will return the name of the class used to create the instance of the given object.
  32371. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32372. * @param object the object to get the class name from
  32373. * @param isType defines if the object is actually a type
  32374. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32375. */
  32376. static GetClassName(object: any, isType?: boolean): string;
  32377. /**
  32378. * Gets the first element of an array satisfying a given predicate
  32379. * @param array defines the array to browse
  32380. * @param predicate defines the predicate to use
  32381. * @returns null if not found or the element
  32382. */
  32383. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32384. /**
  32385. * This method will return the name of the full name of the class, including its owning module (if any).
  32386. * 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).
  32387. * @param object the object to get the class name from
  32388. * @param isType defines if the object is actually a type
  32389. * @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.
  32390. * @ignorenaming
  32391. */
  32392. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32393. /**
  32394. * Returns a promise that resolves after the given amount of time.
  32395. * @param delay Number of milliseconds to delay
  32396. * @returns Promise that resolves after the given amount of time
  32397. */
  32398. static DelayAsync(delay: number): Promise<void>;
  32399. /**
  32400. * Gets the current gradient from an array of IValueGradient
  32401. * @param ratio defines the current ratio to get
  32402. * @param gradients defines the array of IValueGradient
  32403. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32404. */
  32405. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32406. }
  32407. /**
  32408. * This class is used to track a performance counter which is number based.
  32409. * The user has access to many properties which give statistics of different nature.
  32410. *
  32411. * The implementer can track two kinds of Performance Counter: time and count.
  32412. * 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.
  32413. * 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.
  32414. */
  32415. export class PerfCounter {
  32416. /**
  32417. * Gets or sets a global boolean to turn on and off all the counters
  32418. */
  32419. static Enabled: boolean;
  32420. /**
  32421. * Returns the smallest value ever
  32422. */
  32423. readonly min: number;
  32424. /**
  32425. * Returns the biggest value ever
  32426. */
  32427. readonly max: number;
  32428. /**
  32429. * Returns the average value since the performance counter is running
  32430. */
  32431. readonly average: number;
  32432. /**
  32433. * Returns the average value of the last second the counter was monitored
  32434. */
  32435. readonly lastSecAverage: number;
  32436. /**
  32437. * Returns the current value
  32438. */
  32439. readonly current: number;
  32440. /**
  32441. * Gets the accumulated total
  32442. */
  32443. readonly total: number;
  32444. /**
  32445. * Gets the total value count
  32446. */
  32447. readonly count: number;
  32448. /**
  32449. * Creates a new counter
  32450. */
  32451. constructor();
  32452. /**
  32453. * Call this method to start monitoring a new frame.
  32454. * 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.
  32455. */
  32456. fetchNewFrame(): void;
  32457. /**
  32458. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32459. * @param newCount the count value to add to the monitored count
  32460. * @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.
  32461. */
  32462. addCount(newCount: number, fetchResult: boolean): void;
  32463. /**
  32464. * Start monitoring this performance counter
  32465. */
  32466. beginMonitoring(): void;
  32467. /**
  32468. * Compute the time lapsed since the previous beginMonitoring() call.
  32469. * @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
  32470. */
  32471. endMonitoring(newFrame?: boolean): void;
  32472. private _fetchResult;
  32473. private _startMonitoringTime;
  32474. private _min;
  32475. private _max;
  32476. private _average;
  32477. private _current;
  32478. private _totalValueCount;
  32479. private _totalAccumulated;
  32480. private _lastSecAverage;
  32481. private _lastSecAccumulated;
  32482. private _lastSecTime;
  32483. private _lastSecValueCount;
  32484. }
  32485. /**
  32486. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32487. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32488. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32489. * @param name The name of the class, case should be preserved
  32490. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32491. */
  32492. export function className(name: string, module?: string): (target: Object) => void;
  32493. /**
  32494. * An implementation of a loop for asynchronous functions.
  32495. */
  32496. export class AsyncLoop {
  32497. /**
  32498. * Defines the number of iterations for the loop
  32499. */
  32500. iterations: number;
  32501. /**
  32502. * Defines the current index of the loop.
  32503. */
  32504. index: number;
  32505. private _done;
  32506. private _fn;
  32507. private _successCallback;
  32508. /**
  32509. * Constructor.
  32510. * @param iterations the number of iterations.
  32511. * @param func the function to run each iteration
  32512. * @param successCallback the callback that will be called upon succesful execution
  32513. * @param offset starting offset.
  32514. */
  32515. constructor(
  32516. /**
  32517. * Defines the number of iterations for the loop
  32518. */
  32519. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32520. /**
  32521. * Execute the next iteration. Must be called after the last iteration was finished.
  32522. */
  32523. executeNext(): void;
  32524. /**
  32525. * Break the loop and run the success callback.
  32526. */
  32527. breakLoop(): void;
  32528. /**
  32529. * Create and run an async loop.
  32530. * @param iterations the number of iterations.
  32531. * @param fn the function to run each iteration
  32532. * @param successCallback the callback that will be called upon succesful execution
  32533. * @param offset starting offset.
  32534. * @returns the created async loop object
  32535. */
  32536. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32537. /**
  32538. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32539. * @param iterations total number of iterations
  32540. * @param syncedIterations number of synchronous iterations in each async iteration.
  32541. * @param fn the function to call each iteration.
  32542. * @param callback a success call back that will be called when iterating stops.
  32543. * @param breakFunction a break condition (optional)
  32544. * @param timeout timeout settings for the setTimeout function. default - 0.
  32545. * @returns the created async loop object
  32546. */
  32547. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32548. }
  32549. }
  32550. declare module "babylonjs/Collisions/collisionCoordinator" {
  32551. import { Nullable } from "babylonjs/types";
  32552. import { Scene } from "babylonjs/scene";
  32553. import { Vector3 } from "babylonjs/Maths/math";
  32554. import { Collider } from "babylonjs/Collisions/collider";
  32555. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32556. /** @hidden */
  32557. export interface ICollisionCoordinator {
  32558. createCollider(): Collider;
  32559. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32560. init(scene: Scene): void;
  32561. }
  32562. /** @hidden */
  32563. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32564. private _scene;
  32565. private _scaledPosition;
  32566. private _scaledVelocity;
  32567. private _finalPosition;
  32568. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32569. createCollider(): Collider;
  32570. init(scene: Scene): void;
  32571. private _collideWithWorld;
  32572. }
  32573. }
  32574. declare module "babylonjs/Inputs/scene.inputManager" {
  32575. import { Nullable } from "babylonjs/types";
  32576. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32577. import { Vector2 } from "babylonjs/Maths/math";
  32578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32579. import { Scene } from "babylonjs/scene";
  32580. /**
  32581. * Class used to manage all inputs for the scene.
  32582. */
  32583. export class InputManager {
  32584. /** The distance in pixel that you have to move to prevent some events */
  32585. static DragMovementThreshold: number;
  32586. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32587. static LongPressDelay: number;
  32588. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32589. static DoubleClickDelay: number;
  32590. /** If you need to check double click without raising a single click at first click, enable this flag */
  32591. static ExclusiveDoubleClickMode: boolean;
  32592. private _wheelEventName;
  32593. private _onPointerMove;
  32594. private _onPointerDown;
  32595. private _onPointerUp;
  32596. private _initClickEvent;
  32597. private _initActionManager;
  32598. private _delayedSimpleClick;
  32599. private _delayedSimpleClickTimeout;
  32600. private _previousDelayedSimpleClickTimeout;
  32601. private _meshPickProceed;
  32602. private _previousButtonPressed;
  32603. private _currentPickResult;
  32604. private _previousPickResult;
  32605. private _totalPointersPressed;
  32606. private _doubleClickOccured;
  32607. private _pointerOverMesh;
  32608. private _pickedDownMesh;
  32609. private _pickedUpMesh;
  32610. private _pointerX;
  32611. private _pointerY;
  32612. private _unTranslatedPointerX;
  32613. private _unTranslatedPointerY;
  32614. private _startingPointerPosition;
  32615. private _previousStartingPointerPosition;
  32616. private _startingPointerTime;
  32617. private _previousStartingPointerTime;
  32618. private _pointerCaptures;
  32619. private _onKeyDown;
  32620. private _onKeyUp;
  32621. private _onCanvasFocusObserver;
  32622. private _onCanvasBlurObserver;
  32623. private _scene;
  32624. /**
  32625. * Creates a new InputManager
  32626. * @param scene defines the hosting scene
  32627. */
  32628. constructor(scene: Scene);
  32629. /**
  32630. * Gets the mesh that is currently under the pointer
  32631. */
  32632. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32633. /**
  32634. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32635. */
  32636. readonly unTranslatedPointer: Vector2;
  32637. /**
  32638. * Gets or sets the current on-screen X position of the pointer
  32639. */
  32640. pointerX: number;
  32641. /**
  32642. * Gets or sets the current on-screen Y position of the pointer
  32643. */
  32644. pointerY: number;
  32645. private _updatePointerPosition;
  32646. private _processPointerMove;
  32647. private _setRayOnPointerInfo;
  32648. private _checkPrePointerObservable;
  32649. /**
  32650. * Use this method to simulate a pointer move on a mesh
  32651. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32652. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32653. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32654. */
  32655. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32656. /**
  32657. * Use this method to simulate a pointer down on a mesh
  32658. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32659. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32660. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32661. */
  32662. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32663. private _processPointerDown;
  32664. /** @hidden */
  32665. _isPointerSwiping(): boolean;
  32666. /**
  32667. * Use this method to simulate a pointer up on a mesh
  32668. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32669. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32670. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32671. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32672. */
  32673. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32674. private _processPointerUp;
  32675. /**
  32676. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32677. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32678. * @returns true if the pointer was captured
  32679. */
  32680. isPointerCaptured(pointerId?: number): boolean;
  32681. /**
  32682. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32683. * @param attachUp defines if you want to attach events to pointerup
  32684. * @param attachDown defines if you want to attach events to pointerdown
  32685. * @param attachMove defines if you want to attach events to pointermove
  32686. */
  32687. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32688. /**
  32689. * Detaches all event handlers
  32690. */
  32691. detachControl(): void;
  32692. /**
  32693. * Force the value of meshUnderPointer
  32694. * @param mesh defines the mesh to use
  32695. */
  32696. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32697. /**
  32698. * Gets the mesh under the pointer
  32699. * @returns a Mesh or null if no mesh is under the pointer
  32700. */
  32701. getPointerOverMesh(): Nullable<AbstractMesh>;
  32702. }
  32703. }
  32704. declare module "babylonjs/Animations/animationGroup" {
  32705. import { Animatable } from "babylonjs/Animations/animatable";
  32706. import { Animation } from "babylonjs/Animations/animation";
  32707. import { Scene, IDisposable } from "babylonjs/scene";
  32708. import { Observable } from "babylonjs/Misc/observable";
  32709. import { Nullable } from "babylonjs/types";
  32710. import "babylonjs/Animations/animatable";
  32711. /**
  32712. * This class defines the direct association between an animation and a target
  32713. */
  32714. export class TargetedAnimation {
  32715. /**
  32716. * Animation to perform
  32717. */
  32718. animation: Animation;
  32719. /**
  32720. * Target to animate
  32721. */
  32722. target: any;
  32723. /**
  32724. * Serialize the object
  32725. * @returns the JSON object representing the current entity
  32726. */
  32727. serialize(): any;
  32728. }
  32729. /**
  32730. * Use this class to create coordinated animations on multiple targets
  32731. */
  32732. export class AnimationGroup implements IDisposable {
  32733. /** The name of the animation group */
  32734. name: string;
  32735. private _scene;
  32736. private _targetedAnimations;
  32737. private _animatables;
  32738. private _from;
  32739. private _to;
  32740. private _isStarted;
  32741. private _isPaused;
  32742. private _speedRatio;
  32743. private _loopAnimation;
  32744. /**
  32745. * Gets or sets the unique id of the node
  32746. */
  32747. uniqueId: number;
  32748. /**
  32749. * This observable will notify when one animation have ended
  32750. */
  32751. onAnimationEndObservable: Observable<TargetedAnimation>;
  32752. /**
  32753. * Observer raised when one animation loops
  32754. */
  32755. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32756. /**
  32757. * This observable will notify when all animations have ended.
  32758. */
  32759. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32760. /**
  32761. * This observable will notify when all animations have paused.
  32762. */
  32763. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32764. /**
  32765. * This observable will notify when all animations are playing.
  32766. */
  32767. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32768. /**
  32769. * Gets the first frame
  32770. */
  32771. readonly from: number;
  32772. /**
  32773. * Gets the last frame
  32774. */
  32775. readonly to: number;
  32776. /**
  32777. * Define if the animations are started
  32778. */
  32779. readonly isStarted: boolean;
  32780. /**
  32781. * Gets a value indicating that the current group is playing
  32782. */
  32783. readonly isPlaying: boolean;
  32784. /**
  32785. * Gets or sets the speed ratio to use for all animations
  32786. */
  32787. /**
  32788. * Gets or sets the speed ratio to use for all animations
  32789. */
  32790. speedRatio: number;
  32791. /**
  32792. * Gets or sets if all animations should loop or not
  32793. */
  32794. loopAnimation: boolean;
  32795. /**
  32796. * Gets the targeted animations for this animation group
  32797. */
  32798. readonly targetedAnimations: Array<TargetedAnimation>;
  32799. /**
  32800. * returning the list of animatables controlled by this animation group.
  32801. */
  32802. readonly animatables: Array<Animatable>;
  32803. /**
  32804. * Instantiates a new Animation Group.
  32805. * This helps managing several animations at once.
  32806. * @see http://doc.babylonjs.com/how_to/group
  32807. * @param name Defines the name of the group
  32808. * @param scene Defines the scene the group belongs to
  32809. */
  32810. constructor(
  32811. /** The name of the animation group */
  32812. name: string, scene?: Nullable<Scene>);
  32813. /**
  32814. * Add an animation (with its target) in the group
  32815. * @param animation defines the animation we want to add
  32816. * @param target defines the target of the animation
  32817. * @returns the TargetedAnimation object
  32818. */
  32819. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32820. /**
  32821. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32822. * It can add constant keys at begin or end
  32823. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32824. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32825. * @returns the animation group
  32826. */
  32827. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32828. /**
  32829. * Start all animations on given targets
  32830. * @param loop defines if animations must loop
  32831. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32832. * @param from defines the from key (optional)
  32833. * @param to defines the to key (optional)
  32834. * @returns the current animation group
  32835. */
  32836. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32837. /**
  32838. * Pause all animations
  32839. * @returns the animation group
  32840. */
  32841. pause(): AnimationGroup;
  32842. /**
  32843. * Play all animations to initial state
  32844. * This function will start() the animations if they were not started or will restart() them if they were paused
  32845. * @param loop defines if animations must loop
  32846. * @returns the animation group
  32847. */
  32848. play(loop?: boolean): AnimationGroup;
  32849. /**
  32850. * Reset all animations to initial state
  32851. * @returns the animation group
  32852. */
  32853. reset(): AnimationGroup;
  32854. /**
  32855. * Restart animations from key 0
  32856. * @returns the animation group
  32857. */
  32858. restart(): AnimationGroup;
  32859. /**
  32860. * Stop all animations
  32861. * @returns the animation group
  32862. */
  32863. stop(): AnimationGroup;
  32864. /**
  32865. * Set animation weight for all animatables
  32866. * @param weight defines the weight to use
  32867. * @return the animationGroup
  32868. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32869. */
  32870. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32871. /**
  32872. * Synchronize and normalize all animatables with a source animatable
  32873. * @param root defines the root animatable to synchronize with
  32874. * @return the animationGroup
  32875. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32876. */
  32877. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32878. /**
  32879. * Goes to a specific frame in this animation group
  32880. * @param frame the frame number to go to
  32881. * @return the animationGroup
  32882. */
  32883. goToFrame(frame: number): AnimationGroup;
  32884. /**
  32885. * Dispose all associated resources
  32886. */
  32887. dispose(): void;
  32888. private _checkAnimationGroupEnded;
  32889. /**
  32890. * Clone the current animation group and returns a copy
  32891. * @param newName defines the name of the new group
  32892. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32893. * @returns the new aniamtion group
  32894. */
  32895. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32896. /**
  32897. * Serializes the animationGroup to an object
  32898. * @returns Serialized object
  32899. */
  32900. serialize(): any;
  32901. /**
  32902. * Returns a new AnimationGroup object parsed from the source provided.
  32903. * @param parsedAnimationGroup defines the source
  32904. * @param scene defines the scene that will receive the animationGroup
  32905. * @returns a new AnimationGroup
  32906. */
  32907. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32908. /**
  32909. * Returns the string "AnimationGroup"
  32910. * @returns "AnimationGroup"
  32911. */
  32912. getClassName(): string;
  32913. /**
  32914. * Creates a detailled string about the object
  32915. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32916. * @returns a string representing the object
  32917. */
  32918. toString(fullDetails?: boolean): string;
  32919. }
  32920. }
  32921. declare module "babylonjs/scene" {
  32922. import { Nullable } from "babylonjs/types";
  32923. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32924. import { Observable } from "babylonjs/Misc/observable";
  32925. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32926. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32927. import { Geometry } from "babylonjs/Meshes/geometry";
  32928. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32929. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32930. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32931. import { Mesh } from "babylonjs/Meshes/mesh";
  32932. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32933. import { Bone } from "babylonjs/Bones/bone";
  32934. import { Skeleton } from "babylonjs/Bones/skeleton";
  32935. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32936. import { Camera } from "babylonjs/Cameras/camera";
  32937. import { AbstractScene } from "babylonjs/abstractScene";
  32938. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32939. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32940. import { Material } from "babylonjs/Materials/material";
  32941. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32942. import { Effect } from "babylonjs/Materials/effect";
  32943. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32944. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32945. import { Light } from "babylonjs/Lights/light";
  32946. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32947. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  32948. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  32949. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  32950. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32951. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  32952. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32953. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  32954. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  32955. import { Engine } from "babylonjs/Engines/engine";
  32956. import { Node } from "babylonjs/node";
  32957. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32958. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32959. import { WebRequest } from "babylonjs/Misc/webRequest";
  32960. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  32961. import { Ray } from "babylonjs/Culling/ray";
  32962. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32963. import { Animation } from "babylonjs/Animations/animation";
  32964. import { Animatable } from "babylonjs/Animations/animatable";
  32965. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  32966. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32967. import { Collider } from "babylonjs/Collisions/collider";
  32968. /**
  32969. * Define an interface for all classes that will hold resources
  32970. */
  32971. export interface IDisposable {
  32972. /**
  32973. * Releases all held resources
  32974. */
  32975. dispose(): void;
  32976. }
  32977. /** Interface defining initialization parameters for Scene class */
  32978. export interface SceneOptions {
  32979. /**
  32980. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32981. * It will improve performance when the number of geometries becomes important.
  32982. */
  32983. useGeometryUniqueIdsMap?: boolean;
  32984. /**
  32985. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32986. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32987. */
  32988. useMaterialMeshMap?: boolean;
  32989. /**
  32990. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32991. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32992. */
  32993. useClonedMeshhMap?: boolean;
  32994. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32995. virtual?: boolean;
  32996. }
  32997. /**
  32998. * Represents a scene to be rendered by the engine.
  32999. * @see http://doc.babylonjs.com/features/scene
  33000. */
  33001. export class Scene extends AbstractScene implements IAnimatable {
  33002. private static _uniqueIdCounter;
  33003. /** The fog is deactivated */
  33004. static readonly FOGMODE_NONE: number;
  33005. /** The fog density is following an exponential function */
  33006. static readonly FOGMODE_EXP: number;
  33007. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33008. static readonly FOGMODE_EXP2: number;
  33009. /** The fog density is following a linear function. */
  33010. static readonly FOGMODE_LINEAR: number;
  33011. /**
  33012. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33013. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33014. */
  33015. static MinDeltaTime: number;
  33016. /**
  33017. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33018. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33019. */
  33020. static MaxDeltaTime: number;
  33021. /**
  33022. * Factory used to create the default material.
  33023. * @param name The name of the material to create
  33024. * @param scene The scene to create the material for
  33025. * @returns The default material
  33026. */
  33027. static DefaultMaterialFactory(scene: Scene): Material;
  33028. /**
  33029. * Factory used to create the a collision coordinator.
  33030. * @returns The collision coordinator
  33031. */
  33032. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33033. /** @hidden */
  33034. _inputManager: InputManager;
  33035. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33036. cameraToUseForPointers: Nullable<Camera>;
  33037. /** @hidden */
  33038. readonly _isScene: boolean;
  33039. /**
  33040. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33041. */
  33042. autoClear: boolean;
  33043. /**
  33044. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33045. */
  33046. autoClearDepthAndStencil: boolean;
  33047. /**
  33048. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33049. */
  33050. clearColor: Color4;
  33051. /**
  33052. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33053. */
  33054. ambientColor: Color3;
  33055. /**
  33056. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33057. * It should only be one of the following (if not the default embedded one):
  33058. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33059. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33060. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33061. * The material properties need to be setup according to the type of texture in use.
  33062. */
  33063. environmentBRDFTexture: BaseTexture;
  33064. /** @hidden */
  33065. protected _environmentTexture: Nullable<BaseTexture>;
  33066. /**
  33067. * Texture used in all pbr material as the reflection texture.
  33068. * As in the majority of the scene they are the same (exception for multi room and so on),
  33069. * this is easier to reference from here than from all the materials.
  33070. */
  33071. /**
  33072. * Texture used in all pbr material as the reflection texture.
  33073. * As in the majority of the scene they are the same (exception for multi room and so on),
  33074. * this is easier to set here than in all the materials.
  33075. */
  33076. environmentTexture: Nullable<BaseTexture>;
  33077. /** @hidden */
  33078. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33079. /**
  33080. * Default image processing configuration used either in the rendering
  33081. * Forward main pass or through the imageProcessingPostProcess if present.
  33082. * As in the majority of the scene they are the same (exception for multi camera),
  33083. * this is easier to reference from here than from all the materials and post process.
  33084. *
  33085. * No setter as we it is a shared configuration, you can set the values instead.
  33086. */
  33087. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33088. private _forceWireframe;
  33089. /**
  33090. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33091. */
  33092. forceWireframe: boolean;
  33093. private _forcePointsCloud;
  33094. /**
  33095. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33096. */
  33097. forcePointsCloud: boolean;
  33098. /**
  33099. * Gets or sets the active clipplane 1
  33100. */
  33101. clipPlane: Nullable<Plane>;
  33102. /**
  33103. * Gets or sets the active clipplane 2
  33104. */
  33105. clipPlane2: Nullable<Plane>;
  33106. /**
  33107. * Gets or sets the active clipplane 3
  33108. */
  33109. clipPlane3: Nullable<Plane>;
  33110. /**
  33111. * Gets or sets the active clipplane 4
  33112. */
  33113. clipPlane4: Nullable<Plane>;
  33114. /**
  33115. * Gets or sets a boolean indicating if animations are enabled
  33116. */
  33117. animationsEnabled: boolean;
  33118. private _animationPropertiesOverride;
  33119. /**
  33120. * Gets or sets the animation properties override
  33121. */
  33122. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33123. /**
  33124. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33125. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33126. */
  33127. useConstantAnimationDeltaTime: boolean;
  33128. /**
  33129. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33130. * Please note that it requires to run a ray cast through the scene on every frame
  33131. */
  33132. constantlyUpdateMeshUnderPointer: boolean;
  33133. /**
  33134. * Defines the HTML cursor to use when hovering over interactive elements
  33135. */
  33136. hoverCursor: string;
  33137. /**
  33138. * Defines the HTML default cursor to use (empty by default)
  33139. */
  33140. defaultCursor: string;
  33141. /**
  33142. * This is used to call preventDefault() on pointer down
  33143. * in order to block unwanted artifacts like system double clicks
  33144. */
  33145. preventDefaultOnPointerDown: boolean;
  33146. /**
  33147. * This is used to call preventDefault() on pointer up
  33148. * in order to block unwanted artifacts like system double clicks
  33149. */
  33150. preventDefaultOnPointerUp: boolean;
  33151. /**
  33152. * Gets or sets user defined metadata
  33153. */
  33154. metadata: any;
  33155. /**
  33156. * For internal use only. Please do not use.
  33157. */
  33158. reservedDataStore: any;
  33159. /**
  33160. * Gets the name of the plugin used to load this scene (null by default)
  33161. */
  33162. loadingPluginName: string;
  33163. /**
  33164. * Use this array to add regular expressions used to disable offline support for specific urls
  33165. */
  33166. disableOfflineSupportExceptionRules: RegExp[];
  33167. /**
  33168. * An event triggered when the scene is disposed.
  33169. */
  33170. onDisposeObservable: Observable<Scene>;
  33171. private _onDisposeObserver;
  33172. /** Sets a function to be executed when this scene is disposed. */
  33173. onDispose: () => void;
  33174. /**
  33175. * An event triggered before rendering the scene (right after animations and physics)
  33176. */
  33177. onBeforeRenderObservable: Observable<Scene>;
  33178. private _onBeforeRenderObserver;
  33179. /** Sets a function to be executed before rendering this scene */
  33180. beforeRender: Nullable<() => void>;
  33181. /**
  33182. * An event triggered after rendering the scene
  33183. */
  33184. onAfterRenderObservable: Observable<Scene>;
  33185. private _onAfterRenderObserver;
  33186. /** Sets a function to be executed after rendering this scene */
  33187. afterRender: Nullable<() => void>;
  33188. /**
  33189. * An event triggered before animating the scene
  33190. */
  33191. onBeforeAnimationsObservable: Observable<Scene>;
  33192. /**
  33193. * An event triggered after animations processing
  33194. */
  33195. onAfterAnimationsObservable: Observable<Scene>;
  33196. /**
  33197. * An event triggered before draw calls are ready to be sent
  33198. */
  33199. onBeforeDrawPhaseObservable: Observable<Scene>;
  33200. /**
  33201. * An event triggered after draw calls have been sent
  33202. */
  33203. onAfterDrawPhaseObservable: Observable<Scene>;
  33204. /**
  33205. * An event triggered when the scene is ready
  33206. */
  33207. onReadyObservable: Observable<Scene>;
  33208. /**
  33209. * An event triggered before rendering a camera
  33210. */
  33211. onBeforeCameraRenderObservable: Observable<Camera>;
  33212. private _onBeforeCameraRenderObserver;
  33213. /** Sets a function to be executed before rendering a camera*/
  33214. beforeCameraRender: () => void;
  33215. /**
  33216. * An event triggered after rendering a camera
  33217. */
  33218. onAfterCameraRenderObservable: Observable<Camera>;
  33219. private _onAfterCameraRenderObserver;
  33220. /** Sets a function to be executed after rendering a camera*/
  33221. afterCameraRender: () => void;
  33222. /**
  33223. * An event triggered when active meshes evaluation is about to start
  33224. */
  33225. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33226. /**
  33227. * An event triggered when active meshes evaluation is done
  33228. */
  33229. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33230. /**
  33231. * An event triggered when particles rendering is about to start
  33232. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33233. */
  33234. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33235. /**
  33236. * An event triggered when particles rendering is done
  33237. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33238. */
  33239. onAfterParticlesRenderingObservable: Observable<Scene>;
  33240. /**
  33241. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33242. */
  33243. onDataLoadedObservable: Observable<Scene>;
  33244. /**
  33245. * An event triggered when a camera is created
  33246. */
  33247. onNewCameraAddedObservable: Observable<Camera>;
  33248. /**
  33249. * An event triggered when a camera is removed
  33250. */
  33251. onCameraRemovedObservable: Observable<Camera>;
  33252. /**
  33253. * An event triggered when a light is created
  33254. */
  33255. onNewLightAddedObservable: Observable<Light>;
  33256. /**
  33257. * An event triggered when a light is removed
  33258. */
  33259. onLightRemovedObservable: Observable<Light>;
  33260. /**
  33261. * An event triggered when a geometry is created
  33262. */
  33263. onNewGeometryAddedObservable: Observable<Geometry>;
  33264. /**
  33265. * An event triggered when a geometry is removed
  33266. */
  33267. onGeometryRemovedObservable: Observable<Geometry>;
  33268. /**
  33269. * An event triggered when a transform node is created
  33270. */
  33271. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33272. /**
  33273. * An event triggered when a transform node is removed
  33274. */
  33275. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33276. /**
  33277. * An event triggered when a mesh is created
  33278. */
  33279. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33280. /**
  33281. * An event triggered when a mesh is removed
  33282. */
  33283. onMeshRemovedObservable: Observable<AbstractMesh>;
  33284. /**
  33285. * An event triggered when a skeleton is created
  33286. */
  33287. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33288. /**
  33289. * An event triggered when a skeleton is removed
  33290. */
  33291. onSkeletonRemovedObservable: Observable<Skeleton>;
  33292. /**
  33293. * An event triggered when a material is created
  33294. */
  33295. onNewMaterialAddedObservable: Observable<Material>;
  33296. /**
  33297. * An event triggered when a material is removed
  33298. */
  33299. onMaterialRemovedObservable: Observable<Material>;
  33300. /**
  33301. * An event triggered when a texture is created
  33302. */
  33303. onNewTextureAddedObservable: Observable<BaseTexture>;
  33304. /**
  33305. * An event triggered when a texture is removed
  33306. */
  33307. onTextureRemovedObservable: Observable<BaseTexture>;
  33308. /**
  33309. * An event triggered when render targets are about to be rendered
  33310. * Can happen multiple times per frame.
  33311. */
  33312. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33313. /**
  33314. * An event triggered when render targets were rendered.
  33315. * Can happen multiple times per frame.
  33316. */
  33317. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33318. /**
  33319. * An event triggered before calculating deterministic simulation step
  33320. */
  33321. onBeforeStepObservable: Observable<Scene>;
  33322. /**
  33323. * An event triggered after calculating deterministic simulation step
  33324. */
  33325. onAfterStepObservable: Observable<Scene>;
  33326. /**
  33327. * An event triggered when the activeCamera property is updated
  33328. */
  33329. onActiveCameraChanged: Observable<Scene>;
  33330. /**
  33331. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33332. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33333. * 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)
  33334. */
  33335. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33336. /**
  33337. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33338. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33339. * 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)
  33340. */
  33341. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33342. /**
  33343. * This Observable will when a mesh has been imported into the scene.
  33344. */
  33345. onMeshImportedObservable: Observable<AbstractMesh>;
  33346. /**
  33347. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33348. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33349. */
  33350. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33351. /** @hidden */
  33352. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33353. /**
  33354. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33355. */
  33356. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33357. /**
  33358. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33359. */
  33360. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33361. /**
  33362. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33363. */
  33364. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33365. /** Callback called when a pointer move is detected */
  33366. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33367. /** Callback called when a pointer down is detected */
  33368. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33369. /** Callback called when a pointer up is detected */
  33370. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33371. /** Callback called when a pointer pick is detected */
  33372. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33373. /**
  33374. * 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).
  33375. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33376. */
  33377. onPrePointerObservable: Observable<PointerInfoPre>;
  33378. /**
  33379. * Observable event triggered each time an input event is received from the rendering canvas
  33380. */
  33381. onPointerObservable: Observable<PointerInfo>;
  33382. /**
  33383. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33384. */
  33385. readonly unTranslatedPointer: Vector2;
  33386. /**
  33387. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33388. */
  33389. static DragMovementThreshold: number;
  33390. /**
  33391. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33392. */
  33393. static LongPressDelay: number;
  33394. /**
  33395. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33396. */
  33397. static DoubleClickDelay: number;
  33398. /** If you need to check double click without raising a single click at first click, enable this flag */
  33399. static ExclusiveDoubleClickMode: boolean;
  33400. /** @hidden */
  33401. _mirroredCameraPosition: Nullable<Vector3>;
  33402. /**
  33403. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33404. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33405. */
  33406. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33407. /**
  33408. * Observable event triggered each time an keyboard event is received from the hosting window
  33409. */
  33410. onKeyboardObservable: Observable<KeyboardInfo>;
  33411. private _useRightHandedSystem;
  33412. /**
  33413. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33414. */
  33415. useRightHandedSystem: boolean;
  33416. private _timeAccumulator;
  33417. private _currentStepId;
  33418. private _currentInternalStep;
  33419. /**
  33420. * Sets the step Id used by deterministic lock step
  33421. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33422. * @param newStepId defines the step Id
  33423. */
  33424. setStepId(newStepId: number): void;
  33425. /**
  33426. * Gets the step Id used by deterministic lock step
  33427. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33428. * @returns the step Id
  33429. */
  33430. getStepId(): number;
  33431. /**
  33432. * Gets the internal step used by deterministic lock step
  33433. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33434. * @returns the internal step
  33435. */
  33436. getInternalStep(): number;
  33437. private _fogEnabled;
  33438. /**
  33439. * Gets or sets a boolean indicating if fog is enabled on this scene
  33440. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33441. * (Default is true)
  33442. */
  33443. fogEnabled: boolean;
  33444. private _fogMode;
  33445. /**
  33446. * Gets or sets the fog mode to use
  33447. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33448. * | mode | value |
  33449. * | --- | --- |
  33450. * | FOGMODE_NONE | 0 |
  33451. * | FOGMODE_EXP | 1 |
  33452. * | FOGMODE_EXP2 | 2 |
  33453. * | FOGMODE_LINEAR | 3 |
  33454. */
  33455. fogMode: number;
  33456. /**
  33457. * Gets or sets the fog color to use
  33458. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33459. * (Default is Color3(0.2, 0.2, 0.3))
  33460. */
  33461. fogColor: Color3;
  33462. /**
  33463. * Gets or sets the fog density to use
  33464. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33465. * (Default is 0.1)
  33466. */
  33467. fogDensity: number;
  33468. /**
  33469. * Gets or sets the fog start distance to use
  33470. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33471. * (Default is 0)
  33472. */
  33473. fogStart: number;
  33474. /**
  33475. * Gets or sets the fog end distance to use
  33476. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33477. * (Default is 1000)
  33478. */
  33479. fogEnd: number;
  33480. private _shadowsEnabled;
  33481. /**
  33482. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33483. */
  33484. shadowsEnabled: boolean;
  33485. private _lightsEnabled;
  33486. /**
  33487. * Gets or sets a boolean indicating if lights are enabled on this scene
  33488. */
  33489. lightsEnabled: boolean;
  33490. /** All of the active cameras added to this scene. */
  33491. activeCameras: Camera[];
  33492. /** @hidden */
  33493. _activeCamera: Nullable<Camera>;
  33494. /** Gets or sets the current active camera */
  33495. activeCamera: Nullable<Camera>;
  33496. private _defaultMaterial;
  33497. /** The default material used on meshes when no material is affected */
  33498. /** The default material used on meshes when no material is affected */
  33499. defaultMaterial: Material;
  33500. private _texturesEnabled;
  33501. /**
  33502. * Gets or sets a boolean indicating if textures are enabled on this scene
  33503. */
  33504. texturesEnabled: boolean;
  33505. /**
  33506. * Gets or sets a boolean indicating if particles are enabled on this scene
  33507. */
  33508. particlesEnabled: boolean;
  33509. /**
  33510. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33511. */
  33512. spritesEnabled: boolean;
  33513. private _skeletonsEnabled;
  33514. /**
  33515. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33516. */
  33517. skeletonsEnabled: boolean;
  33518. /**
  33519. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33520. */
  33521. lensFlaresEnabled: boolean;
  33522. /**
  33523. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33524. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33525. */
  33526. collisionsEnabled: boolean;
  33527. private _collisionCoordinator;
  33528. /** @hidden */
  33529. readonly collisionCoordinator: ICollisionCoordinator;
  33530. /**
  33531. * Defines the gravity applied to this scene (used only for collisions)
  33532. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33533. */
  33534. gravity: Vector3;
  33535. /**
  33536. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33537. */
  33538. postProcessesEnabled: boolean;
  33539. /**
  33540. * The list of postprocesses added to the scene
  33541. */
  33542. postProcesses: PostProcess[];
  33543. /**
  33544. * Gets the current postprocess manager
  33545. */
  33546. postProcessManager: PostProcessManager;
  33547. /**
  33548. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33549. */
  33550. renderTargetsEnabled: boolean;
  33551. /**
  33552. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33553. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33554. */
  33555. dumpNextRenderTargets: boolean;
  33556. /**
  33557. * The list of user defined render targets added to the scene
  33558. */
  33559. customRenderTargets: RenderTargetTexture[];
  33560. /**
  33561. * Defines if texture loading must be delayed
  33562. * If true, textures will only be loaded when they need to be rendered
  33563. */
  33564. useDelayedTextureLoading: boolean;
  33565. /**
  33566. * Gets the list of meshes imported to the scene through SceneLoader
  33567. */
  33568. importedMeshesFiles: String[];
  33569. /**
  33570. * Gets or sets a boolean indicating if probes are enabled on this scene
  33571. */
  33572. probesEnabled: boolean;
  33573. /**
  33574. * Gets or sets the current offline provider to use to store scene data
  33575. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33576. */
  33577. offlineProvider: IOfflineProvider;
  33578. /**
  33579. * Gets or sets the action manager associated with the scene
  33580. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33581. */
  33582. actionManager: AbstractActionManager;
  33583. private _meshesForIntersections;
  33584. /**
  33585. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33586. */
  33587. proceduralTexturesEnabled: boolean;
  33588. private _engine;
  33589. private _totalVertices;
  33590. /** @hidden */
  33591. _activeIndices: PerfCounter;
  33592. /** @hidden */
  33593. _activeParticles: PerfCounter;
  33594. /** @hidden */
  33595. _activeBones: PerfCounter;
  33596. private _animationRatio;
  33597. /** @hidden */
  33598. _animationTimeLast: number;
  33599. /** @hidden */
  33600. _animationTime: number;
  33601. /**
  33602. * Gets or sets a general scale for animation speed
  33603. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33604. */
  33605. animationTimeScale: number;
  33606. /** @hidden */
  33607. _cachedMaterial: Nullable<Material>;
  33608. /** @hidden */
  33609. _cachedEffect: Nullable<Effect>;
  33610. /** @hidden */
  33611. _cachedVisibility: Nullable<number>;
  33612. private _renderId;
  33613. private _frameId;
  33614. private _executeWhenReadyTimeoutId;
  33615. private _intermediateRendering;
  33616. private _viewUpdateFlag;
  33617. private _projectionUpdateFlag;
  33618. /** @hidden */
  33619. _toBeDisposed: Nullable<IDisposable>[];
  33620. private _activeRequests;
  33621. /** @hidden */
  33622. _pendingData: any[];
  33623. private _isDisposed;
  33624. /**
  33625. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33626. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33627. */
  33628. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33629. private _activeMeshes;
  33630. private _processedMaterials;
  33631. private _renderTargets;
  33632. /** @hidden */
  33633. _activeParticleSystems: SmartArray<IParticleSystem>;
  33634. private _activeSkeletons;
  33635. private _softwareSkinnedMeshes;
  33636. private _renderingManager;
  33637. /** @hidden */
  33638. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33639. private _transformMatrix;
  33640. private _sceneUbo;
  33641. /** @hidden */
  33642. _viewMatrix: Matrix;
  33643. private _projectionMatrix;
  33644. /** @hidden */
  33645. _forcedViewPosition: Nullable<Vector3>;
  33646. /** @hidden */
  33647. _frustumPlanes: Plane[];
  33648. /**
  33649. * Gets the list of frustum planes (built from the active camera)
  33650. */
  33651. readonly frustumPlanes: Plane[];
  33652. /**
  33653. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33654. * This is useful if there are more lights that the maximum simulteanous authorized
  33655. */
  33656. requireLightSorting: boolean;
  33657. /** @hidden */
  33658. readonly useMaterialMeshMap: boolean;
  33659. /** @hidden */
  33660. readonly useClonedMeshhMap: boolean;
  33661. private _externalData;
  33662. private _uid;
  33663. /**
  33664. * @hidden
  33665. * Backing store of defined scene components.
  33666. */
  33667. _components: ISceneComponent[];
  33668. /**
  33669. * @hidden
  33670. * Backing store of defined scene components.
  33671. */
  33672. _serializableComponents: ISceneSerializableComponent[];
  33673. /**
  33674. * List of components to register on the next registration step.
  33675. */
  33676. private _transientComponents;
  33677. /**
  33678. * Registers the transient components if needed.
  33679. */
  33680. private _registerTransientComponents;
  33681. /**
  33682. * @hidden
  33683. * Add a component to the scene.
  33684. * Note that the ccomponent could be registered on th next frame if this is called after
  33685. * the register component stage.
  33686. * @param component Defines the component to add to the scene
  33687. */
  33688. _addComponent(component: ISceneComponent): void;
  33689. /**
  33690. * @hidden
  33691. * Gets a component from the scene.
  33692. * @param name defines the name of the component to retrieve
  33693. * @returns the component or null if not present
  33694. */
  33695. _getComponent(name: string): Nullable<ISceneComponent>;
  33696. /**
  33697. * @hidden
  33698. * Defines the actions happening before camera updates.
  33699. */
  33700. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33701. /**
  33702. * @hidden
  33703. * Defines the actions happening before clear the canvas.
  33704. */
  33705. _beforeClearStage: Stage<SimpleStageAction>;
  33706. /**
  33707. * @hidden
  33708. * Defines the actions when collecting render targets for the frame.
  33709. */
  33710. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33711. /**
  33712. * @hidden
  33713. * Defines the actions happening for one camera in the frame.
  33714. */
  33715. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33716. /**
  33717. * @hidden
  33718. * Defines the actions happening during the per mesh ready checks.
  33719. */
  33720. _isReadyForMeshStage: Stage<MeshStageAction>;
  33721. /**
  33722. * @hidden
  33723. * Defines the actions happening before evaluate active mesh checks.
  33724. */
  33725. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33726. /**
  33727. * @hidden
  33728. * Defines the actions happening during the evaluate sub mesh checks.
  33729. */
  33730. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33731. /**
  33732. * @hidden
  33733. * Defines the actions happening during the active mesh stage.
  33734. */
  33735. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33736. /**
  33737. * @hidden
  33738. * Defines the actions happening during the per camera render target step.
  33739. */
  33740. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33741. /**
  33742. * @hidden
  33743. * Defines the actions happening just before the active camera is drawing.
  33744. */
  33745. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33746. /**
  33747. * @hidden
  33748. * Defines the actions happening just before a render target is drawing.
  33749. */
  33750. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33751. /**
  33752. * @hidden
  33753. * Defines the actions happening just before a rendering group is drawing.
  33754. */
  33755. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33756. /**
  33757. * @hidden
  33758. * Defines the actions happening just before a mesh is drawing.
  33759. */
  33760. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33761. /**
  33762. * @hidden
  33763. * Defines the actions happening just after a mesh has been drawn.
  33764. */
  33765. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33766. /**
  33767. * @hidden
  33768. * Defines the actions happening just after a rendering group has been drawn.
  33769. */
  33770. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33771. /**
  33772. * @hidden
  33773. * Defines the actions happening just after the active camera has been drawn.
  33774. */
  33775. _afterCameraDrawStage: Stage<CameraStageAction>;
  33776. /**
  33777. * @hidden
  33778. * Defines the actions happening just after a render target has been drawn.
  33779. */
  33780. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33781. /**
  33782. * @hidden
  33783. * Defines the actions happening just after rendering all cameras and computing intersections.
  33784. */
  33785. _afterRenderStage: Stage<SimpleStageAction>;
  33786. /**
  33787. * @hidden
  33788. * Defines the actions happening when a pointer move event happens.
  33789. */
  33790. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33791. /**
  33792. * @hidden
  33793. * Defines the actions happening when a pointer down event happens.
  33794. */
  33795. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33796. /**
  33797. * @hidden
  33798. * Defines the actions happening when a pointer up event happens.
  33799. */
  33800. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33801. /**
  33802. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33803. */
  33804. private geometriesByUniqueId;
  33805. /**
  33806. * Creates a new Scene
  33807. * @param engine defines the engine to use to render this scene
  33808. * @param options defines the scene options
  33809. */
  33810. constructor(engine: Engine, options?: SceneOptions);
  33811. /**
  33812. * Gets a string idenfifying the name of the class
  33813. * @returns "Scene" string
  33814. */
  33815. getClassName(): string;
  33816. private _defaultMeshCandidates;
  33817. /**
  33818. * @hidden
  33819. */
  33820. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33821. private _defaultSubMeshCandidates;
  33822. /**
  33823. * @hidden
  33824. */
  33825. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33826. /**
  33827. * Sets the default candidate providers for the scene.
  33828. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33829. * and getCollidingSubMeshCandidates to their default function
  33830. */
  33831. setDefaultCandidateProviders(): void;
  33832. /**
  33833. * Gets the mesh that is currently under the pointer
  33834. */
  33835. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33836. /**
  33837. * Gets or sets the current on-screen X position of the pointer
  33838. */
  33839. pointerX: number;
  33840. /**
  33841. * Gets or sets the current on-screen Y position of the pointer
  33842. */
  33843. pointerY: number;
  33844. /**
  33845. * Gets the cached material (ie. the latest rendered one)
  33846. * @returns the cached material
  33847. */
  33848. getCachedMaterial(): Nullable<Material>;
  33849. /**
  33850. * Gets the cached effect (ie. the latest rendered one)
  33851. * @returns the cached effect
  33852. */
  33853. getCachedEffect(): Nullable<Effect>;
  33854. /**
  33855. * Gets the cached visibility state (ie. the latest rendered one)
  33856. * @returns the cached visibility state
  33857. */
  33858. getCachedVisibility(): Nullable<number>;
  33859. /**
  33860. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33861. * @param material defines the current material
  33862. * @param effect defines the current effect
  33863. * @param visibility defines the current visibility state
  33864. * @returns true if one parameter is not cached
  33865. */
  33866. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33867. /**
  33868. * Gets the engine associated with the scene
  33869. * @returns an Engine
  33870. */
  33871. getEngine(): Engine;
  33872. /**
  33873. * Gets the total number of vertices rendered per frame
  33874. * @returns the total number of vertices rendered per frame
  33875. */
  33876. getTotalVertices(): number;
  33877. /**
  33878. * Gets the performance counter for total vertices
  33879. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33880. */
  33881. readonly totalVerticesPerfCounter: PerfCounter;
  33882. /**
  33883. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33884. * @returns the total number of active indices rendered per frame
  33885. */
  33886. getActiveIndices(): number;
  33887. /**
  33888. * Gets the performance counter for active indices
  33889. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33890. */
  33891. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33892. /**
  33893. * Gets the total number of active particles rendered per frame
  33894. * @returns the total number of active particles rendered per frame
  33895. */
  33896. getActiveParticles(): number;
  33897. /**
  33898. * Gets the performance counter for active particles
  33899. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33900. */
  33901. readonly activeParticlesPerfCounter: PerfCounter;
  33902. /**
  33903. * Gets the total number of active bones rendered per frame
  33904. * @returns the total number of active bones rendered per frame
  33905. */
  33906. getActiveBones(): number;
  33907. /**
  33908. * Gets the performance counter for active bones
  33909. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33910. */
  33911. readonly activeBonesPerfCounter: PerfCounter;
  33912. /**
  33913. * Gets the array of active meshes
  33914. * @returns an array of AbstractMesh
  33915. */
  33916. getActiveMeshes(): SmartArray<AbstractMesh>;
  33917. /**
  33918. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33919. * @returns a number
  33920. */
  33921. getAnimationRatio(): number;
  33922. /**
  33923. * Gets an unique Id for the current render phase
  33924. * @returns a number
  33925. */
  33926. getRenderId(): number;
  33927. /**
  33928. * Gets an unique Id for the current frame
  33929. * @returns a number
  33930. */
  33931. getFrameId(): number;
  33932. /** Call this function if you want to manually increment the render Id*/
  33933. incrementRenderId(): void;
  33934. private _createUbo;
  33935. /**
  33936. * Use this method to simulate a pointer move on a mesh
  33937. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33938. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33939. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33940. * @returns the current scene
  33941. */
  33942. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33943. /**
  33944. * Use this method to simulate a pointer down on a mesh
  33945. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33946. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33947. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33948. * @returns the current scene
  33949. */
  33950. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33951. /**
  33952. * Use this method to simulate a pointer up on a mesh
  33953. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33954. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33955. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33956. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33957. * @returns the current scene
  33958. */
  33959. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33960. /**
  33961. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33962. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33963. * @returns true if the pointer was captured
  33964. */
  33965. isPointerCaptured(pointerId?: number): boolean;
  33966. /**
  33967. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33968. * @param attachUp defines if you want to attach events to pointerup
  33969. * @param attachDown defines if you want to attach events to pointerdown
  33970. * @param attachMove defines if you want to attach events to pointermove
  33971. */
  33972. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33973. /** Detaches all event handlers*/
  33974. detachControl(): void;
  33975. /**
  33976. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33977. * Delay loaded resources are not taking in account
  33978. * @return true if all required resources are ready
  33979. */
  33980. isReady(): boolean;
  33981. /** Resets all cached information relative to material (including effect and visibility) */
  33982. resetCachedMaterial(): void;
  33983. /**
  33984. * Registers a function to be called before every frame render
  33985. * @param func defines the function to register
  33986. */
  33987. registerBeforeRender(func: () => void): void;
  33988. /**
  33989. * Unregisters a function called before every frame render
  33990. * @param func defines the function to unregister
  33991. */
  33992. unregisterBeforeRender(func: () => void): void;
  33993. /**
  33994. * Registers a function to be called after every frame render
  33995. * @param func defines the function to register
  33996. */
  33997. registerAfterRender(func: () => void): void;
  33998. /**
  33999. * Unregisters a function called after every frame render
  34000. * @param func defines the function to unregister
  34001. */
  34002. unregisterAfterRender(func: () => void): void;
  34003. private _executeOnceBeforeRender;
  34004. /**
  34005. * The provided function will run before render once and will be disposed afterwards.
  34006. * A timeout delay can be provided so that the function will be executed in N ms.
  34007. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34008. * @param func The function to be executed.
  34009. * @param timeout optional delay in ms
  34010. */
  34011. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34012. /** @hidden */
  34013. _addPendingData(data: any): void;
  34014. /** @hidden */
  34015. _removePendingData(data: any): void;
  34016. /**
  34017. * Returns the number of items waiting to be loaded
  34018. * @returns the number of items waiting to be loaded
  34019. */
  34020. getWaitingItemsCount(): number;
  34021. /**
  34022. * Returns a boolean indicating if the scene is still loading data
  34023. */
  34024. readonly isLoading: boolean;
  34025. /**
  34026. * Registers a function to be executed when the scene is ready
  34027. * @param {Function} func - the function to be executed
  34028. */
  34029. executeWhenReady(func: () => void): void;
  34030. /**
  34031. * Returns a promise that resolves when the scene is ready
  34032. * @returns A promise that resolves when the scene is ready
  34033. */
  34034. whenReadyAsync(): Promise<void>;
  34035. /** @hidden */
  34036. _checkIsReady(): void;
  34037. /**
  34038. * Gets all animatable attached to the scene
  34039. */
  34040. readonly animatables: Animatable[];
  34041. /**
  34042. * Resets the last animation time frame.
  34043. * Useful to override when animations start running when loading a scene for the first time.
  34044. */
  34045. resetLastAnimationTimeFrame(): void;
  34046. /**
  34047. * Gets the current view matrix
  34048. * @returns a Matrix
  34049. */
  34050. getViewMatrix(): Matrix;
  34051. /**
  34052. * Gets the current projection matrix
  34053. * @returns a Matrix
  34054. */
  34055. getProjectionMatrix(): Matrix;
  34056. /**
  34057. * Gets the current transform matrix
  34058. * @returns a Matrix made of View * Projection
  34059. */
  34060. getTransformMatrix(): Matrix;
  34061. /**
  34062. * Sets the current transform matrix
  34063. * @param viewL defines the View matrix to use
  34064. * @param projectionL defines the Projection matrix to use
  34065. * @param viewR defines the right View matrix to use (if provided)
  34066. * @param projectionR defines the right Projection matrix to use (if provided)
  34067. */
  34068. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34069. /**
  34070. * Gets the uniform buffer used to store scene data
  34071. * @returns a UniformBuffer
  34072. */
  34073. getSceneUniformBuffer(): UniformBuffer;
  34074. /**
  34075. * Gets an unique (relatively to the current scene) Id
  34076. * @returns an unique number for the scene
  34077. */
  34078. getUniqueId(): number;
  34079. /**
  34080. * Add a mesh to the list of scene's meshes
  34081. * @param newMesh defines the mesh to add
  34082. * @param recursive if all child meshes should also be added to the scene
  34083. */
  34084. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34085. /**
  34086. * Remove a mesh for the list of scene's meshes
  34087. * @param toRemove defines the mesh to remove
  34088. * @param recursive if all child meshes should also be removed from the scene
  34089. * @returns the index where the mesh was in the mesh list
  34090. */
  34091. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34092. /**
  34093. * Add a transform node to the list of scene's transform nodes
  34094. * @param newTransformNode defines the transform node to add
  34095. */
  34096. addTransformNode(newTransformNode: TransformNode): void;
  34097. /**
  34098. * Remove a transform node for the list of scene's transform nodes
  34099. * @param toRemove defines the transform node to remove
  34100. * @returns the index where the transform node was in the transform node list
  34101. */
  34102. removeTransformNode(toRemove: TransformNode): number;
  34103. /**
  34104. * Remove a skeleton for the list of scene's skeletons
  34105. * @param toRemove defines the skeleton to remove
  34106. * @returns the index where the skeleton was in the skeleton list
  34107. */
  34108. removeSkeleton(toRemove: Skeleton): number;
  34109. /**
  34110. * Remove a morph target for the list of scene's morph targets
  34111. * @param toRemove defines the morph target to remove
  34112. * @returns the index where the morph target was in the morph target list
  34113. */
  34114. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34115. /**
  34116. * Remove a light for the list of scene's lights
  34117. * @param toRemove defines the light to remove
  34118. * @returns the index where the light was in the light list
  34119. */
  34120. removeLight(toRemove: Light): number;
  34121. /**
  34122. * Remove a camera for the list of scene's cameras
  34123. * @param toRemove defines the camera to remove
  34124. * @returns the index where the camera was in the camera list
  34125. */
  34126. removeCamera(toRemove: Camera): number;
  34127. /**
  34128. * Remove a particle system for the list of scene's particle systems
  34129. * @param toRemove defines the particle system to remove
  34130. * @returns the index where the particle system was in the particle system list
  34131. */
  34132. removeParticleSystem(toRemove: IParticleSystem): number;
  34133. /**
  34134. * Remove a animation for the list of scene's animations
  34135. * @param toRemove defines the animation to remove
  34136. * @returns the index where the animation was in the animation list
  34137. */
  34138. removeAnimation(toRemove: Animation): number;
  34139. /**
  34140. * Will stop the animation of the given target
  34141. * @param target - the target
  34142. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34143. * @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)
  34144. */
  34145. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34146. /**
  34147. * Removes the given animation group from this scene.
  34148. * @param toRemove The animation group to remove
  34149. * @returns The index of the removed animation group
  34150. */
  34151. removeAnimationGroup(toRemove: AnimationGroup): number;
  34152. /**
  34153. * Removes the given multi-material from this scene.
  34154. * @param toRemove The multi-material to remove
  34155. * @returns The index of the removed multi-material
  34156. */
  34157. removeMultiMaterial(toRemove: MultiMaterial): number;
  34158. /**
  34159. * Removes the given material from this scene.
  34160. * @param toRemove The material to remove
  34161. * @returns The index of the removed material
  34162. */
  34163. removeMaterial(toRemove: Material): number;
  34164. /**
  34165. * Removes the given action manager from this scene.
  34166. * @param toRemove The action manager to remove
  34167. * @returns The index of the removed action manager
  34168. */
  34169. removeActionManager(toRemove: AbstractActionManager): number;
  34170. /**
  34171. * Removes the given texture from this scene.
  34172. * @param toRemove The texture to remove
  34173. * @returns The index of the removed texture
  34174. */
  34175. removeTexture(toRemove: BaseTexture): number;
  34176. /**
  34177. * Adds the given light to this scene
  34178. * @param newLight The light to add
  34179. */
  34180. addLight(newLight: Light): void;
  34181. /**
  34182. * Sorts the list list based on light priorities
  34183. */
  34184. sortLightsByPriority(): void;
  34185. /**
  34186. * Adds the given camera to this scene
  34187. * @param newCamera The camera to add
  34188. */
  34189. addCamera(newCamera: Camera): void;
  34190. /**
  34191. * Adds the given skeleton to this scene
  34192. * @param newSkeleton The skeleton to add
  34193. */
  34194. addSkeleton(newSkeleton: Skeleton): void;
  34195. /**
  34196. * Adds the given particle system to this scene
  34197. * @param newParticleSystem The particle system to add
  34198. */
  34199. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34200. /**
  34201. * Adds the given animation to this scene
  34202. * @param newAnimation The animation to add
  34203. */
  34204. addAnimation(newAnimation: Animation): void;
  34205. /**
  34206. * Adds the given animation group to this scene.
  34207. * @param newAnimationGroup The animation group to add
  34208. */
  34209. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34210. /**
  34211. * Adds the given multi-material to this scene
  34212. * @param newMultiMaterial The multi-material to add
  34213. */
  34214. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34215. /**
  34216. * Adds the given material to this scene
  34217. * @param newMaterial The material to add
  34218. */
  34219. addMaterial(newMaterial: Material): void;
  34220. /**
  34221. * Adds the given morph target to this scene
  34222. * @param newMorphTargetManager The morph target to add
  34223. */
  34224. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34225. /**
  34226. * Adds the given geometry to this scene
  34227. * @param newGeometry The geometry to add
  34228. */
  34229. addGeometry(newGeometry: Geometry): void;
  34230. /**
  34231. * Adds the given action manager to this scene
  34232. * @param newActionManager The action manager to add
  34233. */
  34234. addActionManager(newActionManager: AbstractActionManager): void;
  34235. /**
  34236. * Adds the given texture to this scene.
  34237. * @param newTexture The texture to add
  34238. */
  34239. addTexture(newTexture: BaseTexture): void;
  34240. /**
  34241. * Switch active camera
  34242. * @param newCamera defines the new active camera
  34243. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34244. */
  34245. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34246. /**
  34247. * sets the active camera of the scene using its ID
  34248. * @param id defines the camera's ID
  34249. * @return the new active camera or null if none found.
  34250. */
  34251. setActiveCameraByID(id: string): Nullable<Camera>;
  34252. /**
  34253. * sets the active camera of the scene using its name
  34254. * @param name defines the camera's name
  34255. * @returns the new active camera or null if none found.
  34256. */
  34257. setActiveCameraByName(name: string): Nullable<Camera>;
  34258. /**
  34259. * get an animation group using its name
  34260. * @param name defines the material's name
  34261. * @return the animation group or null if none found.
  34262. */
  34263. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34264. /**
  34265. * Get a material using its unique id
  34266. * @param uniqueId defines the material's unique id
  34267. * @return the material or null if none found.
  34268. */
  34269. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34270. /**
  34271. * get a material using its id
  34272. * @param id defines the material's ID
  34273. * @return the material or null if none found.
  34274. */
  34275. getMaterialByID(id: string): Nullable<Material>;
  34276. /**
  34277. * Gets a material using its name
  34278. * @param name defines the material's name
  34279. * @return the material or null if none found.
  34280. */
  34281. getMaterialByName(name: string): Nullable<Material>;
  34282. /**
  34283. * Gets a camera using its id
  34284. * @param id defines the id to look for
  34285. * @returns the camera or null if not found
  34286. */
  34287. getCameraByID(id: string): Nullable<Camera>;
  34288. /**
  34289. * Gets a camera using its unique id
  34290. * @param uniqueId defines the unique id to look for
  34291. * @returns the camera or null if not found
  34292. */
  34293. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34294. /**
  34295. * Gets a camera using its name
  34296. * @param name defines the camera's name
  34297. * @return the camera or null if none found.
  34298. */
  34299. getCameraByName(name: string): Nullable<Camera>;
  34300. /**
  34301. * Gets a bone using its id
  34302. * @param id defines the bone's id
  34303. * @return the bone or null if not found
  34304. */
  34305. getBoneByID(id: string): Nullable<Bone>;
  34306. /**
  34307. * Gets a bone using its id
  34308. * @param name defines the bone's name
  34309. * @return the bone or null if not found
  34310. */
  34311. getBoneByName(name: string): Nullable<Bone>;
  34312. /**
  34313. * Gets a light node using its name
  34314. * @param name defines the the light's name
  34315. * @return the light or null if none found.
  34316. */
  34317. getLightByName(name: string): Nullable<Light>;
  34318. /**
  34319. * Gets a light node using its id
  34320. * @param id defines the light's id
  34321. * @return the light or null if none found.
  34322. */
  34323. getLightByID(id: string): Nullable<Light>;
  34324. /**
  34325. * Gets a light node using its scene-generated unique ID
  34326. * @param uniqueId defines the light's unique id
  34327. * @return the light or null if none found.
  34328. */
  34329. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34330. /**
  34331. * Gets a particle system by id
  34332. * @param id defines the particle system id
  34333. * @return the corresponding system or null if none found
  34334. */
  34335. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34336. /**
  34337. * Gets a geometry using its ID
  34338. * @param id defines the geometry's id
  34339. * @return the geometry or null if none found.
  34340. */
  34341. getGeometryByID(id: string): Nullable<Geometry>;
  34342. private _getGeometryByUniqueID;
  34343. /**
  34344. * Add a new geometry to this scene
  34345. * @param geometry defines the geometry to be added to the scene.
  34346. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34347. * @return a boolean defining if the geometry was added or not
  34348. */
  34349. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34350. /**
  34351. * Removes an existing geometry
  34352. * @param geometry defines the geometry to be removed from the scene
  34353. * @return a boolean defining if the geometry was removed or not
  34354. */
  34355. removeGeometry(geometry: Geometry): boolean;
  34356. /**
  34357. * Gets the list of geometries attached to the scene
  34358. * @returns an array of Geometry
  34359. */
  34360. getGeometries(): Geometry[];
  34361. /**
  34362. * Gets the first added mesh found of a given ID
  34363. * @param id defines the id to search for
  34364. * @return the mesh found or null if not found at all
  34365. */
  34366. getMeshByID(id: string): Nullable<AbstractMesh>;
  34367. /**
  34368. * Gets a list of meshes using their id
  34369. * @param id defines the id to search for
  34370. * @returns a list of meshes
  34371. */
  34372. getMeshesByID(id: string): Array<AbstractMesh>;
  34373. /**
  34374. * Gets the first added transform node found of a given ID
  34375. * @param id defines the id to search for
  34376. * @return the found transform node or null if not found at all.
  34377. */
  34378. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34379. /**
  34380. * Gets a transform node with its auto-generated unique id
  34381. * @param uniqueId efines the unique id to search for
  34382. * @return the found transform node or null if not found at all.
  34383. */
  34384. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34385. /**
  34386. * Gets a list of transform nodes using their id
  34387. * @param id defines the id to search for
  34388. * @returns a list of transform nodes
  34389. */
  34390. getTransformNodesByID(id: string): Array<TransformNode>;
  34391. /**
  34392. * Gets a mesh with its auto-generated unique id
  34393. * @param uniqueId defines the unique id to search for
  34394. * @return the found mesh or null if not found at all.
  34395. */
  34396. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34397. /**
  34398. * Gets a the last added mesh using a given id
  34399. * @param id defines the id to search for
  34400. * @return the found mesh or null if not found at all.
  34401. */
  34402. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34403. /**
  34404. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34405. * @param id defines the id to search for
  34406. * @return the found node or null if not found at all
  34407. */
  34408. getLastEntryByID(id: string): Nullable<Node>;
  34409. /**
  34410. * Gets a node (Mesh, Camera, Light) using a given id
  34411. * @param id defines the id to search for
  34412. * @return the found node or null if not found at all
  34413. */
  34414. getNodeByID(id: string): Nullable<Node>;
  34415. /**
  34416. * Gets a node (Mesh, Camera, Light) using a given name
  34417. * @param name defines the name to search for
  34418. * @return the found node or null if not found at all.
  34419. */
  34420. getNodeByName(name: string): Nullable<Node>;
  34421. /**
  34422. * Gets a mesh using a given name
  34423. * @param name defines the name to search for
  34424. * @return the found mesh or null if not found at all.
  34425. */
  34426. getMeshByName(name: string): Nullable<AbstractMesh>;
  34427. /**
  34428. * Gets a transform node using a given name
  34429. * @param name defines the name to search for
  34430. * @return the found transform node or null if not found at all.
  34431. */
  34432. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34433. /**
  34434. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34435. * @param id defines the id to search for
  34436. * @return the found skeleton or null if not found at all.
  34437. */
  34438. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34439. /**
  34440. * Gets a skeleton using a given auto generated unique id
  34441. * @param uniqueId defines the unique id to search for
  34442. * @return the found skeleton or null if not found at all.
  34443. */
  34444. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34445. /**
  34446. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34447. * @param id defines the id to search for
  34448. * @return the found skeleton or null if not found at all.
  34449. */
  34450. getSkeletonById(id: string): Nullable<Skeleton>;
  34451. /**
  34452. * Gets a skeleton using a given name
  34453. * @param name defines the name to search for
  34454. * @return the found skeleton or null if not found at all.
  34455. */
  34456. getSkeletonByName(name: string): Nullable<Skeleton>;
  34457. /**
  34458. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34459. * @param id defines the id to search for
  34460. * @return the found morph target manager or null if not found at all.
  34461. */
  34462. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34463. /**
  34464. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34465. * @param id defines the id to search for
  34466. * @return the found morph target or null if not found at all.
  34467. */
  34468. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34469. /**
  34470. * Gets a boolean indicating if the given mesh is active
  34471. * @param mesh defines the mesh to look for
  34472. * @returns true if the mesh is in the active list
  34473. */
  34474. isActiveMesh(mesh: AbstractMesh): boolean;
  34475. /**
  34476. * Return a unique id as a string which can serve as an identifier for the scene
  34477. */
  34478. readonly uid: string;
  34479. /**
  34480. * Add an externaly attached data from its key.
  34481. * This method call will fail and return false, if such key already exists.
  34482. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34483. * @param key the unique key that identifies the data
  34484. * @param data the data object to associate to the key for this Engine instance
  34485. * @return true if no such key were already present and the data was added successfully, false otherwise
  34486. */
  34487. addExternalData<T>(key: string, data: T): boolean;
  34488. /**
  34489. * Get an externaly attached data from its key
  34490. * @param key the unique key that identifies the data
  34491. * @return the associated data, if present (can be null), or undefined if not present
  34492. */
  34493. getExternalData<T>(key: string): Nullable<T>;
  34494. /**
  34495. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34496. * @param key the unique key that identifies the data
  34497. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34498. * @return the associated data, can be null if the factory returned null.
  34499. */
  34500. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34501. /**
  34502. * Remove an externaly attached data from the Engine instance
  34503. * @param key the unique key that identifies the data
  34504. * @return true if the data was successfully removed, false if it doesn't exist
  34505. */
  34506. removeExternalData(key: string): boolean;
  34507. private _evaluateSubMesh;
  34508. /**
  34509. * Clear the processed materials smart array preventing retention point in material dispose.
  34510. */
  34511. freeProcessedMaterials(): void;
  34512. private _preventFreeActiveMeshesAndRenderingGroups;
  34513. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34514. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34515. * when disposing several meshes in a row or a hierarchy of meshes.
  34516. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34517. */
  34518. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34519. /**
  34520. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34521. */
  34522. freeActiveMeshes(): void;
  34523. /**
  34524. * Clear the info related to rendering groups preventing retention points during dispose.
  34525. */
  34526. freeRenderingGroups(): void;
  34527. /** @hidden */
  34528. _isInIntermediateRendering(): boolean;
  34529. /**
  34530. * Lambda returning the list of potentially active meshes.
  34531. */
  34532. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34533. /**
  34534. * Lambda returning the list of potentially active sub meshes.
  34535. */
  34536. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34537. /**
  34538. * Lambda returning the list of potentially intersecting sub meshes.
  34539. */
  34540. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34541. /**
  34542. * Lambda returning the list of potentially colliding sub meshes.
  34543. */
  34544. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34545. private _activeMeshesFrozen;
  34546. /**
  34547. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34548. * @returns the current scene
  34549. */
  34550. freezeActiveMeshes(): Scene;
  34551. /**
  34552. * Use this function to restart evaluating active meshes on every frame
  34553. * @returns the current scene
  34554. */
  34555. unfreezeActiveMeshes(): Scene;
  34556. private _evaluateActiveMeshes;
  34557. private _activeMesh;
  34558. /**
  34559. * Update the transform matrix to update from the current active camera
  34560. * @param force defines a boolean used to force the update even if cache is up to date
  34561. */
  34562. updateTransformMatrix(force?: boolean): void;
  34563. private _bindFrameBuffer;
  34564. /** @hidden */
  34565. _allowPostProcessClearColor: boolean;
  34566. /** @hidden */
  34567. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34568. private _processSubCameras;
  34569. private _checkIntersections;
  34570. /** @hidden */
  34571. _advancePhysicsEngineStep(step: number): void;
  34572. /**
  34573. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34574. */
  34575. getDeterministicFrameTime: () => number;
  34576. /** @hidden */
  34577. _animate(): void;
  34578. /** Execute all animations (for a frame) */
  34579. animate(): void;
  34580. /**
  34581. * Render the scene
  34582. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34583. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34584. */
  34585. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34586. /**
  34587. * Freeze all materials
  34588. * A frozen material will not be updatable but should be faster to render
  34589. */
  34590. freezeMaterials(): void;
  34591. /**
  34592. * Unfreeze all materials
  34593. * A frozen material will not be updatable but should be faster to render
  34594. */
  34595. unfreezeMaterials(): void;
  34596. /**
  34597. * Releases all held ressources
  34598. */
  34599. dispose(): void;
  34600. /**
  34601. * Gets if the scene is already disposed
  34602. */
  34603. readonly isDisposed: boolean;
  34604. /**
  34605. * Call this function to reduce memory footprint of the scene.
  34606. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34607. */
  34608. clearCachedVertexData(): void;
  34609. /**
  34610. * This function will remove the local cached buffer data from texture.
  34611. * It will save memory but will prevent the texture from being rebuilt
  34612. */
  34613. cleanCachedTextureBuffer(): void;
  34614. /**
  34615. * Get the world extend vectors with an optional filter
  34616. *
  34617. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34618. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34619. */
  34620. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34621. min: Vector3;
  34622. max: Vector3;
  34623. };
  34624. /**
  34625. * Creates a ray that can be used to pick in the scene
  34626. * @param x defines the x coordinate of the origin (on-screen)
  34627. * @param y defines the y coordinate of the origin (on-screen)
  34628. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34629. * @param camera defines the camera to use for the picking
  34630. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34631. * @returns a Ray
  34632. */
  34633. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34634. /**
  34635. * Creates a ray that can be used to pick in the scene
  34636. * @param x defines the x coordinate of the origin (on-screen)
  34637. * @param y defines the y coordinate of the origin (on-screen)
  34638. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34639. * @param result defines the ray where to store the picking ray
  34640. * @param camera defines the camera to use for the picking
  34641. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34642. * @returns the current scene
  34643. */
  34644. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34645. /**
  34646. * Creates a ray that can be used to pick in the scene
  34647. * @param x defines the x coordinate of the origin (on-screen)
  34648. * @param y defines the y coordinate of the origin (on-screen)
  34649. * @param camera defines the camera to use for the picking
  34650. * @returns a Ray
  34651. */
  34652. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34653. /**
  34654. * Creates a ray that can be used to pick in the scene
  34655. * @param x defines the x coordinate of the origin (on-screen)
  34656. * @param y defines the y coordinate of the origin (on-screen)
  34657. * @param result defines the ray where to store the picking ray
  34658. * @param camera defines the camera to use for the picking
  34659. * @returns the current scene
  34660. */
  34661. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34662. /** Launch a ray to try to pick a mesh in the scene
  34663. * @param x position on screen
  34664. * @param y position on screen
  34665. * @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
  34666. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34667. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34668. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34669. * @returns a PickingInfo
  34670. */
  34671. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  34672. /** Use the given ray to pick a mesh in the scene
  34673. * @param ray The ray to use to pick meshes
  34674. * @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
  34675. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34676. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34677. * @returns a PickingInfo
  34678. */
  34679. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34680. /**
  34681. * Launch a ray to try to pick a mesh in the scene
  34682. * @param x X position on screen
  34683. * @param y Y position on screen
  34684. * @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
  34685. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34686. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34687. * @returns an array of PickingInfo
  34688. */
  34689. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34690. /**
  34691. * Launch a ray to try to pick a mesh in the scene
  34692. * @param ray Ray to use
  34693. * @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
  34694. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34695. * @returns an array of PickingInfo
  34696. */
  34697. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34698. /**
  34699. * Force the value of meshUnderPointer
  34700. * @param mesh defines the mesh to use
  34701. */
  34702. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34703. /**
  34704. * Gets the mesh under the pointer
  34705. * @returns a Mesh or null if no mesh is under the pointer
  34706. */
  34707. getPointerOverMesh(): Nullable<AbstractMesh>;
  34708. /** @hidden */
  34709. _rebuildGeometries(): void;
  34710. /** @hidden */
  34711. _rebuildTextures(): void;
  34712. private _getByTags;
  34713. /**
  34714. * Get a list of meshes by tags
  34715. * @param tagsQuery defines the tags query to use
  34716. * @param forEach defines a predicate used to filter results
  34717. * @returns an array of Mesh
  34718. */
  34719. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34720. /**
  34721. * Get a list of cameras by tags
  34722. * @param tagsQuery defines the tags query to use
  34723. * @param forEach defines a predicate used to filter results
  34724. * @returns an array of Camera
  34725. */
  34726. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34727. /**
  34728. * Get a list of lights by tags
  34729. * @param tagsQuery defines the tags query to use
  34730. * @param forEach defines a predicate used to filter results
  34731. * @returns an array of Light
  34732. */
  34733. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34734. /**
  34735. * Get a list of materials by tags
  34736. * @param tagsQuery defines the tags query to use
  34737. * @param forEach defines a predicate used to filter results
  34738. * @returns an array of Material
  34739. */
  34740. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34741. /**
  34742. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34743. * This allowed control for front to back rendering or reversly depending of the special needs.
  34744. *
  34745. * @param renderingGroupId The rendering group id corresponding to its index
  34746. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34747. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34748. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34749. */
  34750. 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;
  34751. /**
  34752. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34753. *
  34754. * @param renderingGroupId The rendering group id corresponding to its index
  34755. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34756. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34757. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34758. */
  34759. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34760. /**
  34761. * Gets the current auto clear configuration for one rendering group of the rendering
  34762. * manager.
  34763. * @param index the rendering group index to get the information for
  34764. * @returns The auto clear setup for the requested rendering group
  34765. */
  34766. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34767. private _blockMaterialDirtyMechanism;
  34768. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34769. blockMaterialDirtyMechanism: boolean;
  34770. /**
  34771. * Will flag all materials as dirty to trigger new shader compilation
  34772. * @param flag defines the flag used to specify which material part must be marked as dirty
  34773. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34774. */
  34775. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34776. /** @hidden */
  34777. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  34778. /** @hidden */
  34779. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34780. }
  34781. }
  34782. declare module "babylonjs/assetContainer" {
  34783. import { AbstractScene } from "babylonjs/abstractScene";
  34784. import { Scene } from "babylonjs/scene";
  34785. import { Mesh } from "babylonjs/Meshes/mesh";
  34786. /**
  34787. * Set of assets to keep when moving a scene into an asset container.
  34788. */
  34789. export class KeepAssets extends AbstractScene {
  34790. }
  34791. /**
  34792. * Container with a set of assets that can be added or removed from a scene.
  34793. */
  34794. export class AssetContainer extends AbstractScene {
  34795. /**
  34796. * The scene the AssetContainer belongs to.
  34797. */
  34798. scene: Scene;
  34799. /**
  34800. * Instantiates an AssetContainer.
  34801. * @param scene The scene the AssetContainer belongs to.
  34802. */
  34803. constructor(scene: Scene);
  34804. /**
  34805. * Adds all the assets from the container to the scene.
  34806. */
  34807. addAllToScene(): void;
  34808. /**
  34809. * Removes all the assets in the container from the scene
  34810. */
  34811. removeAllFromScene(): void;
  34812. /**
  34813. * Disposes all the assets in the container
  34814. */
  34815. dispose(): void;
  34816. private _moveAssets;
  34817. /**
  34818. * Removes all the assets contained in the scene and adds them to the container.
  34819. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34820. */
  34821. moveAllFromScene(keepAssets?: KeepAssets): void;
  34822. /**
  34823. * 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.
  34824. * @returns the root mesh
  34825. */
  34826. createRootMesh(): Mesh;
  34827. }
  34828. }
  34829. declare module "babylonjs/abstractScene" {
  34830. import { Scene } from "babylonjs/scene";
  34831. import { Nullable } from "babylonjs/types";
  34832. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34833. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34834. import { Geometry } from "babylonjs/Meshes/geometry";
  34835. import { Skeleton } from "babylonjs/Bones/skeleton";
  34836. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34837. import { AssetContainer } from "babylonjs/assetContainer";
  34838. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34839. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34840. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34841. import { Material } from "babylonjs/Materials/material";
  34842. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34843. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34844. import { Camera } from "babylonjs/Cameras/camera";
  34845. import { Light } from "babylonjs/Lights/light";
  34846. import { Node } from "babylonjs/node";
  34847. import { Animation } from "babylonjs/Animations/animation";
  34848. /**
  34849. * Defines how the parser contract is defined.
  34850. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34851. */
  34852. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34853. /**
  34854. * Defines how the individual parser contract is defined.
  34855. * These parser can parse an individual asset
  34856. */
  34857. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34858. /**
  34859. * Base class of the scene acting as a container for the different elements composing a scene.
  34860. * This class is dynamically extended by the different components of the scene increasing
  34861. * flexibility and reducing coupling
  34862. */
  34863. export abstract class AbstractScene {
  34864. /**
  34865. * Stores the list of available parsers in the application.
  34866. */
  34867. private static _BabylonFileParsers;
  34868. /**
  34869. * Stores the list of available individual parsers in the application.
  34870. */
  34871. private static _IndividualBabylonFileParsers;
  34872. /**
  34873. * Adds a parser in the list of available ones
  34874. * @param name Defines the name of the parser
  34875. * @param parser Defines the parser to add
  34876. */
  34877. static AddParser(name: string, parser: BabylonFileParser): void;
  34878. /**
  34879. * Gets a general parser from the list of avaialble ones
  34880. * @param name Defines the name of the parser
  34881. * @returns the requested parser or null
  34882. */
  34883. static GetParser(name: string): Nullable<BabylonFileParser>;
  34884. /**
  34885. * Adds n individual parser in the list of available ones
  34886. * @param name Defines the name of the parser
  34887. * @param parser Defines the parser to add
  34888. */
  34889. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34890. /**
  34891. * Gets an individual parser from the list of avaialble ones
  34892. * @param name Defines the name of the parser
  34893. * @returns the requested parser or null
  34894. */
  34895. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34896. /**
  34897. * Parser json data and populate both a scene and its associated container object
  34898. * @param jsonData Defines the data to parse
  34899. * @param scene Defines the scene to parse the data for
  34900. * @param container Defines the container attached to the parsing sequence
  34901. * @param rootUrl Defines the root url of the data
  34902. */
  34903. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34904. /**
  34905. * Gets the list of root nodes (ie. nodes with no parent)
  34906. */
  34907. rootNodes: Node[];
  34908. /** All of the cameras added to this scene
  34909. * @see http://doc.babylonjs.com/babylon101/cameras
  34910. */
  34911. cameras: Camera[];
  34912. /**
  34913. * All of the lights added to this scene
  34914. * @see http://doc.babylonjs.com/babylon101/lights
  34915. */
  34916. lights: Light[];
  34917. /**
  34918. * All of the (abstract) meshes added to this scene
  34919. */
  34920. meshes: AbstractMesh[];
  34921. /**
  34922. * The list of skeletons added to the scene
  34923. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34924. */
  34925. skeletons: Skeleton[];
  34926. /**
  34927. * All of the particle systems added to this scene
  34928. * @see http://doc.babylonjs.com/babylon101/particles
  34929. */
  34930. particleSystems: IParticleSystem[];
  34931. /**
  34932. * Gets a list of Animations associated with the scene
  34933. */
  34934. animations: Animation[];
  34935. /**
  34936. * All of the animation groups added to this scene
  34937. * @see http://doc.babylonjs.com/how_to/group
  34938. */
  34939. animationGroups: AnimationGroup[];
  34940. /**
  34941. * All of the multi-materials added to this scene
  34942. * @see http://doc.babylonjs.com/how_to/multi_materials
  34943. */
  34944. multiMaterials: MultiMaterial[];
  34945. /**
  34946. * All of the materials added to this scene
  34947. * In the context of a Scene, it is not supposed to be modified manually.
  34948. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34949. * Note also that the order of the Material wihin the array is not significant and might change.
  34950. * @see http://doc.babylonjs.com/babylon101/materials
  34951. */
  34952. materials: Material[];
  34953. /**
  34954. * The list of morph target managers added to the scene
  34955. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34956. */
  34957. morphTargetManagers: MorphTargetManager[];
  34958. /**
  34959. * The list of geometries used in the scene.
  34960. */
  34961. geometries: Geometry[];
  34962. /**
  34963. * All of the tranform nodes added to this scene
  34964. * In the context of a Scene, it is not supposed to be modified manually.
  34965. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34966. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34967. * @see http://doc.babylonjs.com/how_to/transformnode
  34968. */
  34969. transformNodes: TransformNode[];
  34970. /**
  34971. * ActionManagers available on the scene.
  34972. */
  34973. actionManagers: AbstractActionManager[];
  34974. /**
  34975. * Textures to keep.
  34976. */
  34977. textures: BaseTexture[];
  34978. /**
  34979. * Environment texture for the scene
  34980. */
  34981. environmentTexture: Nullable<BaseTexture>;
  34982. }
  34983. }
  34984. declare module "babylonjs/Audio/sound" {
  34985. import { Observable } from "babylonjs/Misc/observable";
  34986. import { Vector3 } from "babylonjs/Maths/math";
  34987. import { Nullable } from "babylonjs/types";
  34988. import { Scene } from "babylonjs/scene";
  34989. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34990. /**
  34991. * Defines a sound that can be played in the application.
  34992. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34993. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34994. */
  34995. export class Sound {
  34996. /**
  34997. * The name of the sound in the scene.
  34998. */
  34999. name: string;
  35000. /**
  35001. * Does the sound autoplay once loaded.
  35002. */
  35003. autoplay: boolean;
  35004. /**
  35005. * Does the sound loop after it finishes playing once.
  35006. */
  35007. loop: boolean;
  35008. /**
  35009. * Does the sound use a custom attenuation curve to simulate the falloff
  35010. * happening when the source gets further away from the camera.
  35011. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35012. */
  35013. useCustomAttenuation: boolean;
  35014. /**
  35015. * The sound track id this sound belongs to.
  35016. */
  35017. soundTrackId: number;
  35018. /**
  35019. * Is this sound currently played.
  35020. */
  35021. isPlaying: boolean;
  35022. /**
  35023. * Is this sound currently paused.
  35024. */
  35025. isPaused: boolean;
  35026. /**
  35027. * Does this sound enables spatial sound.
  35028. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35029. */
  35030. spatialSound: boolean;
  35031. /**
  35032. * Define the reference distance the sound should be heard perfectly.
  35033. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35034. */
  35035. refDistance: number;
  35036. /**
  35037. * Define the roll off factor of spatial sounds.
  35038. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35039. */
  35040. rolloffFactor: number;
  35041. /**
  35042. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35043. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35044. */
  35045. maxDistance: number;
  35046. /**
  35047. * Define the distance attenuation model the sound will follow.
  35048. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35049. */
  35050. distanceModel: string;
  35051. /**
  35052. * @hidden
  35053. * Back Compat
  35054. **/
  35055. onended: () => any;
  35056. /**
  35057. * Observable event when the current playing sound finishes.
  35058. */
  35059. onEndedObservable: Observable<Sound>;
  35060. private _panningModel;
  35061. private _playbackRate;
  35062. private _streaming;
  35063. private _startTime;
  35064. private _startOffset;
  35065. private _position;
  35066. /** @hidden */
  35067. _positionInEmitterSpace: boolean;
  35068. private _localDirection;
  35069. private _volume;
  35070. private _isReadyToPlay;
  35071. private _isDirectional;
  35072. private _readyToPlayCallback;
  35073. private _audioBuffer;
  35074. private _soundSource;
  35075. private _streamingSource;
  35076. private _soundPanner;
  35077. private _soundGain;
  35078. private _inputAudioNode;
  35079. private _outputAudioNode;
  35080. private _coneInnerAngle;
  35081. private _coneOuterAngle;
  35082. private _coneOuterGain;
  35083. private _scene;
  35084. private _connectedTransformNode;
  35085. private _customAttenuationFunction;
  35086. private _registerFunc;
  35087. private _isOutputConnected;
  35088. private _htmlAudioElement;
  35089. private _urlType;
  35090. /** @hidden */
  35091. static _SceneComponentInitialization: (scene: Scene) => void;
  35092. /**
  35093. * Create a sound and attach it to a scene
  35094. * @param name Name of your sound
  35095. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35096. * @param scene defines the scene the sound belongs to
  35097. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35098. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35099. */
  35100. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  35101. /**
  35102. * Release the sound and its associated resources
  35103. */
  35104. dispose(): void;
  35105. /**
  35106. * Gets if the sounds is ready to be played or not.
  35107. * @returns true if ready, otherwise false
  35108. */
  35109. isReady(): boolean;
  35110. private _soundLoaded;
  35111. /**
  35112. * Sets the data of the sound from an audiobuffer
  35113. * @param audioBuffer The audioBuffer containing the data
  35114. */
  35115. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35116. /**
  35117. * Updates the current sounds options such as maxdistance, loop...
  35118. * @param options A JSON object containing values named as the object properties
  35119. */
  35120. updateOptions(options: any): void;
  35121. private _createSpatialParameters;
  35122. private _updateSpatialParameters;
  35123. /**
  35124. * Switch the panning model to HRTF:
  35125. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35126. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35127. */
  35128. switchPanningModelToHRTF(): void;
  35129. /**
  35130. * Switch the panning model to Equal Power:
  35131. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35132. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35133. */
  35134. switchPanningModelToEqualPower(): void;
  35135. private _switchPanningModel;
  35136. /**
  35137. * Connect this sound to a sound track audio node like gain...
  35138. * @param soundTrackAudioNode the sound track audio node to connect to
  35139. */
  35140. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35141. /**
  35142. * Transform this sound into a directional source
  35143. * @param coneInnerAngle Size of the inner cone in degree
  35144. * @param coneOuterAngle Size of the outer cone in degree
  35145. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35146. */
  35147. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35148. /**
  35149. * Gets or sets the inner angle for the directional cone.
  35150. */
  35151. /**
  35152. * Gets or sets the inner angle for the directional cone.
  35153. */
  35154. directionalConeInnerAngle: number;
  35155. /**
  35156. * Gets or sets the outer angle for the directional cone.
  35157. */
  35158. /**
  35159. * Gets or sets the outer angle for the directional cone.
  35160. */
  35161. directionalConeOuterAngle: number;
  35162. /**
  35163. * Sets the position of the emitter if spatial sound is enabled
  35164. * @param newPosition Defines the new posisiton
  35165. */
  35166. setPosition(newPosition: Vector3): void;
  35167. /**
  35168. * Sets the local direction of the emitter if spatial sound is enabled
  35169. * @param newLocalDirection Defines the new local direction
  35170. */
  35171. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35172. private _updateDirection;
  35173. /** @hidden */
  35174. updateDistanceFromListener(): void;
  35175. /**
  35176. * Sets a new custom attenuation function for the sound.
  35177. * @param callback Defines the function used for the attenuation
  35178. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35179. */
  35180. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35181. /**
  35182. * Play the sound
  35183. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35184. * @param offset (optional) Start the sound setting it at a specific time
  35185. */
  35186. play(time?: number, offset?: number): void;
  35187. private _onended;
  35188. /**
  35189. * Stop the sound
  35190. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35191. */
  35192. stop(time?: number): void;
  35193. /**
  35194. * Put the sound in pause
  35195. */
  35196. pause(): void;
  35197. /**
  35198. * Sets a dedicated volume for this sounds
  35199. * @param newVolume Define the new volume of the sound
  35200. * @param time Define in how long the sound should be at this value
  35201. */
  35202. setVolume(newVolume: number, time?: number): void;
  35203. /**
  35204. * Set the sound play back rate
  35205. * @param newPlaybackRate Define the playback rate the sound should be played at
  35206. */
  35207. setPlaybackRate(newPlaybackRate: number): void;
  35208. /**
  35209. * Gets the volume of the sound.
  35210. * @returns the volume of the sound
  35211. */
  35212. getVolume(): number;
  35213. /**
  35214. * Attach the sound to a dedicated mesh
  35215. * @param transformNode The transform node to connect the sound with
  35216. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35217. */
  35218. attachToMesh(transformNode: TransformNode): void;
  35219. /**
  35220. * Detach the sound from the previously attached mesh
  35221. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35222. */
  35223. detachFromMesh(): void;
  35224. private _onRegisterAfterWorldMatrixUpdate;
  35225. /**
  35226. * Clone the current sound in the scene.
  35227. * @returns the new sound clone
  35228. */
  35229. clone(): Nullable<Sound>;
  35230. /**
  35231. * Gets the current underlying audio buffer containing the data
  35232. * @returns the audio buffer
  35233. */
  35234. getAudioBuffer(): Nullable<AudioBuffer>;
  35235. /**
  35236. * Serializes the Sound in a JSON representation
  35237. * @returns the JSON representation of the sound
  35238. */
  35239. serialize(): any;
  35240. /**
  35241. * Parse a JSON representation of a sound to innstantiate in a given scene
  35242. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35243. * @param scene Define the scene the new parsed sound should be created in
  35244. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35245. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35246. * @returns the newly parsed sound
  35247. */
  35248. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35249. }
  35250. }
  35251. declare module "babylonjs/Actions/directAudioActions" {
  35252. import { Action } from "babylonjs/Actions/action";
  35253. import { Condition } from "babylonjs/Actions/condition";
  35254. import { Sound } from "babylonjs/Audio/sound";
  35255. /**
  35256. * This defines an action helpful to play a defined sound on a triggered action.
  35257. */
  35258. export class PlaySoundAction extends Action {
  35259. private _sound;
  35260. /**
  35261. * Instantiate the action
  35262. * @param triggerOptions defines the trigger options
  35263. * @param sound defines the sound to play
  35264. * @param condition defines the trigger related conditions
  35265. */
  35266. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35267. /** @hidden */
  35268. _prepare(): void;
  35269. /**
  35270. * Execute the action and play the sound.
  35271. */
  35272. execute(): void;
  35273. /**
  35274. * Serializes the actions and its related information.
  35275. * @param parent defines the object to serialize in
  35276. * @returns the serialized object
  35277. */
  35278. serialize(parent: any): any;
  35279. }
  35280. /**
  35281. * This defines an action helpful to stop a defined sound on a triggered action.
  35282. */
  35283. export class StopSoundAction extends Action {
  35284. private _sound;
  35285. /**
  35286. * Instantiate the action
  35287. * @param triggerOptions defines the trigger options
  35288. * @param sound defines the sound to stop
  35289. * @param condition defines the trigger related conditions
  35290. */
  35291. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35292. /** @hidden */
  35293. _prepare(): void;
  35294. /**
  35295. * Execute the action and stop the sound.
  35296. */
  35297. execute(): void;
  35298. /**
  35299. * Serializes the actions and its related information.
  35300. * @param parent defines the object to serialize in
  35301. * @returns the serialized object
  35302. */
  35303. serialize(parent: any): any;
  35304. }
  35305. }
  35306. declare module "babylonjs/Actions/interpolateValueAction" {
  35307. import { Action } from "babylonjs/Actions/action";
  35308. import { Condition } from "babylonjs/Actions/condition";
  35309. import { Observable } from "babylonjs/Misc/observable";
  35310. /**
  35311. * This defines an action responsible to change the value of a property
  35312. * by interpolating between its current value and the newly set one once triggered.
  35313. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35314. */
  35315. export class InterpolateValueAction extends Action {
  35316. /**
  35317. * Defines the path of the property where the value should be interpolated
  35318. */
  35319. propertyPath: string;
  35320. /**
  35321. * Defines the target value at the end of the interpolation.
  35322. */
  35323. value: any;
  35324. /**
  35325. * Defines the time it will take for the property to interpolate to the value.
  35326. */
  35327. duration: number;
  35328. /**
  35329. * Defines if the other scene animations should be stopped when the action has been triggered
  35330. */
  35331. stopOtherAnimations?: boolean;
  35332. /**
  35333. * Defines a callback raised once the interpolation animation has been done.
  35334. */
  35335. onInterpolationDone?: () => void;
  35336. /**
  35337. * Observable triggered once the interpolation animation has been done.
  35338. */
  35339. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35340. private _target;
  35341. private _effectiveTarget;
  35342. private _property;
  35343. /**
  35344. * Instantiate the action
  35345. * @param triggerOptions defines the trigger options
  35346. * @param target defines the object containing the value to interpolate
  35347. * @param propertyPath defines the path to the property in the target object
  35348. * @param value defines the target value at the end of the interpolation
  35349. * @param duration deines the time it will take for the property to interpolate to the value.
  35350. * @param condition defines the trigger related conditions
  35351. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35352. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35353. */
  35354. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35355. /** @hidden */
  35356. _prepare(): void;
  35357. /**
  35358. * Execute the action starts the value interpolation.
  35359. */
  35360. execute(): void;
  35361. /**
  35362. * Serializes the actions and its related information.
  35363. * @param parent defines the object to serialize in
  35364. * @returns the serialized object
  35365. */
  35366. serialize(parent: any): any;
  35367. }
  35368. }
  35369. declare module "babylonjs/Actions/index" {
  35370. export * from "babylonjs/Actions/action";
  35371. export * from "babylonjs/Actions/actionEvent";
  35372. export * from "babylonjs/Actions/actionManager";
  35373. export * from "babylonjs/Actions/condition";
  35374. export * from "babylonjs/Actions/directActions";
  35375. export * from "babylonjs/Actions/directAudioActions";
  35376. export * from "babylonjs/Actions/interpolateValueAction";
  35377. }
  35378. declare module "babylonjs/Animations/index" {
  35379. export * from "babylonjs/Animations/animatable";
  35380. export * from "babylonjs/Animations/animation";
  35381. export * from "babylonjs/Animations/animationGroup";
  35382. export * from "babylonjs/Animations/animationPropertiesOverride";
  35383. export * from "babylonjs/Animations/easing";
  35384. export * from "babylonjs/Animations/runtimeAnimation";
  35385. export * from "babylonjs/Animations/animationEvent";
  35386. export * from "babylonjs/Animations/animationGroup";
  35387. export * from "babylonjs/Animations/animationKey";
  35388. export * from "babylonjs/Animations/animationRange";
  35389. }
  35390. declare module "babylonjs/Audio/soundTrack" {
  35391. import { Sound } from "babylonjs/Audio/sound";
  35392. import { Analyser } from "babylonjs/Audio/analyser";
  35393. import { Scene } from "babylonjs/scene";
  35394. /**
  35395. * Options allowed during the creation of a sound track.
  35396. */
  35397. export interface ISoundTrackOptions {
  35398. /**
  35399. * The volume the sound track should take during creation
  35400. */
  35401. volume?: number;
  35402. /**
  35403. * Define if the sound track is the main sound track of the scene
  35404. */
  35405. mainTrack?: boolean;
  35406. }
  35407. /**
  35408. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35409. * It will be also used in a future release to apply effects on a specific track.
  35410. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35411. */
  35412. export class SoundTrack {
  35413. /**
  35414. * The unique identifier of the sound track in the scene.
  35415. */
  35416. id: number;
  35417. /**
  35418. * The list of sounds included in the sound track.
  35419. */
  35420. soundCollection: Array<Sound>;
  35421. private _outputAudioNode;
  35422. private _scene;
  35423. private _isMainTrack;
  35424. private _connectedAnalyser;
  35425. private _options;
  35426. private _isInitialized;
  35427. /**
  35428. * Creates a new sound track.
  35429. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35430. * @param scene Define the scene the sound track belongs to
  35431. * @param options
  35432. */
  35433. constructor(scene: Scene, options?: ISoundTrackOptions);
  35434. private _initializeSoundTrackAudioGraph;
  35435. /**
  35436. * Release the sound track and its associated resources
  35437. */
  35438. dispose(): void;
  35439. /**
  35440. * Adds a sound to this sound track
  35441. * @param sound define the cound to add
  35442. * @ignoreNaming
  35443. */
  35444. AddSound(sound: Sound): void;
  35445. /**
  35446. * Removes a sound to this sound track
  35447. * @param sound define the cound to remove
  35448. * @ignoreNaming
  35449. */
  35450. RemoveSound(sound: Sound): void;
  35451. /**
  35452. * Set a global volume for the full sound track.
  35453. * @param newVolume Define the new volume of the sound track
  35454. */
  35455. setVolume(newVolume: number): void;
  35456. /**
  35457. * Switch the panning model to HRTF:
  35458. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35459. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35460. */
  35461. switchPanningModelToHRTF(): void;
  35462. /**
  35463. * Switch the panning model to Equal Power:
  35464. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35465. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35466. */
  35467. switchPanningModelToEqualPower(): void;
  35468. /**
  35469. * Connect the sound track to an audio analyser allowing some amazing
  35470. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35471. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35472. * @param analyser The analyser to connect to the engine
  35473. */
  35474. connectToAnalyser(analyser: Analyser): void;
  35475. }
  35476. }
  35477. declare module "babylonjs/Audio/audioSceneComponent" {
  35478. import { Sound } from "babylonjs/Audio/sound";
  35479. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  35480. import { Nullable } from "babylonjs/types";
  35481. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  35482. import { Scene } from "babylonjs/scene";
  35483. import { AbstractScene } from "babylonjs/abstractScene";
  35484. module "babylonjs/abstractScene" {
  35485. interface AbstractScene {
  35486. /**
  35487. * The list of sounds used in the scene.
  35488. */
  35489. sounds: Nullable<Array<Sound>>;
  35490. }
  35491. }
  35492. module "babylonjs/scene" {
  35493. interface Scene {
  35494. /**
  35495. * @hidden
  35496. * Backing field
  35497. */
  35498. _mainSoundTrack: SoundTrack;
  35499. /**
  35500. * The main sound track played by the scene.
  35501. * It cotains your primary collection of sounds.
  35502. */
  35503. mainSoundTrack: SoundTrack;
  35504. /**
  35505. * The list of sound tracks added to the scene
  35506. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35507. */
  35508. soundTracks: Nullable<Array<SoundTrack>>;
  35509. /**
  35510. * Gets a sound using a given name
  35511. * @param name defines the name to search for
  35512. * @return the found sound or null if not found at all.
  35513. */
  35514. getSoundByName(name: string): Nullable<Sound>;
  35515. /**
  35516. * Gets or sets if audio support is enabled
  35517. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35518. */
  35519. audioEnabled: boolean;
  35520. /**
  35521. * Gets or sets if audio will be output to headphones
  35522. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35523. */
  35524. headphone: boolean;
  35525. }
  35526. }
  35527. /**
  35528. * Defines the sound scene component responsible to manage any sounds
  35529. * in a given scene.
  35530. */
  35531. export class AudioSceneComponent implements ISceneSerializableComponent {
  35532. /**
  35533. * The component name helpfull to identify the component in the list of scene components.
  35534. */
  35535. readonly name: string;
  35536. /**
  35537. * The scene the component belongs to.
  35538. */
  35539. scene: Scene;
  35540. private _audioEnabled;
  35541. /**
  35542. * Gets whether audio is enabled or not.
  35543. * Please use related enable/disable method to switch state.
  35544. */
  35545. readonly audioEnabled: boolean;
  35546. private _headphone;
  35547. /**
  35548. * Gets whether audio is outputing to headphone or not.
  35549. * Please use the according Switch methods to change output.
  35550. */
  35551. readonly headphone: boolean;
  35552. /**
  35553. * Creates a new instance of the component for the given scene
  35554. * @param scene Defines the scene to register the component in
  35555. */
  35556. constructor(scene: Scene);
  35557. /**
  35558. * Registers the component in a given scene
  35559. */
  35560. register(): void;
  35561. /**
  35562. * Rebuilds the elements related to this component in case of
  35563. * context lost for instance.
  35564. */
  35565. rebuild(): void;
  35566. /**
  35567. * Serializes the component data to the specified json object
  35568. * @param serializationObject The object to serialize to
  35569. */
  35570. serialize(serializationObject: any): void;
  35571. /**
  35572. * Adds all the elements from the container to the scene
  35573. * @param container the container holding the elements
  35574. */
  35575. addFromContainer(container: AbstractScene): void;
  35576. /**
  35577. * Removes all the elements in the container from the scene
  35578. * @param container contains the elements to remove
  35579. * @param dispose if the removed element should be disposed (default: false)
  35580. */
  35581. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35582. /**
  35583. * Disposes the component and the associated ressources.
  35584. */
  35585. dispose(): void;
  35586. /**
  35587. * Disables audio in the associated scene.
  35588. */
  35589. disableAudio(): void;
  35590. /**
  35591. * Enables audio in the associated scene.
  35592. */
  35593. enableAudio(): void;
  35594. /**
  35595. * Switch audio to headphone output.
  35596. */
  35597. switchAudioModeForHeadphones(): void;
  35598. /**
  35599. * Switch audio to normal speakers.
  35600. */
  35601. switchAudioModeForNormalSpeakers(): void;
  35602. private _afterRender;
  35603. }
  35604. }
  35605. declare module "babylonjs/Audio/weightedsound" {
  35606. import { Sound } from "babylonjs/Audio/sound";
  35607. /**
  35608. * Wraps one or more Sound objects and selects one with random weight for playback.
  35609. */
  35610. export class WeightedSound {
  35611. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35612. loop: boolean;
  35613. private _coneInnerAngle;
  35614. private _coneOuterAngle;
  35615. private _volume;
  35616. /** A Sound is currently playing. */
  35617. isPlaying: boolean;
  35618. /** A Sound is currently paused. */
  35619. isPaused: boolean;
  35620. private _sounds;
  35621. private _weights;
  35622. private _currentIndex?;
  35623. /**
  35624. * Creates a new WeightedSound from the list of sounds given.
  35625. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35626. * @param sounds Array of Sounds that will be selected from.
  35627. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35628. */
  35629. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35630. /**
  35631. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35632. */
  35633. /**
  35634. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35635. */
  35636. directionalConeInnerAngle: number;
  35637. /**
  35638. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35639. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35640. */
  35641. /**
  35642. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35643. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35644. */
  35645. directionalConeOuterAngle: number;
  35646. /**
  35647. * Playback volume.
  35648. */
  35649. /**
  35650. * Playback volume.
  35651. */
  35652. volume: number;
  35653. private _onended;
  35654. /**
  35655. * Suspend playback
  35656. */
  35657. pause(): void;
  35658. /**
  35659. * Stop playback
  35660. */
  35661. stop(): void;
  35662. /**
  35663. * Start playback.
  35664. * @param startOffset Position the clip head at a specific time in seconds.
  35665. */
  35666. play(startOffset?: number): void;
  35667. }
  35668. }
  35669. declare module "babylonjs/Audio/index" {
  35670. export * from "babylonjs/Audio/analyser";
  35671. export * from "babylonjs/Audio/audioEngine";
  35672. export * from "babylonjs/Audio/audioSceneComponent";
  35673. export * from "babylonjs/Audio/sound";
  35674. export * from "babylonjs/Audio/soundTrack";
  35675. export * from "babylonjs/Audio/weightedsound";
  35676. }
  35677. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35678. import { Behavior } from "babylonjs/Behaviors/behavior";
  35679. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35680. import { BackEase } from "babylonjs/Animations/easing";
  35681. /**
  35682. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35683. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35684. */
  35685. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35686. /**
  35687. * Gets the name of the behavior.
  35688. */
  35689. readonly name: string;
  35690. /**
  35691. * The easing function used by animations
  35692. */
  35693. static EasingFunction: BackEase;
  35694. /**
  35695. * The easing mode used by animations
  35696. */
  35697. static EasingMode: number;
  35698. /**
  35699. * The duration of the animation, in milliseconds
  35700. */
  35701. transitionDuration: number;
  35702. /**
  35703. * Length of the distance animated by the transition when lower radius is reached
  35704. */
  35705. lowerRadiusTransitionRange: number;
  35706. /**
  35707. * Length of the distance animated by the transition when upper radius is reached
  35708. */
  35709. upperRadiusTransitionRange: number;
  35710. private _autoTransitionRange;
  35711. /**
  35712. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35713. */
  35714. /**
  35715. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35716. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35717. */
  35718. autoTransitionRange: boolean;
  35719. private _attachedCamera;
  35720. private _onAfterCheckInputsObserver;
  35721. private _onMeshTargetChangedObserver;
  35722. /**
  35723. * Initializes the behavior.
  35724. */
  35725. init(): void;
  35726. /**
  35727. * Attaches the behavior to its arc rotate camera.
  35728. * @param camera Defines the camera to attach the behavior to
  35729. */
  35730. attach(camera: ArcRotateCamera): void;
  35731. /**
  35732. * Detaches the behavior from its current arc rotate camera.
  35733. */
  35734. detach(): void;
  35735. private _radiusIsAnimating;
  35736. private _radiusBounceTransition;
  35737. private _animatables;
  35738. private _cachedWheelPrecision;
  35739. /**
  35740. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35741. * @param radiusLimit The limit to check against.
  35742. * @return Bool to indicate if at limit.
  35743. */
  35744. private _isRadiusAtLimit;
  35745. /**
  35746. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35747. * @param radiusDelta The delta by which to animate to. Can be negative.
  35748. */
  35749. private _applyBoundRadiusAnimation;
  35750. /**
  35751. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35752. */
  35753. protected _clearAnimationLocks(): void;
  35754. /**
  35755. * Stops and removes all animations that have been applied to the camera
  35756. */
  35757. stopAllAnimations(): void;
  35758. }
  35759. }
  35760. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35761. import { Behavior } from "babylonjs/Behaviors/behavior";
  35762. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35763. import { ExponentialEase } from "babylonjs/Animations/easing";
  35764. import { Nullable } from "babylonjs/types";
  35765. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35766. import { Vector3 } from "babylonjs/Maths/math";
  35767. /**
  35768. * 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.
  35769. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35770. */
  35771. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35772. /**
  35773. * Gets the name of the behavior.
  35774. */
  35775. readonly name: string;
  35776. private _mode;
  35777. private _radiusScale;
  35778. private _positionScale;
  35779. private _defaultElevation;
  35780. private _elevationReturnTime;
  35781. private _elevationReturnWaitTime;
  35782. private _zoomStopsAnimation;
  35783. private _framingTime;
  35784. /**
  35785. * The easing function used by animations
  35786. */
  35787. static EasingFunction: ExponentialEase;
  35788. /**
  35789. * The easing mode used by animations
  35790. */
  35791. static EasingMode: number;
  35792. /**
  35793. * Sets the current mode used by the behavior
  35794. */
  35795. /**
  35796. * Gets current mode used by the behavior.
  35797. */
  35798. mode: number;
  35799. /**
  35800. * Sets the scale applied to the radius (1 by default)
  35801. */
  35802. /**
  35803. * Gets the scale applied to the radius
  35804. */
  35805. radiusScale: number;
  35806. /**
  35807. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35808. */
  35809. /**
  35810. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35811. */
  35812. positionScale: number;
  35813. /**
  35814. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35815. * behaviour is triggered, in radians.
  35816. */
  35817. /**
  35818. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35819. * behaviour is triggered, in radians.
  35820. */
  35821. defaultElevation: number;
  35822. /**
  35823. * Sets the time (in milliseconds) taken to return to the default beta position.
  35824. * Negative value indicates camera should not return to default.
  35825. */
  35826. /**
  35827. * Gets the time (in milliseconds) taken to return to the default beta position.
  35828. * Negative value indicates camera should not return to default.
  35829. */
  35830. elevationReturnTime: number;
  35831. /**
  35832. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35833. */
  35834. /**
  35835. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35836. */
  35837. elevationReturnWaitTime: number;
  35838. /**
  35839. * Sets the flag that indicates if user zooming should stop animation.
  35840. */
  35841. /**
  35842. * Gets the flag that indicates if user zooming should stop animation.
  35843. */
  35844. zoomStopsAnimation: boolean;
  35845. /**
  35846. * Sets the transition time when framing the mesh, in milliseconds
  35847. */
  35848. /**
  35849. * Gets the transition time when framing the mesh, in milliseconds
  35850. */
  35851. framingTime: number;
  35852. /**
  35853. * Define if the behavior should automatically change the configured
  35854. * camera limits and sensibilities.
  35855. */
  35856. autoCorrectCameraLimitsAndSensibility: boolean;
  35857. private _onPrePointerObservableObserver;
  35858. private _onAfterCheckInputsObserver;
  35859. private _onMeshTargetChangedObserver;
  35860. private _attachedCamera;
  35861. private _isPointerDown;
  35862. private _lastInteractionTime;
  35863. /**
  35864. * Initializes the behavior.
  35865. */
  35866. init(): void;
  35867. /**
  35868. * Attaches the behavior to its arc rotate camera.
  35869. * @param camera Defines the camera to attach the behavior to
  35870. */
  35871. attach(camera: ArcRotateCamera): void;
  35872. /**
  35873. * Detaches the behavior from its current arc rotate camera.
  35874. */
  35875. detach(): void;
  35876. private _animatables;
  35877. private _betaIsAnimating;
  35878. private _betaTransition;
  35879. private _radiusTransition;
  35880. private _vectorTransition;
  35881. /**
  35882. * Targets the given mesh and updates zoom level accordingly.
  35883. * @param mesh The mesh to target.
  35884. * @param radius Optional. If a cached radius position already exists, overrides default.
  35885. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35886. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35887. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35888. */
  35889. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35890. /**
  35891. * Targets the given mesh with its children and updates zoom level accordingly.
  35892. * @param mesh The mesh to target.
  35893. * @param radius Optional. If a cached radius position already exists, overrides default.
  35894. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35895. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35896. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35897. */
  35898. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35899. /**
  35900. * Targets the given meshes with their children and updates zoom level accordingly.
  35901. * @param meshes The mesh to target.
  35902. * @param radius Optional. If a cached radius position already exists, overrides default.
  35903. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35904. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35905. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35906. */
  35907. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35908. /**
  35909. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35910. * @param minimumWorld Determines the smaller position of the bounding box extend
  35911. * @param maximumWorld Determines the bigger position of the bounding box extend
  35912. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35913. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35914. */
  35915. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35916. /**
  35917. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35918. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35919. * frustum width.
  35920. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35921. * to fully enclose the mesh in the viewing frustum.
  35922. */
  35923. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35924. /**
  35925. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35926. * is automatically returned to its default position (expected to be above ground plane).
  35927. */
  35928. private _maintainCameraAboveGround;
  35929. /**
  35930. * Returns the frustum slope based on the canvas ratio and camera FOV
  35931. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35932. */
  35933. private _getFrustumSlope;
  35934. /**
  35935. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35936. */
  35937. private _clearAnimationLocks;
  35938. /**
  35939. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35940. */
  35941. private _applyUserInteraction;
  35942. /**
  35943. * Stops and removes all animations that have been applied to the camera
  35944. */
  35945. stopAllAnimations(): void;
  35946. /**
  35947. * Gets a value indicating if the user is moving the camera
  35948. */
  35949. readonly isUserIsMoving: boolean;
  35950. /**
  35951. * The camera can move all the way towards the mesh.
  35952. */
  35953. static IgnoreBoundsSizeMode: number;
  35954. /**
  35955. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35956. */
  35957. static FitFrustumSidesMode: number;
  35958. }
  35959. }
  35960. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  35961. import { Nullable } from "babylonjs/types";
  35962. import { Camera } from "babylonjs/Cameras/camera";
  35963. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35964. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35965. /**
  35966. * Base class for Camera Pointer Inputs.
  35967. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35968. * for example usage.
  35969. */
  35970. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35971. /**
  35972. * Defines the camera the input is attached to.
  35973. */
  35974. abstract camera: Camera;
  35975. /**
  35976. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35977. */
  35978. protected _altKey: boolean;
  35979. protected _ctrlKey: boolean;
  35980. protected _metaKey: boolean;
  35981. protected _shiftKey: boolean;
  35982. /**
  35983. * Which mouse buttons were pressed at time of last mouse event.
  35984. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35985. */
  35986. protected _buttonsPressed: number;
  35987. /**
  35988. * Defines the buttons associated with the input to handle camera move.
  35989. */
  35990. buttons: number[];
  35991. /**
  35992. * Attach the input controls to a specific dom element to get the input from.
  35993. * @param element Defines the element the controls should be listened from
  35994. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35995. */
  35996. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35997. /**
  35998. * Detach the current controls from the specified dom element.
  35999. * @param element Defines the element to stop listening the inputs from
  36000. */
  36001. detachControl(element: Nullable<HTMLElement>): void;
  36002. /**
  36003. * Gets the class name of the current input.
  36004. * @returns the class name
  36005. */
  36006. getClassName(): string;
  36007. /**
  36008. * Get the friendly name associated with the input class.
  36009. * @returns the input friendly name
  36010. */
  36011. getSimpleName(): string;
  36012. /**
  36013. * Called on pointer POINTERDOUBLETAP event.
  36014. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36015. */
  36016. protected onDoubleTap(type: string): void;
  36017. /**
  36018. * Called on pointer POINTERMOVE event if only a single touch is active.
  36019. * Override this method to provide functionality.
  36020. */
  36021. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36022. /**
  36023. * Called on pointer POINTERMOVE event if multiple touches are active.
  36024. * Override this method to provide functionality.
  36025. */
  36026. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36027. /**
  36028. * Called on JS contextmenu event.
  36029. * Override this method to provide functionality.
  36030. */
  36031. protected onContextMenu(evt: PointerEvent): void;
  36032. /**
  36033. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36034. * press.
  36035. * Override this method to provide functionality.
  36036. */
  36037. protected onButtonDown(evt: PointerEvent): void;
  36038. /**
  36039. * Called each time a new POINTERUP event occurs. Ie, for each button
  36040. * release.
  36041. * Override this method to provide functionality.
  36042. */
  36043. protected onButtonUp(evt: PointerEvent): void;
  36044. /**
  36045. * Called when window becomes inactive.
  36046. * Override this method to provide functionality.
  36047. */
  36048. protected onLostFocus(): void;
  36049. private _pointerInput;
  36050. private _observer;
  36051. private _onLostFocus;
  36052. private pointA;
  36053. private pointB;
  36054. }
  36055. }
  36056. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36057. import { Nullable } from "babylonjs/types";
  36058. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36059. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36060. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36061. /**
  36062. * Manage the pointers inputs to control an arc rotate camera.
  36063. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36064. */
  36065. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36066. /**
  36067. * Defines the camera the input is attached to.
  36068. */
  36069. camera: ArcRotateCamera;
  36070. /**
  36071. * Gets the class name of the current input.
  36072. * @returns the class name
  36073. */
  36074. getClassName(): string;
  36075. /**
  36076. * Defines the buttons associated with the input to handle camera move.
  36077. */
  36078. buttons: number[];
  36079. /**
  36080. * Defines the pointer angular sensibility along the X axis or how fast is
  36081. * the camera rotating.
  36082. */
  36083. angularSensibilityX: number;
  36084. /**
  36085. * Defines the pointer angular sensibility along the Y axis or how fast is
  36086. * the camera rotating.
  36087. */
  36088. angularSensibilityY: number;
  36089. /**
  36090. * Defines the pointer pinch precision or how fast is the camera zooming.
  36091. */
  36092. pinchPrecision: number;
  36093. /**
  36094. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36095. * from 0.
  36096. * It defines the percentage of current camera.radius to use as delta when
  36097. * pinch zoom is used.
  36098. */
  36099. pinchDeltaPercentage: number;
  36100. /**
  36101. * Defines the pointer panning sensibility or how fast is the camera moving.
  36102. */
  36103. panningSensibility: number;
  36104. /**
  36105. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36106. */
  36107. multiTouchPanning: boolean;
  36108. /**
  36109. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36110. * zoom (pinch) through multitouch.
  36111. */
  36112. multiTouchPanAndZoom: boolean;
  36113. /**
  36114. * Revers pinch action direction.
  36115. */
  36116. pinchInwards: boolean;
  36117. private _isPanClick;
  36118. private _twoFingerActivityCount;
  36119. private _isPinching;
  36120. /**
  36121. * Called on pointer POINTERMOVE event if only a single touch is active.
  36122. */
  36123. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36124. /**
  36125. * Called on pointer POINTERDOUBLETAP event.
  36126. */
  36127. protected onDoubleTap(type: string): void;
  36128. /**
  36129. * Called on pointer POINTERMOVE event if multiple touches are active.
  36130. */
  36131. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36132. /**
  36133. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36134. * press.
  36135. */
  36136. protected onButtonDown(evt: PointerEvent): void;
  36137. /**
  36138. * Called each time a new POINTERUP event occurs. Ie, for each button
  36139. * release.
  36140. */
  36141. protected onButtonUp(evt: PointerEvent): void;
  36142. /**
  36143. * Called when window becomes inactive.
  36144. */
  36145. protected onLostFocus(): void;
  36146. }
  36147. }
  36148. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  36149. import { Nullable } from "babylonjs/types";
  36150. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36151. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36152. /**
  36153. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36154. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36155. */
  36156. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36157. /**
  36158. * Defines the camera the input is attached to.
  36159. */
  36160. camera: ArcRotateCamera;
  36161. /**
  36162. * Defines the list of key codes associated with the up action (increase alpha)
  36163. */
  36164. keysUp: number[];
  36165. /**
  36166. * Defines the list of key codes associated with the down action (decrease alpha)
  36167. */
  36168. keysDown: number[];
  36169. /**
  36170. * Defines the list of key codes associated with the left action (increase beta)
  36171. */
  36172. keysLeft: number[];
  36173. /**
  36174. * Defines the list of key codes associated with the right action (decrease beta)
  36175. */
  36176. keysRight: number[];
  36177. /**
  36178. * Defines the list of key codes associated with the reset action.
  36179. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36180. */
  36181. keysReset: number[];
  36182. /**
  36183. * Defines the panning sensibility of the inputs.
  36184. * (How fast is the camera paning)
  36185. */
  36186. panningSensibility: number;
  36187. /**
  36188. * Defines the zooming sensibility of the inputs.
  36189. * (How fast is the camera zooming)
  36190. */
  36191. zoomingSensibility: number;
  36192. /**
  36193. * Defines wether maintaining the alt key down switch the movement mode from
  36194. * orientation to zoom.
  36195. */
  36196. useAltToZoom: boolean;
  36197. /**
  36198. * Rotation speed of the camera
  36199. */
  36200. angularSpeed: number;
  36201. private _keys;
  36202. private _ctrlPressed;
  36203. private _altPressed;
  36204. private _onCanvasBlurObserver;
  36205. private _onKeyboardObserver;
  36206. private _engine;
  36207. private _scene;
  36208. /**
  36209. * Attach the input controls to a specific dom element to get the input from.
  36210. * @param element Defines the element the controls should be listened from
  36211. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36212. */
  36213. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36214. /**
  36215. * Detach the current controls from the specified dom element.
  36216. * @param element Defines the element to stop listening the inputs from
  36217. */
  36218. detachControl(element: Nullable<HTMLElement>): void;
  36219. /**
  36220. * Update the current camera state depending on the inputs that have been used this frame.
  36221. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36222. */
  36223. checkInputs(): void;
  36224. /**
  36225. * Gets the class name of the current intput.
  36226. * @returns the class name
  36227. */
  36228. getClassName(): string;
  36229. /**
  36230. * Get the friendly name associated with the input class.
  36231. * @returns the input friendly name
  36232. */
  36233. getSimpleName(): string;
  36234. }
  36235. }
  36236. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36237. import { Nullable } from "babylonjs/types";
  36238. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36239. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36240. /**
  36241. * Manage the mouse wheel inputs to control an arc rotate camera.
  36242. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36243. */
  36244. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36245. /**
  36246. * Defines the camera the input is attached to.
  36247. */
  36248. camera: ArcRotateCamera;
  36249. /**
  36250. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36251. */
  36252. wheelPrecision: number;
  36253. /**
  36254. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36255. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36256. */
  36257. wheelDeltaPercentage: number;
  36258. private _wheel;
  36259. private _observer;
  36260. private computeDeltaFromMouseWheelLegacyEvent;
  36261. /**
  36262. * Attach the input controls to a specific dom element to get the input from.
  36263. * @param element Defines the element the controls should be listened from
  36264. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36265. */
  36266. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36267. /**
  36268. * Detach the current controls from the specified dom element.
  36269. * @param element Defines the element to stop listening the inputs from
  36270. */
  36271. detachControl(element: Nullable<HTMLElement>): void;
  36272. /**
  36273. * Gets the class name of the current intput.
  36274. * @returns the class name
  36275. */
  36276. getClassName(): string;
  36277. /**
  36278. * Get the friendly name associated with the input class.
  36279. * @returns the input friendly name
  36280. */
  36281. getSimpleName(): string;
  36282. }
  36283. }
  36284. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36285. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36286. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36287. /**
  36288. * Default Inputs manager for the ArcRotateCamera.
  36289. * It groups all the default supported inputs for ease of use.
  36290. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36291. */
  36292. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36293. /**
  36294. * Instantiates a new ArcRotateCameraInputsManager.
  36295. * @param camera Defines the camera the inputs belong to
  36296. */
  36297. constructor(camera: ArcRotateCamera);
  36298. /**
  36299. * Add mouse wheel input support to the input manager.
  36300. * @returns the current input manager
  36301. */
  36302. addMouseWheel(): ArcRotateCameraInputsManager;
  36303. /**
  36304. * Add pointers input support to the input manager.
  36305. * @returns the current input manager
  36306. */
  36307. addPointers(): ArcRotateCameraInputsManager;
  36308. /**
  36309. * Add keyboard input support to the input manager.
  36310. * @returns the current input manager
  36311. */
  36312. addKeyboard(): ArcRotateCameraInputsManager;
  36313. }
  36314. }
  36315. declare module "babylonjs/Cameras/arcRotateCamera" {
  36316. import { Observable } from "babylonjs/Misc/observable";
  36317. import { Nullable } from "babylonjs/types";
  36318. import { Scene } from "babylonjs/scene";
  36319. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  36320. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36321. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36322. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36323. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36324. import { Camera } from "babylonjs/Cameras/camera";
  36325. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36326. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36327. import { Collider } from "babylonjs/Collisions/collider";
  36328. /**
  36329. * This represents an orbital type of camera.
  36330. *
  36331. * 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.
  36332. * 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.
  36333. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36334. */
  36335. export class ArcRotateCamera extends TargetCamera {
  36336. /**
  36337. * Defines the rotation angle of the camera along the longitudinal axis.
  36338. */
  36339. alpha: number;
  36340. /**
  36341. * Defines the rotation angle of the camera along the latitudinal axis.
  36342. */
  36343. beta: number;
  36344. /**
  36345. * Defines the radius of the camera from it s target point.
  36346. */
  36347. radius: number;
  36348. protected _target: Vector3;
  36349. protected _targetHost: Nullable<AbstractMesh>;
  36350. /**
  36351. * Defines the target point of the camera.
  36352. * The camera looks towards it form the radius distance.
  36353. */
  36354. target: Vector3;
  36355. /**
  36356. * Define the current local position of the camera in the scene
  36357. */
  36358. position: Vector3;
  36359. protected _upVector: Vector3;
  36360. protected _upToYMatrix: Matrix;
  36361. protected _YToUpMatrix: Matrix;
  36362. /**
  36363. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36364. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36365. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36366. */
  36367. upVector: Vector3;
  36368. /**
  36369. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36370. */
  36371. setMatUp(): void;
  36372. /**
  36373. * Current inertia value on the longitudinal axis.
  36374. * The bigger this number the longer it will take for the camera to stop.
  36375. */
  36376. inertialAlphaOffset: number;
  36377. /**
  36378. * Current inertia value on the latitudinal axis.
  36379. * The bigger this number the longer it will take for the camera to stop.
  36380. */
  36381. inertialBetaOffset: number;
  36382. /**
  36383. * Current inertia value on the radius axis.
  36384. * The bigger this number the longer it will take for the camera to stop.
  36385. */
  36386. inertialRadiusOffset: number;
  36387. /**
  36388. * Minimum allowed angle on the longitudinal axis.
  36389. * This can help limiting how the Camera is able to move in the scene.
  36390. */
  36391. lowerAlphaLimit: Nullable<number>;
  36392. /**
  36393. * Maximum allowed angle on the longitudinal axis.
  36394. * This can help limiting how the Camera is able to move in the scene.
  36395. */
  36396. upperAlphaLimit: Nullable<number>;
  36397. /**
  36398. * Minimum allowed angle on the latitudinal axis.
  36399. * This can help limiting how the Camera is able to move in the scene.
  36400. */
  36401. lowerBetaLimit: number;
  36402. /**
  36403. * Maximum allowed angle on the latitudinal axis.
  36404. * This can help limiting how the Camera is able to move in the scene.
  36405. */
  36406. upperBetaLimit: number;
  36407. /**
  36408. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36409. * This can help limiting how the Camera is able to move in the scene.
  36410. */
  36411. lowerRadiusLimit: Nullable<number>;
  36412. /**
  36413. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36414. * This can help limiting how the Camera is able to move in the scene.
  36415. */
  36416. upperRadiusLimit: Nullable<number>;
  36417. /**
  36418. * Defines the current inertia value used during panning of the camera along the X axis.
  36419. */
  36420. inertialPanningX: number;
  36421. /**
  36422. * Defines the current inertia value used during panning of the camera along the Y axis.
  36423. */
  36424. inertialPanningY: number;
  36425. /**
  36426. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36427. * Basically if your fingers moves away from more than this distance you will be considered
  36428. * in pinch mode.
  36429. */
  36430. pinchToPanMaxDistance: number;
  36431. /**
  36432. * Defines the maximum distance the camera can pan.
  36433. * This could help keeping the cammera always in your scene.
  36434. */
  36435. panningDistanceLimit: Nullable<number>;
  36436. /**
  36437. * Defines the target of the camera before paning.
  36438. */
  36439. panningOriginTarget: Vector3;
  36440. /**
  36441. * Defines the value of the inertia used during panning.
  36442. * 0 would mean stop inertia and one would mean no decelleration at all.
  36443. */
  36444. panningInertia: number;
  36445. /**
  36446. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36447. */
  36448. angularSensibilityX: number;
  36449. /**
  36450. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36451. */
  36452. angularSensibilityY: number;
  36453. /**
  36454. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36455. */
  36456. pinchPrecision: number;
  36457. /**
  36458. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36459. * It will be used instead of pinchDeltaPrecision if different from 0.
  36460. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36461. */
  36462. pinchDeltaPercentage: number;
  36463. /**
  36464. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36465. */
  36466. panningSensibility: number;
  36467. /**
  36468. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36469. */
  36470. keysUp: number[];
  36471. /**
  36472. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36473. */
  36474. keysDown: number[];
  36475. /**
  36476. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36477. */
  36478. keysLeft: number[];
  36479. /**
  36480. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36481. */
  36482. keysRight: number[];
  36483. /**
  36484. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36485. */
  36486. wheelPrecision: number;
  36487. /**
  36488. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36489. * It will be used instead of pinchDeltaPrecision if different from 0.
  36490. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36491. */
  36492. wheelDeltaPercentage: number;
  36493. /**
  36494. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36495. */
  36496. zoomOnFactor: number;
  36497. /**
  36498. * Defines a screen offset for the camera position.
  36499. */
  36500. targetScreenOffset: Vector2;
  36501. /**
  36502. * Allows the camera to be completely reversed.
  36503. * If false the camera can not arrive upside down.
  36504. */
  36505. allowUpsideDown: boolean;
  36506. /**
  36507. * Define if double tap/click is used to restore the previously saved state of the camera.
  36508. */
  36509. useInputToRestoreState: boolean;
  36510. /** @hidden */
  36511. _viewMatrix: Matrix;
  36512. /** @hidden */
  36513. _useCtrlForPanning: boolean;
  36514. /** @hidden */
  36515. _panningMouseButton: number;
  36516. /**
  36517. * Defines the input associated to the camera.
  36518. */
  36519. inputs: ArcRotateCameraInputsManager;
  36520. /** @hidden */
  36521. _reset: () => void;
  36522. /**
  36523. * Defines the allowed panning axis.
  36524. */
  36525. panningAxis: Vector3;
  36526. protected _localDirection: Vector3;
  36527. protected _transformedDirection: Vector3;
  36528. private _bouncingBehavior;
  36529. /**
  36530. * Gets the bouncing behavior of the camera if it has been enabled.
  36531. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36532. */
  36533. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36534. /**
  36535. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36536. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36537. */
  36538. useBouncingBehavior: boolean;
  36539. private _framingBehavior;
  36540. /**
  36541. * Gets the framing behavior of the camera if it has been enabled.
  36542. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36543. */
  36544. readonly framingBehavior: Nullable<FramingBehavior>;
  36545. /**
  36546. * Defines if the framing behavior of the camera is enabled on the camera.
  36547. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36548. */
  36549. useFramingBehavior: boolean;
  36550. private _autoRotationBehavior;
  36551. /**
  36552. * Gets the auto rotation behavior of the camera if it has been enabled.
  36553. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36554. */
  36555. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36556. /**
  36557. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36558. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36559. */
  36560. useAutoRotationBehavior: boolean;
  36561. /**
  36562. * Observable triggered when the mesh target has been changed on the camera.
  36563. */
  36564. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36565. /**
  36566. * Event raised when the camera is colliding with a mesh.
  36567. */
  36568. onCollide: (collidedMesh: AbstractMesh) => void;
  36569. /**
  36570. * Defines whether the camera should check collision with the objects oh the scene.
  36571. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36572. */
  36573. checkCollisions: boolean;
  36574. /**
  36575. * Defines the collision radius of the camera.
  36576. * This simulates a sphere around the camera.
  36577. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36578. */
  36579. collisionRadius: Vector3;
  36580. protected _collider: Collider;
  36581. protected _previousPosition: Vector3;
  36582. protected _collisionVelocity: Vector3;
  36583. protected _newPosition: Vector3;
  36584. protected _previousAlpha: number;
  36585. protected _previousBeta: number;
  36586. protected _previousRadius: number;
  36587. protected _collisionTriggered: boolean;
  36588. protected _targetBoundingCenter: Nullable<Vector3>;
  36589. private _computationVector;
  36590. /**
  36591. * Instantiates a new ArcRotateCamera in a given scene
  36592. * @param name Defines the name of the camera
  36593. * @param alpha Defines the camera rotation along the logitudinal axis
  36594. * @param beta Defines the camera rotation along the latitudinal axis
  36595. * @param radius Defines the camera distance from its target
  36596. * @param target Defines the camera target
  36597. * @param scene Defines the scene the camera belongs to
  36598. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36599. */
  36600. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36601. /** @hidden */
  36602. _initCache(): void;
  36603. /** @hidden */
  36604. _updateCache(ignoreParentClass?: boolean): void;
  36605. protected _getTargetPosition(): Vector3;
  36606. private _storedAlpha;
  36607. private _storedBeta;
  36608. private _storedRadius;
  36609. private _storedTarget;
  36610. /**
  36611. * Stores the current state of the camera (alpha, beta, radius and target)
  36612. * @returns the camera itself
  36613. */
  36614. storeState(): Camera;
  36615. /**
  36616. * @hidden
  36617. * Restored camera state. You must call storeState() first
  36618. */
  36619. _restoreStateValues(): boolean;
  36620. /** @hidden */
  36621. _isSynchronizedViewMatrix(): boolean;
  36622. /**
  36623. * Attached controls to the current camera.
  36624. * @param element Defines the element the controls should be listened from
  36625. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36626. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36627. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36628. */
  36629. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36630. /**
  36631. * Detach the current controls from the camera.
  36632. * The camera will stop reacting to inputs.
  36633. * @param element Defines the element to stop listening the inputs from
  36634. */
  36635. detachControl(element: HTMLElement): void;
  36636. /** @hidden */
  36637. _checkInputs(): void;
  36638. protected _checkLimits(): void;
  36639. /**
  36640. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36641. */
  36642. rebuildAnglesAndRadius(): void;
  36643. /**
  36644. * Use a position to define the current camera related information like aplha, beta and radius
  36645. * @param position Defines the position to set the camera at
  36646. */
  36647. setPosition(position: Vector3): void;
  36648. /**
  36649. * Defines the target the camera should look at.
  36650. * This will automatically adapt alpha beta and radius to fit within the new target.
  36651. * @param target Defines the new target as a Vector or a mesh
  36652. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36653. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36654. */
  36655. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36656. /** @hidden */
  36657. _getViewMatrix(): Matrix;
  36658. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36659. /**
  36660. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36661. * @param meshes Defines the mesh to zoom on
  36662. * @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)
  36663. */
  36664. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36665. /**
  36666. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36667. * The target will be changed but the radius
  36668. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36669. * @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)
  36670. */
  36671. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36672. min: Vector3;
  36673. max: Vector3;
  36674. distance: number;
  36675. }, doNotUpdateMaxZ?: boolean): void;
  36676. /**
  36677. * @override
  36678. * Override Camera.createRigCamera
  36679. */
  36680. createRigCamera(name: string, cameraIndex: number): Camera;
  36681. /**
  36682. * @hidden
  36683. * @override
  36684. * Override Camera._updateRigCameras
  36685. */
  36686. _updateRigCameras(): void;
  36687. /**
  36688. * Destroy the camera and release the current resources hold by it.
  36689. */
  36690. dispose(): void;
  36691. /**
  36692. * Gets the current object class name.
  36693. * @return the class name
  36694. */
  36695. getClassName(): string;
  36696. }
  36697. }
  36698. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36699. import { Behavior } from "babylonjs/Behaviors/behavior";
  36700. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36701. /**
  36702. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36703. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36704. */
  36705. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36706. /**
  36707. * Gets the name of the behavior.
  36708. */
  36709. readonly name: string;
  36710. private _zoomStopsAnimation;
  36711. private _idleRotationSpeed;
  36712. private _idleRotationWaitTime;
  36713. private _idleRotationSpinupTime;
  36714. /**
  36715. * Sets the flag that indicates if user zooming should stop animation.
  36716. */
  36717. /**
  36718. * Gets the flag that indicates if user zooming should stop animation.
  36719. */
  36720. zoomStopsAnimation: boolean;
  36721. /**
  36722. * Sets the default speed at which the camera rotates around the model.
  36723. */
  36724. /**
  36725. * Gets the default speed at which the camera rotates around the model.
  36726. */
  36727. idleRotationSpeed: number;
  36728. /**
  36729. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36730. */
  36731. /**
  36732. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36733. */
  36734. idleRotationWaitTime: number;
  36735. /**
  36736. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36737. */
  36738. /**
  36739. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36740. */
  36741. idleRotationSpinupTime: number;
  36742. /**
  36743. * Gets a value indicating if the camera is currently rotating because of this behavior
  36744. */
  36745. readonly rotationInProgress: boolean;
  36746. private _onPrePointerObservableObserver;
  36747. private _onAfterCheckInputsObserver;
  36748. private _attachedCamera;
  36749. private _isPointerDown;
  36750. private _lastFrameTime;
  36751. private _lastInteractionTime;
  36752. private _cameraRotationSpeed;
  36753. /**
  36754. * Initializes the behavior.
  36755. */
  36756. init(): void;
  36757. /**
  36758. * Attaches the behavior to its arc rotate camera.
  36759. * @param camera Defines the camera to attach the behavior to
  36760. */
  36761. attach(camera: ArcRotateCamera): void;
  36762. /**
  36763. * Detaches the behavior from its current arc rotate camera.
  36764. */
  36765. detach(): void;
  36766. /**
  36767. * Returns true if user is scrolling.
  36768. * @return true if user is scrolling.
  36769. */
  36770. private _userIsZooming;
  36771. private _lastFrameRadius;
  36772. private _shouldAnimationStopForInteraction;
  36773. /**
  36774. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36775. */
  36776. private _applyUserInteraction;
  36777. private _userIsMoving;
  36778. }
  36779. }
  36780. declare module "babylonjs/Behaviors/Cameras/index" {
  36781. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36782. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36783. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36784. }
  36785. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36786. import { Mesh } from "babylonjs/Meshes/mesh";
  36787. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36788. import { Behavior } from "babylonjs/Behaviors/behavior";
  36789. /**
  36790. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36791. */
  36792. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36793. private ui;
  36794. /**
  36795. * The name of the behavior
  36796. */
  36797. name: string;
  36798. /**
  36799. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36800. */
  36801. distanceAwayFromFace: number;
  36802. /**
  36803. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36804. */
  36805. distanceAwayFromBottomOfFace: number;
  36806. private _faceVectors;
  36807. private _target;
  36808. private _scene;
  36809. private _onRenderObserver;
  36810. private _tmpMatrix;
  36811. private _tmpVector;
  36812. /**
  36813. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36814. * @param ui The transform node that should be attched to the mesh
  36815. */
  36816. constructor(ui: TransformNode);
  36817. /**
  36818. * Initializes the behavior
  36819. */
  36820. init(): void;
  36821. private _closestFace;
  36822. private _zeroVector;
  36823. private _lookAtTmpMatrix;
  36824. private _lookAtToRef;
  36825. /**
  36826. * Attaches the AttachToBoxBehavior to the passed in mesh
  36827. * @param target The mesh that the specified node will be attached to
  36828. */
  36829. attach(target: Mesh): void;
  36830. /**
  36831. * Detaches the behavior from the mesh
  36832. */
  36833. detach(): void;
  36834. }
  36835. }
  36836. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36837. import { Behavior } from "babylonjs/Behaviors/behavior";
  36838. import { Mesh } from "babylonjs/Meshes/mesh";
  36839. /**
  36840. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36841. */
  36842. export class FadeInOutBehavior implements Behavior<Mesh> {
  36843. /**
  36844. * Time in milliseconds to delay before fading in (Default: 0)
  36845. */
  36846. delay: number;
  36847. /**
  36848. * Time in milliseconds for the mesh to fade in (Default: 300)
  36849. */
  36850. fadeInTime: number;
  36851. private _millisecondsPerFrame;
  36852. private _hovered;
  36853. private _hoverValue;
  36854. private _ownerNode;
  36855. /**
  36856. * Instatiates the FadeInOutBehavior
  36857. */
  36858. constructor();
  36859. /**
  36860. * The name of the behavior
  36861. */
  36862. readonly name: string;
  36863. /**
  36864. * Initializes the behavior
  36865. */
  36866. init(): void;
  36867. /**
  36868. * Attaches the fade behavior on the passed in mesh
  36869. * @param ownerNode The mesh that will be faded in/out once attached
  36870. */
  36871. attach(ownerNode: Mesh): void;
  36872. /**
  36873. * Detaches the behavior from the mesh
  36874. */
  36875. detach(): void;
  36876. /**
  36877. * Triggers the mesh to begin fading in or out
  36878. * @param value if the object should fade in or out (true to fade in)
  36879. */
  36880. fadeIn(value: boolean): void;
  36881. private _update;
  36882. private _setAllVisibility;
  36883. }
  36884. }
  36885. declare module "babylonjs/Misc/pivotTools" {
  36886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36887. /**
  36888. * Class containing a set of static utilities functions for managing Pivots
  36889. * @hidden
  36890. */
  36891. export class PivotTools {
  36892. private static _PivotCached;
  36893. private static _OldPivotPoint;
  36894. private static _PivotTranslation;
  36895. private static _PivotTmpVector;
  36896. /** @hidden */
  36897. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36898. /** @hidden */
  36899. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36900. }
  36901. }
  36902. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  36903. import { Scene } from "babylonjs/scene";
  36904. import { Vector4, Plane } from "babylonjs/Maths/math";
  36905. import { Mesh } from "babylonjs/Meshes/mesh";
  36906. import { Nullable } from "babylonjs/types";
  36907. /**
  36908. * Class containing static functions to help procedurally build meshes
  36909. */
  36910. export class PlaneBuilder {
  36911. /**
  36912. * Creates a plane mesh
  36913. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36914. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36915. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36916. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36917. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36918. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36919. * @param name defines the name of the mesh
  36920. * @param options defines the options used to create the mesh
  36921. * @param scene defines the hosting scene
  36922. * @returns the plane mesh
  36923. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36924. */
  36925. static CreatePlane(name: string, options: {
  36926. size?: number;
  36927. width?: number;
  36928. height?: number;
  36929. sideOrientation?: number;
  36930. frontUVs?: Vector4;
  36931. backUVs?: Vector4;
  36932. updatable?: boolean;
  36933. sourcePlane?: Plane;
  36934. }, scene?: Nullable<Scene>): Mesh;
  36935. }
  36936. }
  36937. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36938. import { Behavior } from "babylonjs/Behaviors/behavior";
  36939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36940. import { Observable } from "babylonjs/Misc/observable";
  36941. import { Vector3 } from "babylonjs/Maths/math";
  36942. import { Ray } from "babylonjs/Culling/ray";
  36943. import "babylonjs/Meshes/Builders/planeBuilder";
  36944. /**
  36945. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36946. */
  36947. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36948. private static _AnyMouseID;
  36949. /**
  36950. * Abstract mesh the behavior is set on
  36951. */
  36952. attachedNode: AbstractMesh;
  36953. private _dragPlane;
  36954. private _scene;
  36955. private _pointerObserver;
  36956. private _beforeRenderObserver;
  36957. private static _planeScene;
  36958. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36959. /**
  36960. * 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)
  36961. */
  36962. maxDragAngle: number;
  36963. /**
  36964. * @hidden
  36965. */
  36966. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36967. /**
  36968. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36969. */
  36970. currentDraggingPointerID: number;
  36971. /**
  36972. * The last position where the pointer hit the drag plane in world space
  36973. */
  36974. lastDragPosition: Vector3;
  36975. /**
  36976. * If the behavior is currently in a dragging state
  36977. */
  36978. dragging: boolean;
  36979. /**
  36980. * 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)
  36981. */
  36982. dragDeltaRatio: number;
  36983. /**
  36984. * If the drag plane orientation should be updated during the dragging (Default: true)
  36985. */
  36986. updateDragPlane: boolean;
  36987. private _debugMode;
  36988. private _moving;
  36989. /**
  36990. * Fires each time the attached mesh is dragged with the pointer
  36991. * * delta between last drag position and current drag position in world space
  36992. * * dragDistance along the drag axis
  36993. * * dragPlaneNormal normal of the current drag plane used during the drag
  36994. * * dragPlanePoint in world space where the drag intersects the drag plane
  36995. */
  36996. onDragObservable: Observable<{
  36997. delta: Vector3;
  36998. dragPlanePoint: Vector3;
  36999. dragPlaneNormal: Vector3;
  37000. dragDistance: number;
  37001. pointerId: number;
  37002. }>;
  37003. /**
  37004. * Fires each time a drag begins (eg. mouse down on mesh)
  37005. */
  37006. onDragStartObservable: Observable<{
  37007. dragPlanePoint: Vector3;
  37008. pointerId: number;
  37009. }>;
  37010. /**
  37011. * Fires each time a drag ends (eg. mouse release after drag)
  37012. */
  37013. onDragEndObservable: Observable<{
  37014. dragPlanePoint: Vector3;
  37015. pointerId: number;
  37016. }>;
  37017. /**
  37018. * If the attached mesh should be moved when dragged
  37019. */
  37020. moveAttached: boolean;
  37021. /**
  37022. * If the drag behavior will react to drag events (Default: true)
  37023. */
  37024. enabled: boolean;
  37025. /**
  37026. * If camera controls should be detached during the drag
  37027. */
  37028. detachCameraControls: boolean;
  37029. /**
  37030. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37031. */
  37032. useObjectOrienationForDragging: boolean;
  37033. private _options;
  37034. /**
  37035. * Creates a pointer drag behavior that can be attached to a mesh
  37036. * @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)
  37037. */
  37038. constructor(options?: {
  37039. dragAxis?: Vector3;
  37040. dragPlaneNormal?: Vector3;
  37041. });
  37042. /**
  37043. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37044. */
  37045. validateDrag: (targetPosition: Vector3) => boolean;
  37046. /**
  37047. * The name of the behavior
  37048. */
  37049. readonly name: string;
  37050. /**
  37051. * Initializes the behavior
  37052. */
  37053. init(): void;
  37054. private _tmpVector;
  37055. private _alternatePickedPoint;
  37056. private _worldDragAxis;
  37057. private _targetPosition;
  37058. private _attachedElement;
  37059. /**
  37060. * Attaches the drag behavior the passed in mesh
  37061. * @param ownerNode The mesh that will be dragged around once attached
  37062. */
  37063. attach(ownerNode: AbstractMesh): void;
  37064. /**
  37065. * Force relase the drag action by code.
  37066. */
  37067. releaseDrag(): void;
  37068. private _startDragRay;
  37069. private _lastPointerRay;
  37070. /**
  37071. * Simulates the start of a pointer drag event on the behavior
  37072. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37073. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37074. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37075. */
  37076. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37077. private _startDrag;
  37078. private _dragDelta;
  37079. private _moveDrag;
  37080. private _pickWithRayOnDragPlane;
  37081. private _pointA;
  37082. private _pointB;
  37083. private _pointC;
  37084. private _lineA;
  37085. private _lineB;
  37086. private _localAxis;
  37087. private _lookAt;
  37088. private _updateDragPlanePosition;
  37089. /**
  37090. * Detaches the behavior from the mesh
  37091. */
  37092. detach(): void;
  37093. }
  37094. }
  37095. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37096. import { Mesh } from "babylonjs/Meshes/mesh";
  37097. import { Behavior } from "babylonjs/Behaviors/behavior";
  37098. /**
  37099. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37100. */
  37101. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37102. private _dragBehaviorA;
  37103. private _dragBehaviorB;
  37104. private _startDistance;
  37105. private _initialScale;
  37106. private _targetScale;
  37107. private _ownerNode;
  37108. private _sceneRenderObserver;
  37109. /**
  37110. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37111. */
  37112. constructor();
  37113. /**
  37114. * The name of the behavior
  37115. */
  37116. readonly name: string;
  37117. /**
  37118. * Initializes the behavior
  37119. */
  37120. init(): void;
  37121. private _getCurrentDistance;
  37122. /**
  37123. * Attaches the scale behavior the passed in mesh
  37124. * @param ownerNode The mesh that will be scaled around once attached
  37125. */
  37126. attach(ownerNode: Mesh): void;
  37127. /**
  37128. * Detaches the behavior from the mesh
  37129. */
  37130. detach(): void;
  37131. }
  37132. }
  37133. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  37134. import { Behavior } from "babylonjs/Behaviors/behavior";
  37135. import { Mesh } from "babylonjs/Meshes/mesh";
  37136. import { Observable } from "babylonjs/Misc/observable";
  37137. /**
  37138. * 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
  37139. */
  37140. export class SixDofDragBehavior implements Behavior<Mesh> {
  37141. private static _virtualScene;
  37142. private _ownerNode;
  37143. private _sceneRenderObserver;
  37144. private _scene;
  37145. private _targetPosition;
  37146. private _virtualOriginMesh;
  37147. private _virtualDragMesh;
  37148. private _pointerObserver;
  37149. private _moving;
  37150. private _startingOrientation;
  37151. /**
  37152. * 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)
  37153. */
  37154. private zDragFactor;
  37155. /**
  37156. * If the object should rotate to face the drag origin
  37157. */
  37158. rotateDraggedObject: boolean;
  37159. /**
  37160. * If the behavior is currently in a dragging state
  37161. */
  37162. dragging: boolean;
  37163. /**
  37164. * 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)
  37165. */
  37166. dragDeltaRatio: number;
  37167. /**
  37168. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37169. */
  37170. currentDraggingPointerID: number;
  37171. /**
  37172. * If camera controls should be detached during the drag
  37173. */
  37174. detachCameraControls: boolean;
  37175. /**
  37176. * Fires each time a drag starts
  37177. */
  37178. onDragStartObservable: Observable<{}>;
  37179. /**
  37180. * Fires each time a drag ends (eg. mouse release after drag)
  37181. */
  37182. onDragEndObservable: Observable<{}>;
  37183. /**
  37184. * 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
  37185. */
  37186. constructor();
  37187. /**
  37188. * The name of the behavior
  37189. */
  37190. readonly name: string;
  37191. /**
  37192. * Initializes the behavior
  37193. */
  37194. init(): void;
  37195. /**
  37196. * Attaches the scale behavior the passed in mesh
  37197. * @param ownerNode The mesh that will be scaled around once attached
  37198. */
  37199. attach(ownerNode: Mesh): void;
  37200. /**
  37201. * Detaches the behavior from the mesh
  37202. */
  37203. detach(): void;
  37204. }
  37205. }
  37206. declare module "babylonjs/Behaviors/Meshes/index" {
  37207. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37208. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37209. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37210. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37211. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37212. }
  37213. declare module "babylonjs/Behaviors/index" {
  37214. export * from "babylonjs/Behaviors/behavior";
  37215. export * from "babylonjs/Behaviors/Cameras/index";
  37216. export * from "babylonjs/Behaviors/Meshes/index";
  37217. }
  37218. declare module "babylonjs/Bones/boneIKController" {
  37219. import { Bone } from "babylonjs/Bones/bone";
  37220. import { Vector3 } from "babylonjs/Maths/math";
  37221. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37222. import { Nullable } from "babylonjs/types";
  37223. /**
  37224. * Class used to apply inverse kinematics to bones
  37225. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37226. */
  37227. export class BoneIKController {
  37228. private static _tmpVecs;
  37229. private static _tmpQuat;
  37230. private static _tmpMats;
  37231. /**
  37232. * Gets or sets the target mesh
  37233. */
  37234. targetMesh: AbstractMesh;
  37235. /** Gets or sets the mesh used as pole */
  37236. poleTargetMesh: AbstractMesh;
  37237. /**
  37238. * Gets or sets the bone used as pole
  37239. */
  37240. poleTargetBone: Nullable<Bone>;
  37241. /**
  37242. * Gets or sets the target position
  37243. */
  37244. targetPosition: Vector3;
  37245. /**
  37246. * Gets or sets the pole target position
  37247. */
  37248. poleTargetPosition: Vector3;
  37249. /**
  37250. * Gets or sets the pole target local offset
  37251. */
  37252. poleTargetLocalOffset: Vector3;
  37253. /**
  37254. * Gets or sets the pole angle
  37255. */
  37256. poleAngle: number;
  37257. /**
  37258. * Gets or sets the mesh associated with the controller
  37259. */
  37260. mesh: AbstractMesh;
  37261. /**
  37262. * 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)
  37263. */
  37264. slerpAmount: number;
  37265. private _bone1Quat;
  37266. private _bone1Mat;
  37267. private _bone2Ang;
  37268. private _bone1;
  37269. private _bone2;
  37270. private _bone1Length;
  37271. private _bone2Length;
  37272. private _maxAngle;
  37273. private _maxReach;
  37274. private _rightHandedSystem;
  37275. private _bendAxis;
  37276. private _slerping;
  37277. private _adjustRoll;
  37278. /**
  37279. * Gets or sets maximum allowed angle
  37280. */
  37281. maxAngle: number;
  37282. /**
  37283. * Creates a new BoneIKController
  37284. * @param mesh defines the mesh to control
  37285. * @param bone defines the bone to control
  37286. * @param options defines options to set up the controller
  37287. */
  37288. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37289. targetMesh?: AbstractMesh;
  37290. poleTargetMesh?: AbstractMesh;
  37291. poleTargetBone?: Bone;
  37292. poleTargetLocalOffset?: Vector3;
  37293. poleAngle?: number;
  37294. bendAxis?: Vector3;
  37295. maxAngle?: number;
  37296. slerpAmount?: number;
  37297. });
  37298. private _setMaxAngle;
  37299. /**
  37300. * Force the controller to update the bones
  37301. */
  37302. update(): void;
  37303. }
  37304. }
  37305. declare module "babylonjs/Bones/boneLookController" {
  37306. import { Vector3, Space } from "babylonjs/Maths/math";
  37307. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37308. import { Bone } from "babylonjs/Bones/bone";
  37309. /**
  37310. * Class used to make a bone look toward a point in space
  37311. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37312. */
  37313. export class BoneLookController {
  37314. private static _tmpVecs;
  37315. private static _tmpQuat;
  37316. private static _tmpMats;
  37317. /**
  37318. * The target Vector3 that the bone will look at
  37319. */
  37320. target: Vector3;
  37321. /**
  37322. * The mesh that the bone is attached to
  37323. */
  37324. mesh: AbstractMesh;
  37325. /**
  37326. * The bone that will be looking to the target
  37327. */
  37328. bone: Bone;
  37329. /**
  37330. * The up axis of the coordinate system that is used when the bone is rotated
  37331. */
  37332. upAxis: Vector3;
  37333. /**
  37334. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37335. */
  37336. upAxisSpace: Space;
  37337. /**
  37338. * Used to make an adjustment to the yaw of the bone
  37339. */
  37340. adjustYaw: number;
  37341. /**
  37342. * Used to make an adjustment to the pitch of the bone
  37343. */
  37344. adjustPitch: number;
  37345. /**
  37346. * Used to make an adjustment to the roll of the bone
  37347. */
  37348. adjustRoll: number;
  37349. /**
  37350. * 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)
  37351. */
  37352. slerpAmount: number;
  37353. private _minYaw;
  37354. private _maxYaw;
  37355. private _minPitch;
  37356. private _maxPitch;
  37357. private _minYawSin;
  37358. private _minYawCos;
  37359. private _maxYawSin;
  37360. private _maxYawCos;
  37361. private _midYawConstraint;
  37362. private _minPitchTan;
  37363. private _maxPitchTan;
  37364. private _boneQuat;
  37365. private _slerping;
  37366. private _transformYawPitch;
  37367. private _transformYawPitchInv;
  37368. private _firstFrameSkipped;
  37369. private _yawRange;
  37370. private _fowardAxis;
  37371. /**
  37372. * Gets or sets the minimum yaw angle that the bone can look to
  37373. */
  37374. minYaw: number;
  37375. /**
  37376. * Gets or sets the maximum yaw angle that the bone can look to
  37377. */
  37378. maxYaw: number;
  37379. /**
  37380. * Gets or sets the minimum pitch angle that the bone can look to
  37381. */
  37382. minPitch: number;
  37383. /**
  37384. * Gets or sets the maximum pitch angle that the bone can look to
  37385. */
  37386. maxPitch: number;
  37387. /**
  37388. * Create a BoneLookController
  37389. * @param mesh the mesh that the bone belongs to
  37390. * @param bone the bone that will be looking to the target
  37391. * @param target the target Vector3 to look at
  37392. * @param options optional settings:
  37393. * * maxYaw: the maximum angle the bone will yaw to
  37394. * * minYaw: the minimum angle the bone will yaw to
  37395. * * maxPitch: the maximum angle the bone will pitch to
  37396. * * minPitch: the minimum angle the bone will yaw to
  37397. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37398. * * upAxis: the up axis of the coordinate system
  37399. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37400. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37401. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37402. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37403. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37404. * * adjustRoll: used to make an adjustment to the roll of the bone
  37405. **/
  37406. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37407. maxYaw?: number;
  37408. minYaw?: number;
  37409. maxPitch?: number;
  37410. minPitch?: number;
  37411. slerpAmount?: number;
  37412. upAxis?: Vector3;
  37413. upAxisSpace?: Space;
  37414. yawAxis?: Vector3;
  37415. pitchAxis?: Vector3;
  37416. adjustYaw?: number;
  37417. adjustPitch?: number;
  37418. adjustRoll?: number;
  37419. });
  37420. /**
  37421. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37422. */
  37423. update(): void;
  37424. private _getAngleDiff;
  37425. private _getAngleBetween;
  37426. private _isAngleBetween;
  37427. }
  37428. }
  37429. declare module "babylonjs/Bones/index" {
  37430. export * from "babylonjs/Bones/bone";
  37431. export * from "babylonjs/Bones/boneIKController";
  37432. export * from "babylonjs/Bones/boneLookController";
  37433. export * from "babylonjs/Bones/skeleton";
  37434. }
  37435. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  37436. import { Nullable } from "babylonjs/types";
  37437. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37438. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37439. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37440. /**
  37441. * Manage the gamepad inputs to control an arc rotate camera.
  37442. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37443. */
  37444. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37445. /**
  37446. * Defines the camera the input is attached to.
  37447. */
  37448. camera: ArcRotateCamera;
  37449. /**
  37450. * Defines the gamepad the input is gathering event from.
  37451. */
  37452. gamepad: Nullable<Gamepad>;
  37453. /**
  37454. * Defines the gamepad rotation sensiblity.
  37455. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37456. */
  37457. gamepadRotationSensibility: number;
  37458. /**
  37459. * Defines the gamepad move sensiblity.
  37460. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37461. */
  37462. gamepadMoveSensibility: number;
  37463. private _onGamepadConnectedObserver;
  37464. private _onGamepadDisconnectedObserver;
  37465. /**
  37466. * Attach the input controls to a specific dom element to get the input from.
  37467. * @param element Defines the element the controls should be listened from
  37468. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37469. */
  37470. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37471. /**
  37472. * Detach the current controls from the specified dom element.
  37473. * @param element Defines the element to stop listening the inputs from
  37474. */
  37475. detachControl(element: Nullable<HTMLElement>): void;
  37476. /**
  37477. * Update the current camera state depending on the inputs that have been used this frame.
  37478. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37479. */
  37480. checkInputs(): void;
  37481. /**
  37482. * Gets the class name of the current intput.
  37483. * @returns the class name
  37484. */
  37485. getClassName(): string;
  37486. /**
  37487. * Get the friendly name associated with the input class.
  37488. * @returns the input friendly name
  37489. */
  37490. getSimpleName(): string;
  37491. }
  37492. }
  37493. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  37494. import { Nullable } from "babylonjs/types";
  37495. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37496. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37497. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37498. interface ArcRotateCameraInputsManager {
  37499. /**
  37500. * Add orientation input support to the input manager.
  37501. * @returns the current input manager
  37502. */
  37503. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37504. }
  37505. }
  37506. /**
  37507. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37508. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37509. */
  37510. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37511. /**
  37512. * Defines the camera the input is attached to.
  37513. */
  37514. camera: ArcRotateCamera;
  37515. /**
  37516. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37517. */
  37518. alphaCorrection: number;
  37519. /**
  37520. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37521. */
  37522. gammaCorrection: number;
  37523. private _alpha;
  37524. private _gamma;
  37525. private _dirty;
  37526. private _deviceOrientationHandler;
  37527. /**
  37528. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37529. */
  37530. constructor();
  37531. /**
  37532. * Attach the input controls to a specific dom element to get the input from.
  37533. * @param element Defines the element the controls should be listened from
  37534. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37535. */
  37536. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37537. /** @hidden */
  37538. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37539. /**
  37540. * Update the current camera state depending on the inputs that have been used this frame.
  37541. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37542. */
  37543. checkInputs(): void;
  37544. /**
  37545. * Detach the current controls from the specified dom element.
  37546. * @param element Defines the element to stop listening the inputs from
  37547. */
  37548. detachControl(element: Nullable<HTMLElement>): void;
  37549. /**
  37550. * Gets the class name of the current intput.
  37551. * @returns the class name
  37552. */
  37553. getClassName(): string;
  37554. /**
  37555. * Get the friendly name associated with the input class.
  37556. * @returns the input friendly name
  37557. */
  37558. getSimpleName(): string;
  37559. }
  37560. }
  37561. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37562. import { Nullable } from "babylonjs/types";
  37563. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37564. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37565. /**
  37566. * Listen to mouse events to control the camera.
  37567. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37568. */
  37569. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37570. /**
  37571. * Defines the camera the input is attached to.
  37572. */
  37573. camera: FlyCamera;
  37574. /**
  37575. * Defines if touch is enabled. (Default is true.)
  37576. */
  37577. touchEnabled: boolean;
  37578. /**
  37579. * Defines the buttons associated with the input to handle camera rotation.
  37580. */
  37581. buttons: number[];
  37582. /**
  37583. * Assign buttons for Yaw control.
  37584. */
  37585. buttonsYaw: number[];
  37586. /**
  37587. * Assign buttons for Pitch control.
  37588. */
  37589. buttonsPitch: number[];
  37590. /**
  37591. * Assign buttons for Roll control.
  37592. */
  37593. buttonsRoll: number[];
  37594. /**
  37595. * Detect if any button is being pressed while mouse is moved.
  37596. * -1 = Mouse locked.
  37597. * 0 = Left button.
  37598. * 1 = Middle Button.
  37599. * 2 = Right Button.
  37600. */
  37601. activeButton: number;
  37602. /**
  37603. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37604. * Higher values reduce its sensitivity.
  37605. */
  37606. angularSensibility: number;
  37607. private _mousemoveCallback;
  37608. private _observer;
  37609. private _rollObserver;
  37610. private previousPosition;
  37611. private noPreventDefault;
  37612. private element;
  37613. /**
  37614. * Listen to mouse events to control the camera.
  37615. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37616. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37617. */
  37618. constructor(touchEnabled?: boolean);
  37619. /**
  37620. * Attach the mouse control to the HTML DOM element.
  37621. * @param element Defines the element that listens to the input events.
  37622. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37623. */
  37624. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37625. /**
  37626. * Detach the current controls from the specified dom element.
  37627. * @param element Defines the element to stop listening the inputs from
  37628. */
  37629. detachControl(element: Nullable<HTMLElement>): void;
  37630. /**
  37631. * Gets the class name of the current input.
  37632. * @returns the class name.
  37633. */
  37634. getClassName(): string;
  37635. /**
  37636. * Get the friendly name associated with the input class.
  37637. * @returns the input's friendly name.
  37638. */
  37639. getSimpleName(): string;
  37640. private _pointerInput;
  37641. private _onMouseMove;
  37642. /**
  37643. * Rotate camera by mouse offset.
  37644. */
  37645. private rotateCamera;
  37646. }
  37647. }
  37648. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37649. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37650. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37651. /**
  37652. * Default Inputs manager for the FlyCamera.
  37653. * It groups all the default supported inputs for ease of use.
  37654. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37655. */
  37656. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37657. /**
  37658. * Instantiates a new FlyCameraInputsManager.
  37659. * @param camera Defines the camera the inputs belong to.
  37660. */
  37661. constructor(camera: FlyCamera);
  37662. /**
  37663. * Add keyboard input support to the input manager.
  37664. * @returns the new FlyCameraKeyboardMoveInput().
  37665. */
  37666. addKeyboard(): FlyCameraInputsManager;
  37667. /**
  37668. * Add mouse input support to the input manager.
  37669. * @param touchEnabled Enable touch screen support.
  37670. * @returns the new FlyCameraMouseInput().
  37671. */
  37672. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37673. }
  37674. }
  37675. declare module "babylonjs/Cameras/flyCamera" {
  37676. import { Scene } from "babylonjs/scene";
  37677. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37678. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37679. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37680. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37681. /**
  37682. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37683. * such as in a 3D Space Shooter or a Flight Simulator.
  37684. */
  37685. export class FlyCamera extends TargetCamera {
  37686. /**
  37687. * Define the collision ellipsoid of the camera.
  37688. * This is helpful for simulating a camera body, like a player's body.
  37689. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37690. */
  37691. ellipsoid: Vector3;
  37692. /**
  37693. * Define an offset for the position of the ellipsoid around the camera.
  37694. * This can be helpful if the camera is attached away from the player's body center,
  37695. * such as at its head.
  37696. */
  37697. ellipsoidOffset: Vector3;
  37698. /**
  37699. * Enable or disable collisions of the camera with the rest of the scene objects.
  37700. */
  37701. checkCollisions: boolean;
  37702. /**
  37703. * Enable or disable gravity on the camera.
  37704. */
  37705. applyGravity: boolean;
  37706. /**
  37707. * Define the current direction the camera is moving to.
  37708. */
  37709. cameraDirection: Vector3;
  37710. /**
  37711. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37712. * This overrides and empties cameraRotation.
  37713. */
  37714. rotationQuaternion: Quaternion;
  37715. /**
  37716. * Track Roll to maintain the wanted Rolling when looking around.
  37717. */
  37718. _trackRoll: number;
  37719. /**
  37720. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37721. */
  37722. rollCorrect: number;
  37723. /**
  37724. * Mimic a banked turn, Rolling the camera when Yawing.
  37725. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37726. */
  37727. bankedTurn: boolean;
  37728. /**
  37729. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37730. */
  37731. bankedTurnLimit: number;
  37732. /**
  37733. * Value of 0 disables the banked Roll.
  37734. * Value of 1 is equal to the Yaw angle in radians.
  37735. */
  37736. bankedTurnMultiplier: number;
  37737. /**
  37738. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37739. */
  37740. inputs: FlyCameraInputsManager;
  37741. /**
  37742. * Gets the input sensibility for mouse input.
  37743. * Higher values reduce sensitivity.
  37744. */
  37745. /**
  37746. * Sets the input sensibility for a mouse input.
  37747. * Higher values reduce sensitivity.
  37748. */
  37749. angularSensibility: number;
  37750. /**
  37751. * Get the keys for camera movement forward.
  37752. */
  37753. /**
  37754. * Set the keys for camera movement forward.
  37755. */
  37756. keysForward: number[];
  37757. /**
  37758. * Get the keys for camera movement backward.
  37759. */
  37760. keysBackward: number[];
  37761. /**
  37762. * Get the keys for camera movement up.
  37763. */
  37764. /**
  37765. * Set the keys for camera movement up.
  37766. */
  37767. keysUp: number[];
  37768. /**
  37769. * Get the keys for camera movement down.
  37770. */
  37771. /**
  37772. * Set the keys for camera movement down.
  37773. */
  37774. keysDown: number[];
  37775. /**
  37776. * Get the keys for camera movement left.
  37777. */
  37778. /**
  37779. * Set the keys for camera movement left.
  37780. */
  37781. keysLeft: number[];
  37782. /**
  37783. * Set the keys for camera movement right.
  37784. */
  37785. /**
  37786. * Set the keys for camera movement right.
  37787. */
  37788. keysRight: number[];
  37789. /**
  37790. * Event raised when the camera collides with a mesh in the scene.
  37791. */
  37792. onCollide: (collidedMesh: AbstractMesh) => void;
  37793. private _collider;
  37794. private _needMoveForGravity;
  37795. private _oldPosition;
  37796. private _diffPosition;
  37797. private _newPosition;
  37798. /** @hidden */
  37799. _localDirection: Vector3;
  37800. /** @hidden */
  37801. _transformedDirection: Vector3;
  37802. /**
  37803. * Instantiates a FlyCamera.
  37804. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37805. * such as in a 3D Space Shooter or a Flight Simulator.
  37806. * @param name Define the name of the camera in the scene.
  37807. * @param position Define the starting position of the camera in the scene.
  37808. * @param scene Define the scene the camera belongs to.
  37809. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37810. */
  37811. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37812. /**
  37813. * Attach a control to the HTML DOM element.
  37814. * @param element Defines the element that listens to the input events.
  37815. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37816. */
  37817. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37818. /**
  37819. * Detach a control from the HTML DOM element.
  37820. * The camera will stop reacting to that input.
  37821. * @param element Defines the element that listens to the input events.
  37822. */
  37823. detachControl(element: HTMLElement): void;
  37824. private _collisionMask;
  37825. /**
  37826. * Get the mask that the camera ignores in collision events.
  37827. */
  37828. /**
  37829. * Set the mask that the camera ignores in collision events.
  37830. */
  37831. collisionMask: number;
  37832. /** @hidden */
  37833. _collideWithWorld(displacement: Vector3): void;
  37834. /** @hidden */
  37835. private _onCollisionPositionChange;
  37836. /** @hidden */
  37837. _checkInputs(): void;
  37838. /** @hidden */
  37839. _decideIfNeedsToMove(): boolean;
  37840. /** @hidden */
  37841. _updatePosition(): void;
  37842. /**
  37843. * Restore the Roll to its target value at the rate specified.
  37844. * @param rate - Higher means slower restoring.
  37845. * @hidden
  37846. */
  37847. restoreRoll(rate: number): void;
  37848. /**
  37849. * Destroy the camera and release the current resources held by it.
  37850. */
  37851. dispose(): void;
  37852. /**
  37853. * Get the current object class name.
  37854. * @returns the class name.
  37855. */
  37856. getClassName(): string;
  37857. }
  37858. }
  37859. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37860. import { Nullable } from "babylonjs/types";
  37861. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37862. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37863. /**
  37864. * Listen to keyboard events to control the camera.
  37865. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37866. */
  37867. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37868. /**
  37869. * Defines the camera the input is attached to.
  37870. */
  37871. camera: FlyCamera;
  37872. /**
  37873. * The list of keyboard keys used to control the forward move of the camera.
  37874. */
  37875. keysForward: number[];
  37876. /**
  37877. * The list of keyboard keys used to control the backward move of the camera.
  37878. */
  37879. keysBackward: number[];
  37880. /**
  37881. * The list of keyboard keys used to control the forward move of the camera.
  37882. */
  37883. keysUp: number[];
  37884. /**
  37885. * The list of keyboard keys used to control the backward move of the camera.
  37886. */
  37887. keysDown: number[];
  37888. /**
  37889. * The list of keyboard keys used to control the right strafe move of the camera.
  37890. */
  37891. keysRight: number[];
  37892. /**
  37893. * The list of keyboard keys used to control the left strafe move of the camera.
  37894. */
  37895. keysLeft: number[];
  37896. private _keys;
  37897. private _onCanvasBlurObserver;
  37898. private _onKeyboardObserver;
  37899. private _engine;
  37900. private _scene;
  37901. /**
  37902. * Attach the input controls to a specific dom element to get the input from.
  37903. * @param element Defines the element the controls should be listened from
  37904. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37905. */
  37906. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37907. /**
  37908. * Detach the current controls from the specified dom element.
  37909. * @param element Defines the element to stop listening the inputs from
  37910. */
  37911. detachControl(element: Nullable<HTMLElement>): void;
  37912. /**
  37913. * Gets the class name of the current intput.
  37914. * @returns the class name
  37915. */
  37916. getClassName(): string;
  37917. /** @hidden */
  37918. _onLostFocus(e: FocusEvent): void;
  37919. /**
  37920. * Get the friendly name associated with the input class.
  37921. * @returns the input friendly name
  37922. */
  37923. getSimpleName(): string;
  37924. /**
  37925. * Update the current camera state depending on the inputs that have been used this frame.
  37926. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37927. */
  37928. checkInputs(): void;
  37929. }
  37930. }
  37931. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  37932. import { Nullable } from "babylonjs/types";
  37933. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37934. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37935. /**
  37936. * Manage the mouse wheel inputs to control a follow camera.
  37937. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37938. */
  37939. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37940. /**
  37941. * Defines the camera the input is attached to.
  37942. */
  37943. camera: FollowCamera;
  37944. /**
  37945. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37946. */
  37947. axisControlRadius: boolean;
  37948. /**
  37949. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37950. */
  37951. axisControlHeight: boolean;
  37952. /**
  37953. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37954. */
  37955. axisControlRotation: boolean;
  37956. /**
  37957. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37958. * relation to mouseWheel events.
  37959. */
  37960. wheelPrecision: number;
  37961. /**
  37962. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37963. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37964. */
  37965. wheelDeltaPercentage: number;
  37966. private _wheel;
  37967. private _observer;
  37968. /**
  37969. * Attach the input controls to a specific dom element to get the input from.
  37970. * @param element Defines the element the controls should be listened from
  37971. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37972. */
  37973. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37974. /**
  37975. * Detach the current controls from the specified dom element.
  37976. * @param element Defines the element to stop listening the inputs from
  37977. */
  37978. detachControl(element: Nullable<HTMLElement>): void;
  37979. /**
  37980. * Gets the class name of the current intput.
  37981. * @returns the class name
  37982. */
  37983. getClassName(): string;
  37984. /**
  37985. * Get the friendly name associated with the input class.
  37986. * @returns the input friendly name
  37987. */
  37988. getSimpleName(): string;
  37989. }
  37990. }
  37991. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  37992. import { Nullable } from "babylonjs/types";
  37993. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37994. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37995. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37996. /**
  37997. * Manage the pointers inputs to control an follow camera.
  37998. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37999. */
  38000. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38001. /**
  38002. * Defines the camera the input is attached to.
  38003. */
  38004. camera: FollowCamera;
  38005. /**
  38006. * Gets the class name of the current input.
  38007. * @returns the class name
  38008. */
  38009. getClassName(): string;
  38010. /**
  38011. * Defines the pointer angular sensibility along the X axis or how fast is
  38012. * the camera rotating.
  38013. * A negative number will reverse the axis direction.
  38014. */
  38015. angularSensibilityX: number;
  38016. /**
  38017. * Defines the pointer angular sensibility along the Y axis or how fast is
  38018. * the camera rotating.
  38019. * A negative number will reverse the axis direction.
  38020. */
  38021. angularSensibilityY: number;
  38022. /**
  38023. * Defines the pointer pinch precision or how fast is the camera zooming.
  38024. * A negative number will reverse the axis direction.
  38025. */
  38026. pinchPrecision: number;
  38027. /**
  38028. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38029. * from 0.
  38030. * It defines the percentage of current camera.radius to use as delta when
  38031. * pinch zoom is used.
  38032. */
  38033. pinchDeltaPercentage: number;
  38034. /**
  38035. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38036. */
  38037. axisXControlRadius: boolean;
  38038. /**
  38039. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38040. */
  38041. axisXControlHeight: boolean;
  38042. /**
  38043. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38044. */
  38045. axisXControlRotation: boolean;
  38046. /**
  38047. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38048. */
  38049. axisYControlRadius: boolean;
  38050. /**
  38051. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38052. */
  38053. axisYControlHeight: boolean;
  38054. /**
  38055. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38056. */
  38057. axisYControlRotation: boolean;
  38058. /**
  38059. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38060. */
  38061. axisPinchControlRadius: boolean;
  38062. /**
  38063. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38064. */
  38065. axisPinchControlHeight: boolean;
  38066. /**
  38067. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38068. */
  38069. axisPinchControlRotation: boolean;
  38070. /**
  38071. * Log error messages if basic misconfiguration has occurred.
  38072. */
  38073. warningEnable: boolean;
  38074. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38075. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38076. private _warningCounter;
  38077. private _warning;
  38078. }
  38079. }
  38080. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38081. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38082. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38083. /**
  38084. * Default Inputs manager for the FollowCamera.
  38085. * It groups all the default supported inputs for ease of use.
  38086. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38087. */
  38088. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38089. /**
  38090. * Instantiates a new FollowCameraInputsManager.
  38091. * @param camera Defines the camera the inputs belong to
  38092. */
  38093. constructor(camera: FollowCamera);
  38094. /**
  38095. * Add keyboard input support to the input manager.
  38096. * @returns the current input manager
  38097. */
  38098. addKeyboard(): FollowCameraInputsManager;
  38099. /**
  38100. * Add mouse wheel input support to the input manager.
  38101. * @returns the current input manager
  38102. */
  38103. addMouseWheel(): FollowCameraInputsManager;
  38104. /**
  38105. * Add pointers input support to the input manager.
  38106. * @returns the current input manager
  38107. */
  38108. addPointers(): FollowCameraInputsManager;
  38109. /**
  38110. * Add orientation input support to the input manager.
  38111. * @returns the current input manager
  38112. */
  38113. addVRDeviceOrientation(): FollowCameraInputsManager;
  38114. }
  38115. }
  38116. declare module "babylonjs/Cameras/followCamera" {
  38117. import { Nullable } from "babylonjs/types";
  38118. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38119. import { Scene } from "babylonjs/scene";
  38120. import { Vector3 } from "babylonjs/Maths/math";
  38121. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38122. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38123. /**
  38124. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38125. * an arc rotate version arcFollowCamera are available.
  38126. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38127. */
  38128. export class FollowCamera extends TargetCamera {
  38129. /**
  38130. * Distance the follow camera should follow an object at
  38131. */
  38132. radius: number;
  38133. /**
  38134. * Minimum allowed distance of the camera to the axis of rotation
  38135. * (The camera can not get closer).
  38136. * This can help limiting how the Camera is able to move in the scene.
  38137. */
  38138. lowerRadiusLimit: Nullable<number>;
  38139. /**
  38140. * Maximum allowed distance of the camera to the axis of rotation
  38141. * (The camera can not get further).
  38142. * This can help limiting how the Camera is able to move in the scene.
  38143. */
  38144. upperRadiusLimit: Nullable<number>;
  38145. /**
  38146. * Define a rotation offset between the camera and the object it follows
  38147. */
  38148. rotationOffset: number;
  38149. /**
  38150. * Minimum allowed angle to camera position relative to target object.
  38151. * This can help limiting how the Camera is able to move in the scene.
  38152. */
  38153. lowerRotationOffsetLimit: Nullable<number>;
  38154. /**
  38155. * Maximum allowed angle to camera position relative to target object.
  38156. * This can help limiting how the Camera is able to move in the scene.
  38157. */
  38158. upperRotationOffsetLimit: Nullable<number>;
  38159. /**
  38160. * Define a height offset between the camera and the object it follows.
  38161. * It can help following an object from the top (like a car chaing a plane)
  38162. */
  38163. heightOffset: number;
  38164. /**
  38165. * Minimum allowed height of camera position relative to target object.
  38166. * This can help limiting how the Camera is able to move in the scene.
  38167. */
  38168. lowerHeightOffsetLimit: Nullable<number>;
  38169. /**
  38170. * Maximum allowed height of camera position relative to target object.
  38171. * This can help limiting how the Camera is able to move in the scene.
  38172. */
  38173. upperHeightOffsetLimit: Nullable<number>;
  38174. /**
  38175. * Define how fast the camera can accelerate to follow it s target.
  38176. */
  38177. cameraAcceleration: number;
  38178. /**
  38179. * Define the speed limit of the camera following an object.
  38180. */
  38181. maxCameraSpeed: number;
  38182. /**
  38183. * Define the target of the camera.
  38184. */
  38185. lockedTarget: Nullable<AbstractMesh>;
  38186. /**
  38187. * Defines the input associated with the camera.
  38188. */
  38189. inputs: FollowCameraInputsManager;
  38190. /**
  38191. * Instantiates the follow camera.
  38192. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38193. * @param name Define the name of the camera in the scene
  38194. * @param position Define the position of the camera
  38195. * @param scene Define the scene the camera belong to
  38196. * @param lockedTarget Define the target of the camera
  38197. */
  38198. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38199. private _follow;
  38200. /**
  38201. * Attached controls to the current camera.
  38202. * @param element Defines the element the controls should be listened from
  38203. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38204. */
  38205. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38206. /**
  38207. * Detach the current controls from the camera.
  38208. * The camera will stop reacting to inputs.
  38209. * @param element Defines the element to stop listening the inputs from
  38210. */
  38211. detachControl(element: HTMLElement): void;
  38212. /** @hidden */
  38213. _checkInputs(): void;
  38214. private _checkLimits;
  38215. /**
  38216. * Gets the camera class name.
  38217. * @returns the class name
  38218. */
  38219. getClassName(): string;
  38220. }
  38221. /**
  38222. * Arc Rotate version of the follow camera.
  38223. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38224. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38225. */
  38226. export class ArcFollowCamera extends TargetCamera {
  38227. /** The longitudinal angle of the camera */
  38228. alpha: number;
  38229. /** The latitudinal angle of the camera */
  38230. beta: number;
  38231. /** The radius of the camera from its target */
  38232. radius: number;
  38233. /** Define the camera target (the messh it should follow) */
  38234. target: Nullable<AbstractMesh>;
  38235. private _cartesianCoordinates;
  38236. /**
  38237. * Instantiates a new ArcFollowCamera
  38238. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38239. * @param name Define the name of the camera
  38240. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38241. * @param beta Define the rotation angle of the camera around the elevation axis
  38242. * @param radius Define the radius of the camera from its target point
  38243. * @param target Define the target of the camera
  38244. * @param scene Define the scene the camera belongs to
  38245. */
  38246. constructor(name: string,
  38247. /** The longitudinal angle of the camera */
  38248. alpha: number,
  38249. /** The latitudinal angle of the camera */
  38250. beta: number,
  38251. /** The radius of the camera from its target */
  38252. radius: number,
  38253. /** Define the camera target (the messh it should follow) */
  38254. target: Nullable<AbstractMesh>, scene: Scene);
  38255. private _follow;
  38256. /** @hidden */
  38257. _checkInputs(): void;
  38258. /**
  38259. * Returns the class name of the object.
  38260. * It is mostly used internally for serialization purposes.
  38261. */
  38262. getClassName(): string;
  38263. }
  38264. }
  38265. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38266. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38267. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38268. import { Nullable } from "babylonjs/types";
  38269. /**
  38270. * Manage the keyboard inputs to control the movement of a follow camera.
  38271. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38272. */
  38273. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38274. /**
  38275. * Defines the camera the input is attached to.
  38276. */
  38277. camera: FollowCamera;
  38278. /**
  38279. * Defines the list of key codes associated with the up action (increase heightOffset)
  38280. */
  38281. keysHeightOffsetIncr: number[];
  38282. /**
  38283. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38284. */
  38285. keysHeightOffsetDecr: number[];
  38286. /**
  38287. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38288. */
  38289. keysHeightOffsetModifierAlt: boolean;
  38290. /**
  38291. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38292. */
  38293. keysHeightOffsetModifierCtrl: boolean;
  38294. /**
  38295. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38296. */
  38297. keysHeightOffsetModifierShift: boolean;
  38298. /**
  38299. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38300. */
  38301. keysRotationOffsetIncr: number[];
  38302. /**
  38303. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38304. */
  38305. keysRotationOffsetDecr: number[];
  38306. /**
  38307. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38308. */
  38309. keysRotationOffsetModifierAlt: boolean;
  38310. /**
  38311. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38312. */
  38313. keysRotationOffsetModifierCtrl: boolean;
  38314. /**
  38315. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38316. */
  38317. keysRotationOffsetModifierShift: boolean;
  38318. /**
  38319. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38320. */
  38321. keysRadiusIncr: number[];
  38322. /**
  38323. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38324. */
  38325. keysRadiusDecr: number[];
  38326. /**
  38327. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38328. */
  38329. keysRadiusModifierAlt: boolean;
  38330. /**
  38331. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38332. */
  38333. keysRadiusModifierCtrl: boolean;
  38334. /**
  38335. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38336. */
  38337. keysRadiusModifierShift: boolean;
  38338. /**
  38339. * Defines the rate of change of heightOffset.
  38340. */
  38341. heightSensibility: number;
  38342. /**
  38343. * Defines the rate of change of rotationOffset.
  38344. */
  38345. rotationSensibility: number;
  38346. /**
  38347. * Defines the rate of change of radius.
  38348. */
  38349. radiusSensibility: number;
  38350. private _keys;
  38351. private _ctrlPressed;
  38352. private _altPressed;
  38353. private _shiftPressed;
  38354. private _onCanvasBlurObserver;
  38355. private _onKeyboardObserver;
  38356. private _engine;
  38357. private _scene;
  38358. /**
  38359. * Attach the input controls to a specific dom element to get the input from.
  38360. * @param element Defines the element the controls should be listened from
  38361. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38362. */
  38363. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38364. /**
  38365. * Detach the current controls from the specified dom element.
  38366. * @param element Defines the element to stop listening the inputs from
  38367. */
  38368. detachControl(element: Nullable<HTMLElement>): void;
  38369. /**
  38370. * Update the current camera state depending on the inputs that have been used this frame.
  38371. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38372. */
  38373. checkInputs(): void;
  38374. /**
  38375. * Gets the class name of the current input.
  38376. * @returns the class name
  38377. */
  38378. getClassName(): string;
  38379. /**
  38380. * Get the friendly name associated with the input class.
  38381. * @returns the input friendly name
  38382. */
  38383. getSimpleName(): string;
  38384. /**
  38385. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38386. * allow modification of the heightOffset value.
  38387. */
  38388. private _modifierHeightOffset;
  38389. /**
  38390. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38391. * allow modification of the rotationOffset value.
  38392. */
  38393. private _modifierRotationOffset;
  38394. /**
  38395. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38396. * allow modification of the radius value.
  38397. */
  38398. private _modifierRadius;
  38399. }
  38400. }
  38401. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  38402. import { Nullable } from "babylonjs/types";
  38403. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38404. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38405. import { Observable } from "babylonjs/Misc/observable";
  38406. module "babylonjs/Cameras/freeCameraInputsManager" {
  38407. interface FreeCameraInputsManager {
  38408. /**
  38409. * @hidden
  38410. */
  38411. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38412. /**
  38413. * Add orientation input support to the input manager.
  38414. * @returns the current input manager
  38415. */
  38416. addDeviceOrientation(): FreeCameraInputsManager;
  38417. }
  38418. }
  38419. /**
  38420. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38421. * Screen rotation is taken into account.
  38422. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38423. */
  38424. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38425. private _camera;
  38426. private _screenOrientationAngle;
  38427. private _constantTranform;
  38428. private _screenQuaternion;
  38429. private _alpha;
  38430. private _beta;
  38431. private _gamma;
  38432. /**
  38433. * @hidden
  38434. */
  38435. _onDeviceOrientationChangedObservable: Observable<void>;
  38436. /**
  38437. * Instantiates a new input
  38438. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38439. */
  38440. constructor();
  38441. /**
  38442. * Define the camera controlled by the input.
  38443. */
  38444. camera: FreeCamera;
  38445. /**
  38446. * Attach the input controls to a specific dom element to get the input from.
  38447. * @param element Defines the element the controls should be listened from
  38448. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38449. */
  38450. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38451. private _orientationChanged;
  38452. private _deviceOrientation;
  38453. /**
  38454. * Detach the current controls from the specified dom element.
  38455. * @param element Defines the element to stop listening the inputs from
  38456. */
  38457. detachControl(element: Nullable<HTMLElement>): void;
  38458. /**
  38459. * Update the current camera state depending on the inputs that have been used this frame.
  38460. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38461. */
  38462. checkInputs(): void;
  38463. /**
  38464. * Gets the class name of the current intput.
  38465. * @returns the class name
  38466. */
  38467. getClassName(): string;
  38468. /**
  38469. * Get the friendly name associated with the input class.
  38470. * @returns the input friendly name
  38471. */
  38472. getSimpleName(): string;
  38473. }
  38474. }
  38475. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  38476. import { Nullable } from "babylonjs/types";
  38477. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38478. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38479. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38480. /**
  38481. * Manage the gamepad inputs to control a free camera.
  38482. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38483. */
  38484. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38485. /**
  38486. * Define the camera the input is attached to.
  38487. */
  38488. camera: FreeCamera;
  38489. /**
  38490. * Define the Gamepad controlling the input
  38491. */
  38492. gamepad: Nullable<Gamepad>;
  38493. /**
  38494. * Defines the gamepad rotation sensiblity.
  38495. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38496. */
  38497. gamepadAngularSensibility: number;
  38498. /**
  38499. * Defines the gamepad move sensiblity.
  38500. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38501. */
  38502. gamepadMoveSensibility: number;
  38503. private _onGamepadConnectedObserver;
  38504. private _onGamepadDisconnectedObserver;
  38505. private _cameraTransform;
  38506. private _deltaTransform;
  38507. private _vector3;
  38508. private _vector2;
  38509. /**
  38510. * Attach the input controls to a specific dom element to get the input from.
  38511. * @param element Defines the element the controls should be listened from
  38512. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38513. */
  38514. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38515. /**
  38516. * Detach the current controls from the specified dom element.
  38517. * @param element Defines the element to stop listening the inputs from
  38518. */
  38519. detachControl(element: Nullable<HTMLElement>): void;
  38520. /**
  38521. * Update the current camera state depending on the inputs that have been used this frame.
  38522. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38523. */
  38524. checkInputs(): void;
  38525. /**
  38526. * Gets the class name of the current intput.
  38527. * @returns the class name
  38528. */
  38529. getClassName(): string;
  38530. /**
  38531. * Get the friendly name associated with the input class.
  38532. * @returns the input friendly name
  38533. */
  38534. getSimpleName(): string;
  38535. }
  38536. }
  38537. declare module "babylonjs/Misc/virtualJoystick" {
  38538. import { Nullable } from "babylonjs/types";
  38539. import { Vector3 } from "babylonjs/Maths/math";
  38540. /**
  38541. * Defines the potential axis of a Joystick
  38542. */
  38543. export enum JoystickAxis {
  38544. /** X axis */
  38545. X = 0,
  38546. /** Y axis */
  38547. Y = 1,
  38548. /** Z axis */
  38549. Z = 2
  38550. }
  38551. /**
  38552. * Class used to define virtual joystick (used in touch mode)
  38553. */
  38554. export class VirtualJoystick {
  38555. /**
  38556. * Gets or sets a boolean indicating that left and right values must be inverted
  38557. */
  38558. reverseLeftRight: boolean;
  38559. /**
  38560. * Gets or sets a boolean indicating that up and down values must be inverted
  38561. */
  38562. reverseUpDown: boolean;
  38563. /**
  38564. * Gets the offset value for the position (ie. the change of the position value)
  38565. */
  38566. deltaPosition: Vector3;
  38567. /**
  38568. * Gets a boolean indicating if the virtual joystick was pressed
  38569. */
  38570. pressed: boolean;
  38571. /**
  38572. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38573. */
  38574. static Canvas: Nullable<HTMLCanvasElement>;
  38575. private static _globalJoystickIndex;
  38576. private static vjCanvasContext;
  38577. private static vjCanvasWidth;
  38578. private static vjCanvasHeight;
  38579. private static halfWidth;
  38580. private _action;
  38581. private _axisTargetedByLeftAndRight;
  38582. private _axisTargetedByUpAndDown;
  38583. private _joystickSensibility;
  38584. private _inversedSensibility;
  38585. private _joystickPointerID;
  38586. private _joystickColor;
  38587. private _joystickPointerPos;
  38588. private _joystickPreviousPointerPos;
  38589. private _joystickPointerStartPos;
  38590. private _deltaJoystickVector;
  38591. private _leftJoystick;
  38592. private _touches;
  38593. private _onPointerDownHandlerRef;
  38594. private _onPointerMoveHandlerRef;
  38595. private _onPointerUpHandlerRef;
  38596. private _onResize;
  38597. /**
  38598. * Creates a new virtual joystick
  38599. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38600. */
  38601. constructor(leftJoystick?: boolean);
  38602. /**
  38603. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38604. * @param newJoystickSensibility defines the new sensibility
  38605. */
  38606. setJoystickSensibility(newJoystickSensibility: number): void;
  38607. private _onPointerDown;
  38608. private _onPointerMove;
  38609. private _onPointerUp;
  38610. /**
  38611. * Change the color of the virtual joystick
  38612. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38613. */
  38614. setJoystickColor(newColor: string): void;
  38615. /**
  38616. * Defines a callback to call when the joystick is touched
  38617. * @param action defines the callback
  38618. */
  38619. setActionOnTouch(action: () => any): void;
  38620. /**
  38621. * Defines which axis you'd like to control for left & right
  38622. * @param axis defines the axis to use
  38623. */
  38624. setAxisForLeftRight(axis: JoystickAxis): void;
  38625. /**
  38626. * Defines which axis you'd like to control for up & down
  38627. * @param axis defines the axis to use
  38628. */
  38629. setAxisForUpDown(axis: JoystickAxis): void;
  38630. private _drawVirtualJoystick;
  38631. /**
  38632. * Release internal HTML canvas
  38633. */
  38634. releaseCanvas(): void;
  38635. }
  38636. }
  38637. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38638. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38639. import { Nullable } from "babylonjs/types";
  38640. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38641. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38642. module "babylonjs/Cameras/freeCameraInputsManager" {
  38643. interface FreeCameraInputsManager {
  38644. /**
  38645. * Add virtual joystick input support to the input manager.
  38646. * @returns the current input manager
  38647. */
  38648. addVirtualJoystick(): FreeCameraInputsManager;
  38649. }
  38650. }
  38651. /**
  38652. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38653. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38654. */
  38655. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38656. /**
  38657. * Defines the camera the input is attached to.
  38658. */
  38659. camera: FreeCamera;
  38660. private _leftjoystick;
  38661. private _rightjoystick;
  38662. /**
  38663. * Gets the left stick of the virtual joystick.
  38664. * @returns The virtual Joystick
  38665. */
  38666. getLeftJoystick(): VirtualJoystick;
  38667. /**
  38668. * Gets the right stick of the virtual joystick.
  38669. * @returns The virtual Joystick
  38670. */
  38671. getRightJoystick(): VirtualJoystick;
  38672. /**
  38673. * Update the current camera state depending on the inputs that have been used this frame.
  38674. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38675. */
  38676. checkInputs(): void;
  38677. /**
  38678. * Attach the input controls to a specific dom element to get the input from.
  38679. * @param element Defines the element the controls should be listened from
  38680. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38681. */
  38682. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38683. /**
  38684. * Detach the current controls from the specified dom element.
  38685. * @param element Defines the element to stop listening the inputs from
  38686. */
  38687. detachControl(element: Nullable<HTMLElement>): void;
  38688. /**
  38689. * Gets the class name of the current intput.
  38690. * @returns the class name
  38691. */
  38692. getClassName(): string;
  38693. /**
  38694. * Get the friendly name associated with the input class.
  38695. * @returns the input friendly name
  38696. */
  38697. getSimpleName(): string;
  38698. }
  38699. }
  38700. declare module "babylonjs/Cameras/Inputs/index" {
  38701. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38702. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38703. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38704. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38705. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38706. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38707. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38708. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38709. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38710. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38711. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38712. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38713. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38714. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38715. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38716. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38717. }
  38718. declare module "babylonjs/Cameras/touchCamera" {
  38719. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38720. import { Scene } from "babylonjs/scene";
  38721. import { Vector3 } from "babylonjs/Maths/math";
  38722. /**
  38723. * This represents a FPS type of camera controlled by touch.
  38724. * This is like a universal camera minus the Gamepad controls.
  38725. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38726. */
  38727. export class TouchCamera extends FreeCamera {
  38728. /**
  38729. * Defines the touch sensibility for rotation.
  38730. * The higher the faster.
  38731. */
  38732. touchAngularSensibility: number;
  38733. /**
  38734. * Defines the touch sensibility for move.
  38735. * The higher the faster.
  38736. */
  38737. touchMoveSensibility: number;
  38738. /**
  38739. * Instantiates a new touch camera.
  38740. * This represents a FPS type of camera controlled by touch.
  38741. * This is like a universal camera minus the Gamepad controls.
  38742. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38743. * @param name Define the name of the camera in the scene
  38744. * @param position Define the start position of the camera in the scene
  38745. * @param scene Define the scene the camera belongs to
  38746. */
  38747. constructor(name: string, position: Vector3, scene: Scene);
  38748. /**
  38749. * Gets the current object class name.
  38750. * @return the class name
  38751. */
  38752. getClassName(): string;
  38753. /** @hidden */
  38754. _setupInputs(): void;
  38755. }
  38756. }
  38757. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  38758. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38759. import { Scene } from "babylonjs/scene";
  38760. import { Vector3, Axis } from "babylonjs/Maths/math";
  38761. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38762. /**
  38763. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38764. * being tilted forward or back and left or right.
  38765. */
  38766. export class DeviceOrientationCamera extends FreeCamera {
  38767. private _initialQuaternion;
  38768. private _quaternionCache;
  38769. private _tmpDragQuaternion;
  38770. /**
  38771. * Creates a new device orientation camera
  38772. * @param name The name of the camera
  38773. * @param position The start position camera
  38774. * @param scene The scene the camera belongs to
  38775. */
  38776. constructor(name: string, position: Vector3, scene: Scene);
  38777. /**
  38778. * @hidden
  38779. * Disabled pointer input on first orientation sensor update (Default: true)
  38780. */
  38781. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  38782. private _dragFactor;
  38783. /**
  38784. * Enabled turning on the y axis when the orientation sensor is active
  38785. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38786. */
  38787. enableHorizontalDragging(dragFactor?: number): void;
  38788. /**
  38789. * Gets the current instance class name ("DeviceOrientationCamera").
  38790. * This helps avoiding instanceof at run time.
  38791. * @returns the class name
  38792. */
  38793. getClassName(): string;
  38794. /**
  38795. * @hidden
  38796. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38797. */
  38798. _checkInputs(): void;
  38799. /**
  38800. * Reset the camera to its default orientation on the specified axis only.
  38801. * @param axis The axis to reset
  38802. */
  38803. resetToCurrentRotation(axis?: Axis): void;
  38804. }
  38805. }
  38806. declare module "babylonjs/Gamepads/xboxGamepad" {
  38807. import { Observable } from "babylonjs/Misc/observable";
  38808. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38809. /**
  38810. * Defines supported buttons for XBox360 compatible gamepads
  38811. */
  38812. export enum Xbox360Button {
  38813. /** A */
  38814. A = 0,
  38815. /** B */
  38816. B = 1,
  38817. /** X */
  38818. X = 2,
  38819. /** Y */
  38820. Y = 3,
  38821. /** Start */
  38822. Start = 4,
  38823. /** Back */
  38824. Back = 5,
  38825. /** Left button */
  38826. LB = 6,
  38827. /** Right button */
  38828. RB = 7,
  38829. /** Left stick */
  38830. LeftStick = 8,
  38831. /** Right stick */
  38832. RightStick = 9
  38833. }
  38834. /** Defines values for XBox360 DPad */
  38835. export enum Xbox360Dpad {
  38836. /** Up */
  38837. Up = 0,
  38838. /** Down */
  38839. Down = 1,
  38840. /** Left */
  38841. Left = 2,
  38842. /** Right */
  38843. Right = 3
  38844. }
  38845. /**
  38846. * Defines a XBox360 gamepad
  38847. */
  38848. export class Xbox360Pad extends Gamepad {
  38849. private _leftTrigger;
  38850. private _rightTrigger;
  38851. private _onlefttriggerchanged;
  38852. private _onrighttriggerchanged;
  38853. private _onbuttondown;
  38854. private _onbuttonup;
  38855. private _ondpaddown;
  38856. private _ondpadup;
  38857. /** Observable raised when a button is pressed */
  38858. onButtonDownObservable: Observable<Xbox360Button>;
  38859. /** Observable raised when a button is released */
  38860. onButtonUpObservable: Observable<Xbox360Button>;
  38861. /** Observable raised when a pad is pressed */
  38862. onPadDownObservable: Observable<Xbox360Dpad>;
  38863. /** Observable raised when a pad is released */
  38864. onPadUpObservable: Observable<Xbox360Dpad>;
  38865. private _buttonA;
  38866. private _buttonB;
  38867. private _buttonX;
  38868. private _buttonY;
  38869. private _buttonBack;
  38870. private _buttonStart;
  38871. private _buttonLB;
  38872. private _buttonRB;
  38873. private _buttonLeftStick;
  38874. private _buttonRightStick;
  38875. private _dPadUp;
  38876. private _dPadDown;
  38877. private _dPadLeft;
  38878. private _dPadRight;
  38879. private _isXboxOnePad;
  38880. /**
  38881. * Creates a new XBox360 gamepad object
  38882. * @param id defines the id of this gamepad
  38883. * @param index defines its index
  38884. * @param gamepad defines the internal HTML gamepad object
  38885. * @param xboxOne defines if it is a XBox One gamepad
  38886. */
  38887. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38888. /**
  38889. * Defines the callback to call when left trigger is pressed
  38890. * @param callback defines the callback to use
  38891. */
  38892. onlefttriggerchanged(callback: (value: number) => void): void;
  38893. /**
  38894. * Defines the callback to call when right trigger is pressed
  38895. * @param callback defines the callback to use
  38896. */
  38897. onrighttriggerchanged(callback: (value: number) => void): void;
  38898. /**
  38899. * Gets the left trigger value
  38900. */
  38901. /**
  38902. * Sets the left trigger value
  38903. */
  38904. leftTrigger: number;
  38905. /**
  38906. * Gets the right trigger value
  38907. */
  38908. /**
  38909. * Sets the right trigger value
  38910. */
  38911. rightTrigger: number;
  38912. /**
  38913. * Defines the callback to call when a button is pressed
  38914. * @param callback defines the callback to use
  38915. */
  38916. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38917. /**
  38918. * Defines the callback to call when a button is released
  38919. * @param callback defines the callback to use
  38920. */
  38921. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38922. /**
  38923. * Defines the callback to call when a pad is pressed
  38924. * @param callback defines the callback to use
  38925. */
  38926. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38927. /**
  38928. * Defines the callback to call when a pad is released
  38929. * @param callback defines the callback to use
  38930. */
  38931. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38932. private _setButtonValue;
  38933. private _setDPadValue;
  38934. /**
  38935. * Gets the value of the `A` button
  38936. */
  38937. /**
  38938. * Sets the value of the `A` button
  38939. */
  38940. buttonA: number;
  38941. /**
  38942. * Gets the value of the `B` button
  38943. */
  38944. /**
  38945. * Sets the value of the `B` button
  38946. */
  38947. buttonB: number;
  38948. /**
  38949. * Gets the value of the `X` button
  38950. */
  38951. /**
  38952. * Sets the value of the `X` button
  38953. */
  38954. buttonX: number;
  38955. /**
  38956. * Gets the value of the `Y` button
  38957. */
  38958. /**
  38959. * Sets the value of the `Y` button
  38960. */
  38961. buttonY: number;
  38962. /**
  38963. * Gets the value of the `Start` button
  38964. */
  38965. /**
  38966. * Sets the value of the `Start` button
  38967. */
  38968. buttonStart: number;
  38969. /**
  38970. * Gets the value of the `Back` button
  38971. */
  38972. /**
  38973. * Sets the value of the `Back` button
  38974. */
  38975. buttonBack: number;
  38976. /**
  38977. * Gets the value of the `Left` button
  38978. */
  38979. /**
  38980. * Sets the value of the `Left` button
  38981. */
  38982. buttonLB: number;
  38983. /**
  38984. * Gets the value of the `Right` button
  38985. */
  38986. /**
  38987. * Sets the value of the `Right` button
  38988. */
  38989. buttonRB: number;
  38990. /**
  38991. * Gets the value of the Left joystick
  38992. */
  38993. /**
  38994. * Sets the value of the Left joystick
  38995. */
  38996. buttonLeftStick: number;
  38997. /**
  38998. * Gets the value of the Right joystick
  38999. */
  39000. /**
  39001. * Sets the value of the Right joystick
  39002. */
  39003. buttonRightStick: number;
  39004. /**
  39005. * Gets the value of D-pad up
  39006. */
  39007. /**
  39008. * Sets the value of D-pad up
  39009. */
  39010. dPadUp: number;
  39011. /**
  39012. * Gets the value of D-pad down
  39013. */
  39014. /**
  39015. * Sets the value of D-pad down
  39016. */
  39017. dPadDown: number;
  39018. /**
  39019. * Gets the value of D-pad left
  39020. */
  39021. /**
  39022. * Sets the value of D-pad left
  39023. */
  39024. dPadLeft: number;
  39025. /**
  39026. * Gets the value of D-pad right
  39027. */
  39028. /**
  39029. * Sets the value of D-pad right
  39030. */
  39031. dPadRight: number;
  39032. /**
  39033. * Force the gamepad to synchronize with device values
  39034. */
  39035. update(): void;
  39036. /**
  39037. * Disposes the gamepad
  39038. */
  39039. dispose(): void;
  39040. }
  39041. }
  39042. declare module "babylonjs/Gamepads/gamepadManager" {
  39043. import { Observable } from "babylonjs/Misc/observable";
  39044. import { Nullable } from "babylonjs/types";
  39045. import { Scene } from "babylonjs/scene";
  39046. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39047. /**
  39048. * Manager for handling gamepads
  39049. */
  39050. export class GamepadManager {
  39051. private _scene?;
  39052. private _babylonGamepads;
  39053. private _oneGamepadConnected;
  39054. /** @hidden */
  39055. _isMonitoring: boolean;
  39056. private _gamepadEventSupported;
  39057. private _gamepadSupport;
  39058. /**
  39059. * observable to be triggered when the gamepad controller has been connected
  39060. */
  39061. onGamepadConnectedObservable: Observable<Gamepad>;
  39062. /**
  39063. * observable to be triggered when the gamepad controller has been disconnected
  39064. */
  39065. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39066. private _onGamepadConnectedEvent;
  39067. private _onGamepadDisconnectedEvent;
  39068. /**
  39069. * Initializes the gamepad manager
  39070. * @param _scene BabylonJS scene
  39071. */
  39072. constructor(_scene?: Scene | undefined);
  39073. /**
  39074. * The gamepads in the game pad manager
  39075. */
  39076. readonly gamepads: Gamepad[];
  39077. /**
  39078. * Get the gamepad controllers based on type
  39079. * @param type The type of gamepad controller
  39080. * @returns Nullable gamepad
  39081. */
  39082. getGamepadByType(type?: number): Nullable<Gamepad>;
  39083. /**
  39084. * Disposes the gamepad manager
  39085. */
  39086. dispose(): void;
  39087. private _addNewGamepad;
  39088. private _startMonitoringGamepads;
  39089. private _stopMonitoringGamepads;
  39090. /** @hidden */
  39091. _checkGamepadsStatus(): void;
  39092. private _updateGamepadObjects;
  39093. }
  39094. }
  39095. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39096. import { Nullable } from "babylonjs/types";
  39097. import { Scene } from "babylonjs/scene";
  39098. import { ISceneComponent } from "babylonjs/sceneComponent";
  39099. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39100. module "babylonjs/scene" {
  39101. interface Scene {
  39102. /** @hidden */
  39103. _gamepadManager: Nullable<GamepadManager>;
  39104. /**
  39105. * Gets the gamepad manager associated with the scene
  39106. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39107. */
  39108. gamepadManager: GamepadManager;
  39109. }
  39110. }
  39111. module "babylonjs/Cameras/freeCameraInputsManager" {
  39112. /**
  39113. * Interface representing a free camera inputs manager
  39114. */
  39115. interface FreeCameraInputsManager {
  39116. /**
  39117. * Adds gamepad input support to the FreeCameraInputsManager.
  39118. * @returns the FreeCameraInputsManager
  39119. */
  39120. addGamepad(): FreeCameraInputsManager;
  39121. }
  39122. }
  39123. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39124. /**
  39125. * Interface representing an arc rotate camera inputs manager
  39126. */
  39127. interface ArcRotateCameraInputsManager {
  39128. /**
  39129. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39130. * @returns the camera inputs manager
  39131. */
  39132. addGamepad(): ArcRotateCameraInputsManager;
  39133. }
  39134. }
  39135. /**
  39136. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39137. */
  39138. export class GamepadSystemSceneComponent implements ISceneComponent {
  39139. /**
  39140. * The component name helpfull to identify the component in the list of scene components.
  39141. */
  39142. readonly name: string;
  39143. /**
  39144. * The scene the component belongs to.
  39145. */
  39146. scene: Scene;
  39147. /**
  39148. * Creates a new instance of the component for the given scene
  39149. * @param scene Defines the scene to register the component in
  39150. */
  39151. constructor(scene: Scene);
  39152. /**
  39153. * Registers the component in a given scene
  39154. */
  39155. register(): void;
  39156. /**
  39157. * Rebuilds the elements related to this component in case of
  39158. * context lost for instance.
  39159. */
  39160. rebuild(): void;
  39161. /**
  39162. * Disposes the component and the associated ressources
  39163. */
  39164. dispose(): void;
  39165. private _beforeCameraUpdate;
  39166. }
  39167. }
  39168. declare module "babylonjs/Cameras/universalCamera" {
  39169. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  39170. import { Scene } from "babylonjs/scene";
  39171. import { Vector3 } from "babylonjs/Maths/math";
  39172. import "babylonjs/Gamepads/gamepadSceneComponent";
  39173. /**
  39174. * 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,
  39175. * which still works and will still be found in many Playgrounds.
  39176. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39177. */
  39178. export class UniversalCamera extends TouchCamera {
  39179. /**
  39180. * Defines the gamepad rotation sensiblity.
  39181. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39182. */
  39183. gamepadAngularSensibility: number;
  39184. /**
  39185. * Defines the gamepad move sensiblity.
  39186. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39187. */
  39188. gamepadMoveSensibility: number;
  39189. /**
  39190. * 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,
  39191. * which still works and will still be found in many Playgrounds.
  39192. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39193. * @param name Define the name of the camera in the scene
  39194. * @param position Define the start position of the camera in the scene
  39195. * @param scene Define the scene the camera belongs to
  39196. */
  39197. constructor(name: string, position: Vector3, scene: Scene);
  39198. /**
  39199. * Gets the current object class name.
  39200. * @return the class name
  39201. */
  39202. getClassName(): string;
  39203. }
  39204. }
  39205. declare module "babylonjs/Cameras/gamepadCamera" {
  39206. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39207. import { Scene } from "babylonjs/scene";
  39208. import { Vector3 } from "babylonjs/Maths/math";
  39209. /**
  39210. * This represents a FPS type of camera. This is only here for back compat purpose.
  39211. * Please use the UniversalCamera instead as both are identical.
  39212. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39213. */
  39214. export class GamepadCamera extends UniversalCamera {
  39215. /**
  39216. * Instantiates a new Gamepad Camera
  39217. * This represents a FPS type of camera. This is only here for back compat purpose.
  39218. * Please use the UniversalCamera instead as both are identical.
  39219. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39220. * @param name Define the name of the camera in the scene
  39221. * @param position Define the start position of the camera in the scene
  39222. * @param scene Define the scene the camera belongs to
  39223. */
  39224. constructor(name: string, position: Vector3, scene: Scene);
  39225. /**
  39226. * Gets the current object class name.
  39227. * @return the class name
  39228. */
  39229. getClassName(): string;
  39230. }
  39231. }
  39232. declare module "babylonjs/Shaders/pass.fragment" {
  39233. /** @hidden */
  39234. export var passPixelShader: {
  39235. name: string;
  39236. shader: string;
  39237. };
  39238. }
  39239. declare module "babylonjs/Shaders/passCube.fragment" {
  39240. /** @hidden */
  39241. export var passCubePixelShader: {
  39242. name: string;
  39243. shader: string;
  39244. };
  39245. }
  39246. declare module "babylonjs/PostProcesses/passPostProcess" {
  39247. import { Nullable } from "babylonjs/types";
  39248. import { Camera } from "babylonjs/Cameras/camera";
  39249. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39250. import { Engine } from "babylonjs/Engines/engine";
  39251. import "babylonjs/Shaders/pass.fragment";
  39252. import "babylonjs/Shaders/passCube.fragment";
  39253. /**
  39254. * PassPostProcess which produces an output the same as it's input
  39255. */
  39256. export class PassPostProcess extends PostProcess {
  39257. /**
  39258. * Creates the PassPostProcess
  39259. * @param name The name of the effect.
  39260. * @param options The required width/height ratio to downsize to before computing the render pass.
  39261. * @param camera The camera to apply the render pass to.
  39262. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39263. * @param engine The engine which the post process will be applied. (default: current engine)
  39264. * @param reusable If the post process can be reused on the same frame. (default: false)
  39265. * @param textureType The type of texture to be used when performing the post processing.
  39266. * @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)
  39267. */
  39268. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39269. }
  39270. /**
  39271. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39272. */
  39273. export class PassCubePostProcess extends PostProcess {
  39274. private _face;
  39275. /**
  39276. * Gets or sets the cube face to display.
  39277. * * 0 is +X
  39278. * * 1 is -X
  39279. * * 2 is +Y
  39280. * * 3 is -Y
  39281. * * 4 is +Z
  39282. * * 5 is -Z
  39283. */
  39284. face: number;
  39285. /**
  39286. * Creates the PassCubePostProcess
  39287. * @param name The name of the effect.
  39288. * @param options The required width/height ratio to downsize to before computing the render pass.
  39289. * @param camera The camera to apply the render pass to.
  39290. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39291. * @param engine The engine which the post process will be applied. (default: current engine)
  39292. * @param reusable If the post process can be reused on the same frame. (default: false)
  39293. * @param textureType The type of texture to be used when performing the post processing.
  39294. * @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)
  39295. */
  39296. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39297. }
  39298. }
  39299. declare module "babylonjs/Shaders/anaglyph.fragment" {
  39300. /** @hidden */
  39301. export var anaglyphPixelShader: {
  39302. name: string;
  39303. shader: string;
  39304. };
  39305. }
  39306. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  39307. import { Engine } from "babylonjs/Engines/engine";
  39308. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39309. import { Camera } from "babylonjs/Cameras/camera";
  39310. import "babylonjs/Shaders/anaglyph.fragment";
  39311. /**
  39312. * Postprocess used to generate anaglyphic rendering
  39313. */
  39314. export class AnaglyphPostProcess extends PostProcess {
  39315. private _passedProcess;
  39316. /**
  39317. * Creates a new AnaglyphPostProcess
  39318. * @param name defines postprocess name
  39319. * @param options defines creation options or target ratio scale
  39320. * @param rigCameras defines cameras using this postprocess
  39321. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39322. * @param engine defines hosting engine
  39323. * @param reusable defines if the postprocess will be reused multiple times per frame
  39324. */
  39325. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39326. }
  39327. }
  39328. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  39329. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  39330. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39331. import { Scene } from "babylonjs/scene";
  39332. import { Vector3 } from "babylonjs/Maths/math";
  39333. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39334. /**
  39335. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39336. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39337. */
  39338. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39339. /**
  39340. * Creates a new AnaglyphArcRotateCamera
  39341. * @param name defines camera name
  39342. * @param alpha defines alpha angle (in radians)
  39343. * @param beta defines beta angle (in radians)
  39344. * @param radius defines radius
  39345. * @param target defines camera target
  39346. * @param interaxialDistance defines distance between each color axis
  39347. * @param scene defines the hosting scene
  39348. */
  39349. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39350. /**
  39351. * Gets camera class name
  39352. * @returns AnaglyphArcRotateCamera
  39353. */
  39354. getClassName(): string;
  39355. }
  39356. }
  39357. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  39358. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39359. import { Scene } from "babylonjs/scene";
  39360. import { Vector3 } from "babylonjs/Maths/math";
  39361. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39362. /**
  39363. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39364. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39365. */
  39366. export class AnaglyphFreeCamera extends FreeCamera {
  39367. /**
  39368. * Creates a new AnaglyphFreeCamera
  39369. * @param name defines camera name
  39370. * @param position defines initial position
  39371. * @param interaxialDistance defines distance between each color axis
  39372. * @param scene defines the hosting scene
  39373. */
  39374. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39375. /**
  39376. * Gets camera class name
  39377. * @returns AnaglyphFreeCamera
  39378. */
  39379. getClassName(): string;
  39380. }
  39381. }
  39382. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  39383. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39384. import { Scene } from "babylonjs/scene";
  39385. import { Vector3 } from "babylonjs/Maths/math";
  39386. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39387. /**
  39388. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39389. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39390. */
  39391. export class AnaglyphGamepadCamera extends GamepadCamera {
  39392. /**
  39393. * Creates a new AnaglyphGamepadCamera
  39394. * @param name defines camera name
  39395. * @param position defines initial position
  39396. * @param interaxialDistance defines distance between each color axis
  39397. * @param scene defines the hosting scene
  39398. */
  39399. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39400. /**
  39401. * Gets camera class name
  39402. * @returns AnaglyphGamepadCamera
  39403. */
  39404. getClassName(): string;
  39405. }
  39406. }
  39407. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  39408. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39409. import { Scene } from "babylonjs/scene";
  39410. import { Vector3 } from "babylonjs/Maths/math";
  39411. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39412. /**
  39413. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39414. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39415. */
  39416. export class AnaglyphUniversalCamera extends UniversalCamera {
  39417. /**
  39418. * Creates a new AnaglyphUniversalCamera
  39419. * @param name defines camera name
  39420. * @param position defines initial position
  39421. * @param interaxialDistance defines distance between each color axis
  39422. * @param scene defines the hosting scene
  39423. */
  39424. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39425. /**
  39426. * Gets camera class name
  39427. * @returns AnaglyphUniversalCamera
  39428. */
  39429. getClassName(): string;
  39430. }
  39431. }
  39432. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  39433. /** @hidden */
  39434. export var stereoscopicInterlacePixelShader: {
  39435. name: string;
  39436. shader: string;
  39437. };
  39438. }
  39439. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  39440. import { Camera } from "babylonjs/Cameras/camera";
  39441. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39442. import { Engine } from "babylonjs/Engines/engine";
  39443. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  39444. /**
  39445. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39446. */
  39447. export class StereoscopicInterlacePostProcess extends PostProcess {
  39448. private _stepSize;
  39449. private _passedProcess;
  39450. /**
  39451. * Initializes a StereoscopicInterlacePostProcess
  39452. * @param name The name of the effect.
  39453. * @param rigCameras The rig cameras to be appled to the post process
  39454. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39455. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39456. * @param engine The engine which the post process will be applied. (default: current engine)
  39457. * @param reusable If the post process can be reused on the same frame. (default: false)
  39458. */
  39459. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39460. }
  39461. }
  39462. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  39463. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  39464. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39465. import { Scene } from "babylonjs/scene";
  39466. import { Vector3 } from "babylonjs/Maths/math";
  39467. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39468. /**
  39469. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39470. * @see http://doc.babylonjs.com/features/cameras
  39471. */
  39472. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39473. /**
  39474. * Creates a new StereoscopicArcRotateCamera
  39475. * @param name defines camera name
  39476. * @param alpha defines alpha angle (in radians)
  39477. * @param beta defines beta angle (in radians)
  39478. * @param radius defines radius
  39479. * @param target defines camera target
  39480. * @param interaxialDistance defines distance between each color axis
  39481. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39482. * @param scene defines the hosting scene
  39483. */
  39484. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39485. /**
  39486. * Gets camera class name
  39487. * @returns StereoscopicArcRotateCamera
  39488. */
  39489. getClassName(): string;
  39490. }
  39491. }
  39492. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  39493. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39494. import { Scene } from "babylonjs/scene";
  39495. import { Vector3 } from "babylonjs/Maths/math";
  39496. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39497. /**
  39498. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39499. * @see http://doc.babylonjs.com/features/cameras
  39500. */
  39501. export class StereoscopicFreeCamera extends FreeCamera {
  39502. /**
  39503. * Creates a new StereoscopicFreeCamera
  39504. * @param name defines camera name
  39505. * @param position defines initial position
  39506. * @param interaxialDistance defines distance between each color axis
  39507. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39508. * @param scene defines the hosting scene
  39509. */
  39510. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39511. /**
  39512. * Gets camera class name
  39513. * @returns StereoscopicFreeCamera
  39514. */
  39515. getClassName(): string;
  39516. }
  39517. }
  39518. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  39519. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39520. import { Scene } from "babylonjs/scene";
  39521. import { Vector3 } from "babylonjs/Maths/math";
  39522. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39523. /**
  39524. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39525. * @see http://doc.babylonjs.com/features/cameras
  39526. */
  39527. export class StereoscopicGamepadCamera extends GamepadCamera {
  39528. /**
  39529. * Creates a new StereoscopicGamepadCamera
  39530. * @param name defines camera name
  39531. * @param position defines initial position
  39532. * @param interaxialDistance defines distance between each color axis
  39533. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39534. * @param scene defines the hosting scene
  39535. */
  39536. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39537. /**
  39538. * Gets camera class name
  39539. * @returns StereoscopicGamepadCamera
  39540. */
  39541. getClassName(): string;
  39542. }
  39543. }
  39544. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  39545. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39546. import { Scene } from "babylonjs/scene";
  39547. import { Vector3 } from "babylonjs/Maths/math";
  39548. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39549. /**
  39550. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39551. * @see http://doc.babylonjs.com/features/cameras
  39552. */
  39553. export class StereoscopicUniversalCamera extends UniversalCamera {
  39554. /**
  39555. * Creates a new StereoscopicUniversalCamera
  39556. * @param name defines camera name
  39557. * @param position defines initial position
  39558. * @param interaxialDistance defines distance between each color axis
  39559. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39560. * @param scene defines the hosting scene
  39561. */
  39562. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39563. /**
  39564. * Gets camera class name
  39565. * @returns StereoscopicUniversalCamera
  39566. */
  39567. getClassName(): string;
  39568. }
  39569. }
  39570. declare module "babylonjs/Cameras/Stereoscopic/index" {
  39571. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  39572. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  39573. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  39574. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  39575. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  39576. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  39577. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  39578. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  39579. }
  39580. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  39581. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39582. import { Scene } from "babylonjs/scene";
  39583. import { Vector3 } from "babylonjs/Maths/math";
  39584. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39585. /**
  39586. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39587. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39588. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39589. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39590. */
  39591. export class VirtualJoysticksCamera extends FreeCamera {
  39592. /**
  39593. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39594. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39595. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39596. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39597. * @param name Define the name of the camera in the scene
  39598. * @param position Define the start position of the camera in the scene
  39599. * @param scene Define the scene the camera belongs to
  39600. */
  39601. constructor(name: string, position: Vector3, scene: Scene);
  39602. /**
  39603. * Gets the current object class name.
  39604. * @return the class name
  39605. */
  39606. getClassName(): string;
  39607. }
  39608. }
  39609. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  39610. import { Matrix } from "babylonjs/Maths/math";
  39611. /**
  39612. * This represents all the required metrics to create a VR camera.
  39613. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39614. */
  39615. export class VRCameraMetrics {
  39616. /**
  39617. * Define the horizontal resolution off the screen.
  39618. */
  39619. hResolution: number;
  39620. /**
  39621. * Define the vertical resolution off the screen.
  39622. */
  39623. vResolution: number;
  39624. /**
  39625. * Define the horizontal screen size.
  39626. */
  39627. hScreenSize: number;
  39628. /**
  39629. * Define the vertical screen size.
  39630. */
  39631. vScreenSize: number;
  39632. /**
  39633. * Define the vertical screen center position.
  39634. */
  39635. vScreenCenter: number;
  39636. /**
  39637. * Define the distance of the eyes to the screen.
  39638. */
  39639. eyeToScreenDistance: number;
  39640. /**
  39641. * Define the distance between both lenses
  39642. */
  39643. lensSeparationDistance: number;
  39644. /**
  39645. * Define the distance between both viewer's eyes.
  39646. */
  39647. interpupillaryDistance: number;
  39648. /**
  39649. * Define the distortion factor of the VR postprocess.
  39650. * Please, touch with care.
  39651. */
  39652. distortionK: number[];
  39653. /**
  39654. * Define the chromatic aberration correction factors for the VR post process.
  39655. */
  39656. chromaAbCorrection: number[];
  39657. /**
  39658. * Define the scale factor of the post process.
  39659. * The smaller the better but the slower.
  39660. */
  39661. postProcessScaleFactor: number;
  39662. /**
  39663. * Define an offset for the lens center.
  39664. */
  39665. lensCenterOffset: number;
  39666. /**
  39667. * Define if the current vr camera should compensate the distortion of the lense or not.
  39668. */
  39669. compensateDistortion: boolean;
  39670. /**
  39671. * Defines if multiview should be enabled when rendering (Default: false)
  39672. */
  39673. multiviewEnabled: boolean;
  39674. /**
  39675. * Gets the rendering aspect ratio based on the provided resolutions.
  39676. */
  39677. readonly aspectRatio: number;
  39678. /**
  39679. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39680. */
  39681. readonly aspectRatioFov: number;
  39682. /**
  39683. * @hidden
  39684. */
  39685. readonly leftHMatrix: Matrix;
  39686. /**
  39687. * @hidden
  39688. */
  39689. readonly rightHMatrix: Matrix;
  39690. /**
  39691. * @hidden
  39692. */
  39693. readonly leftPreViewMatrix: Matrix;
  39694. /**
  39695. * @hidden
  39696. */
  39697. readonly rightPreViewMatrix: Matrix;
  39698. /**
  39699. * Get the default VRMetrics based on the most generic setup.
  39700. * @returns the default vr metrics
  39701. */
  39702. static GetDefault(): VRCameraMetrics;
  39703. }
  39704. }
  39705. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  39706. /** @hidden */
  39707. export var vrDistortionCorrectionPixelShader: {
  39708. name: string;
  39709. shader: string;
  39710. };
  39711. }
  39712. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  39713. import { Camera } from "babylonjs/Cameras/camera";
  39714. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39715. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39716. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  39717. /**
  39718. * VRDistortionCorrectionPostProcess used for mobile VR
  39719. */
  39720. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39721. private _isRightEye;
  39722. private _distortionFactors;
  39723. private _postProcessScaleFactor;
  39724. private _lensCenterOffset;
  39725. private _scaleIn;
  39726. private _scaleFactor;
  39727. private _lensCenter;
  39728. /**
  39729. * Initializes the VRDistortionCorrectionPostProcess
  39730. * @param name The name of the effect.
  39731. * @param camera The camera to apply the render pass to.
  39732. * @param isRightEye If this is for the right eye distortion
  39733. * @param vrMetrics All the required metrics for the VR camera
  39734. */
  39735. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39736. }
  39737. }
  39738. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  39739. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  39740. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39741. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39742. import { Scene } from "babylonjs/scene";
  39743. import { Vector3 } from "babylonjs/Maths/math";
  39744. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39745. import "babylonjs/Cameras/RigModes/vrRigMode";
  39746. /**
  39747. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39748. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39749. */
  39750. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39751. /**
  39752. * Creates a new VRDeviceOrientationArcRotateCamera
  39753. * @param name defines camera name
  39754. * @param alpha defines the camera rotation along the logitudinal axis
  39755. * @param beta defines the camera rotation along the latitudinal axis
  39756. * @param radius defines the camera distance from its target
  39757. * @param target defines the camera target
  39758. * @param scene defines the scene the camera belongs to
  39759. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39760. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39761. */
  39762. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39763. /**
  39764. * Gets camera class name
  39765. * @returns VRDeviceOrientationArcRotateCamera
  39766. */
  39767. getClassName(): string;
  39768. }
  39769. }
  39770. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  39771. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39772. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39773. import { Scene } from "babylonjs/scene";
  39774. import { Vector3 } from "babylonjs/Maths/math";
  39775. import "babylonjs/Cameras/RigModes/vrRigMode";
  39776. /**
  39777. * Camera used to simulate VR rendering (based on FreeCamera)
  39778. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39779. */
  39780. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39781. /**
  39782. * Creates a new VRDeviceOrientationFreeCamera
  39783. * @param name defines camera name
  39784. * @param position defines the start position of the camera
  39785. * @param scene defines the scene the camera belongs to
  39786. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39787. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39788. */
  39789. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39790. /**
  39791. * Gets camera class name
  39792. * @returns VRDeviceOrientationFreeCamera
  39793. */
  39794. getClassName(): string;
  39795. }
  39796. }
  39797. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  39798. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39799. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39800. import { Scene } from "babylonjs/scene";
  39801. import { Vector3 } from "babylonjs/Maths/math";
  39802. import "babylonjs/Gamepads/gamepadSceneComponent";
  39803. /**
  39804. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39805. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39806. */
  39807. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39808. /**
  39809. * Creates a new VRDeviceOrientationGamepadCamera
  39810. * @param name defines camera name
  39811. * @param position defines the start position of the camera
  39812. * @param scene defines the scene the camera belongs to
  39813. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39814. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39815. */
  39816. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39817. /**
  39818. * Gets camera class name
  39819. * @returns VRDeviceOrientationGamepadCamera
  39820. */
  39821. getClassName(): string;
  39822. }
  39823. }
  39824. declare module "babylonjs/Materials/pushMaterial" {
  39825. import { Nullable } from "babylonjs/types";
  39826. import { Scene } from "babylonjs/scene";
  39827. import { Matrix } from "babylonjs/Maths/math";
  39828. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39829. import { Mesh } from "babylonjs/Meshes/mesh";
  39830. import { Material } from "babylonjs/Materials/material";
  39831. import { Effect } from "babylonjs/Materials/effect";
  39832. /**
  39833. * Base class of materials working in push mode in babylon JS
  39834. * @hidden
  39835. */
  39836. export class PushMaterial extends Material {
  39837. protected _activeEffect: Effect;
  39838. protected _normalMatrix: Matrix;
  39839. /**
  39840. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39841. * This means that the material can keep using a previous shader while a new one is being compiled.
  39842. * This is mostly used when shader parallel compilation is supported (true by default)
  39843. */
  39844. allowShaderHotSwapping: boolean;
  39845. constructor(name: string, scene: Scene);
  39846. getEffect(): Effect;
  39847. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39848. /**
  39849. * Binds the given world matrix to the active effect
  39850. *
  39851. * @param world the matrix to bind
  39852. */
  39853. bindOnlyWorldMatrix(world: Matrix): void;
  39854. /**
  39855. * Binds the given normal matrix to the active effect
  39856. *
  39857. * @param normalMatrix the matrix to bind
  39858. */
  39859. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39860. bind(world: Matrix, mesh?: Mesh): void;
  39861. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39862. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39863. }
  39864. }
  39865. declare module "babylonjs/Materials/materialFlags" {
  39866. /**
  39867. * This groups all the flags used to control the materials channel.
  39868. */
  39869. export class MaterialFlags {
  39870. private static _DiffuseTextureEnabled;
  39871. /**
  39872. * Are diffuse textures enabled in the application.
  39873. */
  39874. static DiffuseTextureEnabled: boolean;
  39875. private static _AmbientTextureEnabled;
  39876. /**
  39877. * Are ambient textures enabled in the application.
  39878. */
  39879. static AmbientTextureEnabled: boolean;
  39880. private static _OpacityTextureEnabled;
  39881. /**
  39882. * Are opacity textures enabled in the application.
  39883. */
  39884. static OpacityTextureEnabled: boolean;
  39885. private static _ReflectionTextureEnabled;
  39886. /**
  39887. * Are reflection textures enabled in the application.
  39888. */
  39889. static ReflectionTextureEnabled: boolean;
  39890. private static _EmissiveTextureEnabled;
  39891. /**
  39892. * Are emissive textures enabled in the application.
  39893. */
  39894. static EmissiveTextureEnabled: boolean;
  39895. private static _SpecularTextureEnabled;
  39896. /**
  39897. * Are specular textures enabled in the application.
  39898. */
  39899. static SpecularTextureEnabled: boolean;
  39900. private static _BumpTextureEnabled;
  39901. /**
  39902. * Are bump textures enabled in the application.
  39903. */
  39904. static BumpTextureEnabled: boolean;
  39905. private static _LightmapTextureEnabled;
  39906. /**
  39907. * Are lightmap textures enabled in the application.
  39908. */
  39909. static LightmapTextureEnabled: boolean;
  39910. private static _RefractionTextureEnabled;
  39911. /**
  39912. * Are refraction textures enabled in the application.
  39913. */
  39914. static RefractionTextureEnabled: boolean;
  39915. private static _ColorGradingTextureEnabled;
  39916. /**
  39917. * Are color grading textures enabled in the application.
  39918. */
  39919. static ColorGradingTextureEnabled: boolean;
  39920. private static _FresnelEnabled;
  39921. /**
  39922. * Are fresnels enabled in the application.
  39923. */
  39924. static FresnelEnabled: boolean;
  39925. private static _ClearCoatTextureEnabled;
  39926. /**
  39927. * Are clear coat textures enabled in the application.
  39928. */
  39929. static ClearCoatTextureEnabled: boolean;
  39930. private static _ClearCoatBumpTextureEnabled;
  39931. /**
  39932. * Are clear coat bump textures enabled in the application.
  39933. */
  39934. static ClearCoatBumpTextureEnabled: boolean;
  39935. private static _ClearCoatTintTextureEnabled;
  39936. /**
  39937. * Are clear coat tint textures enabled in the application.
  39938. */
  39939. static ClearCoatTintTextureEnabled: boolean;
  39940. private static _SheenTextureEnabled;
  39941. /**
  39942. * Are sheen textures enabled in the application.
  39943. */
  39944. static SheenTextureEnabled: boolean;
  39945. private static _AnisotropicTextureEnabled;
  39946. /**
  39947. * Are anisotropic textures enabled in the application.
  39948. */
  39949. static AnisotropicTextureEnabled: boolean;
  39950. private static _ThicknessTextureEnabled;
  39951. /**
  39952. * Are thickness textures enabled in the application.
  39953. */
  39954. static ThicknessTextureEnabled: boolean;
  39955. }
  39956. }
  39957. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  39958. /** @hidden */
  39959. export var defaultFragmentDeclaration: {
  39960. name: string;
  39961. shader: string;
  39962. };
  39963. }
  39964. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  39965. /** @hidden */
  39966. export var defaultUboDeclaration: {
  39967. name: string;
  39968. shader: string;
  39969. };
  39970. }
  39971. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  39972. /** @hidden */
  39973. export var lightFragmentDeclaration: {
  39974. name: string;
  39975. shader: string;
  39976. };
  39977. }
  39978. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  39979. /** @hidden */
  39980. export var lightUboDeclaration: {
  39981. name: string;
  39982. shader: string;
  39983. };
  39984. }
  39985. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  39986. /** @hidden */
  39987. export var lightsFragmentFunctions: {
  39988. name: string;
  39989. shader: string;
  39990. };
  39991. }
  39992. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  39993. /** @hidden */
  39994. export var shadowsFragmentFunctions: {
  39995. name: string;
  39996. shader: string;
  39997. };
  39998. }
  39999. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  40000. /** @hidden */
  40001. export var fresnelFunction: {
  40002. name: string;
  40003. shader: string;
  40004. };
  40005. }
  40006. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  40007. /** @hidden */
  40008. export var reflectionFunction: {
  40009. name: string;
  40010. shader: string;
  40011. };
  40012. }
  40013. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  40014. /** @hidden */
  40015. export var bumpFragmentFunctions: {
  40016. name: string;
  40017. shader: string;
  40018. };
  40019. }
  40020. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  40021. /** @hidden */
  40022. export var logDepthDeclaration: {
  40023. name: string;
  40024. shader: string;
  40025. };
  40026. }
  40027. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  40028. /** @hidden */
  40029. export var bumpFragment: {
  40030. name: string;
  40031. shader: string;
  40032. };
  40033. }
  40034. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  40035. /** @hidden */
  40036. export var depthPrePass: {
  40037. name: string;
  40038. shader: string;
  40039. };
  40040. }
  40041. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  40042. /** @hidden */
  40043. export var lightFragment: {
  40044. name: string;
  40045. shader: string;
  40046. };
  40047. }
  40048. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  40049. /** @hidden */
  40050. export var logDepthFragment: {
  40051. name: string;
  40052. shader: string;
  40053. };
  40054. }
  40055. declare module "babylonjs/Shaders/default.fragment" {
  40056. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  40057. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40058. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40059. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40060. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40061. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  40062. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  40063. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  40064. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  40065. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40066. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40067. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  40068. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  40069. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40070. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  40071. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  40072. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  40073. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  40074. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  40075. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  40076. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  40077. /** @hidden */
  40078. export var defaultPixelShader: {
  40079. name: string;
  40080. shader: string;
  40081. };
  40082. }
  40083. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  40084. /** @hidden */
  40085. export var defaultVertexDeclaration: {
  40086. name: string;
  40087. shader: string;
  40088. };
  40089. }
  40090. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  40091. /** @hidden */
  40092. export var bumpVertexDeclaration: {
  40093. name: string;
  40094. shader: string;
  40095. };
  40096. }
  40097. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  40098. /** @hidden */
  40099. export var bumpVertex: {
  40100. name: string;
  40101. shader: string;
  40102. };
  40103. }
  40104. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  40105. /** @hidden */
  40106. export var fogVertex: {
  40107. name: string;
  40108. shader: string;
  40109. };
  40110. }
  40111. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  40112. /** @hidden */
  40113. export var shadowsVertex: {
  40114. name: string;
  40115. shader: string;
  40116. };
  40117. }
  40118. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  40119. /** @hidden */
  40120. export var pointCloudVertex: {
  40121. name: string;
  40122. shader: string;
  40123. };
  40124. }
  40125. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  40126. /** @hidden */
  40127. export var logDepthVertex: {
  40128. name: string;
  40129. shader: string;
  40130. };
  40131. }
  40132. declare module "babylonjs/Shaders/default.vertex" {
  40133. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  40134. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40135. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40136. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  40137. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  40138. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  40139. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  40140. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  40141. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40142. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40143. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  40144. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  40145. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40146. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  40147. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  40148. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  40149. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  40150. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  40151. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  40152. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  40153. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  40154. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  40155. /** @hidden */
  40156. export var defaultVertexShader: {
  40157. name: string;
  40158. shader: string;
  40159. };
  40160. }
  40161. declare module "babylonjs/Materials/standardMaterial" {
  40162. import { SmartArray } from "babylonjs/Misc/smartArray";
  40163. import { IAnimatable } from "babylonjs/Misc/tools";
  40164. import { Nullable } from "babylonjs/types";
  40165. import { Scene } from "babylonjs/scene";
  40166. import { Matrix, Color3 } from "babylonjs/Maths/math";
  40167. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40168. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40169. import { Mesh } from "babylonjs/Meshes/mesh";
  40170. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  40171. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40172. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  40173. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  40174. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  40175. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40176. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40177. import "babylonjs/Shaders/default.fragment";
  40178. import "babylonjs/Shaders/default.vertex";
  40179. /** @hidden */
  40180. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40181. MAINUV1: boolean;
  40182. MAINUV2: boolean;
  40183. DIFFUSE: boolean;
  40184. DIFFUSEDIRECTUV: number;
  40185. AMBIENT: boolean;
  40186. AMBIENTDIRECTUV: number;
  40187. OPACITY: boolean;
  40188. OPACITYDIRECTUV: number;
  40189. OPACITYRGB: boolean;
  40190. REFLECTION: boolean;
  40191. EMISSIVE: boolean;
  40192. EMISSIVEDIRECTUV: number;
  40193. SPECULAR: boolean;
  40194. SPECULARDIRECTUV: number;
  40195. BUMP: boolean;
  40196. BUMPDIRECTUV: number;
  40197. PARALLAX: boolean;
  40198. PARALLAXOCCLUSION: boolean;
  40199. SPECULAROVERALPHA: boolean;
  40200. CLIPPLANE: boolean;
  40201. CLIPPLANE2: boolean;
  40202. CLIPPLANE3: boolean;
  40203. CLIPPLANE4: boolean;
  40204. ALPHATEST: boolean;
  40205. DEPTHPREPASS: boolean;
  40206. ALPHAFROMDIFFUSE: boolean;
  40207. POINTSIZE: boolean;
  40208. FOG: boolean;
  40209. SPECULARTERM: boolean;
  40210. DIFFUSEFRESNEL: boolean;
  40211. OPACITYFRESNEL: boolean;
  40212. REFLECTIONFRESNEL: boolean;
  40213. REFRACTIONFRESNEL: boolean;
  40214. EMISSIVEFRESNEL: boolean;
  40215. FRESNEL: boolean;
  40216. NORMAL: boolean;
  40217. UV1: boolean;
  40218. UV2: boolean;
  40219. VERTEXCOLOR: boolean;
  40220. VERTEXALPHA: boolean;
  40221. NUM_BONE_INFLUENCERS: number;
  40222. BonesPerMesh: number;
  40223. BONETEXTURE: boolean;
  40224. INSTANCES: boolean;
  40225. GLOSSINESS: boolean;
  40226. ROUGHNESS: boolean;
  40227. EMISSIVEASILLUMINATION: boolean;
  40228. LINKEMISSIVEWITHDIFFUSE: boolean;
  40229. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40230. LIGHTMAP: boolean;
  40231. LIGHTMAPDIRECTUV: number;
  40232. OBJECTSPACE_NORMALMAP: boolean;
  40233. USELIGHTMAPASSHADOWMAP: boolean;
  40234. REFLECTIONMAP_3D: boolean;
  40235. REFLECTIONMAP_SPHERICAL: boolean;
  40236. REFLECTIONMAP_PLANAR: boolean;
  40237. REFLECTIONMAP_CUBIC: boolean;
  40238. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40239. REFLECTIONMAP_PROJECTION: boolean;
  40240. REFLECTIONMAP_SKYBOX: boolean;
  40241. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40242. REFLECTIONMAP_EXPLICIT: boolean;
  40243. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40244. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40245. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40246. INVERTCUBICMAP: boolean;
  40247. LOGARITHMICDEPTH: boolean;
  40248. REFRACTION: boolean;
  40249. REFRACTIONMAP_3D: boolean;
  40250. REFLECTIONOVERALPHA: boolean;
  40251. TWOSIDEDLIGHTING: boolean;
  40252. SHADOWFLOAT: boolean;
  40253. MORPHTARGETS: boolean;
  40254. MORPHTARGETS_NORMAL: boolean;
  40255. MORPHTARGETS_TANGENT: boolean;
  40256. NUM_MORPH_INFLUENCERS: number;
  40257. NONUNIFORMSCALING: boolean;
  40258. PREMULTIPLYALPHA: boolean;
  40259. IMAGEPROCESSING: boolean;
  40260. VIGNETTE: boolean;
  40261. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40262. VIGNETTEBLENDMODEOPAQUE: boolean;
  40263. TONEMAPPING: boolean;
  40264. TONEMAPPING_ACES: boolean;
  40265. CONTRAST: boolean;
  40266. COLORCURVES: boolean;
  40267. COLORGRADING: boolean;
  40268. COLORGRADING3D: boolean;
  40269. SAMPLER3DGREENDEPTH: boolean;
  40270. SAMPLER3DBGRMAP: boolean;
  40271. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40272. MULTIVIEW: boolean;
  40273. /**
  40274. * If the reflection texture on this material is in linear color space
  40275. * @hidden
  40276. */
  40277. IS_REFLECTION_LINEAR: boolean;
  40278. /**
  40279. * If the refraction texture on this material is in linear color space
  40280. * @hidden
  40281. */
  40282. IS_REFRACTION_LINEAR: boolean;
  40283. EXPOSURE: boolean;
  40284. constructor();
  40285. setReflectionMode(modeToEnable: string): void;
  40286. }
  40287. /**
  40288. * This is the default material used in Babylon. It is the best trade off between quality
  40289. * and performances.
  40290. * @see http://doc.babylonjs.com/babylon101/materials
  40291. */
  40292. export class StandardMaterial extends PushMaterial {
  40293. private _diffuseTexture;
  40294. /**
  40295. * The basic texture of the material as viewed under a light.
  40296. */
  40297. diffuseTexture: Nullable<BaseTexture>;
  40298. private _ambientTexture;
  40299. /**
  40300. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40301. */
  40302. ambientTexture: Nullable<BaseTexture>;
  40303. private _opacityTexture;
  40304. /**
  40305. * Define the transparency of the material from a texture.
  40306. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40307. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40308. */
  40309. opacityTexture: Nullable<BaseTexture>;
  40310. private _reflectionTexture;
  40311. /**
  40312. * Define the texture used to display the reflection.
  40313. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40314. */
  40315. reflectionTexture: Nullable<BaseTexture>;
  40316. private _emissiveTexture;
  40317. /**
  40318. * Define texture of the material as if self lit.
  40319. * This will be mixed in the final result even in the absence of light.
  40320. */
  40321. emissiveTexture: Nullable<BaseTexture>;
  40322. private _specularTexture;
  40323. /**
  40324. * Define how the color and intensity of the highlight given by the light in the material.
  40325. */
  40326. specularTexture: Nullable<BaseTexture>;
  40327. private _bumpTexture;
  40328. /**
  40329. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40330. * 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.
  40331. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40332. */
  40333. bumpTexture: Nullable<BaseTexture>;
  40334. private _lightmapTexture;
  40335. /**
  40336. * Complex lighting can be computationally expensive to compute at runtime.
  40337. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40338. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40339. */
  40340. lightmapTexture: Nullable<BaseTexture>;
  40341. private _refractionTexture;
  40342. /**
  40343. * Define the texture used to display the refraction.
  40344. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40345. */
  40346. refractionTexture: Nullable<BaseTexture>;
  40347. /**
  40348. * The color of the material lit by the environmental background lighting.
  40349. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40350. */
  40351. ambientColor: Color3;
  40352. /**
  40353. * The basic color of the material as viewed under a light.
  40354. */
  40355. diffuseColor: Color3;
  40356. /**
  40357. * Define how the color and intensity of the highlight given by the light in the material.
  40358. */
  40359. specularColor: Color3;
  40360. /**
  40361. * Define the color of the material as if self lit.
  40362. * This will be mixed in the final result even in the absence of light.
  40363. */
  40364. emissiveColor: Color3;
  40365. /**
  40366. * Defines how sharp are the highlights in the material.
  40367. * The bigger the value the sharper giving a more glossy feeling to the result.
  40368. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40369. */
  40370. specularPower: number;
  40371. private _useAlphaFromDiffuseTexture;
  40372. /**
  40373. * Does the transparency come from the diffuse texture alpha channel.
  40374. */
  40375. useAlphaFromDiffuseTexture: boolean;
  40376. private _useEmissiveAsIllumination;
  40377. /**
  40378. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40379. */
  40380. useEmissiveAsIllumination: boolean;
  40381. private _linkEmissiveWithDiffuse;
  40382. /**
  40383. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40384. * the emissive level when the final color is close to one.
  40385. */
  40386. linkEmissiveWithDiffuse: boolean;
  40387. private _useSpecularOverAlpha;
  40388. /**
  40389. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40390. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40391. */
  40392. useSpecularOverAlpha: boolean;
  40393. private _useReflectionOverAlpha;
  40394. /**
  40395. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40396. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40397. */
  40398. useReflectionOverAlpha: boolean;
  40399. private _disableLighting;
  40400. /**
  40401. * Does lights from the scene impacts this material.
  40402. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40403. */
  40404. disableLighting: boolean;
  40405. private _useObjectSpaceNormalMap;
  40406. /**
  40407. * Allows using an object space normal map (instead of tangent space).
  40408. */
  40409. useObjectSpaceNormalMap: boolean;
  40410. private _useParallax;
  40411. /**
  40412. * Is parallax enabled or not.
  40413. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40414. */
  40415. useParallax: boolean;
  40416. private _useParallaxOcclusion;
  40417. /**
  40418. * Is parallax occlusion enabled or not.
  40419. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40420. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40421. */
  40422. useParallaxOcclusion: boolean;
  40423. /**
  40424. * 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.
  40425. */
  40426. parallaxScaleBias: number;
  40427. private _roughness;
  40428. /**
  40429. * Helps to define how blurry the reflections should appears in the material.
  40430. */
  40431. roughness: number;
  40432. /**
  40433. * In case of refraction, define the value of the indice of refraction.
  40434. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40435. */
  40436. indexOfRefraction: number;
  40437. /**
  40438. * Invert the refraction texture alongside the y axis.
  40439. * It can be useful with procedural textures or probe for instance.
  40440. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40441. */
  40442. invertRefractionY: boolean;
  40443. /**
  40444. * Defines the alpha limits in alpha test mode.
  40445. */
  40446. alphaCutOff: number;
  40447. private _useLightmapAsShadowmap;
  40448. /**
  40449. * In case of light mapping, define whether the map contains light or shadow informations.
  40450. */
  40451. useLightmapAsShadowmap: boolean;
  40452. private _diffuseFresnelParameters;
  40453. /**
  40454. * Define the diffuse fresnel parameters of the material.
  40455. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40456. */
  40457. diffuseFresnelParameters: FresnelParameters;
  40458. private _opacityFresnelParameters;
  40459. /**
  40460. * Define the opacity fresnel parameters of the material.
  40461. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40462. */
  40463. opacityFresnelParameters: FresnelParameters;
  40464. private _reflectionFresnelParameters;
  40465. /**
  40466. * Define the reflection fresnel parameters of the material.
  40467. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40468. */
  40469. reflectionFresnelParameters: FresnelParameters;
  40470. private _refractionFresnelParameters;
  40471. /**
  40472. * Define the refraction fresnel parameters of the material.
  40473. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40474. */
  40475. refractionFresnelParameters: FresnelParameters;
  40476. private _emissiveFresnelParameters;
  40477. /**
  40478. * Define the emissive fresnel parameters of the material.
  40479. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40480. */
  40481. emissiveFresnelParameters: FresnelParameters;
  40482. private _useReflectionFresnelFromSpecular;
  40483. /**
  40484. * If true automatically deducts the fresnels values from the material specularity.
  40485. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40486. */
  40487. useReflectionFresnelFromSpecular: boolean;
  40488. private _useGlossinessFromSpecularMapAlpha;
  40489. /**
  40490. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40491. */
  40492. useGlossinessFromSpecularMapAlpha: boolean;
  40493. private _maxSimultaneousLights;
  40494. /**
  40495. * Defines the maximum number of lights that can be used in the material
  40496. */
  40497. maxSimultaneousLights: number;
  40498. private _invertNormalMapX;
  40499. /**
  40500. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40501. */
  40502. invertNormalMapX: boolean;
  40503. private _invertNormalMapY;
  40504. /**
  40505. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40506. */
  40507. invertNormalMapY: boolean;
  40508. private _twoSidedLighting;
  40509. /**
  40510. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40511. */
  40512. twoSidedLighting: boolean;
  40513. /**
  40514. * Default configuration related to image processing available in the standard Material.
  40515. */
  40516. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40517. /**
  40518. * Gets the image processing configuration used either in this material.
  40519. */
  40520. /**
  40521. * Sets the Default image processing configuration used either in the this material.
  40522. *
  40523. * If sets to null, the scene one is in use.
  40524. */
  40525. imageProcessingConfiguration: ImageProcessingConfiguration;
  40526. /**
  40527. * Keep track of the image processing observer to allow dispose and replace.
  40528. */
  40529. private _imageProcessingObserver;
  40530. /**
  40531. * Attaches a new image processing configuration to the Standard Material.
  40532. * @param configuration
  40533. */
  40534. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40535. /**
  40536. * Gets wether the color curves effect is enabled.
  40537. */
  40538. /**
  40539. * Sets wether the color curves effect is enabled.
  40540. */
  40541. cameraColorCurvesEnabled: boolean;
  40542. /**
  40543. * Gets wether the color grading effect is enabled.
  40544. */
  40545. /**
  40546. * Gets wether the color grading effect is enabled.
  40547. */
  40548. cameraColorGradingEnabled: boolean;
  40549. /**
  40550. * Gets wether tonemapping is enabled or not.
  40551. */
  40552. /**
  40553. * Sets wether tonemapping is enabled or not
  40554. */
  40555. cameraToneMappingEnabled: boolean;
  40556. /**
  40557. * The camera exposure used on this material.
  40558. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40559. * This corresponds to a photographic exposure.
  40560. */
  40561. /**
  40562. * The camera exposure used on this material.
  40563. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40564. * This corresponds to a photographic exposure.
  40565. */
  40566. cameraExposure: number;
  40567. /**
  40568. * Gets The camera contrast used on this material.
  40569. */
  40570. /**
  40571. * Sets The camera contrast used on this material.
  40572. */
  40573. cameraContrast: number;
  40574. /**
  40575. * Gets the Color Grading 2D Lookup Texture.
  40576. */
  40577. /**
  40578. * Sets the Color Grading 2D Lookup Texture.
  40579. */
  40580. cameraColorGradingTexture: Nullable<BaseTexture>;
  40581. /**
  40582. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40583. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40584. * 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;
  40585. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40586. */
  40587. /**
  40588. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40589. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40590. * 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;
  40591. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40592. */
  40593. cameraColorCurves: Nullable<ColorCurves>;
  40594. /**
  40595. * Custom callback helping to override the default shader used in the material.
  40596. */
  40597. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40598. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40599. protected _worldViewProjectionMatrix: Matrix;
  40600. protected _globalAmbientColor: Color3;
  40601. protected _useLogarithmicDepth: boolean;
  40602. /**
  40603. * Instantiates a new standard material.
  40604. * This is the default material used in Babylon. It is the best trade off between quality
  40605. * and performances.
  40606. * @see http://doc.babylonjs.com/babylon101/materials
  40607. * @param name Define the name of the material in the scene
  40608. * @param scene Define the scene the material belong to
  40609. */
  40610. constructor(name: string, scene: Scene);
  40611. /**
  40612. * Gets a boolean indicating that current material needs to register RTT
  40613. */
  40614. readonly hasRenderTargetTextures: boolean;
  40615. /**
  40616. * Gets the current class name of the material e.g. "StandardMaterial"
  40617. * Mainly use in serialization.
  40618. * @returns the class name
  40619. */
  40620. getClassName(): string;
  40621. /**
  40622. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40623. * You can try switching to logarithmic depth.
  40624. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40625. */
  40626. useLogarithmicDepth: boolean;
  40627. /**
  40628. * Specifies if the material will require alpha blending
  40629. * @returns a boolean specifying if alpha blending is needed
  40630. */
  40631. needAlphaBlending(): boolean;
  40632. /**
  40633. * Specifies if this material should be rendered in alpha test mode
  40634. * @returns a boolean specifying if an alpha test is needed.
  40635. */
  40636. needAlphaTesting(): boolean;
  40637. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40638. /**
  40639. * Get the texture used for alpha test purpose.
  40640. * @returns the diffuse texture in case of the standard material.
  40641. */
  40642. getAlphaTestTexture(): Nullable<BaseTexture>;
  40643. /**
  40644. * Get if the submesh is ready to be used and all its information available.
  40645. * Child classes can use it to update shaders
  40646. * @param mesh defines the mesh to check
  40647. * @param subMesh defines which submesh to check
  40648. * @param useInstances specifies that instances should be used
  40649. * @returns a boolean indicating that the submesh is ready or not
  40650. */
  40651. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40652. /**
  40653. * Builds the material UBO layouts.
  40654. * Used internally during the effect preparation.
  40655. */
  40656. buildUniformLayout(): void;
  40657. /**
  40658. * Unbinds the material from the mesh
  40659. */
  40660. unbind(): void;
  40661. /**
  40662. * Binds the submesh to this material by preparing the effect and shader to draw
  40663. * @param world defines the world transformation matrix
  40664. * @param mesh defines the mesh containing the submesh
  40665. * @param subMesh defines the submesh to bind the material to
  40666. */
  40667. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40668. /**
  40669. * Get the list of animatables in the material.
  40670. * @returns the list of animatables object used in the material
  40671. */
  40672. getAnimatables(): IAnimatable[];
  40673. /**
  40674. * Gets the active textures from the material
  40675. * @returns an array of textures
  40676. */
  40677. getActiveTextures(): BaseTexture[];
  40678. /**
  40679. * Specifies if the material uses a texture
  40680. * @param texture defines the texture to check against the material
  40681. * @returns a boolean specifying if the material uses the texture
  40682. */
  40683. hasTexture(texture: BaseTexture): boolean;
  40684. /**
  40685. * Disposes the material
  40686. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40687. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40688. */
  40689. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40690. /**
  40691. * Makes a duplicate of the material, and gives it a new name
  40692. * @param name defines the new name for the duplicated material
  40693. * @returns the cloned material
  40694. */
  40695. clone(name: string): StandardMaterial;
  40696. /**
  40697. * Serializes this material in a JSON representation
  40698. * @returns the serialized material object
  40699. */
  40700. serialize(): any;
  40701. /**
  40702. * Creates a standard material from parsed material data
  40703. * @param source defines the JSON representation of the material
  40704. * @param scene defines the hosting scene
  40705. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40706. * @returns a new standard material
  40707. */
  40708. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40709. /**
  40710. * Are diffuse textures enabled in the application.
  40711. */
  40712. static DiffuseTextureEnabled: boolean;
  40713. /**
  40714. * Are ambient textures enabled in the application.
  40715. */
  40716. static AmbientTextureEnabled: boolean;
  40717. /**
  40718. * Are opacity textures enabled in the application.
  40719. */
  40720. static OpacityTextureEnabled: boolean;
  40721. /**
  40722. * Are reflection textures enabled in the application.
  40723. */
  40724. static ReflectionTextureEnabled: boolean;
  40725. /**
  40726. * Are emissive textures enabled in the application.
  40727. */
  40728. static EmissiveTextureEnabled: boolean;
  40729. /**
  40730. * Are specular textures enabled in the application.
  40731. */
  40732. static SpecularTextureEnabled: boolean;
  40733. /**
  40734. * Are bump textures enabled in the application.
  40735. */
  40736. static BumpTextureEnabled: boolean;
  40737. /**
  40738. * Are lightmap textures enabled in the application.
  40739. */
  40740. static LightmapTextureEnabled: boolean;
  40741. /**
  40742. * Are refraction textures enabled in the application.
  40743. */
  40744. static RefractionTextureEnabled: boolean;
  40745. /**
  40746. * Are color grading textures enabled in the application.
  40747. */
  40748. static ColorGradingTextureEnabled: boolean;
  40749. /**
  40750. * Are fresnels enabled in the application.
  40751. */
  40752. static FresnelEnabled: boolean;
  40753. }
  40754. }
  40755. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  40756. import { Scene } from "babylonjs/scene";
  40757. import { Texture } from "babylonjs/Materials/Textures/texture";
  40758. /**
  40759. * A class extending Texture allowing drawing on a texture
  40760. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40761. */
  40762. export class DynamicTexture extends Texture {
  40763. private _generateMipMaps;
  40764. private _canvas;
  40765. private _context;
  40766. private _engine;
  40767. /**
  40768. * Creates a DynamicTexture
  40769. * @param name defines the name of the texture
  40770. * @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
  40771. * @param scene defines the scene where you want the texture
  40772. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40773. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40774. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40775. */
  40776. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40777. /**
  40778. * Get the current class name of the texture useful for serialization or dynamic coding.
  40779. * @returns "DynamicTexture"
  40780. */
  40781. getClassName(): string;
  40782. /**
  40783. * Gets the current state of canRescale
  40784. */
  40785. readonly canRescale: boolean;
  40786. private _recreate;
  40787. /**
  40788. * Scales the texture
  40789. * @param ratio the scale factor to apply to both width and height
  40790. */
  40791. scale(ratio: number): void;
  40792. /**
  40793. * Resizes the texture
  40794. * @param width the new width
  40795. * @param height the new height
  40796. */
  40797. scaleTo(width: number, height: number): void;
  40798. /**
  40799. * Gets the context of the canvas used by the texture
  40800. * @returns the canvas context of the dynamic texture
  40801. */
  40802. getContext(): CanvasRenderingContext2D;
  40803. /**
  40804. * Clears the texture
  40805. */
  40806. clear(): void;
  40807. /**
  40808. * Updates the texture
  40809. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40810. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40811. */
  40812. update(invertY?: boolean, premulAlpha?: boolean): void;
  40813. /**
  40814. * Draws text onto the texture
  40815. * @param text defines the text to be drawn
  40816. * @param x defines the placement of the text from the left
  40817. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40818. * @param font defines the font to be used with font-style, font-size, font-name
  40819. * @param color defines the color used for the text
  40820. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40821. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40822. * @param update defines whether texture is immediately update (default is true)
  40823. */
  40824. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40825. /**
  40826. * Clones the texture
  40827. * @returns the clone of the texture.
  40828. */
  40829. clone(): DynamicTexture;
  40830. /**
  40831. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40832. * @returns a serialized dynamic texture object
  40833. */
  40834. serialize(): any;
  40835. /** @hidden */
  40836. _rebuild(): void;
  40837. }
  40838. }
  40839. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  40840. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40841. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40842. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40843. /** @hidden */
  40844. export var imageProcessingPixelShader: {
  40845. name: string;
  40846. shader: string;
  40847. };
  40848. }
  40849. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  40850. import { Nullable } from "babylonjs/types";
  40851. import { Color4 } from "babylonjs/Maths/math";
  40852. import { Camera } from "babylonjs/Cameras/camera";
  40853. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40854. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40855. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40856. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40857. import { Engine } from "babylonjs/Engines/engine";
  40858. import "babylonjs/Shaders/imageProcessing.fragment";
  40859. import "babylonjs/Shaders/postprocess.vertex";
  40860. /**
  40861. * ImageProcessingPostProcess
  40862. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40863. */
  40864. export class ImageProcessingPostProcess extends PostProcess {
  40865. /**
  40866. * Default configuration related to image processing available in the PBR Material.
  40867. */
  40868. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40869. /**
  40870. * Gets the image processing configuration used either in this material.
  40871. */
  40872. /**
  40873. * Sets the Default image processing configuration used either in the this material.
  40874. *
  40875. * If sets to null, the scene one is in use.
  40876. */
  40877. imageProcessingConfiguration: ImageProcessingConfiguration;
  40878. /**
  40879. * Keep track of the image processing observer to allow dispose and replace.
  40880. */
  40881. private _imageProcessingObserver;
  40882. /**
  40883. * Attaches a new image processing configuration to the PBR Material.
  40884. * @param configuration
  40885. */
  40886. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40887. /**
  40888. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40889. */
  40890. /**
  40891. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40892. */
  40893. colorCurves: Nullable<ColorCurves>;
  40894. /**
  40895. * Gets wether the color curves effect is enabled.
  40896. */
  40897. /**
  40898. * Sets wether the color curves effect is enabled.
  40899. */
  40900. colorCurvesEnabled: boolean;
  40901. /**
  40902. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40903. */
  40904. /**
  40905. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40906. */
  40907. colorGradingTexture: Nullable<BaseTexture>;
  40908. /**
  40909. * Gets wether the color grading effect is enabled.
  40910. */
  40911. /**
  40912. * Gets wether the color grading effect is enabled.
  40913. */
  40914. colorGradingEnabled: boolean;
  40915. /**
  40916. * Gets exposure used in the effect.
  40917. */
  40918. /**
  40919. * Sets exposure used in the effect.
  40920. */
  40921. exposure: number;
  40922. /**
  40923. * Gets wether tonemapping is enabled or not.
  40924. */
  40925. /**
  40926. * Sets wether tonemapping is enabled or not
  40927. */
  40928. toneMappingEnabled: boolean;
  40929. /**
  40930. * Gets the type of tone mapping effect.
  40931. */
  40932. /**
  40933. * Sets the type of tone mapping effect.
  40934. */
  40935. toneMappingType: number;
  40936. /**
  40937. * Gets contrast used in the effect.
  40938. */
  40939. /**
  40940. * Sets contrast used in the effect.
  40941. */
  40942. contrast: number;
  40943. /**
  40944. * Gets Vignette stretch size.
  40945. */
  40946. /**
  40947. * Sets Vignette stretch size.
  40948. */
  40949. vignetteStretch: number;
  40950. /**
  40951. * Gets Vignette centre X Offset.
  40952. */
  40953. /**
  40954. * Sets Vignette centre X Offset.
  40955. */
  40956. vignetteCentreX: number;
  40957. /**
  40958. * Gets Vignette centre Y Offset.
  40959. */
  40960. /**
  40961. * Sets Vignette centre Y Offset.
  40962. */
  40963. vignetteCentreY: number;
  40964. /**
  40965. * Gets Vignette weight or intensity of the vignette effect.
  40966. */
  40967. /**
  40968. * Sets Vignette weight or intensity of the vignette effect.
  40969. */
  40970. vignetteWeight: number;
  40971. /**
  40972. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40973. * if vignetteEnabled is set to true.
  40974. */
  40975. /**
  40976. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40977. * if vignetteEnabled is set to true.
  40978. */
  40979. vignetteColor: Color4;
  40980. /**
  40981. * Gets Camera field of view used by the Vignette effect.
  40982. */
  40983. /**
  40984. * Sets Camera field of view used by the Vignette effect.
  40985. */
  40986. vignetteCameraFov: number;
  40987. /**
  40988. * Gets the vignette blend mode allowing different kind of effect.
  40989. */
  40990. /**
  40991. * Sets the vignette blend mode allowing different kind of effect.
  40992. */
  40993. vignetteBlendMode: number;
  40994. /**
  40995. * Gets wether the vignette effect is enabled.
  40996. */
  40997. /**
  40998. * Sets wether the vignette effect is enabled.
  40999. */
  41000. vignetteEnabled: boolean;
  41001. private _fromLinearSpace;
  41002. /**
  41003. * Gets wether the input of the processing is in Gamma or Linear Space.
  41004. */
  41005. /**
  41006. * Sets wether the input of the processing is in Gamma or Linear Space.
  41007. */
  41008. fromLinearSpace: boolean;
  41009. /**
  41010. * Defines cache preventing GC.
  41011. */
  41012. private _defines;
  41013. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41014. /**
  41015. * "ImageProcessingPostProcess"
  41016. * @returns "ImageProcessingPostProcess"
  41017. */
  41018. getClassName(): string;
  41019. protected _updateParameters(): void;
  41020. dispose(camera?: Camera): void;
  41021. }
  41022. }
  41023. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  41024. import { Scene } from "babylonjs/scene";
  41025. import { Color3 } from "babylonjs/Maths/math";
  41026. import { Mesh } from "babylonjs/Meshes/mesh";
  41027. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  41028. import { Nullable } from "babylonjs/types";
  41029. /**
  41030. * Class containing static functions to help procedurally build meshes
  41031. */
  41032. export class GroundBuilder {
  41033. /**
  41034. * Creates a ground mesh
  41035. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41036. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41038. * @param name defines the name of the mesh
  41039. * @param options defines the options used to create the mesh
  41040. * @param scene defines the hosting scene
  41041. * @returns the ground mesh
  41042. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41043. */
  41044. static CreateGround(name: string, options: {
  41045. width?: number;
  41046. height?: number;
  41047. subdivisions?: number;
  41048. subdivisionsX?: number;
  41049. subdivisionsY?: number;
  41050. updatable?: boolean;
  41051. }, scene: any): Mesh;
  41052. /**
  41053. * Creates a tiled ground mesh
  41054. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41055. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41056. * * 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
  41057. * * 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
  41058. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41059. * @param name defines the name of the mesh
  41060. * @param options defines the options used to create the mesh
  41061. * @param scene defines the hosting scene
  41062. * @returns the tiled ground mesh
  41063. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41064. */
  41065. static CreateTiledGround(name: string, options: {
  41066. xmin: number;
  41067. zmin: number;
  41068. xmax: number;
  41069. zmax: number;
  41070. subdivisions?: {
  41071. w: number;
  41072. h: number;
  41073. };
  41074. precision?: {
  41075. w: number;
  41076. h: number;
  41077. };
  41078. updatable?: boolean;
  41079. }, scene?: Nullable<Scene>): Mesh;
  41080. /**
  41081. * Creates a ground mesh from a height map
  41082. * * The parameter `url` sets the URL of the height map image resource.
  41083. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41084. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41085. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41086. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41087. * * 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.
  41088. * * 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).
  41089. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41091. * @param name defines the name of the mesh
  41092. * @param url defines the url to the height map
  41093. * @param options defines the options used to create the mesh
  41094. * @param scene defines the hosting scene
  41095. * @returns the ground mesh
  41096. * @see https://doc.babylonjs.com/babylon101/height_map
  41097. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41098. */
  41099. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41100. width?: number;
  41101. height?: number;
  41102. subdivisions?: number;
  41103. minHeight?: number;
  41104. maxHeight?: number;
  41105. colorFilter?: Color3;
  41106. alphaFilter?: number;
  41107. updatable?: boolean;
  41108. onReady?: (mesh: GroundMesh) => void;
  41109. }, scene?: Nullable<Scene>): GroundMesh;
  41110. }
  41111. }
  41112. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  41113. import { Vector4 } from "babylonjs/Maths/math";
  41114. import { Mesh } from "babylonjs/Meshes/mesh";
  41115. /**
  41116. * Class containing static functions to help procedurally build meshes
  41117. */
  41118. export class TorusBuilder {
  41119. /**
  41120. * Creates a torus mesh
  41121. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  41122. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  41123. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  41124. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41125. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41127. * @param name defines the name of the mesh
  41128. * @param options defines the options used to create the mesh
  41129. * @param scene defines the hosting scene
  41130. * @returns the torus mesh
  41131. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  41132. */
  41133. static CreateTorus(name: string, options: {
  41134. diameter?: number;
  41135. thickness?: number;
  41136. tessellation?: number;
  41137. updatable?: boolean;
  41138. sideOrientation?: number;
  41139. frontUVs?: Vector4;
  41140. backUVs?: Vector4;
  41141. }, scene: any): Mesh;
  41142. }
  41143. }
  41144. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  41145. import { Color4, Vector4 } from "babylonjs/Maths/math";
  41146. import { Mesh } from "babylonjs/Meshes/mesh";
  41147. /**
  41148. * Class containing static functions to help procedurally build meshes
  41149. */
  41150. export class CylinderBuilder {
  41151. /**
  41152. * Creates a cylinder or a cone mesh
  41153. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  41154. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  41155. * * 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.
  41156. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  41157. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  41158. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  41159. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  41160. * * 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).
  41161. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41162. * * 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).
  41163. * * 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
  41164. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41165. * * 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
  41166. * * 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.
  41167. * * If `enclose` is false, a ring surface is one element.
  41168. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41169. * * 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
  41170. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41171. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41172. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41173. * @param name defines the name of the mesh
  41174. * @param options defines the options used to create the mesh
  41175. * @param scene defines the hosting scene
  41176. * @returns the cylinder mesh
  41177. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41178. */
  41179. static CreateCylinder(name: string, options: {
  41180. height?: number;
  41181. diameterTop?: number;
  41182. diameterBottom?: number;
  41183. diameter?: number;
  41184. tessellation?: number;
  41185. subdivisions?: number;
  41186. arc?: number;
  41187. faceColors?: Color4[];
  41188. faceUV?: Vector4[];
  41189. updatable?: boolean;
  41190. hasRings?: boolean;
  41191. enclose?: boolean;
  41192. cap?: number;
  41193. sideOrientation?: number;
  41194. frontUVs?: Vector4;
  41195. backUVs?: Vector4;
  41196. }, scene: any): Mesh;
  41197. }
  41198. }
  41199. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  41200. import { Observable } from "babylonjs/Misc/observable";
  41201. import { Nullable } from "babylonjs/types";
  41202. import { Camera } from "babylonjs/Cameras/camera";
  41203. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41204. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41205. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  41206. import { Scene } from "babylonjs/scene";
  41207. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41208. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  41209. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41210. import { Mesh } from "babylonjs/Meshes/mesh";
  41211. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  41212. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41213. import "babylonjs/Meshes/Builders/groundBuilder";
  41214. import "babylonjs/Meshes/Builders/torusBuilder";
  41215. import "babylonjs/Meshes/Builders/cylinderBuilder";
  41216. import "babylonjs/Gamepads/gamepadSceneComponent";
  41217. import "babylonjs/Animations/animatable";
  41218. /**
  41219. * Options to modify the vr teleportation behavior.
  41220. */
  41221. export interface VRTeleportationOptions {
  41222. /**
  41223. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41224. */
  41225. floorMeshName?: string;
  41226. /**
  41227. * A list of meshes to be used as the teleportation floor. (default: empty)
  41228. */
  41229. floorMeshes?: Mesh[];
  41230. }
  41231. /**
  41232. * Options to modify the vr experience helper's behavior.
  41233. */
  41234. export interface VRExperienceHelperOptions extends WebVROptions {
  41235. /**
  41236. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41237. */
  41238. createDeviceOrientationCamera?: boolean;
  41239. /**
  41240. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41241. */
  41242. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41243. /**
  41244. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41245. */
  41246. laserToggle?: boolean;
  41247. /**
  41248. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41249. */
  41250. floorMeshes?: Mesh[];
  41251. /**
  41252. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41253. */
  41254. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41255. }
  41256. /**
  41257. * Event containing information after VR has been entered
  41258. */
  41259. export class OnAfterEnteringVRObservableEvent {
  41260. /**
  41261. * If entering vr was successful
  41262. */
  41263. success: boolean;
  41264. }
  41265. /**
  41266. * Helps to quickly add VR support to an existing scene.
  41267. * See http://doc.babylonjs.com/how_to/webvr_helper
  41268. */
  41269. export class VRExperienceHelper {
  41270. /** Options to modify the vr experience helper's behavior. */
  41271. webVROptions: VRExperienceHelperOptions;
  41272. private _scene;
  41273. private _position;
  41274. private _btnVR;
  41275. private _btnVRDisplayed;
  41276. private _webVRsupported;
  41277. private _webVRready;
  41278. private _webVRrequesting;
  41279. private _webVRpresenting;
  41280. private _hasEnteredVR;
  41281. private _fullscreenVRpresenting;
  41282. private _canvas;
  41283. private _webVRCamera;
  41284. private _vrDeviceOrientationCamera;
  41285. private _deviceOrientationCamera;
  41286. private _existingCamera;
  41287. private _onKeyDown;
  41288. private _onVrDisplayPresentChange;
  41289. private _onVRDisplayChanged;
  41290. private _onVRRequestPresentStart;
  41291. private _onVRRequestPresentComplete;
  41292. /**
  41293. * Observable raised right before entering VR.
  41294. */
  41295. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41296. /**
  41297. * Observable raised when entering VR has completed.
  41298. */
  41299. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41300. /**
  41301. * Observable raised when exiting VR.
  41302. */
  41303. onExitingVRObservable: Observable<VRExperienceHelper>;
  41304. /**
  41305. * Observable raised when controller mesh is loaded.
  41306. */
  41307. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41308. /** Return this.onEnteringVRObservable
  41309. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41310. */
  41311. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41312. /** Return this.onExitingVRObservable
  41313. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41314. */
  41315. readonly onExitingVR: Observable<VRExperienceHelper>;
  41316. /** Return this.onControllerMeshLoadedObservable
  41317. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41318. */
  41319. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41320. private _rayLength;
  41321. private _useCustomVRButton;
  41322. private _teleportationRequested;
  41323. private _teleportActive;
  41324. private _floorMeshName;
  41325. private _floorMeshesCollection;
  41326. private _rotationAllowed;
  41327. private _teleportBackwardsVector;
  41328. private _teleportationTarget;
  41329. private _isDefaultTeleportationTarget;
  41330. private _postProcessMove;
  41331. private _teleportationFillColor;
  41332. private _teleportationBorderColor;
  41333. private _rotationAngle;
  41334. private _haloCenter;
  41335. private _cameraGazer;
  41336. private _padSensibilityUp;
  41337. private _padSensibilityDown;
  41338. private _leftController;
  41339. private _rightController;
  41340. /**
  41341. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41342. */
  41343. onNewMeshSelected: Observable<AbstractMesh>;
  41344. /**
  41345. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41346. */
  41347. onNewMeshPicked: Observable<PickingInfo>;
  41348. private _circleEase;
  41349. /**
  41350. * Observable raised before camera teleportation
  41351. */
  41352. onBeforeCameraTeleport: Observable<Vector3>;
  41353. /**
  41354. * Observable raised after camera teleportation
  41355. */
  41356. onAfterCameraTeleport: Observable<Vector3>;
  41357. /**
  41358. * Observable raised when current selected mesh gets unselected
  41359. */
  41360. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41361. private _raySelectionPredicate;
  41362. /**
  41363. * To be optionaly changed by user to define custom ray selection
  41364. */
  41365. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41366. /**
  41367. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41368. */
  41369. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41370. /**
  41371. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41372. */
  41373. teleportationEnabled: boolean;
  41374. private _defaultHeight;
  41375. private _teleportationInitialized;
  41376. private _interactionsEnabled;
  41377. private _interactionsRequested;
  41378. private _displayGaze;
  41379. private _displayLaserPointer;
  41380. /**
  41381. * The mesh used to display where the user is going to teleport.
  41382. */
  41383. /**
  41384. * Sets the mesh to be used to display where the user is going to teleport.
  41385. */
  41386. teleportationTarget: Mesh;
  41387. /**
  41388. * 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
  41389. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41390. * See http://doc.babylonjs.com/resources/baking_transformations
  41391. */
  41392. gazeTrackerMesh: Mesh;
  41393. /**
  41394. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41395. */
  41396. updateGazeTrackerScale: boolean;
  41397. /**
  41398. * If the gaze trackers color should be updated when selecting meshes
  41399. */
  41400. updateGazeTrackerColor: boolean;
  41401. /**
  41402. * The gaze tracking mesh corresponding to the left controller
  41403. */
  41404. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41405. /**
  41406. * The gaze tracking mesh corresponding to the right controller
  41407. */
  41408. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41409. /**
  41410. * If the ray of the gaze should be displayed.
  41411. */
  41412. /**
  41413. * Sets if the ray of the gaze should be displayed.
  41414. */
  41415. displayGaze: boolean;
  41416. /**
  41417. * If the ray of the LaserPointer should be displayed.
  41418. */
  41419. /**
  41420. * Sets if the ray of the LaserPointer should be displayed.
  41421. */
  41422. displayLaserPointer: boolean;
  41423. /**
  41424. * The deviceOrientationCamera used as the camera when not in VR.
  41425. */
  41426. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41427. /**
  41428. * Based on the current WebVR support, returns the current VR camera used.
  41429. */
  41430. readonly currentVRCamera: Nullable<Camera>;
  41431. /**
  41432. * The webVRCamera which is used when in VR.
  41433. */
  41434. readonly webVRCamera: WebVRFreeCamera;
  41435. /**
  41436. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41437. */
  41438. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41439. private readonly _teleportationRequestInitiated;
  41440. /**
  41441. * Defines wether or not Pointer lock should be requested when switching to
  41442. * full screen.
  41443. */
  41444. requestPointerLockOnFullScreen: boolean;
  41445. /**
  41446. * Instantiates a VRExperienceHelper.
  41447. * Helps to quickly add VR support to an existing scene.
  41448. * @param scene The scene the VRExperienceHelper belongs to.
  41449. * @param webVROptions Options to modify the vr experience helper's behavior.
  41450. */
  41451. constructor(scene: Scene,
  41452. /** Options to modify the vr experience helper's behavior. */
  41453. webVROptions?: VRExperienceHelperOptions);
  41454. private _onDefaultMeshLoaded;
  41455. private _onResize;
  41456. private _onFullscreenChange;
  41457. /**
  41458. * Gets a value indicating if we are currently in VR mode.
  41459. */
  41460. readonly isInVRMode: boolean;
  41461. private onVrDisplayPresentChange;
  41462. private onVRDisplayChanged;
  41463. private moveButtonToBottomRight;
  41464. private displayVRButton;
  41465. private updateButtonVisibility;
  41466. private _cachedAngularSensibility;
  41467. /**
  41468. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41469. * Otherwise, will use the fullscreen API.
  41470. */
  41471. enterVR(): void;
  41472. /**
  41473. * Attempt to exit VR, or fullscreen.
  41474. */
  41475. exitVR(): void;
  41476. /**
  41477. * The position of the vr experience helper.
  41478. */
  41479. /**
  41480. * Sets the position of the vr experience helper.
  41481. */
  41482. position: Vector3;
  41483. /**
  41484. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41485. */
  41486. enableInteractions(): void;
  41487. private readonly _noControllerIsActive;
  41488. private beforeRender;
  41489. private _isTeleportationFloor;
  41490. /**
  41491. * Adds a floor mesh to be used for teleportation.
  41492. * @param floorMesh the mesh to be used for teleportation.
  41493. */
  41494. addFloorMesh(floorMesh: Mesh): void;
  41495. /**
  41496. * Removes a floor mesh from being used for teleportation.
  41497. * @param floorMesh the mesh to be removed.
  41498. */
  41499. removeFloorMesh(floorMesh: Mesh): void;
  41500. /**
  41501. * Enables interactions and teleportation using the VR controllers and gaze.
  41502. * @param vrTeleportationOptions options to modify teleportation behavior.
  41503. */
  41504. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41505. private _onNewGamepadConnected;
  41506. private _tryEnableInteractionOnController;
  41507. private _onNewGamepadDisconnected;
  41508. private _enableInteractionOnController;
  41509. private _checkTeleportWithRay;
  41510. private _checkRotate;
  41511. private _checkTeleportBackwards;
  41512. private _enableTeleportationOnController;
  41513. private _createTeleportationCircles;
  41514. private _displayTeleportationTarget;
  41515. private _hideTeleportationTarget;
  41516. private _rotateCamera;
  41517. private _moveTeleportationSelectorTo;
  41518. private _workingVector;
  41519. private _workingQuaternion;
  41520. private _workingMatrix;
  41521. /**
  41522. * Teleports the users feet to the desired location
  41523. * @param location The location where the user's feet should be placed
  41524. */
  41525. teleportCamera(location: Vector3): void;
  41526. private _convertNormalToDirectionOfRay;
  41527. private _castRayAndSelectObject;
  41528. private _notifySelectedMeshUnselected;
  41529. /**
  41530. * Sets the color of the laser ray from the vr controllers.
  41531. * @param color new color for the ray.
  41532. */
  41533. changeLaserColor(color: Color3): void;
  41534. /**
  41535. * Sets the color of the ray from the vr headsets gaze.
  41536. * @param color new color for the ray.
  41537. */
  41538. changeGazeColor(color: Color3): void;
  41539. /**
  41540. * Exits VR and disposes of the vr experience helper
  41541. */
  41542. dispose(): void;
  41543. /**
  41544. * Gets the name of the VRExperienceHelper class
  41545. * @returns "VRExperienceHelper"
  41546. */
  41547. getClassName(): string;
  41548. }
  41549. }
  41550. declare module "babylonjs/Cameras/VR/index" {
  41551. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  41552. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  41553. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41554. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  41555. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  41556. export * from "babylonjs/Cameras/VR/webVRCamera";
  41557. }
  41558. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  41559. import { Observable } from "babylonjs/Misc/observable";
  41560. import { Nullable } from "babylonjs/types";
  41561. import { IDisposable, Scene } from "babylonjs/scene";
  41562. import { Vector3 } from "babylonjs/Maths/math";
  41563. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41564. import { Ray } from "babylonjs/Culling/ray";
  41565. /**
  41566. * Manages an XRSession
  41567. * @see https://doc.babylonjs.com/how_to/webxr
  41568. */
  41569. export class WebXRSessionManager implements IDisposable {
  41570. private scene;
  41571. /**
  41572. * Fires every time a new xrFrame arrives which can be used to update the camera
  41573. */
  41574. onXRFrameObservable: Observable<any>;
  41575. /**
  41576. * Fires when the xr session is ended either by the device or manually done
  41577. */
  41578. onXRSessionEnded: Observable<any>;
  41579. /** @hidden */
  41580. _xrSession: XRSession;
  41581. /** @hidden */
  41582. _frameOfReference: XRFrameOfReference;
  41583. /** @hidden */
  41584. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41585. /** @hidden */
  41586. _currentXRFrame: Nullable<XRFrame>;
  41587. private _xrNavigator;
  41588. private _xrDevice;
  41589. private _tmpMatrix;
  41590. /**
  41591. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41592. * @param scene The scene which the session should be created for
  41593. */
  41594. constructor(scene: Scene);
  41595. /**
  41596. * Initializes the manager
  41597. * After initialization enterXR can be called to start an XR session
  41598. * @returns Promise which resolves after it is initialized
  41599. */
  41600. initializeAsync(): Promise<void>;
  41601. /**
  41602. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  41603. * @param sessionCreationOptions xr options to create the session with
  41604. * @param frameOfReferenceType option to configure how the xr pose is expressed
  41605. * @returns Promise which resolves after it enters XR
  41606. */
  41607. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  41608. /**
  41609. * Stops the xrSession and restores the renderloop
  41610. * @returns Promise which resolves after it exits XR
  41611. */
  41612. exitXRAsync(): Promise<void>;
  41613. /**
  41614. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41615. * @param ray ray to cast into the environment
  41616. * @returns Promise which resolves with a collision point in the environment if it exists
  41617. */
  41618. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41619. /**
  41620. * Checks if a session would be supported for the creation options specified
  41621. * @param options creation options to check if they are supported
  41622. * @returns true if supported
  41623. */
  41624. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41625. /**
  41626. * @hidden
  41627. * Converts the render layer of xrSession to a render target
  41628. * @param session session to create render target for
  41629. * @param scene scene the new render target should be created for
  41630. */
  41631. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  41632. /**
  41633. * Disposes of the session manager
  41634. */
  41635. dispose(): void;
  41636. }
  41637. }
  41638. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41639. import { Scene } from "babylonjs/scene";
  41640. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41641. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41642. /**
  41643. * WebXR Camera which holds the views for the xrSession
  41644. * @see https://doc.babylonjs.com/how_to/webxr
  41645. */
  41646. export class WebXRCamera extends FreeCamera {
  41647. private static _TmpMatrix;
  41648. /**
  41649. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41650. * @param name the name of the camera
  41651. * @param scene the scene to add the camera to
  41652. */
  41653. constructor(name: string, scene: Scene);
  41654. private _updateNumberOfRigCameras;
  41655. /** @hidden */
  41656. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41657. /**
  41658. * Updates the cameras position from the current pose information of the XR session
  41659. * @param xrSessionManager the session containing pose information
  41660. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41661. */
  41662. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41663. }
  41664. }
  41665. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  41666. import { Nullable } from "babylonjs/types";
  41667. import { Observable } from "babylonjs/Misc/observable";
  41668. import { IDisposable, Scene } from "babylonjs/scene";
  41669. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  41670. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41671. import { Ray } from "babylonjs/Culling/ray";
  41672. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41673. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  41674. /**
  41675. * States of the webXR experience
  41676. */
  41677. export enum WebXRState {
  41678. /**
  41679. * Transitioning to being in XR mode
  41680. */
  41681. ENTERING_XR = 0,
  41682. /**
  41683. * Transitioning to non XR mode
  41684. */
  41685. EXITING_XR = 1,
  41686. /**
  41687. * In XR mode and presenting
  41688. */
  41689. IN_XR = 2,
  41690. /**
  41691. * Not entered XR mode
  41692. */
  41693. NOT_IN_XR = 3
  41694. }
  41695. /**
  41696. * Helper class used to enable XR
  41697. * @see https://doc.babylonjs.com/how_to/webxr
  41698. */
  41699. export class WebXRExperienceHelper implements IDisposable {
  41700. private scene;
  41701. /**
  41702. * 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
  41703. */
  41704. container: AbstractMesh;
  41705. /**
  41706. * Camera used to render xr content
  41707. */
  41708. camera: WebXRCamera;
  41709. /**
  41710. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41711. */
  41712. state: WebXRState;
  41713. private _setState;
  41714. private static _TmpVector;
  41715. /**
  41716. * Fires when the state of the experience helper has changed
  41717. */
  41718. onStateChangedObservable: Observable<WebXRState>;
  41719. /** @hidden */
  41720. _sessionManager: WebXRSessionManager;
  41721. private _nonVRCamera;
  41722. private _originalSceneAutoClear;
  41723. private _supported;
  41724. /**
  41725. * Creates the experience helper
  41726. * @param scene the scene to attach the experience helper to
  41727. * @returns a promise for the experience helper
  41728. */
  41729. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41730. /**
  41731. * Creates a WebXRExperienceHelper
  41732. * @param scene The scene the helper should be created in
  41733. */
  41734. private constructor();
  41735. /**
  41736. * Exits XR mode and returns the scene to its original state
  41737. * @returns promise that resolves after xr mode has exited
  41738. */
  41739. exitXRAsync(): Promise<void>;
  41740. /**
  41741. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41742. * @param sessionCreationOptions options for the XR session
  41743. * @param frameOfReference frame of reference of the XR session
  41744. * @returns promise that resolves after xr mode has entered
  41745. */
  41746. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  41747. /**
  41748. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41749. * @param ray ray to cast into the environment
  41750. * @returns Promise which resolves with a collision point in the environment if it exists
  41751. */
  41752. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41753. /**
  41754. * Updates the global position of the camera by moving the camera's container
  41755. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41756. * @param position The desired global position of the camera
  41757. */
  41758. setPositionOfCameraUsingContainer(position: Vector3): void;
  41759. /**
  41760. * Rotates the xr camera by rotating the camera's container around the camera's position
  41761. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41762. * @param rotation the desired quaternion rotation to apply to the camera
  41763. */
  41764. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41765. /**
  41766. * Checks if the creation options are supported by the xr session
  41767. * @param options creation options
  41768. * @returns true if supported
  41769. */
  41770. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41771. /**
  41772. * Disposes of the experience helper
  41773. */
  41774. dispose(): void;
  41775. }
  41776. }
  41777. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  41778. import { Nullable } from "babylonjs/types";
  41779. import { Observable } from "babylonjs/Misc/observable";
  41780. import { IDisposable, Scene } from "babylonjs/scene";
  41781. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41782. /**
  41783. * Button which can be used to enter a different mode of XR
  41784. */
  41785. export class WebXREnterExitUIButton {
  41786. /** button element */
  41787. element: HTMLElement;
  41788. /** XR initialization options for the button */
  41789. initializationOptions: XRSessionCreationOptions;
  41790. /**
  41791. * Creates a WebXREnterExitUIButton
  41792. * @param element button element
  41793. * @param initializationOptions XR initialization options for the button
  41794. */
  41795. constructor(
  41796. /** button element */
  41797. element: HTMLElement,
  41798. /** XR initialization options for the button */
  41799. initializationOptions: XRSessionCreationOptions);
  41800. /**
  41801. * Overwritable function which can be used to update the button's visuals when the state changes
  41802. * @param activeButton the current active button in the UI
  41803. */
  41804. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41805. }
  41806. /**
  41807. * Options to create the webXR UI
  41808. */
  41809. export class WebXREnterExitUIOptions {
  41810. /**
  41811. * Context to enter xr with
  41812. */
  41813. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  41814. /**
  41815. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41816. */
  41817. customButtons?: Array<WebXREnterExitUIButton>;
  41818. }
  41819. /**
  41820. * UI to allow the user to enter/exit XR mode
  41821. */
  41822. export class WebXREnterExitUI implements IDisposable {
  41823. private scene;
  41824. private _overlay;
  41825. private _buttons;
  41826. private _activeButton;
  41827. /**
  41828. * Fired every time the active button is changed.
  41829. *
  41830. * When xr is entered via a button that launches xr that button will be the callback parameter
  41831. *
  41832. * When exiting xr the callback parameter will be null)
  41833. */
  41834. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41835. /**
  41836. * Creates UI to allow the user to enter/exit XR mode
  41837. * @param scene the scene to add the ui to
  41838. * @param helper the xr experience helper to enter/exit xr with
  41839. * @param options options to configure the UI
  41840. * @returns the created ui
  41841. */
  41842. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41843. private constructor();
  41844. private _updateButtons;
  41845. /**
  41846. * Disposes of the object
  41847. */
  41848. dispose(): void;
  41849. }
  41850. }
  41851. declare module "babylonjs/Cameras/XR/webXRInput" {
  41852. import { IDisposable, Scene } from "babylonjs/scene";
  41853. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41854. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41855. /**
  41856. * Represents an XR input
  41857. */
  41858. export class WebXRController {
  41859. /**
  41860. * 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
  41861. */
  41862. grip?: AbstractMesh;
  41863. /**
  41864. * Pointer which can be used to select objects or attach a visible laser to
  41865. */
  41866. pointer: AbstractMesh;
  41867. /**
  41868. * Creates the controller
  41869. * @see https://doc.babylonjs.com/how_to/webxr
  41870. * @param scene the scene which the controller should be associated to
  41871. */
  41872. constructor(scene: Scene);
  41873. /**
  41874. * Disposes of the object
  41875. */
  41876. dispose(): void;
  41877. }
  41878. /**
  41879. * XR input used to track XR inputs such as controllers/rays
  41880. */
  41881. export class WebXRInput implements IDisposable {
  41882. private helper;
  41883. /**
  41884. * XR controllers being tracked
  41885. */
  41886. controllers: Array<WebXRController>;
  41887. private _tmpMatrix;
  41888. private _frameObserver;
  41889. /**
  41890. * Initializes the WebXRInput
  41891. * @param helper experience helper which the input should be created for
  41892. */
  41893. constructor(helper: WebXRExperienceHelper);
  41894. /**
  41895. * Disposes of the object
  41896. */
  41897. dispose(): void;
  41898. }
  41899. }
  41900. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41901. import { Nullable } from "babylonjs/types";
  41902. import { IDisposable } from "babylonjs/scene";
  41903. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41904. /**
  41905. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41906. */
  41907. export class WebXRManagedOutputCanvas implements IDisposable {
  41908. private _canvas;
  41909. /**
  41910. * xrpresent context of the canvas which can be used to display/mirror xr content
  41911. */
  41912. canvasContext: Nullable<WebGLRenderingContext>;
  41913. /**
  41914. * Initializes the canvas to be added/removed upon entering/exiting xr
  41915. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41916. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41917. */
  41918. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41919. /**
  41920. * Disposes of the object
  41921. */
  41922. dispose(): void;
  41923. private _setManagedOutputCanvas;
  41924. private _addCanvas;
  41925. private _removeCanvas;
  41926. }
  41927. }
  41928. declare module "babylonjs/Cameras/XR/index" {
  41929. export * from "babylonjs/Cameras/XR/webXRCamera";
  41930. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  41931. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41932. export * from "babylonjs/Cameras/XR/webXRInput";
  41933. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41934. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  41935. }
  41936. declare module "babylonjs/Cameras/RigModes/index" {
  41937. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41938. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41939. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  41940. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  41941. }
  41942. declare module "babylonjs/Cameras/index" {
  41943. export * from "babylonjs/Cameras/Inputs/index";
  41944. export * from "babylonjs/Cameras/cameraInputsManager";
  41945. export * from "babylonjs/Cameras/camera";
  41946. export * from "babylonjs/Cameras/targetCamera";
  41947. export * from "babylonjs/Cameras/freeCamera";
  41948. export * from "babylonjs/Cameras/freeCameraInputsManager";
  41949. export * from "babylonjs/Cameras/touchCamera";
  41950. export * from "babylonjs/Cameras/arcRotateCamera";
  41951. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  41952. export * from "babylonjs/Cameras/deviceOrientationCamera";
  41953. export * from "babylonjs/Cameras/flyCamera";
  41954. export * from "babylonjs/Cameras/flyCameraInputsManager";
  41955. export * from "babylonjs/Cameras/followCamera";
  41956. export * from "babylonjs/Cameras/gamepadCamera";
  41957. export * from "babylonjs/Cameras/Stereoscopic/index";
  41958. export * from "babylonjs/Cameras/universalCamera";
  41959. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  41960. export * from "babylonjs/Cameras/VR/index";
  41961. export * from "babylonjs/Cameras/XR/index";
  41962. export * from "babylonjs/Cameras/RigModes/index";
  41963. }
  41964. declare module "babylonjs/Collisions/index" {
  41965. export * from "babylonjs/Collisions/collider";
  41966. export * from "babylonjs/Collisions/collisionCoordinator";
  41967. export * from "babylonjs/Collisions/pickingInfo";
  41968. export * from "babylonjs/Collisions/intersectionInfo";
  41969. export * from "babylonjs/Collisions/meshCollisionData";
  41970. }
  41971. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  41972. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  41973. import { Vector3, Plane } from "babylonjs/Maths/math";
  41974. import { Ray } from "babylonjs/Culling/ray";
  41975. /**
  41976. * Contains an array of blocks representing the octree
  41977. */
  41978. export interface IOctreeContainer<T> {
  41979. /**
  41980. * Blocks within the octree
  41981. */
  41982. blocks: Array<OctreeBlock<T>>;
  41983. }
  41984. /**
  41985. * Class used to store a cell in an octree
  41986. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41987. */
  41988. export class OctreeBlock<T> {
  41989. /**
  41990. * Gets the content of the current block
  41991. */
  41992. entries: T[];
  41993. /**
  41994. * Gets the list of block children
  41995. */
  41996. blocks: Array<OctreeBlock<T>>;
  41997. private _depth;
  41998. private _maxDepth;
  41999. private _capacity;
  42000. private _minPoint;
  42001. private _maxPoint;
  42002. private _boundingVectors;
  42003. private _creationFunc;
  42004. /**
  42005. * Creates a new block
  42006. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42007. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42008. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42009. * @param depth defines the current depth of this block in the octree
  42010. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42011. * @param creationFunc defines a callback to call when an element is added to the block
  42012. */
  42013. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42014. /**
  42015. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42016. */
  42017. readonly capacity: number;
  42018. /**
  42019. * Gets the minimum vector (in world space) of the block's bounding box
  42020. */
  42021. readonly minPoint: Vector3;
  42022. /**
  42023. * Gets the maximum vector (in world space) of the block's bounding box
  42024. */
  42025. readonly maxPoint: Vector3;
  42026. /**
  42027. * Add a new element to this block
  42028. * @param entry defines the element to add
  42029. */
  42030. addEntry(entry: T): void;
  42031. /**
  42032. * Remove an element from this block
  42033. * @param entry defines the element to remove
  42034. */
  42035. removeEntry(entry: T): void;
  42036. /**
  42037. * Add an array of elements to this block
  42038. * @param entries defines the array of elements to add
  42039. */
  42040. addEntries(entries: T[]): void;
  42041. /**
  42042. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42043. * @param frustumPlanes defines the frustum planes to test
  42044. * @param selection defines the array to store current content if selection is positive
  42045. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42046. */
  42047. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42048. /**
  42049. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42050. * @param sphereCenter defines the bounding sphere center
  42051. * @param sphereRadius defines the bounding sphere radius
  42052. * @param selection defines the array to store current content if selection is positive
  42053. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42054. */
  42055. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42056. /**
  42057. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42058. * @param ray defines the ray to test with
  42059. * @param selection defines the array to store current content if selection is positive
  42060. */
  42061. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42062. /**
  42063. * Subdivide the content into child blocks (this block will then be empty)
  42064. */
  42065. createInnerBlocks(): void;
  42066. /**
  42067. * @hidden
  42068. */
  42069. 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;
  42070. }
  42071. }
  42072. declare module "babylonjs/Culling/Octrees/octree" {
  42073. import { SmartArray } from "babylonjs/Misc/smartArray";
  42074. import { Vector3, Plane } from "babylonjs/Maths/math";
  42075. import { SubMesh } from "babylonjs/Meshes/subMesh";
  42076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42077. import { Ray } from "babylonjs/Culling/ray";
  42078. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  42079. /**
  42080. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42081. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42082. */
  42083. export class Octree<T> {
  42084. /** 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.) */
  42085. maxDepth: number;
  42086. /**
  42087. * Blocks within the octree containing objects
  42088. */
  42089. blocks: Array<OctreeBlock<T>>;
  42090. /**
  42091. * Content stored in the octree
  42092. */
  42093. dynamicContent: T[];
  42094. private _maxBlockCapacity;
  42095. private _selectionContent;
  42096. private _creationFunc;
  42097. /**
  42098. * Creates a octree
  42099. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42100. * @param creationFunc function to be used to instatiate the octree
  42101. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42102. * @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.)
  42103. */
  42104. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42105. /** 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.) */
  42106. maxDepth?: number);
  42107. /**
  42108. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42109. * @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);
  42110. * @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);
  42111. * @param entries meshes to be added to the octree blocks
  42112. */
  42113. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42114. /**
  42115. * Adds a mesh to the octree
  42116. * @param entry Mesh to add to the octree
  42117. */
  42118. addMesh(entry: T): void;
  42119. /**
  42120. * Remove an element from the octree
  42121. * @param entry defines the element to remove
  42122. */
  42123. removeMesh(entry: T): void;
  42124. /**
  42125. * Selects an array of meshes within the frustum
  42126. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42127. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42128. * @returns array of meshes within the frustum
  42129. */
  42130. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42131. /**
  42132. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42133. * @param sphereCenter defines the bounding sphere center
  42134. * @param sphereRadius defines the bounding sphere radius
  42135. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42136. * @returns an array of objects that intersect the sphere
  42137. */
  42138. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42139. /**
  42140. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42141. * @param ray defines the ray to test with
  42142. * @returns array of intersected objects
  42143. */
  42144. intersectsRay(ray: Ray): SmartArray<T>;
  42145. /**
  42146. * Adds a mesh into the octree block if it intersects the block
  42147. */
  42148. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42149. /**
  42150. * Adds a submesh into the octree block if it intersects the block
  42151. */
  42152. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42153. }
  42154. }
  42155. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  42156. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  42157. import { Scene } from "babylonjs/scene";
  42158. import { SubMesh } from "babylonjs/Meshes/subMesh";
  42159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42160. import { Ray } from "babylonjs/Culling/ray";
  42161. import { Octree } from "babylonjs/Culling/Octrees/octree";
  42162. import { Collider } from "babylonjs/Collisions/collider";
  42163. module "babylonjs/scene" {
  42164. interface Scene {
  42165. /**
  42166. * @hidden
  42167. * Backing Filed
  42168. */
  42169. _selectionOctree: Octree<AbstractMesh>;
  42170. /**
  42171. * Gets the octree used to boost mesh selection (picking)
  42172. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42173. */
  42174. selectionOctree: Octree<AbstractMesh>;
  42175. /**
  42176. * Creates or updates the octree used to boost selection (picking)
  42177. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42178. * @param maxCapacity defines the maximum capacity per leaf
  42179. * @param maxDepth defines the maximum depth of the octree
  42180. * @returns an octree of AbstractMesh
  42181. */
  42182. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42183. }
  42184. }
  42185. module "babylonjs/Meshes/abstractMesh" {
  42186. interface AbstractMesh {
  42187. /**
  42188. * @hidden
  42189. * Backing Field
  42190. */
  42191. _submeshesOctree: Octree<SubMesh>;
  42192. /**
  42193. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42194. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42195. * @param maxCapacity defines the maximum size of each block (64 by default)
  42196. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42197. * @returns the new octree
  42198. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42199. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42200. */
  42201. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42202. }
  42203. }
  42204. /**
  42205. * Defines the octree scene component responsible to manage any octrees
  42206. * in a given scene.
  42207. */
  42208. export class OctreeSceneComponent {
  42209. /**
  42210. * The component name help to identify the component in the list of scene components.
  42211. */
  42212. readonly name: string;
  42213. /**
  42214. * The scene the component belongs to.
  42215. */
  42216. scene: Scene;
  42217. /**
  42218. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42219. */
  42220. readonly checksIsEnabled: boolean;
  42221. /**
  42222. * Creates a new instance of the component for the given scene
  42223. * @param scene Defines the scene to register the component in
  42224. */
  42225. constructor(scene: Scene);
  42226. /**
  42227. * Registers the component in a given scene
  42228. */
  42229. register(): void;
  42230. /**
  42231. * Return the list of active meshes
  42232. * @returns the list of active meshes
  42233. */
  42234. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42235. /**
  42236. * Return the list of active sub meshes
  42237. * @param mesh The mesh to get the candidates sub meshes from
  42238. * @returns the list of active sub meshes
  42239. */
  42240. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42241. private _tempRay;
  42242. /**
  42243. * Return the list of sub meshes intersecting with a given local ray
  42244. * @param mesh defines the mesh to find the submesh for
  42245. * @param localRay defines the ray in local space
  42246. * @returns the list of intersecting sub meshes
  42247. */
  42248. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42249. /**
  42250. * Return the list of sub meshes colliding with a collider
  42251. * @param mesh defines the mesh to find the submesh for
  42252. * @param collider defines the collider to evaluate the collision against
  42253. * @returns the list of colliding sub meshes
  42254. */
  42255. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42256. /**
  42257. * Rebuilds the elements related to this component in case of
  42258. * context lost for instance.
  42259. */
  42260. rebuild(): void;
  42261. /**
  42262. * Disposes the component and the associated ressources.
  42263. */
  42264. dispose(): void;
  42265. }
  42266. }
  42267. declare module "babylonjs/Culling/Octrees/index" {
  42268. export * from "babylonjs/Culling/Octrees/octree";
  42269. export * from "babylonjs/Culling/Octrees/octreeBlock";
  42270. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  42271. }
  42272. declare module "babylonjs/Culling/index" {
  42273. export * from "babylonjs/Culling/boundingBox";
  42274. export * from "babylonjs/Culling/boundingInfo";
  42275. export * from "babylonjs/Culling/boundingSphere";
  42276. export * from "babylonjs/Culling/Octrees/index";
  42277. export * from "babylonjs/Culling/ray";
  42278. }
  42279. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  42280. import { IDisposable, Scene } from "babylonjs/scene";
  42281. import { Nullable } from "babylonjs/types";
  42282. import { Observable } from "babylonjs/Misc/observable";
  42283. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42284. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  42285. /**
  42286. * Renders a layer on top of an existing scene
  42287. */
  42288. export class UtilityLayerRenderer implements IDisposable {
  42289. /** the original scene that will be rendered on top of */
  42290. originalScene: Scene;
  42291. private _pointerCaptures;
  42292. private _lastPointerEvents;
  42293. private static _DefaultUtilityLayer;
  42294. private static _DefaultKeepDepthUtilityLayer;
  42295. private _sharedGizmoLight;
  42296. /**
  42297. * @hidden
  42298. * Light which used by gizmos to get light shading
  42299. */
  42300. _getSharedGizmoLight(): HemisphericLight;
  42301. /**
  42302. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42303. */
  42304. pickUtilitySceneFirst: boolean;
  42305. /**
  42306. * 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)
  42307. */
  42308. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42309. /**
  42310. * 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)
  42311. */
  42312. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42313. /**
  42314. * The scene that is rendered on top of the original scene
  42315. */
  42316. utilityLayerScene: Scene;
  42317. /**
  42318. * If the utility layer should automatically be rendered on top of existing scene
  42319. */
  42320. shouldRender: boolean;
  42321. /**
  42322. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42323. */
  42324. onlyCheckPointerDownEvents: boolean;
  42325. /**
  42326. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42327. */
  42328. processAllEvents: boolean;
  42329. /**
  42330. * Observable raised when the pointer move from the utility layer scene to the main scene
  42331. */
  42332. onPointerOutObservable: Observable<number>;
  42333. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42334. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42335. private _afterRenderObserver;
  42336. private _sceneDisposeObserver;
  42337. private _originalPointerObserver;
  42338. /**
  42339. * Instantiates a UtilityLayerRenderer
  42340. * @param originalScene the original scene that will be rendered on top of
  42341. * @param handleEvents boolean indicating if the utility layer should handle events
  42342. */
  42343. constructor(
  42344. /** the original scene that will be rendered on top of */
  42345. originalScene: Scene, handleEvents?: boolean);
  42346. private _notifyObservers;
  42347. /**
  42348. * Renders the utility layers scene on top of the original scene
  42349. */
  42350. render(): void;
  42351. /**
  42352. * Disposes of the renderer
  42353. */
  42354. dispose(): void;
  42355. private _updateCamera;
  42356. }
  42357. }
  42358. declare module "babylonjs/Gizmos/gizmo" {
  42359. import { Nullable } from "babylonjs/types";
  42360. import { IDisposable } from "babylonjs/scene";
  42361. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42362. import { Mesh } from "babylonjs/Meshes/mesh";
  42363. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42364. /**
  42365. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42366. */
  42367. export class Gizmo implements IDisposable {
  42368. /** The utility layer the gizmo will be added to */
  42369. gizmoLayer: UtilityLayerRenderer;
  42370. /**
  42371. * The root mesh of the gizmo
  42372. */
  42373. _rootMesh: Mesh;
  42374. private _attachedMesh;
  42375. /**
  42376. * Ratio for the scale of the gizmo (Default: 1)
  42377. */
  42378. scaleRatio: number;
  42379. /**
  42380. * If a custom mesh has been set (Default: false)
  42381. */
  42382. protected _customMeshSet: boolean;
  42383. /**
  42384. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42385. * * When set, interactions will be enabled
  42386. */
  42387. attachedMesh: Nullable<AbstractMesh>;
  42388. /**
  42389. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42390. * @param mesh The mesh to replace the default mesh of the gizmo
  42391. */
  42392. setCustomMesh(mesh: Mesh): void;
  42393. /**
  42394. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42395. */
  42396. updateGizmoRotationToMatchAttachedMesh: boolean;
  42397. /**
  42398. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42399. */
  42400. updateGizmoPositionToMatchAttachedMesh: boolean;
  42401. /**
  42402. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  42403. */
  42404. protected _updateScale: boolean;
  42405. protected _interactionsEnabled: boolean;
  42406. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42407. private _beforeRenderObserver;
  42408. private _tempVector;
  42409. /**
  42410. * Creates a gizmo
  42411. * @param gizmoLayer The utility layer the gizmo will be added to
  42412. */
  42413. constructor(
  42414. /** The utility layer the gizmo will be added to */
  42415. gizmoLayer?: UtilityLayerRenderer);
  42416. /**
  42417. * Updates the gizmo to match the attached mesh's position/rotation
  42418. */
  42419. protected _update(): void;
  42420. /**
  42421. * Disposes of the gizmo
  42422. */
  42423. dispose(): void;
  42424. }
  42425. }
  42426. declare module "babylonjs/Gizmos/planeDragGizmo" {
  42427. import { Observable } from "babylonjs/Misc/observable";
  42428. import { Nullable } from "babylonjs/types";
  42429. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42430. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42431. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42432. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42433. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42434. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42435. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42436. import { Scene } from "babylonjs/scene";
  42437. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  42438. /**
  42439. * Single plane drag gizmo
  42440. */
  42441. export class PlaneDragGizmo extends Gizmo {
  42442. /**
  42443. * Drag behavior responsible for the gizmos dragging interactions
  42444. */
  42445. dragBehavior: PointerDragBehavior;
  42446. private _pointerObserver;
  42447. /**
  42448. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42449. */
  42450. snapDistance: number;
  42451. /**
  42452. * Event that fires each time the gizmo snaps to a new location.
  42453. * * snapDistance is the the change in distance
  42454. */
  42455. onSnapObservable: Observable<{
  42456. snapDistance: number;
  42457. }>;
  42458. private _plane;
  42459. private _coloredMaterial;
  42460. private _hoverMaterial;
  42461. private _isEnabled;
  42462. private _parent;
  42463. /** @hidden */
  42464. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42465. /** @hidden */
  42466. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42467. /**
  42468. * Creates a PlaneDragGizmo
  42469. * @param gizmoLayer The utility layer the gizmo will be added to
  42470. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42471. * @param color The color of the gizmo
  42472. */
  42473. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42474. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42475. /**
  42476. * If the gizmo is enabled
  42477. */
  42478. isEnabled: boolean;
  42479. /**
  42480. * Disposes of the gizmo
  42481. */
  42482. dispose(): void;
  42483. }
  42484. }
  42485. declare module "babylonjs/Gizmos/positionGizmo" {
  42486. import { Observable } from "babylonjs/Misc/observable";
  42487. import { Nullable } from "babylonjs/types";
  42488. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42489. import { Mesh } from "babylonjs/Meshes/mesh";
  42490. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42491. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  42492. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  42493. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42494. /**
  42495. * Gizmo that enables dragging a mesh along 3 axis
  42496. */
  42497. export class PositionGizmo extends Gizmo {
  42498. /**
  42499. * Internal gizmo used for interactions on the x axis
  42500. */
  42501. xGizmo: AxisDragGizmo;
  42502. /**
  42503. * Internal gizmo used for interactions on the y axis
  42504. */
  42505. yGizmo: AxisDragGizmo;
  42506. /**
  42507. * Internal gizmo used for interactions on the z axis
  42508. */
  42509. zGizmo: AxisDragGizmo;
  42510. /**
  42511. * Internal gizmo used for interactions on the yz plane
  42512. */
  42513. xPlaneGizmo: PlaneDragGizmo;
  42514. /**
  42515. * Internal gizmo used for interactions on the xz plane
  42516. */
  42517. yPlaneGizmo: PlaneDragGizmo;
  42518. /**
  42519. * Internal gizmo used for interactions on the xy plane
  42520. */
  42521. zPlaneGizmo: PlaneDragGizmo;
  42522. /**
  42523. * private variables
  42524. */
  42525. private _meshAttached;
  42526. private _updateGizmoRotationToMatchAttachedMesh;
  42527. private _snapDistance;
  42528. private _scaleRatio;
  42529. /** Fires an event when any of it's sub gizmos are dragged */
  42530. onDragStartObservable: Observable<{}>;
  42531. /** Fires an event when any of it's sub gizmos are released from dragging */
  42532. onDragEndObservable: Observable<{}>;
  42533. /**
  42534. * If set to true, planar drag is enabled
  42535. */
  42536. private _planarGizmoEnabled;
  42537. attachedMesh: Nullable<AbstractMesh>;
  42538. /**
  42539. * Creates a PositionGizmo
  42540. * @param gizmoLayer The utility layer the gizmo will be added to
  42541. */
  42542. constructor(gizmoLayer?: UtilityLayerRenderer);
  42543. /**
  42544. * If the planar drag gizmo is enabled
  42545. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42546. */
  42547. planarGizmoEnabled: boolean;
  42548. updateGizmoRotationToMatchAttachedMesh: boolean;
  42549. /**
  42550. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42551. */
  42552. snapDistance: number;
  42553. /**
  42554. * Ratio for the scale of the gizmo (Default: 1)
  42555. */
  42556. scaleRatio: number;
  42557. /**
  42558. * Disposes of the gizmo
  42559. */
  42560. dispose(): void;
  42561. /**
  42562. * CustomMeshes are not supported by this gizmo
  42563. * @param mesh The mesh to replace the default mesh of the gizmo
  42564. */
  42565. setCustomMesh(mesh: Mesh): void;
  42566. }
  42567. }
  42568. declare module "babylonjs/Gizmos/axisDragGizmo" {
  42569. import { Observable } from "babylonjs/Misc/observable";
  42570. import { Nullable } from "babylonjs/types";
  42571. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42572. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42573. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42574. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42575. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42576. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42577. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42578. import { Scene } from "babylonjs/scene";
  42579. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  42580. /**
  42581. * Single axis drag gizmo
  42582. */
  42583. export class AxisDragGizmo extends Gizmo {
  42584. /**
  42585. * Drag behavior responsible for the gizmos dragging interactions
  42586. */
  42587. dragBehavior: PointerDragBehavior;
  42588. private _pointerObserver;
  42589. /**
  42590. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42591. */
  42592. snapDistance: number;
  42593. /**
  42594. * Event that fires each time the gizmo snaps to a new location.
  42595. * * snapDistance is the the change in distance
  42596. */
  42597. onSnapObservable: Observable<{
  42598. snapDistance: number;
  42599. }>;
  42600. private _isEnabled;
  42601. private _parent;
  42602. private _arrow;
  42603. private _coloredMaterial;
  42604. private _hoverMaterial;
  42605. /** @hidden */
  42606. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42607. /** @hidden */
  42608. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42609. /**
  42610. * Creates an AxisDragGizmo
  42611. * @param gizmoLayer The utility layer the gizmo will be added to
  42612. * @param dragAxis The axis which the gizmo will be able to drag on
  42613. * @param color The color of the gizmo
  42614. */
  42615. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42616. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42617. /**
  42618. * If the gizmo is enabled
  42619. */
  42620. isEnabled: boolean;
  42621. /**
  42622. * Disposes of the gizmo
  42623. */
  42624. dispose(): void;
  42625. }
  42626. }
  42627. declare module "babylonjs/Debug/axesViewer" {
  42628. import { Vector3 } from "babylonjs/Maths/math";
  42629. import { Nullable } from "babylonjs/types";
  42630. import { Scene } from "babylonjs/scene";
  42631. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42632. /**
  42633. * The Axes viewer will show 3 axes in a specific point in space
  42634. */
  42635. export class AxesViewer {
  42636. private _xAxis;
  42637. private _yAxis;
  42638. private _zAxis;
  42639. private _scaleLinesFactor;
  42640. private _instanced;
  42641. /**
  42642. * Gets the hosting scene
  42643. */
  42644. scene: Scene;
  42645. /**
  42646. * Gets or sets a number used to scale line length
  42647. */
  42648. scaleLines: number;
  42649. /** Gets the node hierarchy used to render x-axis */
  42650. readonly xAxis: TransformNode;
  42651. /** Gets the node hierarchy used to render y-axis */
  42652. readonly yAxis: TransformNode;
  42653. /** Gets the node hierarchy used to render z-axis */
  42654. readonly zAxis: TransformNode;
  42655. /**
  42656. * Creates a new AxesViewer
  42657. * @param scene defines the hosting scene
  42658. * @param scaleLines defines a number used to scale line length (1 by default)
  42659. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42660. * @param xAxis defines the node hierarchy used to render the x-axis
  42661. * @param yAxis defines the node hierarchy used to render the y-axis
  42662. * @param zAxis defines the node hierarchy used to render the z-axis
  42663. */
  42664. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42665. /**
  42666. * Force the viewer to update
  42667. * @param position defines the position of the viewer
  42668. * @param xaxis defines the x axis of the viewer
  42669. * @param yaxis defines the y axis of the viewer
  42670. * @param zaxis defines the z axis of the viewer
  42671. */
  42672. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42673. /**
  42674. * Creates an instance of this axes viewer.
  42675. * @returns a new axes viewer with instanced meshes
  42676. */
  42677. createInstance(): AxesViewer;
  42678. /** Releases resources */
  42679. dispose(): void;
  42680. private static _SetRenderingGroupId;
  42681. }
  42682. }
  42683. declare module "babylonjs/Debug/boneAxesViewer" {
  42684. import { Nullable } from "babylonjs/types";
  42685. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  42686. import { Vector3 } from "babylonjs/Maths/math";
  42687. import { Mesh } from "babylonjs/Meshes/mesh";
  42688. import { Bone } from "babylonjs/Bones/bone";
  42689. import { Scene } from "babylonjs/scene";
  42690. /**
  42691. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42692. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42693. */
  42694. export class BoneAxesViewer extends AxesViewer {
  42695. /**
  42696. * Gets or sets the target mesh where to display the axes viewer
  42697. */
  42698. mesh: Nullable<Mesh>;
  42699. /**
  42700. * Gets or sets the target bone where to display the axes viewer
  42701. */
  42702. bone: Nullable<Bone>;
  42703. /** Gets current position */
  42704. pos: Vector3;
  42705. /** Gets direction of X axis */
  42706. xaxis: Vector3;
  42707. /** Gets direction of Y axis */
  42708. yaxis: Vector3;
  42709. /** Gets direction of Z axis */
  42710. zaxis: Vector3;
  42711. /**
  42712. * Creates a new BoneAxesViewer
  42713. * @param scene defines the hosting scene
  42714. * @param bone defines the target bone
  42715. * @param mesh defines the target mesh
  42716. * @param scaleLines defines a scaling factor for line length (1 by default)
  42717. */
  42718. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42719. /**
  42720. * Force the viewer to update
  42721. */
  42722. update(): void;
  42723. /** Releases resources */
  42724. dispose(): void;
  42725. }
  42726. }
  42727. declare module "babylonjs/Debug/debugLayer" {
  42728. import { Observable } from "babylonjs/Misc/observable";
  42729. import { Scene } from "babylonjs/scene";
  42730. /**
  42731. * Interface used to define scene explorer extensibility option
  42732. */
  42733. export interface IExplorerExtensibilityOption {
  42734. /**
  42735. * Define the option label
  42736. */
  42737. label: string;
  42738. /**
  42739. * Defines the action to execute on click
  42740. */
  42741. action: (entity: any) => void;
  42742. }
  42743. /**
  42744. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42745. */
  42746. export interface IExplorerExtensibilityGroup {
  42747. /**
  42748. * Defines a predicate to test if a given type mut be extended
  42749. */
  42750. predicate: (entity: any) => boolean;
  42751. /**
  42752. * Gets the list of options added to a type
  42753. */
  42754. entries: IExplorerExtensibilityOption[];
  42755. }
  42756. /**
  42757. * Interface used to define the options to use to create the Inspector
  42758. */
  42759. export interface IInspectorOptions {
  42760. /**
  42761. * Display in overlay mode (default: false)
  42762. */
  42763. overlay?: boolean;
  42764. /**
  42765. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42766. */
  42767. globalRoot?: HTMLElement;
  42768. /**
  42769. * Display the Scene explorer
  42770. */
  42771. showExplorer?: boolean;
  42772. /**
  42773. * Display the property inspector
  42774. */
  42775. showInspector?: boolean;
  42776. /**
  42777. * Display in embed mode (both panes on the right)
  42778. */
  42779. embedMode?: boolean;
  42780. /**
  42781. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42782. */
  42783. handleResize?: boolean;
  42784. /**
  42785. * Allow the panes to popup (default: true)
  42786. */
  42787. enablePopup?: boolean;
  42788. /**
  42789. * Allow the panes to be closed by users (default: true)
  42790. */
  42791. enableClose?: boolean;
  42792. /**
  42793. * Optional list of extensibility entries
  42794. */
  42795. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42796. /**
  42797. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42798. */
  42799. inspectorURL?: string;
  42800. }
  42801. module "babylonjs/scene" {
  42802. interface Scene {
  42803. /**
  42804. * @hidden
  42805. * Backing field
  42806. */
  42807. _debugLayer: DebugLayer;
  42808. /**
  42809. * Gets the debug layer (aka Inspector) associated with the scene
  42810. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42811. */
  42812. debugLayer: DebugLayer;
  42813. }
  42814. }
  42815. /**
  42816. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42817. * what is happening in your scene
  42818. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42819. */
  42820. export class DebugLayer {
  42821. /**
  42822. * Define the url to get the inspector script from.
  42823. * By default it uses the babylonjs CDN.
  42824. * @ignoreNaming
  42825. */
  42826. static InspectorURL: string;
  42827. private _scene;
  42828. private BJSINSPECTOR;
  42829. /**
  42830. * Observable triggered when a property is changed through the inspector.
  42831. */
  42832. onPropertyChangedObservable: Observable<{
  42833. object: any;
  42834. property: string;
  42835. value: any;
  42836. initialValue: any;
  42837. }>;
  42838. /**
  42839. * Instantiates a new debug layer.
  42840. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42841. * what is happening in your scene
  42842. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42843. * @param scene Defines the scene to inspect
  42844. */
  42845. constructor(scene: Scene);
  42846. /** Creates the inspector window. */
  42847. private _createInspector;
  42848. /**
  42849. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42850. * @param entity defines the entity to select
  42851. * @param lineContainerTitle defines the specific block to highlight
  42852. */
  42853. select(entity: any, lineContainerTitle?: string): void;
  42854. /** Get the inspector from bundle or global */
  42855. private _getGlobalInspector;
  42856. /**
  42857. * Get if the inspector is visible or not.
  42858. * @returns true if visible otherwise, false
  42859. */
  42860. isVisible(): boolean;
  42861. /**
  42862. * Hide the inspector and close its window.
  42863. */
  42864. hide(): void;
  42865. /**
  42866. * Launch the debugLayer.
  42867. * @param config Define the configuration of the inspector
  42868. * @return a promise fulfilled when the debug layer is visible
  42869. */
  42870. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42871. }
  42872. }
  42873. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  42874. import { Nullable } from "babylonjs/types";
  42875. import { Scene } from "babylonjs/scene";
  42876. import { Vector4, Color4 } from "babylonjs/Maths/math";
  42877. import { Mesh } from "babylonjs/Meshes/mesh";
  42878. /**
  42879. * Class containing static functions to help procedurally build meshes
  42880. */
  42881. export class BoxBuilder {
  42882. /**
  42883. * Creates a box mesh
  42884. * * The parameter `size` sets the size (float) of each box side (default 1)
  42885. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42886. * * 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)
  42887. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42888. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42889. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42890. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42891. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42892. * @param name defines the name of the mesh
  42893. * @param options defines the options used to create the mesh
  42894. * @param scene defines the hosting scene
  42895. * @returns the box mesh
  42896. */
  42897. static CreateBox(name: string, options: {
  42898. size?: number;
  42899. width?: number;
  42900. height?: number;
  42901. depth?: number;
  42902. faceUV?: Vector4[];
  42903. faceColors?: Color4[];
  42904. sideOrientation?: number;
  42905. frontUVs?: Vector4;
  42906. backUVs?: Vector4;
  42907. wrap?: boolean;
  42908. topBaseAt?: number;
  42909. bottomBaseAt?: number;
  42910. updatable?: boolean;
  42911. }, scene?: Nullable<Scene>): Mesh;
  42912. }
  42913. }
  42914. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  42915. import { Vector4 } from "babylonjs/Maths/math";
  42916. import { Mesh } from "babylonjs/Meshes/mesh";
  42917. /**
  42918. * Class containing static functions to help procedurally build meshes
  42919. */
  42920. export class SphereBuilder {
  42921. /**
  42922. * Creates a sphere mesh
  42923. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42924. * * 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`)
  42925. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42926. * * 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
  42927. * * 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)
  42928. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42929. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42931. * @param name defines the name of the mesh
  42932. * @param options defines the options used to create the mesh
  42933. * @param scene defines the hosting scene
  42934. * @returns the sphere mesh
  42935. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42936. */
  42937. static CreateSphere(name: string, options: {
  42938. segments?: number;
  42939. diameter?: number;
  42940. diameterX?: number;
  42941. diameterY?: number;
  42942. diameterZ?: number;
  42943. arc?: number;
  42944. slice?: number;
  42945. sideOrientation?: number;
  42946. frontUVs?: Vector4;
  42947. backUVs?: Vector4;
  42948. updatable?: boolean;
  42949. }, scene: any): Mesh;
  42950. }
  42951. }
  42952. declare module "babylonjs/Debug/physicsViewer" {
  42953. import { Nullable } from "babylonjs/types";
  42954. import { Scene } from "babylonjs/scene";
  42955. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42956. import { Mesh } from "babylonjs/Meshes/mesh";
  42957. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  42958. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  42959. /**
  42960. * Used to show the physics impostor around the specific mesh
  42961. */
  42962. export class PhysicsViewer {
  42963. /** @hidden */
  42964. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42965. /** @hidden */
  42966. protected _meshes: Array<Nullable<AbstractMesh>>;
  42967. /** @hidden */
  42968. protected _scene: Nullable<Scene>;
  42969. /** @hidden */
  42970. protected _numMeshes: number;
  42971. /** @hidden */
  42972. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42973. private _renderFunction;
  42974. private _utilityLayer;
  42975. private _debugBoxMesh;
  42976. private _debugSphereMesh;
  42977. private _debugCylinderMesh;
  42978. private _debugMaterial;
  42979. private _debugMeshMeshes;
  42980. /**
  42981. * Creates a new PhysicsViewer
  42982. * @param scene defines the hosting scene
  42983. */
  42984. constructor(scene: Scene);
  42985. /** @hidden */
  42986. protected _updateDebugMeshes(): void;
  42987. /**
  42988. * Renders a specified physic impostor
  42989. * @param impostor defines the impostor to render
  42990. * @param targetMesh defines the mesh represented by the impostor
  42991. * @returns the new debug mesh used to render the impostor
  42992. */
  42993. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42994. /**
  42995. * Hides a specified physic impostor
  42996. * @param impostor defines the impostor to hide
  42997. */
  42998. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42999. private _getDebugMaterial;
  43000. private _getDebugBoxMesh;
  43001. private _getDebugSphereMesh;
  43002. private _getDebugCylinderMesh;
  43003. private _getDebugMeshMesh;
  43004. private _getDebugMesh;
  43005. /** Releases all resources */
  43006. dispose(): void;
  43007. }
  43008. }
  43009. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  43010. import { Vector3, Color4 } from "babylonjs/Maths/math";
  43011. import { Nullable } from "babylonjs/types";
  43012. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  43013. import { Scene } from "babylonjs/scene";
  43014. /**
  43015. * Class containing static functions to help procedurally build meshes
  43016. */
  43017. export class LinesBuilder {
  43018. /**
  43019. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43020. * * 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
  43021. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43022. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43023. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43024. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43025. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43026. * * 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
  43027. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43028. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43029. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43030. * @param name defines the name of the new line system
  43031. * @param options defines the options used to create the line system
  43032. * @param scene defines the hosting scene
  43033. * @returns a new line system mesh
  43034. */
  43035. static CreateLineSystem(name: string, options: {
  43036. lines: Vector3[][];
  43037. updatable?: boolean;
  43038. instance?: Nullable<LinesMesh>;
  43039. colors?: Nullable<Color4[][]>;
  43040. useVertexAlpha?: boolean;
  43041. }, scene: Nullable<Scene>): LinesMesh;
  43042. /**
  43043. * Creates a line mesh
  43044. * 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
  43045. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43046. * * The parameter `points` is an array successive Vector3
  43047. * * 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
  43048. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43049. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43050. * * When updating an instance, remember that only point positions can change, not the number of points
  43051. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43052. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43053. * @param name defines the name of the new line system
  43054. * @param options defines the options used to create the line system
  43055. * @param scene defines the hosting scene
  43056. * @returns a new line mesh
  43057. */
  43058. static CreateLines(name: string, options: {
  43059. points: Vector3[];
  43060. updatable?: boolean;
  43061. instance?: Nullable<LinesMesh>;
  43062. colors?: Color4[];
  43063. useVertexAlpha?: boolean;
  43064. }, scene?: Nullable<Scene>): LinesMesh;
  43065. /**
  43066. * Creates a dashed line mesh
  43067. * * 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
  43068. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43069. * * The parameter `points` is an array successive Vector3
  43070. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43071. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43072. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43073. * * 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
  43074. * * When updating an instance, remember that only point positions can change, not the number of points
  43075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43076. * @param name defines the name of the mesh
  43077. * @param options defines the options used to create the mesh
  43078. * @param scene defines the hosting scene
  43079. * @returns the dashed line mesh
  43080. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43081. */
  43082. static CreateDashedLines(name: string, options: {
  43083. points: Vector3[];
  43084. dashSize?: number;
  43085. gapSize?: number;
  43086. dashNb?: number;
  43087. updatable?: boolean;
  43088. instance?: LinesMesh;
  43089. }, scene?: Nullable<Scene>): LinesMesh;
  43090. }
  43091. }
  43092. declare module "babylonjs/Debug/rayHelper" {
  43093. import { Nullable } from "babylonjs/types";
  43094. import { Ray } from "babylonjs/Culling/ray";
  43095. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43096. import { Scene } from "babylonjs/scene";
  43097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43098. import "babylonjs/Meshes/Builders/linesBuilder";
  43099. /**
  43100. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43101. * in order to better appreciate the issue one might have.
  43102. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43103. */
  43104. export class RayHelper {
  43105. /**
  43106. * Defines the ray we are currently tryin to visualize.
  43107. */
  43108. ray: Nullable<Ray>;
  43109. private _renderPoints;
  43110. private _renderLine;
  43111. private _renderFunction;
  43112. private _scene;
  43113. private _updateToMeshFunction;
  43114. private _attachedToMesh;
  43115. private _meshSpaceDirection;
  43116. private _meshSpaceOrigin;
  43117. /**
  43118. * Helper function to create a colored helper in a scene in one line.
  43119. * @param ray Defines the ray we are currently tryin to visualize
  43120. * @param scene Defines the scene the ray is used in
  43121. * @param color Defines the color we want to see the ray in
  43122. * @returns The newly created ray helper.
  43123. */
  43124. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43125. /**
  43126. * Instantiate a new ray helper.
  43127. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43128. * in order to better appreciate the issue one might have.
  43129. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43130. * @param ray Defines the ray we are currently tryin to visualize
  43131. */
  43132. constructor(ray: Ray);
  43133. /**
  43134. * Shows the ray we are willing to debug.
  43135. * @param scene Defines the scene the ray needs to be rendered in
  43136. * @param color Defines the color the ray needs to be rendered in
  43137. */
  43138. show(scene: Scene, color?: Color3): void;
  43139. /**
  43140. * Hides the ray we are debugging.
  43141. */
  43142. hide(): void;
  43143. private _render;
  43144. /**
  43145. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43146. * @param mesh Defines the mesh we want the helper attached to
  43147. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43148. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43149. * @param length Defines the length of the ray
  43150. */
  43151. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43152. /**
  43153. * Detach the ray helper from the mesh it has previously been attached to.
  43154. */
  43155. detachFromMesh(): void;
  43156. private _updateToMesh;
  43157. /**
  43158. * Dispose the helper and release its associated resources.
  43159. */
  43160. dispose(): void;
  43161. }
  43162. }
  43163. declare module "babylonjs/Debug/skeletonViewer" {
  43164. import { Color3 } from "babylonjs/Maths/math";
  43165. import { Scene } from "babylonjs/scene";
  43166. import { Nullable } from "babylonjs/types";
  43167. import { Skeleton } from "babylonjs/Bones/skeleton";
  43168. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43169. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  43170. /**
  43171. * Class used to render a debug view of a given skeleton
  43172. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43173. */
  43174. export class SkeletonViewer {
  43175. /** defines the skeleton to render */
  43176. skeleton: Skeleton;
  43177. /** defines the mesh attached to the skeleton */
  43178. mesh: AbstractMesh;
  43179. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43180. autoUpdateBonesMatrices: boolean;
  43181. /** defines the rendering group id to use with the viewer */
  43182. renderingGroupId: number;
  43183. /** Gets or sets the color used to render the skeleton */
  43184. color: Color3;
  43185. private _scene;
  43186. private _debugLines;
  43187. private _debugMesh;
  43188. private _isEnabled;
  43189. private _renderFunction;
  43190. private _utilityLayer;
  43191. /**
  43192. * Returns the mesh used to render the bones
  43193. */
  43194. readonly debugMesh: Nullable<LinesMesh>;
  43195. /**
  43196. * Creates a new SkeletonViewer
  43197. * @param skeleton defines the skeleton to render
  43198. * @param mesh defines the mesh attached to the skeleton
  43199. * @param scene defines the hosting scene
  43200. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43201. * @param renderingGroupId defines the rendering group id to use with the viewer
  43202. */
  43203. constructor(
  43204. /** defines the skeleton to render */
  43205. skeleton: Skeleton,
  43206. /** defines the mesh attached to the skeleton */
  43207. mesh: AbstractMesh, scene: Scene,
  43208. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43209. autoUpdateBonesMatrices?: boolean,
  43210. /** defines the rendering group id to use with the viewer */
  43211. renderingGroupId?: number);
  43212. /** Gets or sets a boolean indicating if the viewer is enabled */
  43213. isEnabled: boolean;
  43214. private _getBonePosition;
  43215. private _getLinesForBonesWithLength;
  43216. private _getLinesForBonesNoLength;
  43217. /** Update the viewer to sync with current skeleton state */
  43218. update(): void;
  43219. /** Release associated resources */
  43220. dispose(): void;
  43221. }
  43222. }
  43223. declare module "babylonjs/Debug/index" {
  43224. export * from "babylonjs/Debug/axesViewer";
  43225. export * from "babylonjs/Debug/boneAxesViewer";
  43226. export * from "babylonjs/Debug/debugLayer";
  43227. export * from "babylonjs/Debug/physicsViewer";
  43228. export * from "babylonjs/Debug/rayHelper";
  43229. export * from "babylonjs/Debug/skeletonViewer";
  43230. }
  43231. declare module "babylonjs/Engines/nullEngine" {
  43232. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  43233. import { Scene } from "babylonjs/scene";
  43234. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  43235. import { Engine } from "babylonjs/Engines/engine";
  43236. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  43237. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  43238. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43239. import { Effect } from "babylonjs/Materials/effect";
  43240. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  43241. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43242. /**
  43243. * Options to create the null engine
  43244. */
  43245. export class NullEngineOptions {
  43246. /**
  43247. * Render width (Default: 512)
  43248. */
  43249. renderWidth: number;
  43250. /**
  43251. * Render height (Default: 256)
  43252. */
  43253. renderHeight: number;
  43254. /**
  43255. * Texture size (Default: 512)
  43256. */
  43257. textureSize: number;
  43258. /**
  43259. * If delta time between frames should be constant
  43260. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43261. */
  43262. deterministicLockstep: boolean;
  43263. /**
  43264. * Maximum about of steps between frames (Default: 4)
  43265. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43266. */
  43267. lockstepMaxSteps: number;
  43268. }
  43269. /**
  43270. * The null engine class provides support for headless version of babylon.js.
  43271. * This can be used in server side scenario or for testing purposes
  43272. */
  43273. export class NullEngine extends Engine {
  43274. private _options;
  43275. /**
  43276. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43277. */
  43278. isDeterministicLockStep(): boolean;
  43279. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  43280. getLockstepMaxSteps(): number;
  43281. /**
  43282. * Sets hardware scaling, used to save performance if needed
  43283. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  43284. */
  43285. getHardwareScalingLevel(): number;
  43286. constructor(options?: NullEngineOptions);
  43287. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43288. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43289. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43290. getRenderWidth(useScreen?: boolean): number;
  43291. getRenderHeight(useScreen?: boolean): number;
  43292. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  43293. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43294. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43295. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43296. bindSamplers(effect: Effect): void;
  43297. enableEffect(effect: Effect): void;
  43298. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43299. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43300. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43301. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43302. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43303. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43304. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43305. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43306. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43307. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43308. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43309. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43310. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43311. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43312. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  43313. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43314. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43315. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43316. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43317. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43318. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43319. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43320. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  43321. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  43322. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43323. bindBuffers(vertexBuffers: {
  43324. [key: string]: VertexBuffer;
  43325. }, indexBuffer: DataBuffer, effect: Effect): void;
  43326. wipeCaches(bruteForce?: boolean): void;
  43327. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43328. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43329. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43330. /** @hidden */
  43331. _createTexture(): WebGLTexture;
  43332. /** @hidden */
  43333. _releaseTexture(texture: InternalTexture): void;
  43334. 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;
  43335. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43336. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43337. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43338. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43339. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43340. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43341. areAllEffectsReady(): boolean;
  43342. /**
  43343. * @hidden
  43344. * Get the current error code of the webGL context
  43345. * @returns the error code
  43346. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43347. */
  43348. getError(): number;
  43349. /** @hidden */
  43350. _getUnpackAlignement(): number;
  43351. /** @hidden */
  43352. _unpackFlipY(value: boolean): void;
  43353. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43354. /**
  43355. * Updates a dynamic vertex buffer.
  43356. * @param vertexBuffer the vertex buffer to update
  43357. * @param data the data used to update the vertex buffer
  43358. * @param byteOffset the byte offset of the data (optional)
  43359. * @param byteLength the byte length of the data (optional)
  43360. */
  43361. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43362. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43363. /** @hidden */
  43364. _bindTexture(channel: number, texture: InternalTexture): void;
  43365. /** @hidden */
  43366. _releaseBuffer(buffer: DataBuffer): boolean;
  43367. releaseEffects(): void;
  43368. displayLoadingUI(): void;
  43369. hideLoadingUI(): void;
  43370. /** @hidden */
  43371. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43372. /** @hidden */
  43373. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43374. /** @hidden */
  43375. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43376. /** @hidden */
  43377. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43378. }
  43379. }
  43380. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  43381. import { Nullable, int } from "babylonjs/types";
  43382. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  43383. /** @hidden */
  43384. export class _OcclusionDataStorage {
  43385. /** @hidden */
  43386. occlusionInternalRetryCounter: number;
  43387. /** @hidden */
  43388. isOcclusionQueryInProgress: boolean;
  43389. /** @hidden */
  43390. isOccluded: boolean;
  43391. /** @hidden */
  43392. occlusionRetryCount: number;
  43393. /** @hidden */
  43394. occlusionType: number;
  43395. /** @hidden */
  43396. occlusionQueryAlgorithmType: number;
  43397. }
  43398. module "babylonjs/Engines/engine" {
  43399. interface Engine {
  43400. /**
  43401. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43402. * @return the new query
  43403. */
  43404. createQuery(): WebGLQuery;
  43405. /**
  43406. * Delete and release a webGL query
  43407. * @param query defines the query to delete
  43408. * @return the current engine
  43409. */
  43410. deleteQuery(query: WebGLQuery): Engine;
  43411. /**
  43412. * Check if a given query has resolved and got its value
  43413. * @param query defines the query to check
  43414. * @returns true if the query got its value
  43415. */
  43416. isQueryResultAvailable(query: WebGLQuery): boolean;
  43417. /**
  43418. * Gets the value of a given query
  43419. * @param query defines the query to check
  43420. * @returns the value of the query
  43421. */
  43422. getQueryResult(query: WebGLQuery): number;
  43423. /**
  43424. * Initiates an occlusion query
  43425. * @param algorithmType defines the algorithm to use
  43426. * @param query defines the query to use
  43427. * @returns the current engine
  43428. * @see http://doc.babylonjs.com/features/occlusionquery
  43429. */
  43430. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43431. /**
  43432. * Ends an occlusion query
  43433. * @see http://doc.babylonjs.com/features/occlusionquery
  43434. * @param algorithmType defines the algorithm to use
  43435. * @returns the current engine
  43436. */
  43437. endOcclusionQuery(algorithmType: number): Engine;
  43438. /**
  43439. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43440. * Please note that only one query can be issued at a time
  43441. * @returns a time token used to track the time span
  43442. */
  43443. startTimeQuery(): Nullable<_TimeToken>;
  43444. /**
  43445. * Ends a time query
  43446. * @param token defines the token used to measure the time span
  43447. * @returns the time spent (in ns)
  43448. */
  43449. endTimeQuery(token: _TimeToken): int;
  43450. /** @hidden */
  43451. _currentNonTimestampToken: Nullable<_TimeToken>;
  43452. /** @hidden */
  43453. _createTimeQuery(): WebGLQuery;
  43454. /** @hidden */
  43455. _deleteTimeQuery(query: WebGLQuery): void;
  43456. /** @hidden */
  43457. _getGlAlgorithmType(algorithmType: number): number;
  43458. /** @hidden */
  43459. _getTimeQueryResult(query: WebGLQuery): any;
  43460. /** @hidden */
  43461. _getTimeQueryAvailability(query: WebGLQuery): any;
  43462. }
  43463. }
  43464. module "babylonjs/Meshes/abstractMesh" {
  43465. interface AbstractMesh {
  43466. /**
  43467. * Backing filed
  43468. * @hidden
  43469. */
  43470. __occlusionDataStorage: _OcclusionDataStorage;
  43471. /**
  43472. * Access property
  43473. * @hidden
  43474. */
  43475. _occlusionDataStorage: _OcclusionDataStorage;
  43476. /**
  43477. * 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.
  43478. * The default value is -1 which means don't break the query and wait till the result
  43479. * @see http://doc.babylonjs.com/features/occlusionquery
  43480. */
  43481. occlusionRetryCount: number;
  43482. /**
  43483. * 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:
  43484. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43485. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43486. * * 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.
  43487. * @see http://doc.babylonjs.com/features/occlusionquery
  43488. */
  43489. occlusionType: number;
  43490. /**
  43491. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43492. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43493. * * 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.
  43494. * @see http://doc.babylonjs.com/features/occlusionquery
  43495. */
  43496. occlusionQueryAlgorithmType: number;
  43497. /**
  43498. * 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
  43499. * @see http://doc.babylonjs.com/features/occlusionquery
  43500. */
  43501. isOccluded: boolean;
  43502. /**
  43503. * Flag to check the progress status of the query
  43504. * @see http://doc.babylonjs.com/features/occlusionquery
  43505. */
  43506. isOcclusionQueryInProgress: boolean;
  43507. }
  43508. }
  43509. }
  43510. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  43511. import { Nullable } from "babylonjs/types";
  43512. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43513. /** @hidden */
  43514. export var _forceTransformFeedbackToBundle: boolean;
  43515. module "babylonjs/Engines/engine" {
  43516. interface Engine {
  43517. /**
  43518. * Creates a webGL transform feedback object
  43519. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43520. * @returns the webGL transform feedback object
  43521. */
  43522. createTransformFeedback(): WebGLTransformFeedback;
  43523. /**
  43524. * Delete a webGL transform feedback object
  43525. * @param value defines the webGL transform feedback object to delete
  43526. */
  43527. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43528. /**
  43529. * Bind a webGL transform feedback object to the webgl context
  43530. * @param value defines the webGL transform feedback object to bind
  43531. */
  43532. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43533. /**
  43534. * Begins a transform feedback operation
  43535. * @param usePoints defines if points or triangles must be used
  43536. */
  43537. beginTransformFeedback(usePoints: boolean): void;
  43538. /**
  43539. * Ends a transform feedback operation
  43540. */
  43541. endTransformFeedback(): void;
  43542. /**
  43543. * Specify the varyings to use with transform feedback
  43544. * @param program defines the associated webGL program
  43545. * @param value defines the list of strings representing the varying names
  43546. */
  43547. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43548. /**
  43549. * Bind a webGL buffer for a transform feedback operation
  43550. * @param value defines the webGL buffer to bind
  43551. */
  43552. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43553. }
  43554. }
  43555. }
  43556. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  43557. import { Scene } from "babylonjs/scene";
  43558. import { Engine } from "babylonjs/Engines/engine";
  43559. import { Texture } from "babylonjs/Materials/Textures/texture";
  43560. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43561. import "babylonjs/Engines/Extensions/engine.multiRender";
  43562. /**
  43563. * Creation options of the multi render target texture.
  43564. */
  43565. export interface IMultiRenderTargetOptions {
  43566. /**
  43567. * Define if the texture needs to create mip maps after render.
  43568. */
  43569. generateMipMaps?: boolean;
  43570. /**
  43571. * Define the types of all the draw buffers we want to create
  43572. */
  43573. types?: number[];
  43574. /**
  43575. * Define the sampling modes of all the draw buffers we want to create
  43576. */
  43577. samplingModes?: number[];
  43578. /**
  43579. * Define if a depth buffer is required
  43580. */
  43581. generateDepthBuffer?: boolean;
  43582. /**
  43583. * Define if a stencil buffer is required
  43584. */
  43585. generateStencilBuffer?: boolean;
  43586. /**
  43587. * Define if a depth texture is required instead of a depth buffer
  43588. */
  43589. generateDepthTexture?: boolean;
  43590. /**
  43591. * Define the number of desired draw buffers
  43592. */
  43593. textureCount?: number;
  43594. /**
  43595. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43596. */
  43597. doNotChangeAspectRatio?: boolean;
  43598. /**
  43599. * Define the default type of the buffers we are creating
  43600. */
  43601. defaultType?: number;
  43602. }
  43603. /**
  43604. * A multi render target, like a render target provides the ability to render to a texture.
  43605. * Unlike the render target, it can render to several draw buffers in one draw.
  43606. * This is specially interesting in deferred rendering or for any effects requiring more than
  43607. * just one color from a single pass.
  43608. */
  43609. export class MultiRenderTarget extends RenderTargetTexture {
  43610. private _internalTextures;
  43611. private _textures;
  43612. private _multiRenderTargetOptions;
  43613. /**
  43614. * Get if draw buffers are currently supported by the used hardware and browser.
  43615. */
  43616. readonly isSupported: boolean;
  43617. /**
  43618. * Get the list of textures generated by the multi render target.
  43619. */
  43620. readonly textures: Texture[];
  43621. /**
  43622. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43623. */
  43624. readonly depthTexture: Texture;
  43625. /**
  43626. * Set the wrapping mode on U of all the textures we are rendering to.
  43627. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43628. */
  43629. wrapU: number;
  43630. /**
  43631. * Set the wrapping mode on V of all the textures we are rendering to.
  43632. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43633. */
  43634. wrapV: number;
  43635. /**
  43636. * Instantiate a new multi render target texture.
  43637. * A multi render target, like a render target provides the ability to render to a texture.
  43638. * Unlike the render target, it can render to several draw buffers in one draw.
  43639. * This is specially interesting in deferred rendering or for any effects requiring more than
  43640. * just one color from a single pass.
  43641. * @param name Define the name of the texture
  43642. * @param size Define the size of the buffers to render to
  43643. * @param count Define the number of target we are rendering into
  43644. * @param scene Define the scene the texture belongs to
  43645. * @param options Define the options used to create the multi render target
  43646. */
  43647. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43648. /** @hidden */
  43649. _rebuild(): void;
  43650. private _createInternalTextures;
  43651. private _createTextures;
  43652. /**
  43653. * Define the number of samples used if MSAA is enabled.
  43654. */
  43655. samples: number;
  43656. /**
  43657. * Resize all the textures in the multi render target.
  43658. * Be carrefull as it will recreate all the data in the new texture.
  43659. * @param size Define the new size
  43660. */
  43661. resize(size: any): void;
  43662. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43663. /**
  43664. * Dispose the render targets and their associated resources
  43665. */
  43666. dispose(): void;
  43667. /**
  43668. * Release all the underlying texture used as draw buffers.
  43669. */
  43670. releaseInternalTextures(): void;
  43671. }
  43672. }
  43673. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  43674. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43675. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  43676. import { Nullable } from "babylonjs/types";
  43677. module "babylonjs/Engines/engine" {
  43678. interface Engine {
  43679. /**
  43680. * Unbind a list of render target textures from the webGL context
  43681. * This is used only when drawBuffer extension or webGL2 are active
  43682. * @param textures defines the render target textures to unbind
  43683. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43684. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43685. */
  43686. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43687. /**
  43688. * Create a multi render target texture
  43689. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43690. * @param size defines the size of the texture
  43691. * @param options defines the creation options
  43692. * @returns the cube texture as an InternalTexture
  43693. */
  43694. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43695. /**
  43696. * Update the sample count for a given multiple render target texture
  43697. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43698. * @param textures defines the textures to update
  43699. * @param samples defines the sample count to set
  43700. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43701. */
  43702. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43703. }
  43704. }
  43705. }
  43706. declare module "babylonjs/Engines/Extensions/index" {
  43707. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  43708. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  43709. export * from "babylonjs/Engines/Extensions/engine.multiview";
  43710. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  43711. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  43712. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  43713. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  43714. export * from "babylonjs/Engines/Extensions/engine.webVR";
  43715. }
  43716. declare module "babylonjs/Engines/index" {
  43717. export * from "babylonjs/Engines/constants";
  43718. export * from "babylonjs/Engines/engine";
  43719. export * from "babylonjs/Engines/engineStore";
  43720. export * from "babylonjs/Engines/nullEngine";
  43721. export * from "babylonjs/Engines/Extensions/index";
  43722. export * from "babylonjs/Engines/IPipelineContext";
  43723. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  43724. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  43725. }
  43726. declare module "babylonjs/Events/clipboardEvents" {
  43727. /**
  43728. * Gather the list of clipboard event types as constants.
  43729. */
  43730. export class ClipboardEventTypes {
  43731. /**
  43732. * The clipboard event is fired when a copy command is active (pressed).
  43733. */
  43734. static readonly COPY: number;
  43735. /**
  43736. * The clipboard event is fired when a cut command is active (pressed).
  43737. */
  43738. static readonly CUT: number;
  43739. /**
  43740. * The clipboard event is fired when a paste command is active (pressed).
  43741. */
  43742. static readonly PASTE: number;
  43743. }
  43744. /**
  43745. * This class is used to store clipboard related info for the onClipboardObservable event.
  43746. */
  43747. export class ClipboardInfo {
  43748. /**
  43749. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43750. */
  43751. type: number;
  43752. /**
  43753. * Defines the related dom event
  43754. */
  43755. event: ClipboardEvent;
  43756. /**
  43757. *Creates an instance of ClipboardInfo.
  43758. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43759. * @param event Defines the related dom event
  43760. */
  43761. constructor(
  43762. /**
  43763. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43764. */
  43765. type: number,
  43766. /**
  43767. * Defines the related dom event
  43768. */
  43769. event: ClipboardEvent);
  43770. /**
  43771. * Get the clipboard event's type from the keycode.
  43772. * @param keyCode Defines the keyCode for the current keyboard event.
  43773. * @return {number}
  43774. */
  43775. static GetTypeFromCharacter(keyCode: number): number;
  43776. }
  43777. }
  43778. declare module "babylonjs/Events/index" {
  43779. export * from "babylonjs/Events/keyboardEvents";
  43780. export * from "babylonjs/Events/pointerEvents";
  43781. export * from "babylonjs/Events/clipboardEvents";
  43782. }
  43783. declare module "babylonjs/Loading/sceneLoader" {
  43784. import { Observable } from "babylonjs/Misc/observable";
  43785. import { Nullable } from "babylonjs/types";
  43786. import { Scene } from "babylonjs/scene";
  43787. import { Engine } from "babylonjs/Engines/engine";
  43788. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43789. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43790. import { AssetContainer } from "babylonjs/assetContainer";
  43791. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43792. import { Skeleton } from "babylonjs/Bones/skeleton";
  43793. /**
  43794. * Class used to represent data loading progression
  43795. */
  43796. export class SceneLoaderProgressEvent {
  43797. /** defines if data length to load can be evaluated */
  43798. readonly lengthComputable: boolean;
  43799. /** defines the loaded data length */
  43800. readonly loaded: number;
  43801. /** defines the data length to load */
  43802. readonly total: number;
  43803. /**
  43804. * Create a new progress event
  43805. * @param lengthComputable defines if data length to load can be evaluated
  43806. * @param loaded defines the loaded data length
  43807. * @param total defines the data length to load
  43808. */
  43809. constructor(
  43810. /** defines if data length to load can be evaluated */
  43811. lengthComputable: boolean,
  43812. /** defines the loaded data length */
  43813. loaded: number,
  43814. /** defines the data length to load */
  43815. total: number);
  43816. /**
  43817. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43818. * @param event defines the source event
  43819. * @returns a new SceneLoaderProgressEvent
  43820. */
  43821. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43822. }
  43823. /**
  43824. * Interface used by SceneLoader plugins to define supported file extensions
  43825. */
  43826. export interface ISceneLoaderPluginExtensions {
  43827. /**
  43828. * Defines the list of supported extensions
  43829. */
  43830. [extension: string]: {
  43831. isBinary: boolean;
  43832. };
  43833. }
  43834. /**
  43835. * Interface used by SceneLoader plugin factory
  43836. */
  43837. export interface ISceneLoaderPluginFactory {
  43838. /**
  43839. * Defines the name of the factory
  43840. */
  43841. name: string;
  43842. /**
  43843. * Function called to create a new plugin
  43844. * @return the new plugin
  43845. */
  43846. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43847. /**
  43848. * Boolean indicating if the plugin can direct load specific data
  43849. */
  43850. canDirectLoad?: (data: string) => boolean;
  43851. }
  43852. /**
  43853. * Interface used to define a SceneLoader plugin
  43854. */
  43855. export interface ISceneLoaderPlugin {
  43856. /**
  43857. * The friendly name of this plugin.
  43858. */
  43859. name: string;
  43860. /**
  43861. * The file extensions supported by this plugin.
  43862. */
  43863. extensions: string | ISceneLoaderPluginExtensions;
  43864. /**
  43865. * Import meshes into a scene.
  43866. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43867. * @param scene The scene to import into
  43868. * @param data The data to import
  43869. * @param rootUrl The root url for scene and resources
  43870. * @param meshes The meshes array to import into
  43871. * @param particleSystems The particle systems array to import into
  43872. * @param skeletons The skeletons array to import into
  43873. * @param onError The callback when import fails
  43874. * @returns True if successful or false otherwise
  43875. */
  43876. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43877. /**
  43878. * Load into a scene.
  43879. * @param scene The scene to load into
  43880. * @param data The data to import
  43881. * @param rootUrl The root url for scene and resources
  43882. * @param onError The callback when import fails
  43883. * @returns true if successful or false otherwise
  43884. */
  43885. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43886. /**
  43887. * The callback that returns true if the data can be directly loaded.
  43888. */
  43889. canDirectLoad?: (data: string) => boolean;
  43890. /**
  43891. * The callback that allows custom handling of the root url based on the response url.
  43892. */
  43893. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43894. /**
  43895. * Load into an asset container.
  43896. * @param scene The scene to load into
  43897. * @param data The data to import
  43898. * @param rootUrl The root url for scene and resources
  43899. * @param onError The callback when import fails
  43900. * @returns The loaded asset container
  43901. */
  43902. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43903. }
  43904. /**
  43905. * Interface used to define an async SceneLoader plugin
  43906. */
  43907. export interface ISceneLoaderPluginAsync {
  43908. /**
  43909. * The friendly name of this plugin.
  43910. */
  43911. name: string;
  43912. /**
  43913. * The file extensions supported by this plugin.
  43914. */
  43915. extensions: string | ISceneLoaderPluginExtensions;
  43916. /**
  43917. * Import meshes into a scene.
  43918. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43919. * @param scene The scene to import into
  43920. * @param data The data to import
  43921. * @param rootUrl The root url for scene and resources
  43922. * @param onProgress The callback when the load progresses
  43923. * @param fileName Defines the name of the file to load
  43924. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43925. */
  43926. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43927. meshes: AbstractMesh[];
  43928. particleSystems: IParticleSystem[];
  43929. skeletons: Skeleton[];
  43930. animationGroups: AnimationGroup[];
  43931. }>;
  43932. /**
  43933. * Load into a scene.
  43934. * @param scene The scene to load into
  43935. * @param data The data to import
  43936. * @param rootUrl The root url for scene and resources
  43937. * @param onProgress The callback when the load progresses
  43938. * @param fileName Defines the name of the file to load
  43939. * @returns Nothing
  43940. */
  43941. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43942. /**
  43943. * The callback that returns true if the data can be directly loaded.
  43944. */
  43945. canDirectLoad?: (data: string) => boolean;
  43946. /**
  43947. * The callback that allows custom handling of the root url based on the response url.
  43948. */
  43949. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43950. /**
  43951. * Load into an asset container.
  43952. * @param scene The scene to load into
  43953. * @param data The data to import
  43954. * @param rootUrl The root url for scene and resources
  43955. * @param onProgress The callback when the load progresses
  43956. * @param fileName Defines the name of the file to load
  43957. * @returns The loaded asset container
  43958. */
  43959. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43960. }
  43961. /**
  43962. * Class used to load scene from various file formats using registered plugins
  43963. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43964. */
  43965. export class SceneLoader {
  43966. /**
  43967. * No logging while loading
  43968. */
  43969. static readonly NO_LOGGING: number;
  43970. /**
  43971. * Minimal logging while loading
  43972. */
  43973. static readonly MINIMAL_LOGGING: number;
  43974. /**
  43975. * Summary logging while loading
  43976. */
  43977. static readonly SUMMARY_LOGGING: number;
  43978. /**
  43979. * Detailled logging while loading
  43980. */
  43981. static readonly DETAILED_LOGGING: number;
  43982. /**
  43983. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43984. */
  43985. static ForceFullSceneLoadingForIncremental: boolean;
  43986. /**
  43987. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43988. */
  43989. static ShowLoadingScreen: boolean;
  43990. /**
  43991. * Defines the current logging level (while loading the scene)
  43992. * @ignorenaming
  43993. */
  43994. static loggingLevel: number;
  43995. /**
  43996. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43997. */
  43998. static CleanBoneMatrixWeights: boolean;
  43999. /**
  44000. * Event raised when a plugin is used to load a scene
  44001. */
  44002. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44003. private static _registeredPlugins;
  44004. private static _getDefaultPlugin;
  44005. private static _getPluginForExtension;
  44006. private static _getPluginForDirectLoad;
  44007. private static _getPluginForFilename;
  44008. private static _getDirectLoad;
  44009. private static _loadData;
  44010. private static _getFileInfo;
  44011. /**
  44012. * Gets a plugin that can load the given extension
  44013. * @param extension defines the extension to load
  44014. * @returns a plugin or null if none works
  44015. */
  44016. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44017. /**
  44018. * Gets a boolean indicating that the given extension can be loaded
  44019. * @param extension defines the extension to load
  44020. * @returns true if the extension is supported
  44021. */
  44022. static IsPluginForExtensionAvailable(extension: string): boolean;
  44023. /**
  44024. * Adds a new plugin to the list of registered plugins
  44025. * @param plugin defines the plugin to add
  44026. */
  44027. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44028. /**
  44029. * Import meshes into a scene
  44030. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44031. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  44032. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  44033. * @param scene the instance of BABYLON.Scene to append to
  44034. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44035. * @param onProgress a callback with a progress event for each file being loaded
  44036. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44037. * @param pluginExtension the extension used to determine the plugin
  44038. * @returns The loaded plugin
  44039. */
  44040. static 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>;
  44041. /**
  44042. * Import meshes into a scene
  44043. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44044. * @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)
  44045. * @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)
  44046. * @param scene the instance of BABYLON.Scene to append to
  44047. * @param onProgress a callback with a progress event for each file being loaded
  44048. * @param pluginExtension the extension used to determine the plugin
  44049. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44050. */
  44051. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44052. meshes: AbstractMesh[];
  44053. particleSystems: IParticleSystem[];
  44054. skeletons: Skeleton[];
  44055. animationGroups: AnimationGroup[];
  44056. }>;
  44057. /**
  44058. * Load a scene
  44059. * @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)
  44060. * @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)
  44061. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44062. * @param onSuccess a callback with the scene when import succeeds
  44063. * @param onProgress a callback with a progress event for each file being loaded
  44064. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44065. * @param pluginExtension the extension used to determine the plugin
  44066. * @returns The loaded plugin
  44067. */
  44068. 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>;
  44069. /**
  44070. * Load a scene
  44071. * @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)
  44072. * @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)
  44073. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44074. * @param onProgress a callback with a progress event for each file being loaded
  44075. * @param pluginExtension the extension used to determine the plugin
  44076. * @returns The loaded scene
  44077. */
  44078. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44079. /**
  44080. * Append a scene
  44081. * @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)
  44082. * @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)
  44083. * @param scene is the instance of BABYLON.Scene to append to
  44084. * @param onSuccess a callback with the scene when import succeeds
  44085. * @param onProgress a callback with a progress event for each file being loaded
  44086. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44087. * @param pluginExtension the extension used to determine the plugin
  44088. * @returns The loaded plugin
  44089. */
  44090. 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>;
  44091. /**
  44092. * Append a scene
  44093. * @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)
  44094. * @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)
  44095. * @param scene is the instance of BABYLON.Scene to append to
  44096. * @param onProgress a callback with a progress event for each file being loaded
  44097. * @param pluginExtension the extension used to determine the plugin
  44098. * @returns The given scene
  44099. */
  44100. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44101. /**
  44102. * Load a scene into an asset container
  44103. * @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)
  44104. * @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)
  44105. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44106. * @param onSuccess a callback with the scene when import succeeds
  44107. * @param onProgress a callback with a progress event for each file being loaded
  44108. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44109. * @param pluginExtension the extension used to determine the plugin
  44110. * @returns The loaded plugin
  44111. */
  44112. 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>;
  44113. /**
  44114. * Load a scene into an asset container
  44115. * @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)
  44116. * @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)
  44117. * @param scene is the instance of Scene to append to
  44118. * @param onProgress a callback with a progress event for each file being loaded
  44119. * @param pluginExtension the extension used to determine the plugin
  44120. * @returns The loaded asset container
  44121. */
  44122. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44123. }
  44124. }
  44125. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  44126. import { Scene } from "babylonjs/scene";
  44127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44128. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44129. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44130. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44131. /**
  44132. * Google Daydream controller
  44133. */
  44134. export class DaydreamController extends WebVRController {
  44135. /**
  44136. * Base Url for the controller model.
  44137. */
  44138. static MODEL_BASE_URL: string;
  44139. /**
  44140. * File name for the controller model.
  44141. */
  44142. static MODEL_FILENAME: string;
  44143. /**
  44144. * Gamepad Id prefix used to identify Daydream Controller.
  44145. */
  44146. static readonly GAMEPAD_ID_PREFIX: string;
  44147. /**
  44148. * Creates a new DaydreamController from a gamepad
  44149. * @param vrGamepad the gamepad that the controller should be created from
  44150. */
  44151. constructor(vrGamepad: any);
  44152. /**
  44153. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44154. * @param scene scene in which to add meshes
  44155. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44156. */
  44157. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44158. /**
  44159. * Called once for each button that changed state since the last frame
  44160. * @param buttonIdx Which button index changed
  44161. * @param state New state of the button
  44162. * @param changes Which properties on the state changed since last frame
  44163. */
  44164. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44165. }
  44166. }
  44167. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  44168. import { Scene } from "babylonjs/scene";
  44169. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44170. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44171. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44172. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44173. /**
  44174. * Gear VR Controller
  44175. */
  44176. export class GearVRController extends WebVRController {
  44177. /**
  44178. * Base Url for the controller model.
  44179. */
  44180. static MODEL_BASE_URL: string;
  44181. /**
  44182. * File name for the controller model.
  44183. */
  44184. static MODEL_FILENAME: string;
  44185. /**
  44186. * Gamepad Id prefix used to identify this controller.
  44187. */
  44188. static readonly GAMEPAD_ID_PREFIX: string;
  44189. private readonly _buttonIndexToObservableNameMap;
  44190. /**
  44191. * Creates a new GearVRController from a gamepad
  44192. * @param vrGamepad the gamepad that the controller should be created from
  44193. */
  44194. constructor(vrGamepad: any);
  44195. /**
  44196. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44197. * @param scene scene in which to add meshes
  44198. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44199. */
  44200. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44201. /**
  44202. * Called once for each button that changed state since the last frame
  44203. * @param buttonIdx Which button index changed
  44204. * @param state New state of the button
  44205. * @param changes Which properties on the state changed since last frame
  44206. */
  44207. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44208. }
  44209. }
  44210. declare module "babylonjs/Gamepads/Controllers/genericController" {
  44211. import { Scene } from "babylonjs/scene";
  44212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44213. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44214. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44215. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44216. /**
  44217. * Generic Controller
  44218. */
  44219. export class GenericController extends WebVRController {
  44220. /**
  44221. * Base Url for the controller model.
  44222. */
  44223. static readonly MODEL_BASE_URL: string;
  44224. /**
  44225. * File name for the controller model.
  44226. */
  44227. static readonly MODEL_FILENAME: string;
  44228. /**
  44229. * Creates a new GenericController from a gamepad
  44230. * @param vrGamepad the gamepad that the controller should be created from
  44231. */
  44232. constructor(vrGamepad: any);
  44233. /**
  44234. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44235. * @param scene scene in which to add meshes
  44236. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44237. */
  44238. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44239. /**
  44240. * Called once for each button that changed state since the last frame
  44241. * @param buttonIdx Which button index changed
  44242. * @param state New state of the button
  44243. * @param changes Which properties on the state changed since last frame
  44244. */
  44245. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44246. }
  44247. }
  44248. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44249. import { Observable } from "babylonjs/Misc/observable";
  44250. import { Scene } from "babylonjs/scene";
  44251. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44252. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44253. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44254. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44255. /**
  44256. * Oculus Touch Controller
  44257. */
  44258. export class OculusTouchController extends WebVRController {
  44259. /**
  44260. * Base Url for the controller model.
  44261. */
  44262. static MODEL_BASE_URL: string;
  44263. /**
  44264. * File name for the left controller model.
  44265. */
  44266. static MODEL_LEFT_FILENAME: string;
  44267. /**
  44268. * File name for the right controller model.
  44269. */
  44270. static MODEL_RIGHT_FILENAME: string;
  44271. /**
  44272. * Fired when the secondary trigger on this controller is modified
  44273. */
  44274. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44275. /**
  44276. * Fired when the thumb rest on this controller is modified
  44277. */
  44278. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44279. /**
  44280. * Creates a new OculusTouchController from a gamepad
  44281. * @param vrGamepad the gamepad that the controller should be created from
  44282. */
  44283. constructor(vrGamepad: any);
  44284. /**
  44285. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44286. * @param scene scene in which to add meshes
  44287. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44288. */
  44289. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44290. /**
  44291. * Fired when the A button on this controller is modified
  44292. */
  44293. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44294. /**
  44295. * Fired when the B button on this controller is modified
  44296. */
  44297. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44298. /**
  44299. * Fired when the X button on this controller is modified
  44300. */
  44301. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44302. /**
  44303. * Fired when the Y button on this controller is modified
  44304. */
  44305. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44306. /**
  44307. * Called once for each button that changed state since the last frame
  44308. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44309. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44310. * 2) secondary trigger (same)
  44311. * 3) A (right) X (left), touch, pressed = value
  44312. * 4) B / Y
  44313. * 5) thumb rest
  44314. * @param buttonIdx Which button index changed
  44315. * @param state New state of the button
  44316. * @param changes Which properties on the state changed since last frame
  44317. */
  44318. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44319. }
  44320. }
  44321. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44322. import { Scene } from "babylonjs/scene";
  44323. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44324. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44325. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44326. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44327. import { Observable } from "babylonjs/Misc/observable";
  44328. /**
  44329. * Vive Controller
  44330. */
  44331. export class ViveController extends WebVRController {
  44332. /**
  44333. * Base Url for the controller model.
  44334. */
  44335. static MODEL_BASE_URL: string;
  44336. /**
  44337. * File name for the controller model.
  44338. */
  44339. static MODEL_FILENAME: string;
  44340. /**
  44341. * Creates a new ViveController from a gamepad
  44342. * @param vrGamepad the gamepad that the controller should be created from
  44343. */
  44344. constructor(vrGamepad: any);
  44345. /**
  44346. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44347. * @param scene scene in which to add meshes
  44348. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44349. */
  44350. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44351. /**
  44352. * Fired when the left button on this controller is modified
  44353. */
  44354. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44355. /**
  44356. * Fired when the right button on this controller is modified
  44357. */
  44358. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44359. /**
  44360. * Fired when the menu button on this controller is modified
  44361. */
  44362. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44363. /**
  44364. * Called once for each button that changed state since the last frame
  44365. * Vive mapping:
  44366. * 0: touchpad
  44367. * 1: trigger
  44368. * 2: left AND right buttons
  44369. * 3: menu button
  44370. * @param buttonIdx Which button index changed
  44371. * @param state New state of the button
  44372. * @param changes Which properties on the state changed since last frame
  44373. */
  44374. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44375. }
  44376. }
  44377. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44378. import { Observable } from "babylonjs/Misc/observable";
  44379. import { Scene } from "babylonjs/scene";
  44380. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44381. import { Ray } from "babylonjs/Culling/ray";
  44382. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44383. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44384. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44385. /**
  44386. * Defines the WindowsMotionController object that the state of the windows motion controller
  44387. */
  44388. export class WindowsMotionController extends WebVRController {
  44389. /**
  44390. * The base url used to load the left and right controller models
  44391. */
  44392. static MODEL_BASE_URL: string;
  44393. /**
  44394. * The name of the left controller model file
  44395. */
  44396. static MODEL_LEFT_FILENAME: string;
  44397. /**
  44398. * The name of the right controller model file
  44399. */
  44400. static MODEL_RIGHT_FILENAME: string;
  44401. /**
  44402. * The controller name prefix for this controller type
  44403. */
  44404. static readonly GAMEPAD_ID_PREFIX: string;
  44405. /**
  44406. * The controller id pattern for this controller type
  44407. */
  44408. private static readonly GAMEPAD_ID_PATTERN;
  44409. private _loadedMeshInfo;
  44410. private readonly _mapping;
  44411. /**
  44412. * Fired when the trackpad on this controller is clicked
  44413. */
  44414. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44415. /**
  44416. * Fired when the trackpad on this controller is modified
  44417. */
  44418. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44419. /**
  44420. * The current x and y values of this controller's trackpad
  44421. */
  44422. trackpad: StickValues;
  44423. /**
  44424. * Creates a new WindowsMotionController from a gamepad
  44425. * @param vrGamepad the gamepad that the controller should be created from
  44426. */
  44427. constructor(vrGamepad: any);
  44428. /**
  44429. * Fired when the trigger on this controller is modified
  44430. */
  44431. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44432. /**
  44433. * Fired when the menu button on this controller is modified
  44434. */
  44435. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44436. /**
  44437. * Fired when the grip button on this controller is modified
  44438. */
  44439. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44440. /**
  44441. * Fired when the thumbstick button on this controller is modified
  44442. */
  44443. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44444. /**
  44445. * Fired when the touchpad button on this controller is modified
  44446. */
  44447. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44448. /**
  44449. * Fired when the touchpad values on this controller are modified
  44450. */
  44451. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44452. private _updateTrackpad;
  44453. /**
  44454. * Called once per frame by the engine.
  44455. */
  44456. update(): void;
  44457. /**
  44458. * Called once for each button that changed state since the last frame
  44459. * @param buttonIdx Which button index changed
  44460. * @param state New state of the button
  44461. * @param changes Which properties on the state changed since last frame
  44462. */
  44463. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44464. /**
  44465. * Moves the buttons on the controller mesh based on their current state
  44466. * @param buttonName the name of the button to move
  44467. * @param buttonValue the value of the button which determines the buttons new position
  44468. */
  44469. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44470. /**
  44471. * Moves the axis on the controller mesh based on its current state
  44472. * @param axis the index of the axis
  44473. * @param axisValue the value of the axis which determines the meshes new position
  44474. * @hidden
  44475. */
  44476. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44477. /**
  44478. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44479. * @param scene scene in which to add meshes
  44480. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44481. */
  44482. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44483. /**
  44484. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44485. * can be transformed by button presses and axes values, based on this._mapping.
  44486. *
  44487. * @param scene scene in which the meshes exist
  44488. * @param meshes list of meshes that make up the controller model to process
  44489. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44490. */
  44491. private processModel;
  44492. private createMeshInfo;
  44493. /**
  44494. * Gets the ray of the controller in the direction the controller is pointing
  44495. * @param length the length the resulting ray should be
  44496. * @returns a ray in the direction the controller is pointing
  44497. */
  44498. getForwardRay(length?: number): Ray;
  44499. /**
  44500. * Disposes of the controller
  44501. */
  44502. dispose(): void;
  44503. }
  44504. }
  44505. declare module "babylonjs/Gamepads/Controllers/index" {
  44506. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  44507. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  44508. export * from "babylonjs/Gamepads/Controllers/genericController";
  44509. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  44510. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44511. export * from "babylonjs/Gamepads/Controllers/viveController";
  44512. export * from "babylonjs/Gamepads/Controllers/webVRController";
  44513. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  44514. }
  44515. declare module "babylonjs/Gamepads/index" {
  44516. export * from "babylonjs/Gamepads/Controllers/index";
  44517. export * from "babylonjs/Gamepads/gamepad";
  44518. export * from "babylonjs/Gamepads/gamepadManager";
  44519. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  44520. export * from "babylonjs/Gamepads/xboxGamepad";
  44521. }
  44522. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  44523. import { Scene } from "babylonjs/scene";
  44524. import { Color4, Vector4 } from "babylonjs/Maths/math";
  44525. import { Mesh } from "babylonjs/Meshes/mesh";
  44526. import { Nullable } from "babylonjs/types";
  44527. /**
  44528. * Class containing static functions to help procedurally build meshes
  44529. */
  44530. export class PolyhedronBuilder {
  44531. /**
  44532. * Creates a polyhedron mesh
  44533. * * 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
  44534. * * The parameter `size` (positive float, default 1) sets the polygon size
  44535. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44536. * * 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`
  44537. * * 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
  44538. * * 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)`)
  44539. * * 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
  44540. * * 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
  44541. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44542. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44543. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44544. * @param name defines the name of the mesh
  44545. * @param options defines the options used to create the mesh
  44546. * @param scene defines the hosting scene
  44547. * @returns the polyhedron mesh
  44548. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44549. */
  44550. static CreatePolyhedron(name: string, options: {
  44551. type?: number;
  44552. size?: number;
  44553. sizeX?: number;
  44554. sizeY?: number;
  44555. sizeZ?: number;
  44556. custom?: any;
  44557. faceUV?: Vector4[];
  44558. faceColors?: Color4[];
  44559. flat?: boolean;
  44560. updatable?: boolean;
  44561. sideOrientation?: number;
  44562. frontUVs?: Vector4;
  44563. backUVs?: Vector4;
  44564. }, scene?: Nullable<Scene>): Mesh;
  44565. }
  44566. }
  44567. declare module "babylonjs/Gizmos/scaleGizmo" {
  44568. import { Observable } from "babylonjs/Misc/observable";
  44569. import { Nullable } from "babylonjs/types";
  44570. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44571. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44572. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44573. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44574. /**
  44575. * Gizmo that enables scaling a mesh along 3 axis
  44576. */
  44577. export class ScaleGizmo extends Gizmo {
  44578. /**
  44579. * Internal gizmo used for interactions on the x axis
  44580. */
  44581. xGizmo: AxisScaleGizmo;
  44582. /**
  44583. * Internal gizmo used for interactions on the y axis
  44584. */
  44585. yGizmo: AxisScaleGizmo;
  44586. /**
  44587. * Internal gizmo used for interactions on the z axis
  44588. */
  44589. zGizmo: AxisScaleGizmo;
  44590. /**
  44591. * Internal gizmo used to scale all axis equally
  44592. */
  44593. uniformScaleGizmo: AxisScaleGizmo;
  44594. private _meshAttached;
  44595. private _updateGizmoRotationToMatchAttachedMesh;
  44596. private _snapDistance;
  44597. private _scaleRatio;
  44598. private _uniformScalingMesh;
  44599. private _octahedron;
  44600. /** Fires an event when any of it's sub gizmos are dragged */
  44601. onDragStartObservable: Observable<{}>;
  44602. /** Fires an event when any of it's sub gizmos are released from dragging */
  44603. onDragEndObservable: Observable<{}>;
  44604. attachedMesh: Nullable<AbstractMesh>;
  44605. /**
  44606. * Creates a ScaleGizmo
  44607. * @param gizmoLayer The utility layer the gizmo will be added to
  44608. */
  44609. constructor(gizmoLayer?: UtilityLayerRenderer);
  44610. updateGizmoRotationToMatchAttachedMesh: boolean;
  44611. /**
  44612. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44613. */
  44614. snapDistance: number;
  44615. /**
  44616. * Ratio for the scale of the gizmo (Default: 1)
  44617. */
  44618. scaleRatio: number;
  44619. /**
  44620. * Disposes of the gizmo
  44621. */
  44622. dispose(): void;
  44623. }
  44624. }
  44625. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  44626. import { Observable } from "babylonjs/Misc/observable";
  44627. import { Nullable } from "babylonjs/types";
  44628. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44629. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44630. import { Mesh } from "babylonjs/Meshes/mesh";
  44631. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44632. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44633. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44634. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44635. /**
  44636. * Single axis scale gizmo
  44637. */
  44638. export class AxisScaleGizmo extends Gizmo {
  44639. /**
  44640. * Drag behavior responsible for the gizmos dragging interactions
  44641. */
  44642. dragBehavior: PointerDragBehavior;
  44643. private _pointerObserver;
  44644. /**
  44645. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44646. */
  44647. snapDistance: number;
  44648. /**
  44649. * Event that fires each time the gizmo snaps to a new location.
  44650. * * snapDistance is the the change in distance
  44651. */
  44652. onSnapObservable: Observable<{
  44653. snapDistance: number;
  44654. }>;
  44655. /**
  44656. * If the scaling operation should be done on all axis (default: false)
  44657. */
  44658. uniformScaling: boolean;
  44659. private _isEnabled;
  44660. private _parent;
  44661. private _arrow;
  44662. private _coloredMaterial;
  44663. private _hoverMaterial;
  44664. /**
  44665. * Creates an AxisScaleGizmo
  44666. * @param gizmoLayer The utility layer the gizmo will be added to
  44667. * @param dragAxis The axis which the gizmo will be able to scale on
  44668. * @param color The color of the gizmo
  44669. */
  44670. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  44671. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44672. /**
  44673. * If the gizmo is enabled
  44674. */
  44675. isEnabled: boolean;
  44676. /**
  44677. * Disposes of the gizmo
  44678. */
  44679. dispose(): void;
  44680. /**
  44681. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44682. * @param mesh The mesh to replace the default mesh of the gizmo
  44683. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44684. */
  44685. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44686. }
  44687. }
  44688. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  44689. import { Observable } from "babylonjs/Misc/observable";
  44690. import { Nullable } from "babylonjs/types";
  44691. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44692. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44693. import { Mesh } from "babylonjs/Meshes/mesh";
  44694. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44695. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44696. import "babylonjs/Meshes/Builders/boxBuilder";
  44697. /**
  44698. * Bounding box gizmo
  44699. */
  44700. export class BoundingBoxGizmo extends Gizmo {
  44701. private _lineBoundingBox;
  44702. private _rotateSpheresParent;
  44703. private _scaleBoxesParent;
  44704. private _boundingDimensions;
  44705. private _renderObserver;
  44706. private _pointerObserver;
  44707. private _scaleDragSpeed;
  44708. private _tmpQuaternion;
  44709. private _tmpVector;
  44710. private _tmpRotationMatrix;
  44711. /**
  44712. * 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)
  44713. */
  44714. ignoreChildren: boolean;
  44715. /**
  44716. * 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)
  44717. */
  44718. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44719. /**
  44720. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44721. */
  44722. rotationSphereSize: number;
  44723. /**
  44724. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44725. */
  44726. scaleBoxSize: number;
  44727. /**
  44728. * 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)
  44729. */
  44730. fixedDragMeshScreenSize: boolean;
  44731. /**
  44732. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44733. */
  44734. fixedDragMeshScreenSizeDistanceFactor: number;
  44735. /**
  44736. * Fired when a rotation sphere or scale box is dragged
  44737. */
  44738. onDragStartObservable: Observable<{}>;
  44739. /**
  44740. * Fired when a scale box is dragged
  44741. */
  44742. onScaleBoxDragObservable: Observable<{}>;
  44743. /**
  44744. * Fired when a scale box drag is ended
  44745. */
  44746. onScaleBoxDragEndObservable: Observable<{}>;
  44747. /**
  44748. * Fired when a rotation sphere is dragged
  44749. */
  44750. onRotationSphereDragObservable: Observable<{}>;
  44751. /**
  44752. * Fired when a rotation sphere drag is ended
  44753. */
  44754. onRotationSphereDragEndObservable: Observable<{}>;
  44755. /**
  44756. * 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)
  44757. */
  44758. scalePivot: Nullable<Vector3>;
  44759. /**
  44760. * Mesh used as a pivot to rotate the attached mesh
  44761. */
  44762. private _anchorMesh;
  44763. private _existingMeshScale;
  44764. private _dragMesh;
  44765. private pointerDragBehavior;
  44766. private coloredMaterial;
  44767. private hoverColoredMaterial;
  44768. /**
  44769. * Sets the color of the bounding box gizmo
  44770. * @param color the color to set
  44771. */
  44772. setColor(color: Color3): void;
  44773. /**
  44774. * Creates an BoundingBoxGizmo
  44775. * @param gizmoLayer The utility layer the gizmo will be added to
  44776. * @param color The color of the gizmo
  44777. */
  44778. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44779. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44780. private _selectNode;
  44781. /**
  44782. * Updates the bounding box information for the Gizmo
  44783. */
  44784. updateBoundingBox(): void;
  44785. private _updateRotationSpheres;
  44786. private _updateScaleBoxes;
  44787. /**
  44788. * Enables rotation on the specified axis and disables rotation on the others
  44789. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44790. */
  44791. setEnabledRotationAxis(axis: string): void;
  44792. /**
  44793. * Enables/disables scaling
  44794. * @param enable if scaling should be enabled
  44795. */
  44796. setEnabledScaling(enable: boolean): void;
  44797. private _updateDummy;
  44798. /**
  44799. * Enables a pointer drag behavior on the bounding box of the gizmo
  44800. */
  44801. enableDragBehavior(): void;
  44802. /**
  44803. * Disposes of the gizmo
  44804. */
  44805. dispose(): void;
  44806. /**
  44807. * 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)
  44808. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44809. * @returns the bounding box mesh with the passed in mesh as a child
  44810. */
  44811. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44812. /**
  44813. * CustomMeshes are not supported by this gizmo
  44814. * @param mesh The mesh to replace the default mesh of the gizmo
  44815. */
  44816. setCustomMesh(mesh: Mesh): void;
  44817. }
  44818. }
  44819. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  44820. import { Observable } from "babylonjs/Misc/observable";
  44821. import { Nullable } from "babylonjs/types";
  44822. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44823. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44824. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44825. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44826. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44827. import "babylonjs/Meshes/Builders/linesBuilder";
  44828. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  44829. /**
  44830. * Single plane rotation gizmo
  44831. */
  44832. export class PlaneRotationGizmo extends Gizmo {
  44833. /**
  44834. * Drag behavior responsible for the gizmos dragging interactions
  44835. */
  44836. dragBehavior: PointerDragBehavior;
  44837. private _pointerObserver;
  44838. /**
  44839. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44840. */
  44841. snapDistance: number;
  44842. /**
  44843. * Event that fires each time the gizmo snaps to a new location.
  44844. * * snapDistance is the the change in distance
  44845. */
  44846. onSnapObservable: Observable<{
  44847. snapDistance: number;
  44848. }>;
  44849. private _isEnabled;
  44850. private _parent;
  44851. /**
  44852. * Creates a PlaneRotationGizmo
  44853. * @param gizmoLayer The utility layer the gizmo will be added to
  44854. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44855. * @param color The color of the gizmo
  44856. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44857. */
  44858. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  44859. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44860. /**
  44861. * If the gizmo is enabled
  44862. */
  44863. isEnabled: boolean;
  44864. /**
  44865. * Disposes of the gizmo
  44866. */
  44867. dispose(): void;
  44868. }
  44869. }
  44870. declare module "babylonjs/Gizmos/rotationGizmo" {
  44871. import { Observable } from "babylonjs/Misc/observable";
  44872. import { Nullable } from "babylonjs/types";
  44873. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44874. import { Mesh } from "babylonjs/Meshes/mesh";
  44875. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44876. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  44877. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44878. /**
  44879. * Gizmo that enables rotating a mesh along 3 axis
  44880. */
  44881. export class RotationGizmo extends Gizmo {
  44882. /**
  44883. * Internal gizmo used for interactions on the x axis
  44884. */
  44885. xGizmo: PlaneRotationGizmo;
  44886. /**
  44887. * Internal gizmo used for interactions on the y axis
  44888. */
  44889. yGizmo: PlaneRotationGizmo;
  44890. /**
  44891. * Internal gizmo used for interactions on the z axis
  44892. */
  44893. zGizmo: PlaneRotationGizmo;
  44894. /** Fires an event when any of it's sub gizmos are dragged */
  44895. onDragStartObservable: Observable<{}>;
  44896. /** Fires an event when any of it's sub gizmos are released from dragging */
  44897. onDragEndObservable: Observable<{}>;
  44898. private _meshAttached;
  44899. attachedMesh: Nullable<AbstractMesh>;
  44900. /**
  44901. * Creates a RotationGizmo
  44902. * @param gizmoLayer The utility layer the gizmo will be added to
  44903. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44904. */
  44905. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  44906. updateGizmoRotationToMatchAttachedMesh: boolean;
  44907. /**
  44908. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44909. */
  44910. snapDistance: number;
  44911. /**
  44912. * Ratio for the scale of the gizmo (Default: 1)
  44913. */
  44914. scaleRatio: number;
  44915. /**
  44916. * Disposes of the gizmo
  44917. */
  44918. dispose(): void;
  44919. /**
  44920. * CustomMeshes are not supported by this gizmo
  44921. * @param mesh The mesh to replace the default mesh of the gizmo
  44922. */
  44923. setCustomMesh(mesh: Mesh): void;
  44924. }
  44925. }
  44926. declare module "babylonjs/Gizmos/gizmoManager" {
  44927. import { Observable } from "babylonjs/Misc/observable";
  44928. import { Nullable } from "babylonjs/types";
  44929. import { Scene, IDisposable } from "babylonjs/scene";
  44930. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44931. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44932. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  44933. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44934. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44935. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  44936. /**
  44937. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44938. */
  44939. export class GizmoManager implements IDisposable {
  44940. private scene;
  44941. /**
  44942. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44943. */
  44944. gizmos: {
  44945. positionGizmo: Nullable<PositionGizmo>;
  44946. rotationGizmo: Nullable<RotationGizmo>;
  44947. scaleGizmo: Nullable<ScaleGizmo>;
  44948. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44949. };
  44950. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44951. clearGizmoOnEmptyPointerEvent: boolean;
  44952. /** Fires an event when the manager is attached to a mesh */
  44953. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44954. private _gizmosEnabled;
  44955. private _pointerObserver;
  44956. private _attachedMesh;
  44957. private _boundingBoxColor;
  44958. private _defaultUtilityLayer;
  44959. private _defaultKeepDepthUtilityLayer;
  44960. /**
  44961. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44962. */
  44963. boundingBoxDragBehavior: SixDofDragBehavior;
  44964. /**
  44965. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44966. */
  44967. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44968. /**
  44969. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44970. */
  44971. usePointerToAttachGizmos: boolean;
  44972. /**
  44973. * Instatiates a gizmo manager
  44974. * @param scene the scene to overlay the gizmos on top of
  44975. */
  44976. constructor(scene: Scene);
  44977. /**
  44978. * Attaches a set of gizmos to the specified mesh
  44979. * @param mesh The mesh the gizmo's should be attached to
  44980. */
  44981. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44982. /**
  44983. * If the position gizmo is enabled
  44984. */
  44985. positionGizmoEnabled: boolean;
  44986. /**
  44987. * If the rotation gizmo is enabled
  44988. */
  44989. rotationGizmoEnabled: boolean;
  44990. /**
  44991. * If the scale gizmo is enabled
  44992. */
  44993. scaleGizmoEnabled: boolean;
  44994. /**
  44995. * If the boundingBox gizmo is enabled
  44996. */
  44997. boundingBoxGizmoEnabled: boolean;
  44998. /**
  44999. * Disposes of the gizmo manager
  45000. */
  45001. dispose(): void;
  45002. }
  45003. }
  45004. declare module "babylonjs/Lights/directionalLight" {
  45005. import { Camera } from "babylonjs/Cameras/camera";
  45006. import { Scene } from "babylonjs/scene";
  45007. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  45008. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45009. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45010. import { Effect } from "babylonjs/Materials/effect";
  45011. /**
  45012. * A directional light is defined by a direction (what a surprise!).
  45013. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45014. * 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.
  45015. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45016. */
  45017. export class DirectionalLight extends ShadowLight {
  45018. private _shadowFrustumSize;
  45019. /**
  45020. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45021. */
  45022. /**
  45023. * Specifies a fix frustum size for the shadow generation.
  45024. */
  45025. shadowFrustumSize: number;
  45026. private _shadowOrthoScale;
  45027. /**
  45028. * Gets the shadow projection scale against the optimal computed one.
  45029. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45030. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45031. */
  45032. /**
  45033. * Sets the shadow projection scale against the optimal computed one.
  45034. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45035. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45036. */
  45037. shadowOrthoScale: number;
  45038. /**
  45039. * Automatically compute the projection matrix to best fit (including all the casters)
  45040. * on each frame.
  45041. */
  45042. autoUpdateExtends: boolean;
  45043. private _orthoLeft;
  45044. private _orthoRight;
  45045. private _orthoTop;
  45046. private _orthoBottom;
  45047. /**
  45048. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45049. * The directional light is emitted from everywhere in the given direction.
  45050. * It can cast shadows.
  45051. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45052. * @param name The friendly name of the light
  45053. * @param direction The direction of the light
  45054. * @param scene The scene the light belongs to
  45055. */
  45056. constructor(name: string, direction: Vector3, scene: Scene);
  45057. /**
  45058. * Returns the string "DirectionalLight".
  45059. * @return The class name
  45060. */
  45061. getClassName(): string;
  45062. /**
  45063. * Returns the integer 1.
  45064. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45065. */
  45066. getTypeID(): number;
  45067. /**
  45068. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45069. * Returns the DirectionalLight Shadow projection matrix.
  45070. */
  45071. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45072. /**
  45073. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45074. * Returns the DirectionalLight Shadow projection matrix.
  45075. */
  45076. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45077. /**
  45078. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45079. * Returns the DirectionalLight Shadow projection matrix.
  45080. */
  45081. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45082. protected _buildUniformLayout(): void;
  45083. /**
  45084. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45085. * @param effect The effect to update
  45086. * @param lightIndex The index of the light in the effect to update
  45087. * @returns The directional light
  45088. */
  45089. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45090. /**
  45091. * Gets the minZ used for shadow according to both the scene and the light.
  45092. *
  45093. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45094. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45095. * @param activeCamera The camera we are returning the min for
  45096. * @returns the depth min z
  45097. */
  45098. getDepthMinZ(activeCamera: Camera): number;
  45099. /**
  45100. * Gets the maxZ used for shadow according to both the scene and the light.
  45101. *
  45102. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45103. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45104. * @param activeCamera The camera we are returning the max for
  45105. * @returns the depth max z
  45106. */
  45107. getDepthMaxZ(activeCamera: Camera): number;
  45108. /**
  45109. * Prepares the list of defines specific to the light type.
  45110. * @param defines the list of defines
  45111. * @param lightIndex defines the index of the light for the effect
  45112. */
  45113. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45114. }
  45115. }
  45116. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  45117. import { Mesh } from "babylonjs/Meshes/mesh";
  45118. /**
  45119. * Class containing static functions to help procedurally build meshes
  45120. */
  45121. export class HemisphereBuilder {
  45122. /**
  45123. * Creates a hemisphere mesh
  45124. * @param name defines the name of the mesh
  45125. * @param options defines the options used to create the mesh
  45126. * @param scene defines the hosting scene
  45127. * @returns the hemisphere mesh
  45128. */
  45129. static CreateHemisphere(name: string, options: {
  45130. segments?: number;
  45131. diameter?: number;
  45132. sideOrientation?: number;
  45133. }, scene: any): Mesh;
  45134. }
  45135. }
  45136. declare module "babylonjs/Lights/spotLight" {
  45137. import { Nullable } from "babylonjs/types";
  45138. import { Scene } from "babylonjs/scene";
  45139. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  45140. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45141. import { Effect } from "babylonjs/Materials/effect";
  45142. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45143. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45144. /**
  45145. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45146. * These values define a cone of light starting from the position, emitting toward the direction.
  45147. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45148. * and the exponent defines the speed of the decay of the light with distance (reach).
  45149. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45150. */
  45151. export class SpotLight extends ShadowLight {
  45152. private _angle;
  45153. private _innerAngle;
  45154. private _cosHalfAngle;
  45155. private _lightAngleScale;
  45156. private _lightAngleOffset;
  45157. /**
  45158. * Gets the cone angle of the spot light in Radians.
  45159. */
  45160. /**
  45161. * Sets the cone angle of the spot light in Radians.
  45162. */
  45163. angle: number;
  45164. /**
  45165. * Only used in gltf falloff mode, this defines the angle where
  45166. * the directional falloff will start before cutting at angle which could be seen
  45167. * as outer angle.
  45168. */
  45169. /**
  45170. * Only used in gltf falloff mode, this defines the angle where
  45171. * the directional falloff will start before cutting at angle which could be seen
  45172. * as outer angle.
  45173. */
  45174. innerAngle: number;
  45175. private _shadowAngleScale;
  45176. /**
  45177. * Allows scaling the angle of the light for shadow generation only.
  45178. */
  45179. /**
  45180. * Allows scaling the angle of the light for shadow generation only.
  45181. */
  45182. shadowAngleScale: number;
  45183. /**
  45184. * The light decay speed with the distance from the emission spot.
  45185. */
  45186. exponent: number;
  45187. private _projectionTextureMatrix;
  45188. /**
  45189. * Allows reading the projecton texture
  45190. */
  45191. readonly projectionTextureMatrix: Matrix;
  45192. protected _projectionTextureLightNear: number;
  45193. /**
  45194. * Gets the near clip of the Spotlight for texture projection.
  45195. */
  45196. /**
  45197. * Sets the near clip of the Spotlight for texture projection.
  45198. */
  45199. projectionTextureLightNear: number;
  45200. protected _projectionTextureLightFar: number;
  45201. /**
  45202. * Gets the far clip of the Spotlight for texture projection.
  45203. */
  45204. /**
  45205. * Sets the far clip of the Spotlight for texture projection.
  45206. */
  45207. projectionTextureLightFar: number;
  45208. protected _projectionTextureUpDirection: Vector3;
  45209. /**
  45210. * Gets the Up vector of the Spotlight for texture projection.
  45211. */
  45212. /**
  45213. * Sets the Up vector of the Spotlight for texture projection.
  45214. */
  45215. projectionTextureUpDirection: Vector3;
  45216. private _projectionTexture;
  45217. /**
  45218. * Gets the projection texture of the light.
  45219. */
  45220. /**
  45221. * Sets the projection texture of the light.
  45222. */
  45223. projectionTexture: Nullable<BaseTexture>;
  45224. private _projectionTextureViewLightDirty;
  45225. private _projectionTextureProjectionLightDirty;
  45226. private _projectionTextureDirty;
  45227. private _projectionTextureViewTargetVector;
  45228. private _projectionTextureViewLightMatrix;
  45229. private _projectionTextureProjectionLightMatrix;
  45230. private _projectionTextureScalingMatrix;
  45231. /**
  45232. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45233. * It can cast shadows.
  45234. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45235. * @param name The light friendly name
  45236. * @param position The position of the spot light in the scene
  45237. * @param direction The direction of the light in the scene
  45238. * @param angle The cone angle of the light in Radians
  45239. * @param exponent The light decay speed with the distance from the emission spot
  45240. * @param scene The scene the lights belongs to
  45241. */
  45242. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45243. /**
  45244. * Returns the string "SpotLight".
  45245. * @returns the class name
  45246. */
  45247. getClassName(): string;
  45248. /**
  45249. * Returns the integer 2.
  45250. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45251. */
  45252. getTypeID(): number;
  45253. /**
  45254. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45255. */
  45256. protected _setDirection(value: Vector3): void;
  45257. /**
  45258. * Overrides the position setter to recompute the projection texture view light Matrix.
  45259. */
  45260. protected _setPosition(value: Vector3): void;
  45261. /**
  45262. * 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.
  45263. * Returns the SpotLight.
  45264. */
  45265. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45266. protected _computeProjectionTextureViewLightMatrix(): void;
  45267. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45268. /**
  45269. * Main function for light texture projection matrix computing.
  45270. */
  45271. protected _computeProjectionTextureMatrix(): void;
  45272. protected _buildUniformLayout(): void;
  45273. private _computeAngleValues;
  45274. /**
  45275. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45276. * @param effect The effect to update
  45277. * @param lightIndex The index of the light in the effect to update
  45278. * @returns The spot light
  45279. */
  45280. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45281. /**
  45282. * Disposes the light and the associated resources.
  45283. */
  45284. dispose(): void;
  45285. /**
  45286. * Prepares the list of defines specific to the light type.
  45287. * @param defines the list of defines
  45288. * @param lightIndex defines the index of the light for the effect
  45289. */
  45290. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45291. }
  45292. }
  45293. declare module "babylonjs/Gizmos/lightGizmo" {
  45294. import { Nullable } from "babylonjs/types";
  45295. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45296. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45297. import { Light } from "babylonjs/Lights/light";
  45298. /**
  45299. * Gizmo that enables viewing a light
  45300. */
  45301. export class LightGizmo extends Gizmo {
  45302. private _lightMesh;
  45303. private _material;
  45304. private cachedPosition;
  45305. private cachedForward;
  45306. /**
  45307. * Creates a LightGizmo
  45308. * @param gizmoLayer The utility layer the gizmo will be added to
  45309. */
  45310. constructor(gizmoLayer?: UtilityLayerRenderer);
  45311. private _light;
  45312. /**
  45313. * The light that the gizmo is attached to
  45314. */
  45315. light: Nullable<Light>;
  45316. /**
  45317. * @hidden
  45318. * Updates the gizmo to match the attached mesh's position/rotation
  45319. */
  45320. protected _update(): void;
  45321. private static _Scale;
  45322. /**
  45323. * Creates the lines for a light mesh
  45324. */
  45325. private static _createLightLines;
  45326. /**
  45327. * Disposes of the light gizmo
  45328. */
  45329. dispose(): void;
  45330. private static _CreateHemisphericLightMesh;
  45331. private static _CreatePointLightMesh;
  45332. private static _CreateSpotLightMesh;
  45333. private static _CreateDirectionalLightMesh;
  45334. }
  45335. }
  45336. declare module "babylonjs/Gizmos/index" {
  45337. export * from "babylonjs/Gizmos/axisDragGizmo";
  45338. export * from "babylonjs/Gizmos/axisScaleGizmo";
  45339. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  45340. export * from "babylonjs/Gizmos/gizmo";
  45341. export * from "babylonjs/Gizmos/gizmoManager";
  45342. export * from "babylonjs/Gizmos/planeRotationGizmo";
  45343. export * from "babylonjs/Gizmos/positionGizmo";
  45344. export * from "babylonjs/Gizmos/rotationGizmo";
  45345. export * from "babylonjs/Gizmos/scaleGizmo";
  45346. export * from "babylonjs/Gizmos/lightGizmo";
  45347. }
  45348. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  45349. /** @hidden */
  45350. export var backgroundFragmentDeclaration: {
  45351. name: string;
  45352. shader: string;
  45353. };
  45354. }
  45355. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  45356. /** @hidden */
  45357. export var backgroundUboDeclaration: {
  45358. name: string;
  45359. shader: string;
  45360. };
  45361. }
  45362. declare module "babylonjs/Shaders/background.fragment" {
  45363. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  45364. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45365. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  45366. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  45367. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45368. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45369. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45370. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  45371. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  45372. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  45373. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  45374. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45375. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45376. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45377. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45378. /** @hidden */
  45379. export var backgroundPixelShader: {
  45380. name: string;
  45381. shader: string;
  45382. };
  45383. }
  45384. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  45385. /** @hidden */
  45386. export var backgroundVertexDeclaration: {
  45387. name: string;
  45388. shader: string;
  45389. };
  45390. }
  45391. declare module "babylonjs/Shaders/background.vertex" {
  45392. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  45393. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45394. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45395. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45396. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45397. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45398. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45399. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45400. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45401. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45402. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45403. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45404. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45405. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45406. /** @hidden */
  45407. export var backgroundVertexShader: {
  45408. name: string;
  45409. shader: string;
  45410. };
  45411. }
  45412. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  45413. import { Nullable, int, float } from "babylonjs/types";
  45414. import { Scene } from "babylonjs/scene";
  45415. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  45416. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45417. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45418. import { Mesh } from "babylonjs/Meshes/mesh";
  45419. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45420. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45421. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45422. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45423. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  45424. import "babylonjs/Shaders/background.fragment";
  45425. import "babylonjs/Shaders/background.vertex";
  45426. /**
  45427. * Background material used to create an efficient environement around your scene.
  45428. */
  45429. export class BackgroundMaterial extends PushMaterial {
  45430. /**
  45431. * Standard reflectance value at parallel view angle.
  45432. */
  45433. static StandardReflectance0: number;
  45434. /**
  45435. * Standard reflectance value at grazing angle.
  45436. */
  45437. static StandardReflectance90: number;
  45438. protected _primaryColor: Color3;
  45439. /**
  45440. * Key light Color (multiply against the environement texture)
  45441. */
  45442. primaryColor: Color3;
  45443. protected __perceptualColor: Nullable<Color3>;
  45444. /**
  45445. * Experimental Internal Use Only.
  45446. *
  45447. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45448. * This acts as a helper to set the primary color to a more "human friendly" value.
  45449. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45450. * output color as close as possible from the chosen value.
  45451. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45452. * part of lighting setup.)
  45453. */
  45454. _perceptualColor: Nullable<Color3>;
  45455. protected _primaryColorShadowLevel: float;
  45456. /**
  45457. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45458. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45459. */
  45460. primaryColorShadowLevel: float;
  45461. protected _primaryColorHighlightLevel: float;
  45462. /**
  45463. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45464. * The primary color is used at the level chosen to define what the white area would look.
  45465. */
  45466. primaryColorHighlightLevel: float;
  45467. protected _reflectionTexture: Nullable<BaseTexture>;
  45468. /**
  45469. * Reflection Texture used in the material.
  45470. * Should be author in a specific way for the best result (refer to the documentation).
  45471. */
  45472. reflectionTexture: Nullable<BaseTexture>;
  45473. protected _reflectionBlur: float;
  45474. /**
  45475. * Reflection Texture level of blur.
  45476. *
  45477. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45478. * texture twice.
  45479. */
  45480. reflectionBlur: float;
  45481. protected _diffuseTexture: Nullable<BaseTexture>;
  45482. /**
  45483. * Diffuse Texture used in the material.
  45484. * Should be author in a specific way for the best result (refer to the documentation).
  45485. */
  45486. diffuseTexture: Nullable<BaseTexture>;
  45487. protected _shadowLights: Nullable<IShadowLight[]>;
  45488. /**
  45489. * Specify the list of lights casting shadow on the material.
  45490. * All scene shadow lights will be included if null.
  45491. */
  45492. shadowLights: Nullable<IShadowLight[]>;
  45493. protected _shadowLevel: float;
  45494. /**
  45495. * Helps adjusting the shadow to a softer level if required.
  45496. * 0 means black shadows and 1 means no shadows.
  45497. */
  45498. shadowLevel: float;
  45499. protected _sceneCenter: Vector3;
  45500. /**
  45501. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45502. * It is usually zero but might be interesting to modify according to your setup.
  45503. */
  45504. sceneCenter: Vector3;
  45505. protected _opacityFresnel: boolean;
  45506. /**
  45507. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45508. * This helps ensuring a nice transition when the camera goes under the ground.
  45509. */
  45510. opacityFresnel: boolean;
  45511. protected _reflectionFresnel: boolean;
  45512. /**
  45513. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45514. * This helps adding a mirror texture on the ground.
  45515. */
  45516. reflectionFresnel: boolean;
  45517. protected _reflectionFalloffDistance: number;
  45518. /**
  45519. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45520. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45521. */
  45522. reflectionFalloffDistance: number;
  45523. protected _reflectionAmount: number;
  45524. /**
  45525. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45526. */
  45527. reflectionAmount: number;
  45528. protected _reflectionReflectance0: number;
  45529. /**
  45530. * This specifies the weight of the reflection at grazing angle.
  45531. */
  45532. reflectionReflectance0: number;
  45533. protected _reflectionReflectance90: number;
  45534. /**
  45535. * This specifies the weight of the reflection at a perpendicular point of view.
  45536. */
  45537. reflectionReflectance90: number;
  45538. /**
  45539. * Sets the reflection reflectance fresnel values according to the default standard
  45540. * empirically know to work well :-)
  45541. */
  45542. reflectionStandardFresnelWeight: number;
  45543. protected _useRGBColor: boolean;
  45544. /**
  45545. * Helps to directly use the maps channels instead of their level.
  45546. */
  45547. useRGBColor: boolean;
  45548. protected _enableNoise: boolean;
  45549. /**
  45550. * This helps reducing the banding effect that could occur on the background.
  45551. */
  45552. enableNoise: boolean;
  45553. /**
  45554. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45555. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45556. * Recommended to be keep at 1.0 except for special cases.
  45557. */
  45558. fovMultiplier: number;
  45559. private _fovMultiplier;
  45560. /**
  45561. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45562. */
  45563. useEquirectangularFOV: boolean;
  45564. private _maxSimultaneousLights;
  45565. /**
  45566. * Number of Simultaneous lights allowed on the material.
  45567. */
  45568. maxSimultaneousLights: int;
  45569. /**
  45570. * Default configuration related to image processing available in the Background Material.
  45571. */
  45572. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45573. /**
  45574. * Keep track of the image processing observer to allow dispose and replace.
  45575. */
  45576. private _imageProcessingObserver;
  45577. /**
  45578. * Attaches a new image processing configuration to the PBR Material.
  45579. * @param configuration (if null the scene configuration will be use)
  45580. */
  45581. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45582. /**
  45583. * Gets the image processing configuration used either in this material.
  45584. */
  45585. /**
  45586. * Sets the Default image processing configuration used either in the this material.
  45587. *
  45588. * If sets to null, the scene one is in use.
  45589. */
  45590. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45591. /**
  45592. * Gets wether the color curves effect is enabled.
  45593. */
  45594. /**
  45595. * Sets wether the color curves effect is enabled.
  45596. */
  45597. cameraColorCurvesEnabled: boolean;
  45598. /**
  45599. * Gets wether the color grading effect is enabled.
  45600. */
  45601. /**
  45602. * Gets wether the color grading effect is enabled.
  45603. */
  45604. cameraColorGradingEnabled: boolean;
  45605. /**
  45606. * Gets wether tonemapping is enabled or not.
  45607. */
  45608. /**
  45609. * Sets wether tonemapping is enabled or not
  45610. */
  45611. cameraToneMappingEnabled: boolean;
  45612. /**
  45613. * The camera exposure used on this material.
  45614. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45615. * This corresponds to a photographic exposure.
  45616. */
  45617. /**
  45618. * The camera exposure used on this material.
  45619. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45620. * This corresponds to a photographic exposure.
  45621. */
  45622. cameraExposure: float;
  45623. /**
  45624. * Gets The camera contrast used on this material.
  45625. */
  45626. /**
  45627. * Sets The camera contrast used on this material.
  45628. */
  45629. cameraContrast: float;
  45630. /**
  45631. * Gets the Color Grading 2D Lookup Texture.
  45632. */
  45633. /**
  45634. * Sets the Color Grading 2D Lookup Texture.
  45635. */
  45636. cameraColorGradingTexture: Nullable<BaseTexture>;
  45637. /**
  45638. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45639. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45640. * 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;
  45641. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45642. */
  45643. /**
  45644. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45645. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45646. * 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;
  45647. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45648. */
  45649. cameraColorCurves: Nullable<ColorCurves>;
  45650. /**
  45651. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45652. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45653. */
  45654. switchToBGR: boolean;
  45655. private _renderTargets;
  45656. private _reflectionControls;
  45657. private _white;
  45658. private _primaryShadowColor;
  45659. private _primaryHighlightColor;
  45660. /**
  45661. * Instantiates a Background Material in the given scene
  45662. * @param name The friendly name of the material
  45663. * @param scene The scene to add the material to
  45664. */
  45665. constructor(name: string, scene: Scene);
  45666. /**
  45667. * Gets a boolean indicating that current material needs to register RTT
  45668. */
  45669. readonly hasRenderTargetTextures: boolean;
  45670. /**
  45671. * The entire material has been created in order to prevent overdraw.
  45672. * @returns false
  45673. */
  45674. needAlphaTesting(): boolean;
  45675. /**
  45676. * The entire material has been created in order to prevent overdraw.
  45677. * @returns true if blending is enable
  45678. */
  45679. needAlphaBlending(): boolean;
  45680. /**
  45681. * Checks wether the material is ready to be rendered for a given mesh.
  45682. * @param mesh The mesh to render
  45683. * @param subMesh The submesh to check against
  45684. * @param useInstances Specify wether or not the material is used with instances
  45685. * @returns true if all the dependencies are ready (Textures, Effects...)
  45686. */
  45687. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45688. /**
  45689. * Compute the primary color according to the chosen perceptual color.
  45690. */
  45691. private _computePrimaryColorFromPerceptualColor;
  45692. /**
  45693. * Compute the highlights and shadow colors according to their chosen levels.
  45694. */
  45695. private _computePrimaryColors;
  45696. /**
  45697. * Build the uniform buffer used in the material.
  45698. */
  45699. buildUniformLayout(): void;
  45700. /**
  45701. * Unbind the material.
  45702. */
  45703. unbind(): void;
  45704. /**
  45705. * Bind only the world matrix to the material.
  45706. * @param world The world matrix to bind.
  45707. */
  45708. bindOnlyWorldMatrix(world: Matrix): void;
  45709. /**
  45710. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45711. * @param world The world matrix to bind.
  45712. * @param subMesh The submesh to bind for.
  45713. */
  45714. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45715. /**
  45716. * Dispose the material.
  45717. * @param forceDisposeEffect Force disposal of the associated effect.
  45718. * @param forceDisposeTextures Force disposal of the associated textures.
  45719. */
  45720. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45721. /**
  45722. * Clones the material.
  45723. * @param name The cloned name.
  45724. * @returns The cloned material.
  45725. */
  45726. clone(name: string): BackgroundMaterial;
  45727. /**
  45728. * Serializes the current material to its JSON representation.
  45729. * @returns The JSON representation.
  45730. */
  45731. serialize(): any;
  45732. /**
  45733. * Gets the class name of the material
  45734. * @returns "BackgroundMaterial"
  45735. */
  45736. getClassName(): string;
  45737. /**
  45738. * Parse a JSON input to create back a background material.
  45739. * @param source The JSON data to parse
  45740. * @param scene The scene to create the parsed material in
  45741. * @param rootUrl The root url of the assets the material depends upon
  45742. * @returns the instantiated BackgroundMaterial.
  45743. */
  45744. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45745. }
  45746. }
  45747. declare module "babylonjs/Helpers/environmentHelper" {
  45748. import { Observable } from "babylonjs/Misc/observable";
  45749. import { Nullable } from "babylonjs/types";
  45750. import { Scene } from "babylonjs/scene";
  45751. import { Vector3, Color3 } from "babylonjs/Maths/math";
  45752. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45753. import { Mesh } from "babylonjs/Meshes/mesh";
  45754. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45755. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  45756. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45757. import "babylonjs/Meshes/Builders/planeBuilder";
  45758. import "babylonjs/Meshes/Builders/boxBuilder";
  45759. /**
  45760. * Represents the different options available during the creation of
  45761. * a Environment helper.
  45762. *
  45763. * This can control the default ground, skybox and image processing setup of your scene.
  45764. */
  45765. export interface IEnvironmentHelperOptions {
  45766. /**
  45767. * Specifies wether or not to create a ground.
  45768. * True by default.
  45769. */
  45770. createGround: boolean;
  45771. /**
  45772. * Specifies the ground size.
  45773. * 15 by default.
  45774. */
  45775. groundSize: number;
  45776. /**
  45777. * The texture used on the ground for the main color.
  45778. * Comes from the BabylonJS CDN by default.
  45779. *
  45780. * Remarks: Can be either a texture or a url.
  45781. */
  45782. groundTexture: string | BaseTexture;
  45783. /**
  45784. * The color mixed in the ground texture by default.
  45785. * BabylonJS clearColor by default.
  45786. */
  45787. groundColor: Color3;
  45788. /**
  45789. * Specifies the ground opacity.
  45790. * 1 by default.
  45791. */
  45792. groundOpacity: number;
  45793. /**
  45794. * Enables the ground to receive shadows.
  45795. * True by default.
  45796. */
  45797. enableGroundShadow: boolean;
  45798. /**
  45799. * Helps preventing the shadow to be fully black on the ground.
  45800. * 0.5 by default.
  45801. */
  45802. groundShadowLevel: number;
  45803. /**
  45804. * Creates a mirror texture attach to the ground.
  45805. * false by default.
  45806. */
  45807. enableGroundMirror: boolean;
  45808. /**
  45809. * Specifies the ground mirror size ratio.
  45810. * 0.3 by default as the default kernel is 64.
  45811. */
  45812. groundMirrorSizeRatio: number;
  45813. /**
  45814. * Specifies the ground mirror blur kernel size.
  45815. * 64 by default.
  45816. */
  45817. groundMirrorBlurKernel: number;
  45818. /**
  45819. * Specifies the ground mirror visibility amount.
  45820. * 1 by default
  45821. */
  45822. groundMirrorAmount: number;
  45823. /**
  45824. * Specifies the ground mirror reflectance weight.
  45825. * This uses the standard weight of the background material to setup the fresnel effect
  45826. * of the mirror.
  45827. * 1 by default.
  45828. */
  45829. groundMirrorFresnelWeight: number;
  45830. /**
  45831. * Specifies the ground mirror Falloff distance.
  45832. * This can helps reducing the size of the reflection.
  45833. * 0 by Default.
  45834. */
  45835. groundMirrorFallOffDistance: number;
  45836. /**
  45837. * Specifies the ground mirror texture type.
  45838. * Unsigned Int by Default.
  45839. */
  45840. groundMirrorTextureType: number;
  45841. /**
  45842. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45843. * the shown objects.
  45844. */
  45845. groundYBias: number;
  45846. /**
  45847. * Specifies wether or not to create a skybox.
  45848. * True by default.
  45849. */
  45850. createSkybox: boolean;
  45851. /**
  45852. * Specifies the skybox size.
  45853. * 20 by default.
  45854. */
  45855. skyboxSize: number;
  45856. /**
  45857. * The texture used on the skybox for the main color.
  45858. * Comes from the BabylonJS CDN by default.
  45859. *
  45860. * Remarks: Can be either a texture or a url.
  45861. */
  45862. skyboxTexture: string | BaseTexture;
  45863. /**
  45864. * The color mixed in the skybox texture by default.
  45865. * BabylonJS clearColor by default.
  45866. */
  45867. skyboxColor: Color3;
  45868. /**
  45869. * The background rotation around the Y axis of the scene.
  45870. * This helps aligning the key lights of your scene with the background.
  45871. * 0 by default.
  45872. */
  45873. backgroundYRotation: number;
  45874. /**
  45875. * Compute automatically the size of the elements to best fit with the scene.
  45876. */
  45877. sizeAuto: boolean;
  45878. /**
  45879. * Default position of the rootMesh if autoSize is not true.
  45880. */
  45881. rootPosition: Vector3;
  45882. /**
  45883. * Sets up the image processing in the scene.
  45884. * true by default.
  45885. */
  45886. setupImageProcessing: boolean;
  45887. /**
  45888. * The texture used as your environment texture in the scene.
  45889. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45890. *
  45891. * Remarks: Can be either a texture or a url.
  45892. */
  45893. environmentTexture: string | BaseTexture;
  45894. /**
  45895. * The value of the exposure to apply to the scene.
  45896. * 0.6 by default if setupImageProcessing is true.
  45897. */
  45898. cameraExposure: number;
  45899. /**
  45900. * The value of the contrast to apply to the scene.
  45901. * 1.6 by default if setupImageProcessing is true.
  45902. */
  45903. cameraContrast: number;
  45904. /**
  45905. * Specifies wether or not tonemapping should be enabled in the scene.
  45906. * true by default if setupImageProcessing is true.
  45907. */
  45908. toneMappingEnabled: boolean;
  45909. }
  45910. /**
  45911. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45912. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45913. * It also helps with the default setup of your imageProcessing configuration.
  45914. */
  45915. export class EnvironmentHelper {
  45916. /**
  45917. * Default ground texture URL.
  45918. */
  45919. private static _groundTextureCDNUrl;
  45920. /**
  45921. * Default skybox texture URL.
  45922. */
  45923. private static _skyboxTextureCDNUrl;
  45924. /**
  45925. * Default environment texture URL.
  45926. */
  45927. private static _environmentTextureCDNUrl;
  45928. /**
  45929. * Creates the default options for the helper.
  45930. */
  45931. private static _getDefaultOptions;
  45932. private _rootMesh;
  45933. /**
  45934. * Gets the root mesh created by the helper.
  45935. */
  45936. readonly rootMesh: Mesh;
  45937. private _skybox;
  45938. /**
  45939. * Gets the skybox created by the helper.
  45940. */
  45941. readonly skybox: Nullable<Mesh>;
  45942. private _skyboxTexture;
  45943. /**
  45944. * Gets the skybox texture created by the helper.
  45945. */
  45946. readonly skyboxTexture: Nullable<BaseTexture>;
  45947. private _skyboxMaterial;
  45948. /**
  45949. * Gets the skybox material created by the helper.
  45950. */
  45951. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45952. private _ground;
  45953. /**
  45954. * Gets the ground mesh created by the helper.
  45955. */
  45956. readonly ground: Nullable<Mesh>;
  45957. private _groundTexture;
  45958. /**
  45959. * Gets the ground texture created by the helper.
  45960. */
  45961. readonly groundTexture: Nullable<BaseTexture>;
  45962. private _groundMirror;
  45963. /**
  45964. * Gets the ground mirror created by the helper.
  45965. */
  45966. readonly groundMirror: Nullable<MirrorTexture>;
  45967. /**
  45968. * Gets the ground mirror render list to helps pushing the meshes
  45969. * you wish in the ground reflection.
  45970. */
  45971. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45972. private _groundMaterial;
  45973. /**
  45974. * Gets the ground material created by the helper.
  45975. */
  45976. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45977. /**
  45978. * Stores the creation options.
  45979. */
  45980. private readonly _scene;
  45981. private _options;
  45982. /**
  45983. * This observable will be notified with any error during the creation of the environment,
  45984. * mainly texture creation errors.
  45985. */
  45986. onErrorObservable: Observable<{
  45987. message?: string;
  45988. exception?: any;
  45989. }>;
  45990. /**
  45991. * constructor
  45992. * @param options Defines the options we want to customize the helper
  45993. * @param scene The scene to add the material to
  45994. */
  45995. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45996. /**
  45997. * Updates the background according to the new options
  45998. * @param options
  45999. */
  46000. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46001. /**
  46002. * Sets the primary color of all the available elements.
  46003. * @param color the main color to affect to the ground and the background
  46004. */
  46005. setMainColor(color: Color3): void;
  46006. /**
  46007. * Setup the image processing according to the specified options.
  46008. */
  46009. private _setupImageProcessing;
  46010. /**
  46011. * Setup the environment texture according to the specified options.
  46012. */
  46013. private _setupEnvironmentTexture;
  46014. /**
  46015. * Setup the background according to the specified options.
  46016. */
  46017. private _setupBackground;
  46018. /**
  46019. * Get the scene sizes according to the setup.
  46020. */
  46021. private _getSceneSize;
  46022. /**
  46023. * Setup the ground according to the specified options.
  46024. */
  46025. private _setupGround;
  46026. /**
  46027. * Setup the ground material according to the specified options.
  46028. */
  46029. private _setupGroundMaterial;
  46030. /**
  46031. * Setup the ground diffuse texture according to the specified options.
  46032. */
  46033. private _setupGroundDiffuseTexture;
  46034. /**
  46035. * Setup the ground mirror texture according to the specified options.
  46036. */
  46037. private _setupGroundMirrorTexture;
  46038. /**
  46039. * Setup the ground to receive the mirror texture.
  46040. */
  46041. private _setupMirrorInGroundMaterial;
  46042. /**
  46043. * Setup the skybox according to the specified options.
  46044. */
  46045. private _setupSkybox;
  46046. /**
  46047. * Setup the skybox material according to the specified options.
  46048. */
  46049. private _setupSkyboxMaterial;
  46050. /**
  46051. * Setup the skybox reflection texture according to the specified options.
  46052. */
  46053. private _setupSkyboxReflectionTexture;
  46054. private _errorHandler;
  46055. /**
  46056. * Dispose all the elements created by the Helper.
  46057. */
  46058. dispose(): void;
  46059. }
  46060. }
  46061. declare module "babylonjs/Helpers/photoDome" {
  46062. import { Observable } from "babylonjs/Misc/observable";
  46063. import { Nullable } from "babylonjs/types";
  46064. import { Scene } from "babylonjs/scene";
  46065. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46066. import { Mesh } from "babylonjs/Meshes/mesh";
  46067. import { Texture } from "babylonjs/Materials/Textures/texture";
  46068. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46069. import "babylonjs/Meshes/Builders/sphereBuilder";
  46070. /**
  46071. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46072. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46073. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46074. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46075. */
  46076. export class PhotoDome extends TransformNode {
  46077. /**
  46078. * Define the image as a Monoscopic panoramic 360 image.
  46079. */
  46080. static readonly MODE_MONOSCOPIC: number;
  46081. /**
  46082. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46083. */
  46084. static readonly MODE_TOPBOTTOM: number;
  46085. /**
  46086. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46087. */
  46088. static readonly MODE_SIDEBYSIDE: number;
  46089. private _useDirectMapping;
  46090. /**
  46091. * The texture being displayed on the sphere
  46092. */
  46093. protected _photoTexture: Texture;
  46094. /**
  46095. * Gets or sets the texture being displayed on the sphere
  46096. */
  46097. photoTexture: Texture;
  46098. /**
  46099. * Observable raised when an error occured while loading the 360 image
  46100. */
  46101. onLoadErrorObservable: Observable<string>;
  46102. /**
  46103. * The skybox material
  46104. */
  46105. protected _material: BackgroundMaterial;
  46106. /**
  46107. * The surface used for the skybox
  46108. */
  46109. protected _mesh: Mesh;
  46110. /**
  46111. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46112. * Also see the options.resolution property.
  46113. */
  46114. fovMultiplier: number;
  46115. private _imageMode;
  46116. /**
  46117. * Gets or set the current video mode for the video. It can be:
  46118. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46119. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46120. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46121. */
  46122. imageMode: number;
  46123. /**
  46124. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46125. * @param name Element's name, child elements will append suffixes for their own names.
  46126. * @param urlsOfPhoto defines the url of the photo to display
  46127. * @param options defines an object containing optional or exposed sub element properties
  46128. * @param onError defines a callback called when an error occured while loading the texture
  46129. */
  46130. constructor(name: string, urlOfPhoto: string, options: {
  46131. resolution?: number;
  46132. size?: number;
  46133. useDirectMapping?: boolean;
  46134. faceForward?: boolean;
  46135. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46136. private _onBeforeCameraRenderObserver;
  46137. private _changeImageMode;
  46138. /**
  46139. * Releases resources associated with this node.
  46140. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46141. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46142. */
  46143. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46144. }
  46145. }
  46146. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46147. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46148. /** @hidden */
  46149. export var rgbdDecodePixelShader: {
  46150. name: string;
  46151. shader: string;
  46152. };
  46153. }
  46154. declare module "babylonjs/Misc/brdfTextureTools" {
  46155. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46156. import { Scene } from "babylonjs/scene";
  46157. import "babylonjs/Shaders/rgbdDecode.fragment";
  46158. /**
  46159. * Class used to host texture specific utilities
  46160. */
  46161. export class BRDFTextureTools {
  46162. /**
  46163. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  46164. * @param texture the texture to expand.
  46165. */
  46166. private static _ExpandDefaultBRDFTexture;
  46167. /**
  46168. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46169. * @param scene defines the hosting scene
  46170. * @returns the environment BRDF texture
  46171. */
  46172. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46173. private static _environmentBRDFBase64Texture;
  46174. }
  46175. }
  46176. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  46177. import { Nullable } from "babylonjs/types";
  46178. import { IAnimatable } from "babylonjs/Misc/tools";
  46179. import { Color3 } from "babylonjs/Maths/math";
  46180. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46181. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46182. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46183. import { Engine } from "babylonjs/Engines/engine";
  46184. import { Scene } from "babylonjs/scene";
  46185. /**
  46186. * @hidden
  46187. */
  46188. export interface IMaterialClearCoatDefines {
  46189. CLEARCOAT: boolean;
  46190. CLEARCOAT_DEFAULTIOR: boolean;
  46191. CLEARCOAT_TEXTURE: boolean;
  46192. CLEARCOAT_TEXTUREDIRECTUV: number;
  46193. CLEARCOAT_BUMP: boolean;
  46194. CLEARCOAT_BUMPDIRECTUV: number;
  46195. CLEARCOAT_TINT: boolean;
  46196. CLEARCOAT_TINT_TEXTURE: boolean;
  46197. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46198. /** @hidden */
  46199. _areTexturesDirty: boolean;
  46200. }
  46201. /**
  46202. * Define the code related to the clear coat parameters of the pbr material.
  46203. */
  46204. export class PBRClearCoatConfiguration {
  46205. /**
  46206. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46207. * The default fits with a polyurethane material.
  46208. */
  46209. private static readonly _DefaultIndiceOfRefraction;
  46210. private _isEnabled;
  46211. /**
  46212. * Defines if the clear coat is enabled in the material.
  46213. */
  46214. isEnabled: boolean;
  46215. /**
  46216. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  46217. */
  46218. intensity: number;
  46219. /**
  46220. * Defines the clear coat layer roughness.
  46221. */
  46222. roughness: number;
  46223. private _indiceOfRefraction;
  46224. /**
  46225. * Defines the indice of refraction of the clear coat.
  46226. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46227. * The default fits with a polyurethane material.
  46228. * Changing the default value is more performance intensive.
  46229. */
  46230. indiceOfRefraction: number;
  46231. private _texture;
  46232. /**
  46233. * Stores the clear coat values in a texture.
  46234. */
  46235. texture: Nullable<BaseTexture>;
  46236. private _bumpTexture;
  46237. /**
  46238. * Define the clear coat specific bump texture.
  46239. */
  46240. bumpTexture: Nullable<BaseTexture>;
  46241. private _isTintEnabled;
  46242. /**
  46243. * Defines if the clear coat tint is enabled in the material.
  46244. */
  46245. isTintEnabled: boolean;
  46246. /**
  46247. * Defines the clear coat tint of the material.
  46248. * This is only use if tint is enabled
  46249. */
  46250. tintColor: Color3;
  46251. /**
  46252. * Defines the distance at which the tint color should be found in the
  46253. * clear coat media.
  46254. * This is only use if tint is enabled
  46255. */
  46256. tintColorAtDistance: number;
  46257. /**
  46258. * Defines the clear coat layer thickness.
  46259. * This is only use if tint is enabled
  46260. */
  46261. tintThickness: number;
  46262. private _tintTexture;
  46263. /**
  46264. * Stores the clear tint values in a texture.
  46265. * rgb is tint
  46266. * a is a thickness factor
  46267. */
  46268. tintTexture: Nullable<BaseTexture>;
  46269. /** @hidden */
  46270. private _internalMarkAllSubMeshesAsTexturesDirty;
  46271. /** @hidden */
  46272. _markAllSubMeshesAsTexturesDirty(): void;
  46273. /**
  46274. * Instantiate a new istance of clear coat configuration.
  46275. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46276. */
  46277. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46278. /**
  46279. * Gets wehter the submesh is ready to be used or not.
  46280. * @param defines the list of "defines" to update.
  46281. * @param scene defines the scene the material belongs to.
  46282. * @param engine defines the engine the material belongs to.
  46283. * @param disableBumpMap defines wether the material disables bump or not.
  46284. * @returns - boolean indicating that the submesh is ready or not.
  46285. */
  46286. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46287. /**
  46288. * Checks to see if a texture is used in the material.
  46289. * @param defines the list of "defines" to update.
  46290. * @param scene defines the scene to the material belongs to.
  46291. */
  46292. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46293. /**
  46294. * Binds the material data.
  46295. * @param uniformBuffer defines the Uniform buffer to fill in.
  46296. * @param scene defines the scene the material belongs to.
  46297. * @param engine defines the engine the material belongs to.
  46298. * @param disableBumpMap defines wether the material disables bump or not.
  46299. * @param isFrozen defines wether the material is frozen or not.
  46300. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46301. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46302. */
  46303. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46304. /**
  46305. * Checks to see if a texture is used in the material.
  46306. * @param texture - Base texture to use.
  46307. * @returns - Boolean specifying if a texture is used in the material.
  46308. */
  46309. hasTexture(texture: BaseTexture): boolean;
  46310. /**
  46311. * Returns an array of the actively used textures.
  46312. * @param activeTextures Array of BaseTextures
  46313. */
  46314. getActiveTextures(activeTextures: BaseTexture[]): void;
  46315. /**
  46316. * Returns the animatable textures.
  46317. * @param animatables Array of animatable textures.
  46318. */
  46319. getAnimatables(animatables: IAnimatable[]): void;
  46320. /**
  46321. * Disposes the resources of the material.
  46322. * @param forceDisposeTextures - Forces the disposal of all textures.
  46323. */
  46324. dispose(forceDisposeTextures?: boolean): void;
  46325. /**
  46326. * Get the current class name of the texture useful for serialization or dynamic coding.
  46327. * @returns "PBRClearCoatConfiguration"
  46328. */
  46329. getClassName(): string;
  46330. /**
  46331. * Add fallbacks to the effect fallbacks list.
  46332. * @param defines defines the Base texture to use.
  46333. * @param fallbacks defines the current fallback list.
  46334. * @param currentRank defines the current fallback rank.
  46335. * @returns the new fallback rank.
  46336. */
  46337. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46338. /**
  46339. * Add the required uniforms to the current list.
  46340. * @param uniforms defines the current uniform list.
  46341. */
  46342. static AddUniforms(uniforms: string[]): void;
  46343. /**
  46344. * Add the required samplers to the current list.
  46345. * @param samplers defines the current sampler list.
  46346. */
  46347. static AddSamplers(samplers: string[]): void;
  46348. /**
  46349. * Add the required uniforms to the current buffer.
  46350. * @param uniformBuffer defines the current uniform buffer.
  46351. */
  46352. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46353. /**
  46354. * Makes a duplicate of the current configuration into another one.
  46355. * @param clearCoatConfiguration define the config where to copy the info
  46356. */
  46357. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46358. /**
  46359. * Serializes this clear coat configuration.
  46360. * @returns - An object with the serialized config.
  46361. */
  46362. serialize(): any;
  46363. /**
  46364. * Parses a Clear Coat Configuration from a serialized object.
  46365. * @param source - Serialized object.
  46366. */
  46367. parse(source: any): void;
  46368. }
  46369. }
  46370. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  46371. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46372. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46373. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46374. import { Vector2 } from "babylonjs/Maths/math";
  46375. import { Scene } from "babylonjs/scene";
  46376. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46377. import { IAnimatable } from "babylonjs/Misc/tools";
  46378. import { Nullable } from "babylonjs/types";
  46379. /**
  46380. * @hidden
  46381. */
  46382. export interface IMaterialAnisotropicDefines {
  46383. ANISOTROPIC: boolean;
  46384. ANISOTROPIC_TEXTURE: boolean;
  46385. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46386. MAINUV1: boolean;
  46387. _areTexturesDirty: boolean;
  46388. _needUVs: boolean;
  46389. }
  46390. /**
  46391. * Define the code related to the anisotropic parameters of the pbr material.
  46392. */
  46393. export class PBRAnisotropicConfiguration {
  46394. private _isEnabled;
  46395. /**
  46396. * Defines if the anisotropy is enabled in the material.
  46397. */
  46398. isEnabled: boolean;
  46399. /**
  46400. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46401. */
  46402. intensity: number;
  46403. /**
  46404. * Defines if the effect is along the tangents, bitangents or in between.
  46405. * By default, the effect is "strectching" the highlights along the tangents.
  46406. */
  46407. direction: Vector2;
  46408. private _texture;
  46409. /**
  46410. * Stores the anisotropy values in a texture.
  46411. * rg is direction (like normal from -1 to 1)
  46412. * b is a intensity
  46413. */
  46414. texture: Nullable<BaseTexture>;
  46415. /** @hidden */
  46416. private _internalMarkAllSubMeshesAsTexturesDirty;
  46417. /** @hidden */
  46418. _markAllSubMeshesAsTexturesDirty(): void;
  46419. /**
  46420. * Instantiate a new istance of anisotropy configuration.
  46421. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46422. */
  46423. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46424. /**
  46425. * Specifies that the submesh is ready to be used.
  46426. * @param defines the list of "defines" to update.
  46427. * @param scene defines the scene the material belongs to.
  46428. * @returns - boolean indicating that the submesh is ready or not.
  46429. */
  46430. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46431. /**
  46432. * Checks to see if a texture is used in the material.
  46433. * @param defines the list of "defines" to update.
  46434. * @param mesh the mesh we are preparing the defines for.
  46435. * @param scene defines the scene the material belongs to.
  46436. */
  46437. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46438. /**
  46439. * Binds the material data.
  46440. * @param uniformBuffer defines the Uniform buffer to fill in.
  46441. * @param scene defines the scene the material belongs to.
  46442. * @param isFrozen defines wether the material is frozen or not.
  46443. */
  46444. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46445. /**
  46446. * Checks to see if a texture is used in the material.
  46447. * @param texture - Base texture to use.
  46448. * @returns - Boolean specifying if a texture is used in the material.
  46449. */
  46450. hasTexture(texture: BaseTexture): boolean;
  46451. /**
  46452. * Returns an array of the actively used textures.
  46453. * @param activeTextures Array of BaseTextures
  46454. */
  46455. getActiveTextures(activeTextures: BaseTexture[]): void;
  46456. /**
  46457. * Returns the animatable textures.
  46458. * @param animatables Array of animatable textures.
  46459. */
  46460. getAnimatables(animatables: IAnimatable[]): void;
  46461. /**
  46462. * Disposes the resources of the material.
  46463. * @param forceDisposeTextures - Forces the disposal of all textures.
  46464. */
  46465. dispose(forceDisposeTextures?: boolean): void;
  46466. /**
  46467. * Get the current class name of the texture useful for serialization or dynamic coding.
  46468. * @returns "PBRAnisotropicConfiguration"
  46469. */
  46470. getClassName(): string;
  46471. /**
  46472. * Add fallbacks to the effect fallbacks list.
  46473. * @param defines defines the Base texture to use.
  46474. * @param fallbacks defines the current fallback list.
  46475. * @param currentRank defines the current fallback rank.
  46476. * @returns the new fallback rank.
  46477. */
  46478. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46479. /**
  46480. * Add the required uniforms to the current list.
  46481. * @param uniforms defines the current uniform list.
  46482. */
  46483. static AddUniforms(uniforms: string[]): void;
  46484. /**
  46485. * Add the required uniforms to the current buffer.
  46486. * @param uniformBuffer defines the current uniform buffer.
  46487. */
  46488. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46489. /**
  46490. * Add the required samplers to the current list.
  46491. * @param samplers defines the current sampler list.
  46492. */
  46493. static AddSamplers(samplers: string[]): void;
  46494. /**
  46495. * Makes a duplicate of the current configuration into another one.
  46496. * @param anisotropicConfiguration define the config where to copy the info
  46497. */
  46498. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46499. /**
  46500. * Serializes this anisotropy configuration.
  46501. * @returns - An object with the serialized config.
  46502. */
  46503. serialize(): any;
  46504. /**
  46505. * Parses a anisotropy Configuration from a serialized object.
  46506. * @param source - Serialized object.
  46507. */
  46508. parse(source: any): void;
  46509. }
  46510. }
  46511. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  46512. /**
  46513. * @hidden
  46514. */
  46515. export interface IMaterialBRDFDefines {
  46516. BRDF_V_HEIGHT_CORRELATED: boolean;
  46517. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46518. SPHERICAL_HARMONICS: boolean;
  46519. /** @hidden */
  46520. _areMiscDirty: boolean;
  46521. }
  46522. /**
  46523. * Define the code related to the BRDF parameters of the pbr material.
  46524. */
  46525. export class PBRBRDFConfiguration {
  46526. /**
  46527. * Default value used for the energy conservation.
  46528. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46529. */
  46530. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46531. /**
  46532. * Default value used for the Smith Visibility Height Correlated mode.
  46533. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46534. */
  46535. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46536. /**
  46537. * Default value used for the IBL diffuse part.
  46538. * This can help switching back to the polynomials mode globally which is a tiny bit
  46539. * less GPU intensive at the drawback of a lower quality.
  46540. */
  46541. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46542. private _useEnergyConservation;
  46543. /**
  46544. * Defines if the material uses energy conservation.
  46545. */
  46546. useEnergyConservation: boolean;
  46547. private _useSmithVisibilityHeightCorrelated;
  46548. /**
  46549. * LEGACY Mode set to false
  46550. * Defines if the material uses height smith correlated visibility term.
  46551. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46552. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46553. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46554. * Not relying on height correlated will also disable energy conservation.
  46555. */
  46556. useSmithVisibilityHeightCorrelated: boolean;
  46557. private _useSphericalHarmonics;
  46558. /**
  46559. * LEGACY Mode set to false
  46560. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46561. * diffuse part of the IBL.
  46562. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46563. * to the ground truth.
  46564. */
  46565. useSphericalHarmonics: boolean;
  46566. /** @hidden */
  46567. private _internalMarkAllSubMeshesAsMiscDirty;
  46568. /** @hidden */
  46569. _markAllSubMeshesAsMiscDirty(): void;
  46570. /**
  46571. * Instantiate a new istance of clear coat configuration.
  46572. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46573. */
  46574. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46575. /**
  46576. * Checks to see if a texture is used in the material.
  46577. * @param defines the list of "defines" to update.
  46578. */
  46579. prepareDefines(defines: IMaterialBRDFDefines): void;
  46580. /**
  46581. * Get the current class name of the texture useful for serialization or dynamic coding.
  46582. * @returns "PBRClearCoatConfiguration"
  46583. */
  46584. getClassName(): string;
  46585. /**
  46586. * Makes a duplicate of the current configuration into another one.
  46587. * @param brdfConfiguration define the config where to copy the info
  46588. */
  46589. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46590. /**
  46591. * Serializes this BRDF configuration.
  46592. * @returns - An object with the serialized config.
  46593. */
  46594. serialize(): any;
  46595. /**
  46596. * Parses a BRDF Configuration from a serialized object.
  46597. * @param source - Serialized object.
  46598. */
  46599. parse(source: any): void;
  46600. }
  46601. }
  46602. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  46603. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46604. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46605. import { Color3 } from "babylonjs/Maths/math";
  46606. import { Scene } from "babylonjs/scene";
  46607. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46608. import { IAnimatable } from "babylonjs/Misc/tools";
  46609. import { Nullable } from "babylonjs/types";
  46610. /**
  46611. * @hidden
  46612. */
  46613. export interface IMaterialSheenDefines {
  46614. SHEEN: boolean;
  46615. SHEEN_TEXTURE: boolean;
  46616. SHEEN_TEXTUREDIRECTUV: number;
  46617. SHEEN_LINKWITHALBEDO: boolean;
  46618. /** @hidden */
  46619. _areTexturesDirty: boolean;
  46620. }
  46621. /**
  46622. * Define the code related to the Sheen parameters of the pbr material.
  46623. */
  46624. export class PBRSheenConfiguration {
  46625. private _isEnabled;
  46626. /**
  46627. * Defines if the material uses sheen.
  46628. */
  46629. isEnabled: boolean;
  46630. private _linkSheenWithAlbedo;
  46631. /**
  46632. * Defines if the sheen is linked to the sheen color.
  46633. */
  46634. linkSheenWithAlbedo: boolean;
  46635. /**
  46636. * Defines the sheen intensity.
  46637. */
  46638. intensity: number;
  46639. /**
  46640. * Defines the sheen color.
  46641. */
  46642. color: Color3;
  46643. private _texture;
  46644. /**
  46645. * Stores the sheen tint values in a texture.
  46646. * rgb is tint
  46647. * a is a intensity
  46648. */
  46649. texture: Nullable<BaseTexture>;
  46650. /** @hidden */
  46651. private _internalMarkAllSubMeshesAsTexturesDirty;
  46652. /** @hidden */
  46653. _markAllSubMeshesAsTexturesDirty(): void;
  46654. /**
  46655. * Instantiate a new istance of clear coat configuration.
  46656. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46657. */
  46658. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46659. /**
  46660. * Specifies that the submesh is ready to be used.
  46661. * @param defines the list of "defines" to update.
  46662. * @param scene defines the scene the material belongs to.
  46663. * @returns - boolean indicating that the submesh is ready or not.
  46664. */
  46665. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46666. /**
  46667. * Checks to see if a texture is used in the material.
  46668. * @param defines the list of "defines" to update.
  46669. * @param scene defines the scene the material belongs to.
  46670. */
  46671. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46672. /**
  46673. * Binds the material data.
  46674. * @param uniformBuffer defines the Uniform buffer to fill in.
  46675. * @param scene defines the scene the material belongs to.
  46676. * @param isFrozen defines wether the material is frozen or not.
  46677. */
  46678. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46679. /**
  46680. * Checks to see if a texture is used in the material.
  46681. * @param texture - Base texture to use.
  46682. * @returns - Boolean specifying if a texture is used in the material.
  46683. */
  46684. hasTexture(texture: BaseTexture): boolean;
  46685. /**
  46686. * Returns an array of the actively used textures.
  46687. * @param activeTextures Array of BaseTextures
  46688. */
  46689. getActiveTextures(activeTextures: BaseTexture[]): void;
  46690. /**
  46691. * Returns the animatable textures.
  46692. * @param animatables Array of animatable textures.
  46693. */
  46694. getAnimatables(animatables: IAnimatable[]): void;
  46695. /**
  46696. * Disposes the resources of the material.
  46697. * @param forceDisposeTextures - Forces the disposal of all textures.
  46698. */
  46699. dispose(forceDisposeTextures?: boolean): void;
  46700. /**
  46701. * Get the current class name of the texture useful for serialization or dynamic coding.
  46702. * @returns "PBRSheenConfiguration"
  46703. */
  46704. getClassName(): string;
  46705. /**
  46706. * Add fallbacks to the effect fallbacks list.
  46707. * @param defines defines the Base texture to use.
  46708. * @param fallbacks defines the current fallback list.
  46709. * @param currentRank defines the current fallback rank.
  46710. * @returns the new fallback rank.
  46711. */
  46712. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46713. /**
  46714. * Add the required uniforms to the current list.
  46715. * @param uniforms defines the current uniform list.
  46716. */
  46717. static AddUniforms(uniforms: string[]): void;
  46718. /**
  46719. * Add the required uniforms to the current buffer.
  46720. * @param uniformBuffer defines the current uniform buffer.
  46721. */
  46722. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46723. /**
  46724. * Add the required samplers to the current list.
  46725. * @param samplers defines the current sampler list.
  46726. */
  46727. static AddSamplers(samplers: string[]): void;
  46728. /**
  46729. * Makes a duplicate of the current configuration into another one.
  46730. * @param sheenConfiguration define the config where to copy the info
  46731. */
  46732. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46733. /**
  46734. * Serializes this BRDF configuration.
  46735. * @returns - An object with the serialized config.
  46736. */
  46737. serialize(): any;
  46738. /**
  46739. * Parses a Sheen Configuration from a serialized object.
  46740. * @param source - Serialized object.
  46741. */
  46742. parse(source: any): void;
  46743. }
  46744. }
  46745. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  46746. import { Nullable } from "babylonjs/types";
  46747. import { IAnimatable } from "babylonjs/Misc/tools";
  46748. import { Color3 } from "babylonjs/Maths/math";
  46749. import { SmartArray } from "babylonjs/Misc/smartArray";
  46750. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46751. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46752. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  46753. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46754. import { Engine } from "babylonjs/Engines/engine";
  46755. import { Scene } from "babylonjs/scene";
  46756. /**
  46757. * @hidden
  46758. */
  46759. export interface IMaterialSubSurfaceDefines {
  46760. SUBSURFACE: boolean;
  46761. SS_REFRACTION: boolean;
  46762. SS_TRANSLUCENCY: boolean;
  46763. SS_SCATERRING: boolean;
  46764. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46765. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46766. SS_REFRACTIONMAP_3D: boolean;
  46767. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46768. SS_LODINREFRACTIONALPHA: boolean;
  46769. SS_GAMMAREFRACTION: boolean;
  46770. SS_RGBDREFRACTION: boolean;
  46771. SS_LINEARSPECULARREFRACTION: boolean;
  46772. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46773. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46774. /** @hidden */
  46775. _areTexturesDirty: boolean;
  46776. }
  46777. /**
  46778. * Define the code related to the sub surface parameters of the pbr material.
  46779. */
  46780. export class PBRSubSurfaceConfiguration {
  46781. private _isRefractionEnabled;
  46782. /**
  46783. * Defines if the refraction is enabled in the material.
  46784. */
  46785. isRefractionEnabled: boolean;
  46786. private _isTranslucencyEnabled;
  46787. /**
  46788. * Defines if the translucency is enabled in the material.
  46789. */
  46790. isTranslucencyEnabled: boolean;
  46791. private _isScatteringEnabled;
  46792. /**
  46793. * Defines the refraction intensity of the material.
  46794. * The refraction when enabled replaces the Diffuse part of the material.
  46795. * The intensity helps transitionning between diffuse and refraction.
  46796. */
  46797. refractionIntensity: number;
  46798. /**
  46799. * Defines the translucency intensity of the material.
  46800. * When translucency has been enabled, this defines how much of the "translucency"
  46801. * is addded to the diffuse part of the material.
  46802. */
  46803. translucencyIntensity: number;
  46804. /**
  46805. * Defines the scattering intensity of the material.
  46806. * When scattering has been enabled, this defines how much of the "scattered light"
  46807. * is addded to the diffuse part of the material.
  46808. */
  46809. scatteringIntensity: number;
  46810. private _thicknessTexture;
  46811. /**
  46812. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46813. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46814. * 0 would mean minimumThickness
  46815. * 1 would mean maximumThickness
  46816. * The other channels might be use as a mask to vary the different effects intensity.
  46817. */
  46818. thicknessTexture: Nullable<BaseTexture>;
  46819. private _refractionTexture;
  46820. /**
  46821. * Defines the texture to use for refraction.
  46822. */
  46823. refractionTexture: Nullable<BaseTexture>;
  46824. private _indexOfRefraction;
  46825. /**
  46826. * Defines the indice of refraction used in the material.
  46827. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46828. */
  46829. indexOfRefraction: number;
  46830. private _invertRefractionY;
  46831. /**
  46832. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46833. */
  46834. invertRefractionY: boolean;
  46835. private _linkRefractionWithTransparency;
  46836. /**
  46837. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46838. * Materials half opaque for instance using refraction could benefit from this control.
  46839. */
  46840. linkRefractionWithTransparency: boolean;
  46841. /**
  46842. * Defines the minimum thickness stored in the thickness map.
  46843. * If no thickness map is defined, this value will be used to simulate thickness.
  46844. */
  46845. minimumThickness: number;
  46846. /**
  46847. * Defines the maximum thickness stored in the thickness map.
  46848. */
  46849. maximumThickness: number;
  46850. /**
  46851. * Defines the volume tint of the material.
  46852. * This is used for both translucency and scattering.
  46853. */
  46854. tintColor: Color3;
  46855. /**
  46856. * Defines the distance at which the tint color should be found in the media.
  46857. * This is used for refraction only.
  46858. */
  46859. tintColorAtDistance: number;
  46860. /**
  46861. * Defines how far each channel transmit through the media.
  46862. * It is defined as a color to simplify it selection.
  46863. */
  46864. diffusionDistance: Color3;
  46865. private _useMaskFromThicknessTexture;
  46866. /**
  46867. * Stores the intensity of the different subsurface effects in the thickness texture.
  46868. * * the green channel is the translucency intensity.
  46869. * * the blue channel is the scattering intensity.
  46870. * * the alpha channel is the refraction intensity.
  46871. */
  46872. useMaskFromThicknessTexture: boolean;
  46873. /** @hidden */
  46874. private _internalMarkAllSubMeshesAsTexturesDirty;
  46875. /** @hidden */
  46876. _markAllSubMeshesAsTexturesDirty(): void;
  46877. /**
  46878. * Instantiate a new istance of sub surface configuration.
  46879. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46880. */
  46881. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46882. /**
  46883. * Gets wehter the submesh is ready to be used or not.
  46884. * @param defines the list of "defines" to update.
  46885. * @param scene defines the scene the material belongs to.
  46886. * @returns - boolean indicating that the submesh is ready or not.
  46887. */
  46888. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46889. /**
  46890. * Checks to see if a texture is used in the material.
  46891. * @param defines the list of "defines" to update.
  46892. * @param scene defines the scene to the material belongs to.
  46893. */
  46894. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46895. /**
  46896. * Binds the material data.
  46897. * @param uniformBuffer defines the Uniform buffer to fill in.
  46898. * @param scene defines the scene the material belongs to.
  46899. * @param engine defines the engine the material belongs to.
  46900. * @param isFrozen defines wether the material is frozen or not.
  46901. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46902. */
  46903. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46904. /**
  46905. * Unbinds the material from the mesh.
  46906. * @param activeEffect defines the effect that should be unbound from.
  46907. * @returns true if unbound, otherwise false
  46908. */
  46909. unbind(activeEffect: Effect): boolean;
  46910. /**
  46911. * Returns the texture used for refraction or null if none is used.
  46912. * @param scene defines the scene the material belongs to.
  46913. * @returns - Refraction texture if present. If no refraction texture and refraction
  46914. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46915. */
  46916. private _getRefractionTexture;
  46917. /**
  46918. * Returns true if alpha blending should be disabled.
  46919. */
  46920. readonly disableAlphaBlending: boolean;
  46921. /**
  46922. * Fills the list of render target textures.
  46923. * @param renderTargets the list of render targets to update
  46924. */
  46925. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46926. /**
  46927. * Checks to see if a texture is used in the material.
  46928. * @param texture - Base texture to use.
  46929. * @returns - Boolean specifying if a texture is used in the material.
  46930. */
  46931. hasTexture(texture: BaseTexture): boolean;
  46932. /**
  46933. * Gets a boolean indicating that current material needs to register RTT
  46934. * @returns true if this uses a render target otherwise false.
  46935. */
  46936. hasRenderTargetTextures(): boolean;
  46937. /**
  46938. * Returns an array of the actively used textures.
  46939. * @param activeTextures Array of BaseTextures
  46940. */
  46941. getActiveTextures(activeTextures: BaseTexture[]): void;
  46942. /**
  46943. * Returns the animatable textures.
  46944. * @param animatables Array of animatable textures.
  46945. */
  46946. getAnimatables(animatables: IAnimatable[]): void;
  46947. /**
  46948. * Disposes the resources of the material.
  46949. * @param forceDisposeTextures - Forces the disposal of all textures.
  46950. */
  46951. dispose(forceDisposeTextures?: boolean): void;
  46952. /**
  46953. * Get the current class name of the texture useful for serialization or dynamic coding.
  46954. * @returns "PBRSubSurfaceConfiguration"
  46955. */
  46956. getClassName(): string;
  46957. /**
  46958. * Add fallbacks to the effect fallbacks list.
  46959. * @param defines defines the Base texture to use.
  46960. * @param fallbacks defines the current fallback list.
  46961. * @param currentRank defines the current fallback rank.
  46962. * @returns the new fallback rank.
  46963. */
  46964. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46965. /**
  46966. * Add the required uniforms to the current list.
  46967. * @param uniforms defines the current uniform list.
  46968. */
  46969. static AddUniforms(uniforms: string[]): void;
  46970. /**
  46971. * Add the required samplers to the current list.
  46972. * @param samplers defines the current sampler list.
  46973. */
  46974. static AddSamplers(samplers: string[]): void;
  46975. /**
  46976. * Add the required uniforms to the current buffer.
  46977. * @param uniformBuffer defines the current uniform buffer.
  46978. */
  46979. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46980. /**
  46981. * Makes a duplicate of the current configuration into another one.
  46982. * @param configuration define the config where to copy the info
  46983. */
  46984. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46985. /**
  46986. * Serializes this Sub Surface configuration.
  46987. * @returns - An object with the serialized config.
  46988. */
  46989. serialize(): any;
  46990. /**
  46991. * Parses a Sub Surface Configuration from a serialized object.
  46992. * @param source - Serialized object.
  46993. */
  46994. parse(source: any): void;
  46995. }
  46996. }
  46997. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  46998. /** @hidden */
  46999. export var pbrFragmentDeclaration: {
  47000. name: string;
  47001. shader: string;
  47002. };
  47003. }
  47004. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  47005. /** @hidden */
  47006. export var pbrUboDeclaration: {
  47007. name: string;
  47008. shader: string;
  47009. };
  47010. }
  47011. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  47012. /** @hidden */
  47013. export var pbrFragmentExtraDeclaration: {
  47014. name: string;
  47015. shader: string;
  47016. };
  47017. }
  47018. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  47019. /** @hidden */
  47020. export var pbrFragmentSamplersDeclaration: {
  47021. name: string;
  47022. shader: string;
  47023. };
  47024. }
  47025. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  47026. /** @hidden */
  47027. export var pbrHelperFunctions: {
  47028. name: string;
  47029. shader: string;
  47030. };
  47031. }
  47032. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  47033. /** @hidden */
  47034. export var harmonicsFunctions: {
  47035. name: string;
  47036. shader: string;
  47037. };
  47038. }
  47039. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  47040. /** @hidden */
  47041. export var pbrDirectLightingSetupFunctions: {
  47042. name: string;
  47043. shader: string;
  47044. };
  47045. }
  47046. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  47047. /** @hidden */
  47048. export var pbrDirectLightingFalloffFunctions: {
  47049. name: string;
  47050. shader: string;
  47051. };
  47052. }
  47053. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  47054. /** @hidden */
  47055. export var pbrBRDFFunctions: {
  47056. name: string;
  47057. shader: string;
  47058. };
  47059. }
  47060. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  47061. /** @hidden */
  47062. export var pbrDirectLightingFunctions: {
  47063. name: string;
  47064. shader: string;
  47065. };
  47066. }
  47067. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  47068. /** @hidden */
  47069. export var pbrIBLFunctions: {
  47070. name: string;
  47071. shader: string;
  47072. };
  47073. }
  47074. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  47075. /** @hidden */
  47076. export var pbrDebug: {
  47077. name: string;
  47078. shader: string;
  47079. };
  47080. }
  47081. declare module "babylonjs/Shaders/pbr.fragment" {
  47082. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  47083. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47084. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  47085. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47086. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47087. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  47088. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47089. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47090. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47091. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47092. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47093. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  47094. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47095. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47096. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47097. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  47098. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  47099. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  47100. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  47101. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  47102. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  47103. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47104. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47105. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  47106. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  47107. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47108. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  47109. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47110. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  47111. /** @hidden */
  47112. export var pbrPixelShader: {
  47113. name: string;
  47114. shader: string;
  47115. };
  47116. }
  47117. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  47118. /** @hidden */
  47119. export var pbrVertexDeclaration: {
  47120. name: string;
  47121. shader: string;
  47122. };
  47123. }
  47124. declare module "babylonjs/Shaders/pbr.vertex" {
  47125. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  47126. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47127. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47128. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47129. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47130. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47131. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  47132. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47133. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47134. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47135. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47136. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  47137. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  47138. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47139. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  47140. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47141. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47142. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  47143. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47144. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47145. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47146. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  47147. /** @hidden */
  47148. export var pbrVertexShader: {
  47149. name: string;
  47150. shader: string;
  47151. };
  47152. }
  47153. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  47154. import { IAnimatable } from "babylonjs/Misc/tools";
  47155. import { Nullable } from "babylonjs/types";
  47156. import { Scene } from "babylonjs/scene";
  47157. import { Matrix, Color3 } from "babylonjs/Maths/math";
  47158. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47160. import { Mesh } from "babylonjs/Meshes/mesh";
  47161. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  47162. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  47163. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  47164. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  47165. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  47166. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  47167. import { Material } from "babylonjs/Materials/material";
  47168. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  47169. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47170. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47171. import "babylonjs/Shaders/pbr.fragment";
  47172. import "babylonjs/Shaders/pbr.vertex";
  47173. /**
  47174. * Manages the defines for the PBR Material.
  47175. * @hidden
  47176. */
  47177. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  47178. PBR: boolean;
  47179. MAINUV1: boolean;
  47180. MAINUV2: boolean;
  47181. UV1: boolean;
  47182. UV2: boolean;
  47183. ALBEDO: boolean;
  47184. ALBEDODIRECTUV: number;
  47185. VERTEXCOLOR: boolean;
  47186. AMBIENT: boolean;
  47187. AMBIENTDIRECTUV: number;
  47188. AMBIENTINGRAYSCALE: boolean;
  47189. OPACITY: boolean;
  47190. VERTEXALPHA: boolean;
  47191. OPACITYDIRECTUV: number;
  47192. OPACITYRGB: boolean;
  47193. ALPHATEST: boolean;
  47194. DEPTHPREPASS: boolean;
  47195. ALPHABLEND: boolean;
  47196. ALPHAFROMALBEDO: boolean;
  47197. ALPHATESTVALUE: string;
  47198. SPECULAROVERALPHA: boolean;
  47199. RADIANCEOVERALPHA: boolean;
  47200. ALPHAFRESNEL: boolean;
  47201. LINEARALPHAFRESNEL: boolean;
  47202. PREMULTIPLYALPHA: boolean;
  47203. EMISSIVE: boolean;
  47204. EMISSIVEDIRECTUV: number;
  47205. REFLECTIVITY: boolean;
  47206. REFLECTIVITYDIRECTUV: number;
  47207. SPECULARTERM: boolean;
  47208. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47209. MICROSURFACEAUTOMATIC: boolean;
  47210. LODBASEDMICROSFURACE: boolean;
  47211. MICROSURFACEMAP: boolean;
  47212. MICROSURFACEMAPDIRECTUV: number;
  47213. METALLICWORKFLOW: boolean;
  47214. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  47215. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  47216. METALLNESSSTOREINMETALMAPBLUE: boolean;
  47217. AOSTOREINMETALMAPRED: boolean;
  47218. ENVIRONMENTBRDF: boolean;
  47219. ENVIRONMENTBRDF_RGBD: boolean;
  47220. NORMAL: boolean;
  47221. TANGENT: boolean;
  47222. BUMP: boolean;
  47223. BUMPDIRECTUV: number;
  47224. OBJECTSPACE_NORMALMAP: boolean;
  47225. PARALLAX: boolean;
  47226. PARALLAXOCCLUSION: boolean;
  47227. NORMALXYSCALE: boolean;
  47228. LIGHTMAP: boolean;
  47229. LIGHTMAPDIRECTUV: number;
  47230. USELIGHTMAPASSHADOWMAP: boolean;
  47231. GAMMALIGHTMAP: boolean;
  47232. REFLECTION: boolean;
  47233. REFLECTIONMAP_3D: boolean;
  47234. REFLECTIONMAP_SPHERICAL: boolean;
  47235. REFLECTIONMAP_PLANAR: boolean;
  47236. REFLECTIONMAP_CUBIC: boolean;
  47237. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  47238. REFLECTIONMAP_PROJECTION: boolean;
  47239. REFLECTIONMAP_SKYBOX: boolean;
  47240. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  47241. REFLECTIONMAP_EXPLICIT: boolean;
  47242. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  47243. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  47244. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  47245. INVERTCUBICMAP: boolean;
  47246. USESPHERICALFROMREFLECTIONMAP: boolean;
  47247. USEIRRADIANCEMAP: boolean;
  47248. SPHERICAL_HARMONICS: boolean;
  47249. USESPHERICALINVERTEX: boolean;
  47250. REFLECTIONMAP_OPPOSITEZ: boolean;
  47251. LODINREFLECTIONALPHA: boolean;
  47252. GAMMAREFLECTION: boolean;
  47253. RGBDREFLECTION: boolean;
  47254. LINEARSPECULARREFLECTION: boolean;
  47255. RADIANCEOCCLUSION: boolean;
  47256. HORIZONOCCLUSION: boolean;
  47257. INSTANCES: boolean;
  47258. NUM_BONE_INFLUENCERS: number;
  47259. BonesPerMesh: number;
  47260. BONETEXTURE: boolean;
  47261. NONUNIFORMSCALING: boolean;
  47262. MORPHTARGETS: boolean;
  47263. MORPHTARGETS_NORMAL: boolean;
  47264. MORPHTARGETS_TANGENT: boolean;
  47265. NUM_MORPH_INFLUENCERS: number;
  47266. IMAGEPROCESSING: boolean;
  47267. VIGNETTE: boolean;
  47268. VIGNETTEBLENDMODEMULTIPLY: boolean;
  47269. VIGNETTEBLENDMODEOPAQUE: boolean;
  47270. TONEMAPPING: boolean;
  47271. TONEMAPPING_ACES: boolean;
  47272. CONTRAST: boolean;
  47273. COLORCURVES: boolean;
  47274. COLORGRADING: boolean;
  47275. COLORGRADING3D: boolean;
  47276. SAMPLER3DGREENDEPTH: boolean;
  47277. SAMPLER3DBGRMAP: boolean;
  47278. IMAGEPROCESSINGPOSTPROCESS: boolean;
  47279. EXPOSURE: boolean;
  47280. MULTIVIEW: boolean;
  47281. USEPHYSICALLIGHTFALLOFF: boolean;
  47282. USEGLTFLIGHTFALLOFF: boolean;
  47283. TWOSIDEDLIGHTING: boolean;
  47284. SHADOWFLOAT: boolean;
  47285. CLIPPLANE: boolean;
  47286. CLIPPLANE2: boolean;
  47287. CLIPPLANE3: boolean;
  47288. CLIPPLANE4: boolean;
  47289. POINTSIZE: boolean;
  47290. FOG: boolean;
  47291. LOGARITHMICDEPTH: boolean;
  47292. FORCENORMALFORWARD: boolean;
  47293. SPECULARAA: boolean;
  47294. CLEARCOAT: boolean;
  47295. CLEARCOAT_DEFAULTIOR: boolean;
  47296. CLEARCOAT_TEXTURE: boolean;
  47297. CLEARCOAT_TEXTUREDIRECTUV: number;
  47298. CLEARCOAT_BUMP: boolean;
  47299. CLEARCOAT_BUMPDIRECTUV: number;
  47300. CLEARCOAT_TINT: boolean;
  47301. CLEARCOAT_TINT_TEXTURE: boolean;
  47302. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47303. ANISOTROPIC: boolean;
  47304. ANISOTROPIC_TEXTURE: boolean;
  47305. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47306. BRDF_V_HEIGHT_CORRELATED: boolean;
  47307. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47308. SHEEN: boolean;
  47309. SHEEN_TEXTURE: boolean;
  47310. SHEEN_TEXTUREDIRECTUV: number;
  47311. SHEEN_LINKWITHALBEDO: boolean;
  47312. SUBSURFACE: boolean;
  47313. SS_REFRACTION: boolean;
  47314. SS_TRANSLUCENCY: boolean;
  47315. SS_SCATERRING: boolean;
  47316. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47317. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47318. SS_REFRACTIONMAP_3D: boolean;
  47319. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47320. SS_LODINREFRACTIONALPHA: boolean;
  47321. SS_GAMMAREFRACTION: boolean;
  47322. SS_RGBDREFRACTION: boolean;
  47323. SS_LINEARSPECULARREFRACTION: boolean;
  47324. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47325. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47326. UNLIT: boolean;
  47327. DEBUGMODE: number;
  47328. /**
  47329. * Initializes the PBR Material defines.
  47330. */
  47331. constructor();
  47332. /**
  47333. * Resets the PBR Material defines.
  47334. */
  47335. reset(): void;
  47336. }
  47337. /**
  47338. * The Physically based material base class of BJS.
  47339. *
  47340. * This offers the main features of a standard PBR material.
  47341. * For more information, please refer to the documentation :
  47342. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47343. */
  47344. export abstract class PBRBaseMaterial extends PushMaterial {
  47345. /**
  47346. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47347. */
  47348. static readonly PBRMATERIAL_OPAQUE: number;
  47349. /**
  47350. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47351. */
  47352. static readonly PBRMATERIAL_ALPHATEST: number;
  47353. /**
  47354. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47355. */
  47356. static readonly PBRMATERIAL_ALPHABLEND: number;
  47357. /**
  47358. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47359. * They are also discarded below the alpha cutoff threshold to improve performances.
  47360. */
  47361. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47362. /**
  47363. * Defines the default value of how much AO map is occluding the analytical lights
  47364. * (point spot...).
  47365. */
  47366. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47367. /**
  47368. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47369. */
  47370. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47371. /**
  47372. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47373. * to enhance interoperability with other engines.
  47374. */
  47375. static readonly LIGHTFALLOFF_GLTF: number;
  47376. /**
  47377. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47378. * to enhance interoperability with other materials.
  47379. */
  47380. static readonly LIGHTFALLOFF_STANDARD: number;
  47381. /**
  47382. * Intensity of the direct lights e.g. the four lights available in your scene.
  47383. * This impacts both the direct diffuse and specular highlights.
  47384. */
  47385. protected _directIntensity: number;
  47386. /**
  47387. * Intensity of the emissive part of the material.
  47388. * This helps controlling the emissive effect without modifying the emissive color.
  47389. */
  47390. protected _emissiveIntensity: number;
  47391. /**
  47392. * Intensity of the environment e.g. how much the environment will light the object
  47393. * either through harmonics for rough material or through the refelction for shiny ones.
  47394. */
  47395. protected _environmentIntensity: number;
  47396. /**
  47397. * This is a special control allowing the reduction of the specular highlights coming from the
  47398. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47399. */
  47400. protected _specularIntensity: number;
  47401. /**
  47402. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47403. */
  47404. private _lightingInfos;
  47405. /**
  47406. * Debug Control allowing disabling the bump map on this material.
  47407. */
  47408. protected _disableBumpMap: boolean;
  47409. /**
  47410. * AKA Diffuse Texture in standard nomenclature.
  47411. */
  47412. protected _albedoTexture: Nullable<BaseTexture>;
  47413. /**
  47414. * AKA Occlusion Texture in other nomenclature.
  47415. */
  47416. protected _ambientTexture: Nullable<BaseTexture>;
  47417. /**
  47418. * AKA Occlusion Texture Intensity in other nomenclature.
  47419. */
  47420. protected _ambientTextureStrength: number;
  47421. /**
  47422. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47423. * 1 means it completely occludes it
  47424. * 0 mean it has no impact
  47425. */
  47426. protected _ambientTextureImpactOnAnalyticalLights: number;
  47427. /**
  47428. * Stores the alpha values in a texture.
  47429. */
  47430. protected _opacityTexture: Nullable<BaseTexture>;
  47431. /**
  47432. * Stores the reflection values in a texture.
  47433. */
  47434. protected _reflectionTexture: Nullable<BaseTexture>;
  47435. /**
  47436. * Stores the emissive values in a texture.
  47437. */
  47438. protected _emissiveTexture: Nullable<BaseTexture>;
  47439. /**
  47440. * AKA Specular texture in other nomenclature.
  47441. */
  47442. protected _reflectivityTexture: Nullable<BaseTexture>;
  47443. /**
  47444. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47445. */
  47446. protected _metallicTexture: Nullable<BaseTexture>;
  47447. /**
  47448. * Specifies the metallic scalar of the metallic/roughness workflow.
  47449. * Can also be used to scale the metalness values of the metallic texture.
  47450. */
  47451. protected _metallic: Nullable<number>;
  47452. /**
  47453. * Specifies the roughness scalar of the metallic/roughness workflow.
  47454. * Can also be used to scale the roughness values of the metallic texture.
  47455. */
  47456. protected _roughness: Nullable<number>;
  47457. /**
  47458. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47459. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47460. */
  47461. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47462. /**
  47463. * Stores surface normal data used to displace a mesh in a texture.
  47464. */
  47465. protected _bumpTexture: Nullable<BaseTexture>;
  47466. /**
  47467. * Stores the pre-calculated light information of a mesh in a texture.
  47468. */
  47469. protected _lightmapTexture: Nullable<BaseTexture>;
  47470. /**
  47471. * The color of a material in ambient lighting.
  47472. */
  47473. protected _ambientColor: Color3;
  47474. /**
  47475. * AKA Diffuse Color in other nomenclature.
  47476. */
  47477. protected _albedoColor: Color3;
  47478. /**
  47479. * AKA Specular Color in other nomenclature.
  47480. */
  47481. protected _reflectivityColor: Color3;
  47482. /**
  47483. * The color applied when light is reflected from a material.
  47484. */
  47485. protected _reflectionColor: Color3;
  47486. /**
  47487. * The color applied when light is emitted from a material.
  47488. */
  47489. protected _emissiveColor: Color3;
  47490. /**
  47491. * AKA Glossiness in other nomenclature.
  47492. */
  47493. protected _microSurface: number;
  47494. /**
  47495. * Specifies that the material will use the light map as a show map.
  47496. */
  47497. protected _useLightmapAsShadowmap: boolean;
  47498. /**
  47499. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47500. * makes the reflect vector face the model (under horizon).
  47501. */
  47502. protected _useHorizonOcclusion: boolean;
  47503. /**
  47504. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47505. * too much the area relying on ambient texture to define their ambient occlusion.
  47506. */
  47507. protected _useRadianceOcclusion: boolean;
  47508. /**
  47509. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47510. */
  47511. protected _useAlphaFromAlbedoTexture: boolean;
  47512. /**
  47513. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47514. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47515. */
  47516. protected _useSpecularOverAlpha: boolean;
  47517. /**
  47518. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47519. */
  47520. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47521. /**
  47522. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47523. */
  47524. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47525. /**
  47526. * Specifies if the metallic texture contains the roughness information in its green channel.
  47527. */
  47528. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47529. /**
  47530. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47531. */
  47532. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47533. /**
  47534. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47535. */
  47536. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47537. /**
  47538. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47539. */
  47540. protected _useAmbientInGrayScale: boolean;
  47541. /**
  47542. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47543. * The material will try to infer what glossiness each pixel should be.
  47544. */
  47545. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47546. /**
  47547. * Defines the falloff type used in this material.
  47548. * It by default is Physical.
  47549. */
  47550. protected _lightFalloff: number;
  47551. /**
  47552. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47553. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47554. */
  47555. protected _useRadianceOverAlpha: boolean;
  47556. /**
  47557. * Allows using an object space normal map (instead of tangent space).
  47558. */
  47559. protected _useObjectSpaceNormalMap: boolean;
  47560. /**
  47561. * Allows using the bump map in parallax mode.
  47562. */
  47563. protected _useParallax: boolean;
  47564. /**
  47565. * Allows using the bump map in parallax occlusion mode.
  47566. */
  47567. protected _useParallaxOcclusion: boolean;
  47568. /**
  47569. * Controls the scale bias of the parallax mode.
  47570. */
  47571. protected _parallaxScaleBias: number;
  47572. /**
  47573. * If sets to true, disables all the lights affecting the material.
  47574. */
  47575. protected _disableLighting: boolean;
  47576. /**
  47577. * Number of Simultaneous lights allowed on the material.
  47578. */
  47579. protected _maxSimultaneousLights: number;
  47580. /**
  47581. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47582. */
  47583. protected _invertNormalMapX: boolean;
  47584. /**
  47585. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47586. */
  47587. protected _invertNormalMapY: boolean;
  47588. /**
  47589. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47590. */
  47591. protected _twoSidedLighting: boolean;
  47592. /**
  47593. * Defines the alpha limits in alpha test mode.
  47594. */
  47595. protected _alphaCutOff: number;
  47596. /**
  47597. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47598. */
  47599. protected _forceAlphaTest: boolean;
  47600. /**
  47601. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47602. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47603. */
  47604. protected _useAlphaFresnel: boolean;
  47605. /**
  47606. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47607. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47608. */
  47609. protected _useLinearAlphaFresnel: boolean;
  47610. /**
  47611. * The transparency mode of the material.
  47612. */
  47613. protected _transparencyMode: Nullable<number>;
  47614. /**
  47615. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47616. * from cos thetav and roughness:
  47617. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47618. */
  47619. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47620. /**
  47621. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47622. */
  47623. protected _forceIrradianceInFragment: boolean;
  47624. /**
  47625. * Force normal to face away from face.
  47626. */
  47627. protected _forceNormalForward: boolean;
  47628. /**
  47629. * Enables specular anti aliasing in the PBR shader.
  47630. * It will both interacts on the Geometry for analytical and IBL lighting.
  47631. * It also prefilter the roughness map based on the bump values.
  47632. */
  47633. protected _enableSpecularAntiAliasing: boolean;
  47634. /**
  47635. * Default configuration related to image processing available in the PBR Material.
  47636. */
  47637. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47638. /**
  47639. * Keep track of the image processing observer to allow dispose and replace.
  47640. */
  47641. private _imageProcessingObserver;
  47642. /**
  47643. * Attaches a new image processing configuration to the PBR Material.
  47644. * @param configuration
  47645. */
  47646. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47647. /**
  47648. * Stores the available render targets.
  47649. */
  47650. private _renderTargets;
  47651. /**
  47652. * Sets the global ambient color for the material used in lighting calculations.
  47653. */
  47654. private _globalAmbientColor;
  47655. /**
  47656. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47657. */
  47658. private _useLogarithmicDepth;
  47659. /**
  47660. * If set to true, no lighting calculations will be applied.
  47661. */
  47662. private _unlit;
  47663. private _debugMode;
  47664. /**
  47665. * @hidden
  47666. * This is reserved for the inspector.
  47667. * Defines the material debug mode.
  47668. * It helps seeing only some components of the material while troubleshooting.
  47669. */
  47670. debugMode: number;
  47671. /**
  47672. * @hidden
  47673. * This is reserved for the inspector.
  47674. * Specify from where on screen the debug mode should start.
  47675. * The value goes from -1 (full screen) to 1 (not visible)
  47676. * It helps with side by side comparison against the final render
  47677. * This defaults to -1
  47678. */
  47679. private debugLimit;
  47680. /**
  47681. * @hidden
  47682. * This is reserved for the inspector.
  47683. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47684. * You can use the factor to better multiply the final value.
  47685. */
  47686. private debugFactor;
  47687. /**
  47688. * Defines the clear coat layer parameters for the material.
  47689. */
  47690. readonly clearCoat: PBRClearCoatConfiguration;
  47691. /**
  47692. * Defines the anisotropic parameters for the material.
  47693. */
  47694. readonly anisotropy: PBRAnisotropicConfiguration;
  47695. /**
  47696. * Defines the BRDF parameters for the material.
  47697. */
  47698. readonly brdf: PBRBRDFConfiguration;
  47699. /**
  47700. * Defines the Sheen parameters for the material.
  47701. */
  47702. readonly sheen: PBRSheenConfiguration;
  47703. /**
  47704. * Defines the SubSurface parameters for the material.
  47705. */
  47706. readonly subSurface: PBRSubSurfaceConfiguration;
  47707. /**
  47708. * Custom callback helping to override the default shader used in the material.
  47709. */
  47710. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47711. /**
  47712. * Instantiates a new PBRMaterial instance.
  47713. *
  47714. * @param name The material name
  47715. * @param scene The scene the material will be use in.
  47716. */
  47717. constructor(name: string, scene: Scene);
  47718. /**
  47719. * Gets a boolean indicating that current material needs to register RTT
  47720. */
  47721. readonly hasRenderTargetTextures: boolean;
  47722. /**
  47723. * Gets the name of the material class.
  47724. */
  47725. getClassName(): string;
  47726. /**
  47727. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47728. */
  47729. /**
  47730. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47731. */
  47732. useLogarithmicDepth: boolean;
  47733. /**
  47734. * Gets the current transparency mode.
  47735. */
  47736. /**
  47737. * Sets the transparency mode of the material.
  47738. *
  47739. * | Value | Type | Description |
  47740. * | ----- | ----------------------------------- | ----------- |
  47741. * | 0 | OPAQUE | |
  47742. * | 1 | ALPHATEST | |
  47743. * | 2 | ALPHABLEND | |
  47744. * | 3 | ALPHATESTANDBLEND | |
  47745. *
  47746. */
  47747. transparencyMode: Nullable<number>;
  47748. /**
  47749. * Returns true if alpha blending should be disabled.
  47750. */
  47751. private readonly _disableAlphaBlending;
  47752. /**
  47753. * Specifies whether or not this material should be rendered in alpha blend mode.
  47754. */
  47755. needAlphaBlending(): boolean;
  47756. /**
  47757. * Specifies if the mesh will require alpha blending.
  47758. * @param mesh - BJS mesh.
  47759. */
  47760. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47761. /**
  47762. * Specifies whether or not this material should be rendered in alpha test mode.
  47763. */
  47764. needAlphaTesting(): boolean;
  47765. /**
  47766. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47767. */
  47768. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47769. /**
  47770. * Gets the texture used for the alpha test.
  47771. */
  47772. getAlphaTestTexture(): Nullable<BaseTexture>;
  47773. /**
  47774. * Specifies that the submesh is ready to be used.
  47775. * @param mesh - BJS mesh.
  47776. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47777. * @param useInstances - Specifies that instances should be used.
  47778. * @returns - boolean indicating that the submesh is ready or not.
  47779. */
  47780. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47781. /**
  47782. * Specifies if the material uses metallic roughness workflow.
  47783. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47784. */
  47785. isMetallicWorkflow(): boolean;
  47786. private _prepareEffect;
  47787. private _prepareDefines;
  47788. /**
  47789. * Force shader compilation
  47790. */
  47791. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47792. clipPlane: boolean;
  47793. }>): void;
  47794. /**
  47795. * Initializes the uniform buffer layout for the shader.
  47796. */
  47797. buildUniformLayout(): void;
  47798. /**
  47799. * Unbinds the material from the mesh
  47800. */
  47801. unbind(): void;
  47802. /**
  47803. * Binds the submesh data.
  47804. * @param world - The world matrix.
  47805. * @param mesh - The BJS mesh.
  47806. * @param subMesh - A submesh of the BJS mesh.
  47807. */
  47808. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47809. /**
  47810. * Returns the animatable textures.
  47811. * @returns - Array of animatable textures.
  47812. */
  47813. getAnimatables(): IAnimatable[];
  47814. /**
  47815. * Returns the texture used for reflections.
  47816. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47817. */
  47818. private _getReflectionTexture;
  47819. /**
  47820. * Returns an array of the actively used textures.
  47821. * @returns - Array of BaseTextures
  47822. */
  47823. getActiveTextures(): BaseTexture[];
  47824. /**
  47825. * Checks to see if a texture is used in the material.
  47826. * @param texture - Base texture to use.
  47827. * @returns - Boolean specifying if a texture is used in the material.
  47828. */
  47829. hasTexture(texture: BaseTexture): boolean;
  47830. /**
  47831. * Disposes the resources of the material.
  47832. * @param forceDisposeEffect - Forces the disposal of effects.
  47833. * @param forceDisposeTextures - Forces the disposal of all textures.
  47834. */
  47835. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47836. }
  47837. }
  47838. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  47839. import { Nullable } from "babylonjs/types";
  47840. import { Scene } from "babylonjs/scene";
  47841. import { Color3 } from "babylonjs/Maths/math";
  47842. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47843. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47844. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47845. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47846. /**
  47847. * The Physically based material of BJS.
  47848. *
  47849. * This offers the main features of a standard PBR material.
  47850. * For more information, please refer to the documentation :
  47851. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47852. */
  47853. export class PBRMaterial extends PBRBaseMaterial {
  47854. /**
  47855. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47856. */
  47857. static readonly PBRMATERIAL_OPAQUE: number;
  47858. /**
  47859. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47860. */
  47861. static readonly PBRMATERIAL_ALPHATEST: number;
  47862. /**
  47863. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47864. */
  47865. static readonly PBRMATERIAL_ALPHABLEND: number;
  47866. /**
  47867. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47868. * They are also discarded below the alpha cutoff threshold to improve performances.
  47869. */
  47870. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47871. /**
  47872. * Defines the default value of how much AO map is occluding the analytical lights
  47873. * (point spot...).
  47874. */
  47875. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47876. /**
  47877. * Intensity of the direct lights e.g. the four lights available in your scene.
  47878. * This impacts both the direct diffuse and specular highlights.
  47879. */
  47880. directIntensity: number;
  47881. /**
  47882. * Intensity of the emissive part of the material.
  47883. * This helps controlling the emissive effect without modifying the emissive color.
  47884. */
  47885. emissiveIntensity: number;
  47886. /**
  47887. * Intensity of the environment e.g. how much the environment will light the object
  47888. * either through harmonics for rough material or through the refelction for shiny ones.
  47889. */
  47890. environmentIntensity: number;
  47891. /**
  47892. * This is a special control allowing the reduction of the specular highlights coming from the
  47893. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47894. */
  47895. specularIntensity: number;
  47896. /**
  47897. * Debug Control allowing disabling the bump map on this material.
  47898. */
  47899. disableBumpMap: boolean;
  47900. /**
  47901. * AKA Diffuse Texture in standard nomenclature.
  47902. */
  47903. albedoTexture: BaseTexture;
  47904. /**
  47905. * AKA Occlusion Texture in other nomenclature.
  47906. */
  47907. ambientTexture: BaseTexture;
  47908. /**
  47909. * AKA Occlusion Texture Intensity in other nomenclature.
  47910. */
  47911. ambientTextureStrength: number;
  47912. /**
  47913. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47914. * 1 means it completely occludes it
  47915. * 0 mean it has no impact
  47916. */
  47917. ambientTextureImpactOnAnalyticalLights: number;
  47918. /**
  47919. * Stores the alpha values in a texture.
  47920. */
  47921. opacityTexture: BaseTexture;
  47922. /**
  47923. * Stores the reflection values in a texture.
  47924. */
  47925. reflectionTexture: Nullable<BaseTexture>;
  47926. /**
  47927. * Stores the emissive values in a texture.
  47928. */
  47929. emissiveTexture: BaseTexture;
  47930. /**
  47931. * AKA Specular texture in other nomenclature.
  47932. */
  47933. reflectivityTexture: BaseTexture;
  47934. /**
  47935. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47936. */
  47937. metallicTexture: BaseTexture;
  47938. /**
  47939. * Specifies the metallic scalar of the metallic/roughness workflow.
  47940. * Can also be used to scale the metalness values of the metallic texture.
  47941. */
  47942. metallic: Nullable<number>;
  47943. /**
  47944. * Specifies the roughness scalar of the metallic/roughness workflow.
  47945. * Can also be used to scale the roughness values of the metallic texture.
  47946. */
  47947. roughness: Nullable<number>;
  47948. /**
  47949. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47950. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47951. */
  47952. microSurfaceTexture: BaseTexture;
  47953. /**
  47954. * Stores surface normal data used to displace a mesh in a texture.
  47955. */
  47956. bumpTexture: BaseTexture;
  47957. /**
  47958. * Stores the pre-calculated light information of a mesh in a texture.
  47959. */
  47960. lightmapTexture: BaseTexture;
  47961. /**
  47962. * Stores the refracted light information in a texture.
  47963. */
  47964. refractionTexture: Nullable<BaseTexture>;
  47965. /**
  47966. * The color of a material in ambient lighting.
  47967. */
  47968. ambientColor: Color3;
  47969. /**
  47970. * AKA Diffuse Color in other nomenclature.
  47971. */
  47972. albedoColor: Color3;
  47973. /**
  47974. * AKA Specular Color in other nomenclature.
  47975. */
  47976. reflectivityColor: Color3;
  47977. /**
  47978. * The color reflected from the material.
  47979. */
  47980. reflectionColor: Color3;
  47981. /**
  47982. * The color emitted from the material.
  47983. */
  47984. emissiveColor: Color3;
  47985. /**
  47986. * AKA Glossiness in other nomenclature.
  47987. */
  47988. microSurface: number;
  47989. /**
  47990. * source material index of refraction (IOR)' / 'destination material IOR.
  47991. */
  47992. indexOfRefraction: number;
  47993. /**
  47994. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47995. */
  47996. invertRefractionY: boolean;
  47997. /**
  47998. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47999. * Materials half opaque for instance using refraction could benefit from this control.
  48000. */
  48001. linkRefractionWithTransparency: boolean;
  48002. /**
  48003. * If true, the light map contains occlusion information instead of lighting info.
  48004. */
  48005. useLightmapAsShadowmap: boolean;
  48006. /**
  48007. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48008. */
  48009. useAlphaFromAlbedoTexture: boolean;
  48010. /**
  48011. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48012. */
  48013. forceAlphaTest: boolean;
  48014. /**
  48015. * Defines the alpha limits in alpha test mode.
  48016. */
  48017. alphaCutOff: number;
  48018. /**
  48019. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48020. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48021. */
  48022. useSpecularOverAlpha: boolean;
  48023. /**
  48024. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48025. */
  48026. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48027. /**
  48028. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48029. */
  48030. useRoughnessFromMetallicTextureAlpha: boolean;
  48031. /**
  48032. * Specifies if the metallic texture contains the roughness information in its green channel.
  48033. */
  48034. useRoughnessFromMetallicTextureGreen: boolean;
  48035. /**
  48036. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48037. */
  48038. useMetallnessFromMetallicTextureBlue: boolean;
  48039. /**
  48040. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48041. */
  48042. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48043. /**
  48044. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48045. */
  48046. useAmbientInGrayScale: boolean;
  48047. /**
  48048. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48049. * The material will try to infer what glossiness each pixel should be.
  48050. */
  48051. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48052. /**
  48053. * BJS is using an harcoded light falloff based on a manually sets up range.
  48054. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48055. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48056. */
  48057. /**
  48058. * BJS is using an harcoded light falloff based on a manually sets up range.
  48059. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48060. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48061. */
  48062. usePhysicalLightFalloff: boolean;
  48063. /**
  48064. * In order to support the falloff compatibility with gltf, a special mode has been added
  48065. * to reproduce the gltf light falloff.
  48066. */
  48067. /**
  48068. * In order to support the falloff compatibility with gltf, a special mode has been added
  48069. * to reproduce the gltf light falloff.
  48070. */
  48071. useGLTFLightFalloff: boolean;
  48072. /**
  48073. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48074. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48075. */
  48076. useRadianceOverAlpha: boolean;
  48077. /**
  48078. * Allows using an object space normal map (instead of tangent space).
  48079. */
  48080. useObjectSpaceNormalMap: boolean;
  48081. /**
  48082. * Allows using the bump map in parallax mode.
  48083. */
  48084. useParallax: boolean;
  48085. /**
  48086. * Allows using the bump map in parallax occlusion mode.
  48087. */
  48088. useParallaxOcclusion: boolean;
  48089. /**
  48090. * Controls the scale bias of the parallax mode.
  48091. */
  48092. parallaxScaleBias: number;
  48093. /**
  48094. * If sets to true, disables all the lights affecting the material.
  48095. */
  48096. disableLighting: boolean;
  48097. /**
  48098. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48099. */
  48100. forceIrradianceInFragment: boolean;
  48101. /**
  48102. * Number of Simultaneous lights allowed on the material.
  48103. */
  48104. maxSimultaneousLights: number;
  48105. /**
  48106. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48107. */
  48108. invertNormalMapX: boolean;
  48109. /**
  48110. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48111. */
  48112. invertNormalMapY: boolean;
  48113. /**
  48114. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48115. */
  48116. twoSidedLighting: boolean;
  48117. /**
  48118. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48119. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48120. */
  48121. useAlphaFresnel: boolean;
  48122. /**
  48123. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48124. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48125. */
  48126. useLinearAlphaFresnel: boolean;
  48127. /**
  48128. * Let user defines the brdf lookup texture used for IBL.
  48129. * A default 8bit version is embedded but you could point at :
  48130. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  48131. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48132. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48133. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48134. */
  48135. environmentBRDFTexture: Nullable<BaseTexture>;
  48136. /**
  48137. * Force normal to face away from face.
  48138. */
  48139. forceNormalForward: boolean;
  48140. /**
  48141. * Enables specular anti aliasing in the PBR shader.
  48142. * It will both interacts on the Geometry for analytical and IBL lighting.
  48143. * It also prefilter the roughness map based on the bump values.
  48144. */
  48145. enableSpecularAntiAliasing: boolean;
  48146. /**
  48147. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48148. * makes the reflect vector face the model (under horizon).
  48149. */
  48150. useHorizonOcclusion: boolean;
  48151. /**
  48152. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48153. * too much the area relying on ambient texture to define their ambient occlusion.
  48154. */
  48155. useRadianceOcclusion: boolean;
  48156. /**
  48157. * If set to true, no lighting calculations will be applied.
  48158. */
  48159. unlit: boolean;
  48160. /**
  48161. * Gets the image processing configuration used either in this material.
  48162. */
  48163. /**
  48164. * Sets the Default image processing configuration used either in the this material.
  48165. *
  48166. * If sets to null, the scene one is in use.
  48167. */
  48168. imageProcessingConfiguration: ImageProcessingConfiguration;
  48169. /**
  48170. * Gets wether the color curves effect is enabled.
  48171. */
  48172. /**
  48173. * Sets wether the color curves effect is enabled.
  48174. */
  48175. cameraColorCurvesEnabled: boolean;
  48176. /**
  48177. * Gets wether the color grading effect is enabled.
  48178. */
  48179. /**
  48180. * Gets wether the color grading effect is enabled.
  48181. */
  48182. cameraColorGradingEnabled: boolean;
  48183. /**
  48184. * Gets wether tonemapping is enabled or not.
  48185. */
  48186. /**
  48187. * Sets wether tonemapping is enabled or not
  48188. */
  48189. cameraToneMappingEnabled: boolean;
  48190. /**
  48191. * The camera exposure used on this material.
  48192. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48193. * This corresponds to a photographic exposure.
  48194. */
  48195. /**
  48196. * The camera exposure used on this material.
  48197. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48198. * This corresponds to a photographic exposure.
  48199. */
  48200. cameraExposure: number;
  48201. /**
  48202. * Gets The camera contrast used on this material.
  48203. */
  48204. /**
  48205. * Sets The camera contrast used on this material.
  48206. */
  48207. cameraContrast: number;
  48208. /**
  48209. * Gets the Color Grading 2D Lookup Texture.
  48210. */
  48211. /**
  48212. * Sets the Color Grading 2D Lookup Texture.
  48213. */
  48214. cameraColorGradingTexture: Nullable<BaseTexture>;
  48215. /**
  48216. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48217. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48218. * 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;
  48219. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48220. */
  48221. /**
  48222. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48223. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48224. * 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;
  48225. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48226. */
  48227. cameraColorCurves: Nullable<ColorCurves>;
  48228. /**
  48229. * Instantiates a new PBRMaterial instance.
  48230. *
  48231. * @param name The material name
  48232. * @param scene The scene the material will be use in.
  48233. */
  48234. constructor(name: string, scene: Scene);
  48235. /**
  48236. * Returns the name of this material class.
  48237. */
  48238. getClassName(): string;
  48239. /**
  48240. * Makes a duplicate of the current material.
  48241. * @param name - name to use for the new material.
  48242. */
  48243. clone(name: string): PBRMaterial;
  48244. /**
  48245. * Serializes this PBR Material.
  48246. * @returns - An object with the serialized material.
  48247. */
  48248. serialize(): any;
  48249. /**
  48250. * Parses a PBR Material from a serialized object.
  48251. * @param source - Serialized object.
  48252. * @param scene - BJS scene instance.
  48253. * @param rootUrl - url for the scene object
  48254. * @returns - PBRMaterial
  48255. */
  48256. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  48257. }
  48258. }
  48259. declare module "babylonjs/Misc/dds" {
  48260. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48261. import { Engine } from "babylonjs/Engines/engine";
  48262. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48263. import { Nullable } from "babylonjs/types";
  48264. import { Scene } from "babylonjs/scene";
  48265. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  48266. /**
  48267. * Direct draw surface info
  48268. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48269. */
  48270. export interface DDSInfo {
  48271. /**
  48272. * Width of the texture
  48273. */
  48274. width: number;
  48275. /**
  48276. * Width of the texture
  48277. */
  48278. height: number;
  48279. /**
  48280. * Number of Mipmaps for the texture
  48281. * @see https://en.wikipedia.org/wiki/Mipmap
  48282. */
  48283. mipmapCount: number;
  48284. /**
  48285. * If the textures format is a known fourCC format
  48286. * @see https://www.fourcc.org/
  48287. */
  48288. isFourCC: boolean;
  48289. /**
  48290. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48291. */
  48292. isRGB: boolean;
  48293. /**
  48294. * If the texture is a lumincance format
  48295. */
  48296. isLuminance: boolean;
  48297. /**
  48298. * If this is a cube texture
  48299. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48300. */
  48301. isCube: boolean;
  48302. /**
  48303. * If the texture is a compressed format eg. FOURCC_DXT1
  48304. */
  48305. isCompressed: boolean;
  48306. /**
  48307. * The dxgiFormat of the texture
  48308. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48309. */
  48310. dxgiFormat: number;
  48311. /**
  48312. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48313. */
  48314. textureType: number;
  48315. /**
  48316. * Sphericle polynomial created for the dds texture
  48317. */
  48318. sphericalPolynomial?: SphericalPolynomial;
  48319. }
  48320. /**
  48321. * Class used to provide DDS decompression tools
  48322. */
  48323. export class DDSTools {
  48324. /**
  48325. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48326. */
  48327. static StoreLODInAlphaChannel: boolean;
  48328. /**
  48329. * Gets DDS information from an array buffer
  48330. * @param arrayBuffer defines the array buffer to read data from
  48331. * @returns the DDS information
  48332. */
  48333. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48334. private static _FloatView;
  48335. private static _Int32View;
  48336. private static _ToHalfFloat;
  48337. private static _FromHalfFloat;
  48338. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48339. private static _GetHalfFloatRGBAArrayBuffer;
  48340. private static _GetFloatRGBAArrayBuffer;
  48341. private static _GetFloatAsUIntRGBAArrayBuffer;
  48342. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48343. private static _GetRGBAArrayBuffer;
  48344. private static _ExtractLongWordOrder;
  48345. private static _GetRGBArrayBuffer;
  48346. private static _GetLuminanceArrayBuffer;
  48347. /**
  48348. * Uploads DDS Levels to a Babylon Texture
  48349. * @hidden
  48350. */
  48351. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48352. }
  48353. module "babylonjs/Engines/engine" {
  48354. interface Engine {
  48355. /**
  48356. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48357. * @param rootUrl defines the url where the file to load is located
  48358. * @param scene defines the current scene
  48359. * @param lodScale defines scale to apply to the mip map selection
  48360. * @param lodOffset defines offset to apply to the mip map selection
  48361. * @param onLoad defines an optional callback raised when the texture is loaded
  48362. * @param onError defines an optional callback raised if there is an issue to load the texture
  48363. * @param format defines the format of the data
  48364. * @param forcedExtension defines the extension to use to pick the right loader
  48365. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48366. * @returns the cube texture as an InternalTexture
  48367. */
  48368. 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;
  48369. }
  48370. }
  48371. }
  48372. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  48373. import { Nullable } from "babylonjs/types";
  48374. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48375. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48376. /**
  48377. * Implementation of the DDS Texture Loader.
  48378. * @hidden
  48379. */
  48380. export class _DDSTextureLoader implements IInternalTextureLoader {
  48381. /**
  48382. * Defines wether the loader supports cascade loading the different faces.
  48383. */
  48384. readonly supportCascades: boolean;
  48385. /**
  48386. * This returns if the loader support the current file information.
  48387. * @param extension defines the file extension of the file being loaded
  48388. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48389. * @param fallback defines the fallback internal texture if any
  48390. * @param isBase64 defines whether the texture is encoded as a base64
  48391. * @param isBuffer defines whether the texture data are stored as a buffer
  48392. * @returns true if the loader can load the specified file
  48393. */
  48394. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48395. /**
  48396. * Transform the url before loading if required.
  48397. * @param rootUrl the url of the texture
  48398. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48399. * @returns the transformed texture
  48400. */
  48401. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48402. /**
  48403. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48404. * @param rootUrl the url of the texture
  48405. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48406. * @returns the fallback texture
  48407. */
  48408. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48409. /**
  48410. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48411. * @param data contains the texture data
  48412. * @param texture defines the BabylonJS internal texture
  48413. * @param createPolynomials will be true if polynomials have been requested
  48414. * @param onLoad defines the callback to trigger once the texture is ready
  48415. * @param onError defines the callback to trigger in case of error
  48416. */
  48417. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48418. /**
  48419. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48420. * @param data contains the texture data
  48421. * @param texture defines the BabylonJS internal texture
  48422. * @param callback defines the method to call once ready to upload
  48423. */
  48424. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48425. }
  48426. }
  48427. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48428. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48429. /** @hidden */
  48430. export var rgbdEncodePixelShader: {
  48431. name: string;
  48432. shader: string;
  48433. };
  48434. }
  48435. declare module "babylonjs/Misc/environmentTextureTools" {
  48436. import { Nullable } from "babylonjs/types";
  48437. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48438. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48439. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48440. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48441. import "babylonjs/Shaders/rgbdEncode.fragment";
  48442. import "babylonjs/Shaders/rgbdDecode.fragment";
  48443. /**
  48444. * Raw texture data and descriptor sufficient for WebGL texture upload
  48445. */
  48446. export interface EnvironmentTextureInfo {
  48447. /**
  48448. * Version of the environment map
  48449. */
  48450. version: number;
  48451. /**
  48452. * Width of image
  48453. */
  48454. width: number;
  48455. /**
  48456. * Irradiance information stored in the file.
  48457. */
  48458. irradiance: any;
  48459. /**
  48460. * Specular information stored in the file.
  48461. */
  48462. specular: any;
  48463. }
  48464. /**
  48465. * Sets of helpers addressing the serialization and deserialization of environment texture
  48466. * stored in a BabylonJS env file.
  48467. * Those files are usually stored as .env files.
  48468. */
  48469. export class EnvironmentTextureTools {
  48470. /**
  48471. * Magic number identifying the env file.
  48472. */
  48473. private static _MagicBytes;
  48474. /**
  48475. * Gets the environment info from an env file.
  48476. * @param data The array buffer containing the .env bytes.
  48477. * @returns the environment file info (the json header) if successfully parsed.
  48478. */
  48479. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48480. /**
  48481. * Creates an environment texture from a loaded cube texture.
  48482. * @param texture defines the cube texture to convert in env file
  48483. * @return a promise containing the environment data if succesfull.
  48484. */
  48485. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48486. /**
  48487. * Creates a JSON representation of the spherical data.
  48488. * @param texture defines the texture containing the polynomials
  48489. * @return the JSON representation of the spherical info
  48490. */
  48491. private static _CreateEnvTextureIrradiance;
  48492. /**
  48493. * Uploads the texture info contained in the env file to the GPU.
  48494. * @param texture defines the internal texture to upload to
  48495. * @param arrayBuffer defines the buffer cotaining the data to load
  48496. * @param info defines the texture info retrieved through the GetEnvInfo method
  48497. * @returns a promise
  48498. */
  48499. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48500. /**
  48501. * Uploads the levels of image data to the GPU.
  48502. * @param texture defines the internal texture to upload to
  48503. * @param imageData defines the array buffer views of image data [mipmap][face]
  48504. * @returns a promise
  48505. */
  48506. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48507. /**
  48508. * Uploads spherical polynomials information to the texture.
  48509. * @param texture defines the texture we are trying to upload the information to
  48510. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48511. */
  48512. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48513. /** @hidden */
  48514. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48515. }
  48516. }
  48517. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48518. import { Nullable } from "babylonjs/types";
  48519. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48520. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48521. /**
  48522. * Implementation of the ENV Texture Loader.
  48523. * @hidden
  48524. */
  48525. export class _ENVTextureLoader implements IInternalTextureLoader {
  48526. /**
  48527. * Defines wether the loader supports cascade loading the different faces.
  48528. */
  48529. readonly supportCascades: boolean;
  48530. /**
  48531. * This returns if the loader support the current file information.
  48532. * @param extension defines the file extension of the file being loaded
  48533. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48534. * @param fallback defines the fallback internal texture if any
  48535. * @param isBase64 defines whether the texture is encoded as a base64
  48536. * @param isBuffer defines whether the texture data are stored as a buffer
  48537. * @returns true if the loader can load the specified file
  48538. */
  48539. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48540. /**
  48541. * Transform the url before loading if required.
  48542. * @param rootUrl the url of the texture
  48543. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48544. * @returns the transformed texture
  48545. */
  48546. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48547. /**
  48548. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48549. * @param rootUrl the url of the texture
  48550. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48551. * @returns the fallback texture
  48552. */
  48553. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48554. /**
  48555. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48556. * @param data contains the texture data
  48557. * @param texture defines the BabylonJS internal texture
  48558. * @param createPolynomials will be true if polynomials have been requested
  48559. * @param onLoad defines the callback to trigger once the texture is ready
  48560. * @param onError defines the callback to trigger in case of error
  48561. */
  48562. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48563. /**
  48564. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48565. * @param data contains the texture data
  48566. * @param texture defines the BabylonJS internal texture
  48567. * @param callback defines the method to call once ready to upload
  48568. */
  48569. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48570. }
  48571. }
  48572. declare module "babylonjs/Misc/khronosTextureContainer" {
  48573. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48574. /**
  48575. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48576. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48577. */
  48578. export class KhronosTextureContainer {
  48579. /** contents of the KTX container file */
  48580. arrayBuffer: any;
  48581. private static HEADER_LEN;
  48582. private static COMPRESSED_2D;
  48583. private static COMPRESSED_3D;
  48584. private static TEX_2D;
  48585. private static TEX_3D;
  48586. /**
  48587. * Gets the openGL type
  48588. */
  48589. glType: number;
  48590. /**
  48591. * Gets the openGL type size
  48592. */
  48593. glTypeSize: number;
  48594. /**
  48595. * Gets the openGL format
  48596. */
  48597. glFormat: number;
  48598. /**
  48599. * Gets the openGL internal format
  48600. */
  48601. glInternalFormat: number;
  48602. /**
  48603. * Gets the base internal format
  48604. */
  48605. glBaseInternalFormat: number;
  48606. /**
  48607. * Gets image width in pixel
  48608. */
  48609. pixelWidth: number;
  48610. /**
  48611. * Gets image height in pixel
  48612. */
  48613. pixelHeight: number;
  48614. /**
  48615. * Gets image depth in pixels
  48616. */
  48617. pixelDepth: number;
  48618. /**
  48619. * Gets the number of array elements
  48620. */
  48621. numberOfArrayElements: number;
  48622. /**
  48623. * Gets the number of faces
  48624. */
  48625. numberOfFaces: number;
  48626. /**
  48627. * Gets the number of mipmap levels
  48628. */
  48629. numberOfMipmapLevels: number;
  48630. /**
  48631. * Gets the bytes of key value data
  48632. */
  48633. bytesOfKeyValueData: number;
  48634. /**
  48635. * Gets the load type
  48636. */
  48637. loadType: number;
  48638. /**
  48639. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48640. */
  48641. isInvalid: boolean;
  48642. /**
  48643. * Creates a new KhronosTextureContainer
  48644. * @param arrayBuffer contents of the KTX container file
  48645. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48646. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48647. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48648. */
  48649. constructor(
  48650. /** contents of the KTX container file */
  48651. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48652. /**
  48653. * Uploads KTX content to a Babylon Texture.
  48654. * It is assumed that the texture has already been created & is currently bound
  48655. * @hidden
  48656. */
  48657. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48658. private _upload2DCompressedLevels;
  48659. }
  48660. }
  48661. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48662. import { Nullable } from "babylonjs/types";
  48663. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48664. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48665. /**
  48666. * Implementation of the KTX Texture Loader.
  48667. * @hidden
  48668. */
  48669. export class _KTXTextureLoader implements IInternalTextureLoader {
  48670. /**
  48671. * Defines wether the loader supports cascade loading the different faces.
  48672. */
  48673. readonly supportCascades: boolean;
  48674. /**
  48675. * This returns if the loader support the current file information.
  48676. * @param extension defines the file extension of the file being loaded
  48677. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48678. * @param fallback defines the fallback internal texture if any
  48679. * @param isBase64 defines whether the texture is encoded as a base64
  48680. * @param isBuffer defines whether the texture data are stored as a buffer
  48681. * @returns true if the loader can load the specified file
  48682. */
  48683. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48684. /**
  48685. * Transform the url before loading if required.
  48686. * @param rootUrl the url of the texture
  48687. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48688. * @returns the transformed texture
  48689. */
  48690. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48691. /**
  48692. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48693. * @param rootUrl the url of the texture
  48694. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48695. * @returns the fallback texture
  48696. */
  48697. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48698. /**
  48699. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48700. * @param data contains the texture data
  48701. * @param texture defines the BabylonJS internal texture
  48702. * @param createPolynomials will be true if polynomials have been requested
  48703. * @param onLoad defines the callback to trigger once the texture is ready
  48704. * @param onError defines the callback to trigger in case of error
  48705. */
  48706. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48707. /**
  48708. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48709. * @param data contains the texture data
  48710. * @param texture defines the BabylonJS internal texture
  48711. * @param callback defines the method to call once ready to upload
  48712. */
  48713. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48714. }
  48715. }
  48716. declare module "babylonjs/Helpers/sceneHelpers" {
  48717. import { Nullable } from "babylonjs/types";
  48718. import { Mesh } from "babylonjs/Meshes/mesh";
  48719. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48720. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  48721. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  48722. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  48723. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  48724. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  48725. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  48726. import "babylonjs/Meshes/Builders/boxBuilder";
  48727. /** @hidden */
  48728. export var _forceSceneHelpersToBundle: boolean;
  48729. module "babylonjs/scene" {
  48730. interface Scene {
  48731. /**
  48732. * Creates a default light for the scene.
  48733. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48734. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48735. */
  48736. createDefaultLight(replace?: boolean): void;
  48737. /**
  48738. * Creates a default camera for the scene.
  48739. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48740. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48741. * @param replace has default false, when true replaces the active camera in the scene
  48742. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48743. */
  48744. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48745. /**
  48746. * Creates a default camera and a default light.
  48747. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48748. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48749. * @param replace has the default false, when true replaces the active camera/light in the scene
  48750. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48751. */
  48752. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48753. /**
  48754. * Creates a new sky box
  48755. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48756. * @param environmentTexture defines the texture to use as environment texture
  48757. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48758. * @param scale defines the overall scale of the skybox
  48759. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48760. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48761. * @returns a new mesh holding the sky box
  48762. */
  48763. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48764. /**
  48765. * Creates a new environment
  48766. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48767. * @param options defines the options you can use to configure the environment
  48768. * @returns the new EnvironmentHelper
  48769. */
  48770. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48771. /**
  48772. * Creates a new VREXperienceHelper
  48773. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48774. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48775. * @returns a new VREXperienceHelper
  48776. */
  48777. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48778. /**
  48779. * Creates a new XREXperienceHelper
  48780. * @see http://doc.babylonjs.com/how_to/webxr
  48781. * @returns a promise for a new XREXperienceHelper
  48782. */
  48783. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  48784. }
  48785. }
  48786. }
  48787. declare module "babylonjs/Helpers/videoDome" {
  48788. import { Scene } from "babylonjs/scene";
  48789. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48790. import { Mesh } from "babylonjs/Meshes/mesh";
  48791. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  48792. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48793. import "babylonjs/Meshes/Builders/sphereBuilder";
  48794. /**
  48795. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48796. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48797. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48798. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48799. */
  48800. export class VideoDome extends TransformNode {
  48801. /**
  48802. * Define the video source as a Monoscopic panoramic 360 video.
  48803. */
  48804. static readonly MODE_MONOSCOPIC: number;
  48805. /**
  48806. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48807. */
  48808. static readonly MODE_TOPBOTTOM: number;
  48809. /**
  48810. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48811. */
  48812. static readonly MODE_SIDEBYSIDE: number;
  48813. private _useDirectMapping;
  48814. /**
  48815. * The video texture being displayed on the sphere
  48816. */
  48817. protected _videoTexture: VideoTexture;
  48818. /**
  48819. * Gets the video texture being displayed on the sphere
  48820. */
  48821. readonly videoTexture: VideoTexture;
  48822. /**
  48823. * The skybox material
  48824. */
  48825. protected _material: BackgroundMaterial;
  48826. /**
  48827. * The surface used for the skybox
  48828. */
  48829. protected _mesh: Mesh;
  48830. /**
  48831. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48832. * Also see the options.resolution property.
  48833. */
  48834. fovMultiplier: number;
  48835. private _videoMode;
  48836. /**
  48837. * Gets or set the current video mode for the video. It can be:
  48838. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48839. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48840. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48841. */
  48842. videoMode: number;
  48843. /**
  48844. * Oberserver used in Stereoscopic VR Mode.
  48845. */
  48846. private _onBeforeCameraRenderObserver;
  48847. /**
  48848. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48849. * @param name Element's name, child elements will append suffixes for their own names.
  48850. * @param urlsOrVideo defines the url(s) or the video element to use
  48851. * @param options An object containing optional or exposed sub element properties
  48852. */
  48853. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48854. resolution?: number;
  48855. clickToPlay?: boolean;
  48856. autoPlay?: boolean;
  48857. loop?: boolean;
  48858. size?: number;
  48859. poster?: string;
  48860. faceForward?: boolean;
  48861. useDirectMapping?: boolean;
  48862. }, scene: Scene);
  48863. private _changeVideoMode;
  48864. /**
  48865. * Releases resources associated with this node.
  48866. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48867. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48868. */
  48869. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48870. }
  48871. }
  48872. declare module "babylonjs/Helpers/index" {
  48873. export * from "babylonjs/Helpers/environmentHelper";
  48874. export * from "babylonjs/Helpers/photoDome";
  48875. export * from "babylonjs/Helpers/sceneHelpers";
  48876. export * from "babylonjs/Helpers/videoDome";
  48877. }
  48878. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  48879. import { PerfCounter } from "babylonjs/Misc/tools";
  48880. import { IDisposable } from "babylonjs/scene";
  48881. import { Engine } from "babylonjs/Engines/engine";
  48882. /**
  48883. * This class can be used to get instrumentation data from a Babylon engine
  48884. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48885. */
  48886. export class EngineInstrumentation implements IDisposable {
  48887. /**
  48888. * Define the instrumented engine.
  48889. */
  48890. engine: Engine;
  48891. private _captureGPUFrameTime;
  48892. private _gpuFrameTimeToken;
  48893. private _gpuFrameTime;
  48894. private _captureShaderCompilationTime;
  48895. private _shaderCompilationTime;
  48896. private _onBeginFrameObserver;
  48897. private _onEndFrameObserver;
  48898. private _onBeforeShaderCompilationObserver;
  48899. private _onAfterShaderCompilationObserver;
  48900. /**
  48901. * Gets the perf counter used for GPU frame time
  48902. */
  48903. readonly gpuFrameTimeCounter: PerfCounter;
  48904. /**
  48905. * Gets the GPU frame time capture status
  48906. */
  48907. /**
  48908. * Enable or disable the GPU frame time capture
  48909. */
  48910. captureGPUFrameTime: boolean;
  48911. /**
  48912. * Gets the perf counter used for shader compilation time
  48913. */
  48914. readonly shaderCompilationTimeCounter: PerfCounter;
  48915. /**
  48916. * Gets the shader compilation time capture status
  48917. */
  48918. /**
  48919. * Enable or disable the shader compilation time capture
  48920. */
  48921. captureShaderCompilationTime: boolean;
  48922. /**
  48923. * Instantiates a new engine instrumentation.
  48924. * This class can be used to get instrumentation data from a Babylon engine
  48925. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48926. * @param engine Defines the engine to instrument
  48927. */
  48928. constructor(
  48929. /**
  48930. * Define the instrumented engine.
  48931. */
  48932. engine: Engine);
  48933. /**
  48934. * Dispose and release associated resources.
  48935. */
  48936. dispose(): void;
  48937. }
  48938. }
  48939. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  48940. import { PerfCounter } from "babylonjs/Misc/tools";
  48941. import { Scene, IDisposable } from "babylonjs/scene";
  48942. /**
  48943. * This class can be used to get instrumentation data from a Babylon engine
  48944. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48945. */
  48946. export class SceneInstrumentation implements IDisposable {
  48947. /**
  48948. * Defines the scene to instrument
  48949. */
  48950. scene: Scene;
  48951. private _captureActiveMeshesEvaluationTime;
  48952. private _activeMeshesEvaluationTime;
  48953. private _captureRenderTargetsRenderTime;
  48954. private _renderTargetsRenderTime;
  48955. private _captureFrameTime;
  48956. private _frameTime;
  48957. private _captureRenderTime;
  48958. private _renderTime;
  48959. private _captureInterFrameTime;
  48960. private _interFrameTime;
  48961. private _captureParticlesRenderTime;
  48962. private _particlesRenderTime;
  48963. private _captureSpritesRenderTime;
  48964. private _spritesRenderTime;
  48965. private _capturePhysicsTime;
  48966. private _physicsTime;
  48967. private _captureAnimationsTime;
  48968. private _animationsTime;
  48969. private _captureCameraRenderTime;
  48970. private _cameraRenderTime;
  48971. private _onBeforeActiveMeshesEvaluationObserver;
  48972. private _onAfterActiveMeshesEvaluationObserver;
  48973. private _onBeforeRenderTargetsRenderObserver;
  48974. private _onAfterRenderTargetsRenderObserver;
  48975. private _onAfterRenderObserver;
  48976. private _onBeforeDrawPhaseObserver;
  48977. private _onAfterDrawPhaseObserver;
  48978. private _onBeforeAnimationsObserver;
  48979. private _onBeforeParticlesRenderingObserver;
  48980. private _onAfterParticlesRenderingObserver;
  48981. private _onBeforeSpritesRenderingObserver;
  48982. private _onAfterSpritesRenderingObserver;
  48983. private _onBeforePhysicsObserver;
  48984. private _onAfterPhysicsObserver;
  48985. private _onAfterAnimationsObserver;
  48986. private _onBeforeCameraRenderObserver;
  48987. private _onAfterCameraRenderObserver;
  48988. /**
  48989. * Gets the perf counter used for active meshes evaluation time
  48990. */
  48991. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48992. /**
  48993. * Gets the active meshes evaluation time capture status
  48994. */
  48995. /**
  48996. * Enable or disable the active meshes evaluation time capture
  48997. */
  48998. captureActiveMeshesEvaluationTime: boolean;
  48999. /**
  49000. * Gets the perf counter used for render targets render time
  49001. */
  49002. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49003. /**
  49004. * Gets the render targets render time capture status
  49005. */
  49006. /**
  49007. * Enable or disable the render targets render time capture
  49008. */
  49009. captureRenderTargetsRenderTime: boolean;
  49010. /**
  49011. * Gets the perf counter used for particles render time
  49012. */
  49013. readonly particlesRenderTimeCounter: PerfCounter;
  49014. /**
  49015. * Gets the particles render time capture status
  49016. */
  49017. /**
  49018. * Enable or disable the particles render time capture
  49019. */
  49020. captureParticlesRenderTime: boolean;
  49021. /**
  49022. * Gets the perf counter used for sprites render time
  49023. */
  49024. readonly spritesRenderTimeCounter: PerfCounter;
  49025. /**
  49026. * Gets the sprites render time capture status
  49027. */
  49028. /**
  49029. * Enable or disable the sprites render time capture
  49030. */
  49031. captureSpritesRenderTime: boolean;
  49032. /**
  49033. * Gets the perf counter used for physics time
  49034. */
  49035. readonly physicsTimeCounter: PerfCounter;
  49036. /**
  49037. * Gets the physics time capture status
  49038. */
  49039. /**
  49040. * Enable or disable the physics time capture
  49041. */
  49042. capturePhysicsTime: boolean;
  49043. /**
  49044. * Gets the perf counter used for animations time
  49045. */
  49046. readonly animationsTimeCounter: PerfCounter;
  49047. /**
  49048. * Gets the animations time capture status
  49049. */
  49050. /**
  49051. * Enable or disable the animations time capture
  49052. */
  49053. captureAnimationsTime: boolean;
  49054. /**
  49055. * Gets the perf counter used for frame time capture
  49056. */
  49057. readonly frameTimeCounter: PerfCounter;
  49058. /**
  49059. * Gets the frame time capture status
  49060. */
  49061. /**
  49062. * Enable or disable the frame time capture
  49063. */
  49064. captureFrameTime: boolean;
  49065. /**
  49066. * Gets the perf counter used for inter-frames time capture
  49067. */
  49068. readonly interFrameTimeCounter: PerfCounter;
  49069. /**
  49070. * Gets the inter-frames time capture status
  49071. */
  49072. /**
  49073. * Enable or disable the inter-frames time capture
  49074. */
  49075. captureInterFrameTime: boolean;
  49076. /**
  49077. * Gets the perf counter used for render time capture
  49078. */
  49079. readonly renderTimeCounter: PerfCounter;
  49080. /**
  49081. * Gets the render time capture status
  49082. */
  49083. /**
  49084. * Enable or disable the render time capture
  49085. */
  49086. captureRenderTime: boolean;
  49087. /**
  49088. * Gets the perf counter used for camera render time capture
  49089. */
  49090. readonly cameraRenderTimeCounter: PerfCounter;
  49091. /**
  49092. * Gets the camera render time capture status
  49093. */
  49094. /**
  49095. * Enable or disable the camera render time capture
  49096. */
  49097. captureCameraRenderTime: boolean;
  49098. /**
  49099. * Gets the perf counter used for draw calls
  49100. */
  49101. readonly drawCallsCounter: PerfCounter;
  49102. /**
  49103. * Instantiates a new scene instrumentation.
  49104. * This class can be used to get instrumentation data from a Babylon engine
  49105. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49106. * @param scene Defines the scene to instrument
  49107. */
  49108. constructor(
  49109. /**
  49110. * Defines the scene to instrument
  49111. */
  49112. scene: Scene);
  49113. /**
  49114. * Dispose and release associated resources.
  49115. */
  49116. dispose(): void;
  49117. }
  49118. }
  49119. declare module "babylonjs/Instrumentation/index" {
  49120. export * from "babylonjs/Instrumentation/engineInstrumentation";
  49121. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  49122. export * from "babylonjs/Instrumentation/timeToken";
  49123. }
  49124. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  49125. /** @hidden */
  49126. export var glowMapGenerationPixelShader: {
  49127. name: string;
  49128. shader: string;
  49129. };
  49130. }
  49131. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  49132. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49133. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49134. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49135. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49136. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49137. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49138. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49139. /** @hidden */
  49140. export var glowMapGenerationVertexShader: {
  49141. name: string;
  49142. shader: string;
  49143. };
  49144. }
  49145. declare module "babylonjs/Layers/effectLayer" {
  49146. import { Observable } from "babylonjs/Misc/observable";
  49147. import { Nullable } from "babylonjs/types";
  49148. import { Camera } from "babylonjs/Cameras/camera";
  49149. import { Scene } from "babylonjs/scene";
  49150. import { Color4, ISize } from "babylonjs/Maths/math";
  49151. import { Engine } from "babylonjs/Engines/engine";
  49152. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49153. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49154. import { Mesh } from "babylonjs/Meshes/mesh";
  49155. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  49156. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49157. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49158. import { Effect } from "babylonjs/Materials/effect";
  49159. import { Material } from "babylonjs/Materials/material";
  49160. import "babylonjs/Shaders/glowMapGeneration.fragment";
  49161. import "babylonjs/Shaders/glowMapGeneration.vertex";
  49162. /**
  49163. * Effect layer options. This helps customizing the behaviour
  49164. * of the effect layer.
  49165. */
  49166. export interface IEffectLayerOptions {
  49167. /**
  49168. * Multiplication factor apply to the canvas size to compute the render target size
  49169. * used to generated the objects (the smaller the faster).
  49170. */
  49171. mainTextureRatio: number;
  49172. /**
  49173. * Enforces a fixed size texture to ensure effect stability across devices.
  49174. */
  49175. mainTextureFixedSize?: number;
  49176. /**
  49177. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  49178. */
  49179. alphaBlendingMode: number;
  49180. /**
  49181. * The camera attached to the layer.
  49182. */
  49183. camera: Nullable<Camera>;
  49184. /**
  49185. * The rendering group to draw the layer in.
  49186. */
  49187. renderingGroupId: number;
  49188. }
  49189. /**
  49190. * The effect layer Helps adding post process effect blended with the main pass.
  49191. *
  49192. * This can be for instance use to generate glow or higlight effects on the scene.
  49193. *
  49194. * The effect layer class can not be used directly and is intented to inherited from to be
  49195. * customized per effects.
  49196. */
  49197. export abstract class EffectLayer {
  49198. private _vertexBuffers;
  49199. private _indexBuffer;
  49200. private _cachedDefines;
  49201. private _effectLayerMapGenerationEffect;
  49202. private _effectLayerOptions;
  49203. private _mergeEffect;
  49204. protected _scene: Scene;
  49205. protected _engine: Engine;
  49206. protected _maxSize: number;
  49207. protected _mainTextureDesiredSize: ISize;
  49208. protected _mainTexture: RenderTargetTexture;
  49209. protected _shouldRender: boolean;
  49210. protected _postProcesses: PostProcess[];
  49211. protected _textures: BaseTexture[];
  49212. protected _emissiveTextureAndColor: {
  49213. texture: Nullable<BaseTexture>;
  49214. color: Color4;
  49215. };
  49216. /**
  49217. * The name of the layer
  49218. */
  49219. name: string;
  49220. /**
  49221. * The clear color of the texture used to generate the glow map.
  49222. */
  49223. neutralColor: Color4;
  49224. /**
  49225. * Specifies wether the highlight layer is enabled or not.
  49226. */
  49227. isEnabled: boolean;
  49228. /**
  49229. * Gets the camera attached to the layer.
  49230. */
  49231. readonly camera: Nullable<Camera>;
  49232. /**
  49233. * Gets the rendering group id the layer should render in.
  49234. */
  49235. readonly renderingGroupId: number;
  49236. /**
  49237. * An event triggered when the effect layer has been disposed.
  49238. */
  49239. onDisposeObservable: Observable<EffectLayer>;
  49240. /**
  49241. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  49242. */
  49243. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  49244. /**
  49245. * An event triggered when the generated texture is being merged in the scene.
  49246. */
  49247. onBeforeComposeObservable: Observable<EffectLayer>;
  49248. /**
  49249. * An event triggered when the generated texture has been merged in the scene.
  49250. */
  49251. onAfterComposeObservable: Observable<EffectLayer>;
  49252. /**
  49253. * An event triggered when the efffect layer changes its size.
  49254. */
  49255. onSizeChangedObservable: Observable<EffectLayer>;
  49256. /** @hidden */
  49257. static _SceneComponentInitialization: (scene: Scene) => void;
  49258. /**
  49259. * Instantiates a new effect Layer and references it in the scene.
  49260. * @param name The name of the layer
  49261. * @param scene The scene to use the layer in
  49262. */
  49263. constructor(
  49264. /** The Friendly of the effect in the scene */
  49265. name: string, scene: Scene);
  49266. /**
  49267. * Get the effect name of the layer.
  49268. * @return The effect name
  49269. */
  49270. abstract getEffectName(): string;
  49271. /**
  49272. * Checks for the readiness of the element composing the layer.
  49273. * @param subMesh the mesh to check for
  49274. * @param useInstances specify wether or not to use instances to render the mesh
  49275. * @return true if ready otherwise, false
  49276. */
  49277. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49278. /**
  49279. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49280. * @returns true if the effect requires stencil during the main canvas render pass.
  49281. */
  49282. abstract needStencil(): boolean;
  49283. /**
  49284. * Create the merge effect. This is the shader use to blit the information back
  49285. * to the main canvas at the end of the scene rendering.
  49286. * @returns The effect containing the shader used to merge the effect on the main canvas
  49287. */
  49288. protected abstract _createMergeEffect(): Effect;
  49289. /**
  49290. * Creates the render target textures and post processes used in the effect layer.
  49291. */
  49292. protected abstract _createTextureAndPostProcesses(): void;
  49293. /**
  49294. * Implementation specific of rendering the generating effect on the main canvas.
  49295. * @param effect The effect used to render through
  49296. */
  49297. protected abstract _internalRender(effect: Effect): void;
  49298. /**
  49299. * Sets the required values for both the emissive texture and and the main color.
  49300. */
  49301. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49302. /**
  49303. * Free any resources and references associated to a mesh.
  49304. * Internal use
  49305. * @param mesh The mesh to free.
  49306. */
  49307. abstract _disposeMesh(mesh: Mesh): void;
  49308. /**
  49309. * Serializes this layer (Glow or Highlight for example)
  49310. * @returns a serialized layer object
  49311. */
  49312. abstract serialize?(): any;
  49313. /**
  49314. * Initializes the effect layer with the required options.
  49315. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  49316. */
  49317. protected _init(options: Partial<IEffectLayerOptions>): void;
  49318. /**
  49319. * Generates the index buffer of the full screen quad blending to the main canvas.
  49320. */
  49321. private _generateIndexBuffer;
  49322. /**
  49323. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  49324. */
  49325. private _generateVertexBuffer;
  49326. /**
  49327. * Sets the main texture desired size which is the closest power of two
  49328. * of the engine canvas size.
  49329. */
  49330. private _setMainTextureSize;
  49331. /**
  49332. * Creates the main texture for the effect layer.
  49333. */
  49334. protected _createMainTexture(): void;
  49335. /**
  49336. * Adds specific effects defines.
  49337. * @param defines The defines to add specifics to.
  49338. */
  49339. protected _addCustomEffectDefines(defines: string[]): void;
  49340. /**
  49341. * Checks for the readiness of the element composing the layer.
  49342. * @param subMesh the mesh to check for
  49343. * @param useInstances specify wether or not to use instances to render the mesh
  49344. * @param emissiveTexture the associated emissive texture used to generate the glow
  49345. * @return true if ready otherwise, false
  49346. */
  49347. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  49348. /**
  49349. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  49350. */
  49351. render(): void;
  49352. /**
  49353. * Determine if a given mesh will be used in the current effect.
  49354. * @param mesh mesh to test
  49355. * @returns true if the mesh will be used
  49356. */
  49357. hasMesh(mesh: AbstractMesh): boolean;
  49358. /**
  49359. * Returns true if the layer contains information to display, otherwise false.
  49360. * @returns true if the glow layer should be rendered
  49361. */
  49362. shouldRender(): boolean;
  49363. /**
  49364. * Returns true if the mesh should render, otherwise false.
  49365. * @param mesh The mesh to render
  49366. * @returns true if it should render otherwise false
  49367. */
  49368. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  49369. /**
  49370. * Returns true if the mesh can be rendered, otherwise false.
  49371. * @param mesh The mesh to render
  49372. * @param material The material used on the mesh
  49373. * @returns true if it can be rendered otherwise false
  49374. */
  49375. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49376. /**
  49377. * Returns true if the mesh should render, otherwise false.
  49378. * @param mesh The mesh to render
  49379. * @returns true if it should render otherwise false
  49380. */
  49381. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  49382. /**
  49383. * Renders the submesh passed in parameter to the generation map.
  49384. */
  49385. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  49386. /**
  49387. * Rebuild the required buffers.
  49388. * @hidden Internal use only.
  49389. */
  49390. _rebuild(): void;
  49391. /**
  49392. * Dispose only the render target textures and post process.
  49393. */
  49394. private _disposeTextureAndPostProcesses;
  49395. /**
  49396. * Dispose the highlight layer and free resources.
  49397. */
  49398. dispose(): void;
  49399. /**
  49400. * Gets the class name of the effect layer
  49401. * @returns the string with the class name of the effect layer
  49402. */
  49403. getClassName(): string;
  49404. /**
  49405. * Creates an effect layer from parsed effect layer data
  49406. * @param parsedEffectLayer defines effect layer data
  49407. * @param scene defines the current scene
  49408. * @param rootUrl defines the root URL containing the effect layer information
  49409. * @returns a parsed effect Layer
  49410. */
  49411. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49412. }
  49413. }
  49414. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  49415. import { Scene } from "babylonjs/scene";
  49416. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49417. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49418. import { AbstractScene } from "babylonjs/abstractScene";
  49419. module "babylonjs/abstractScene" {
  49420. interface AbstractScene {
  49421. /**
  49422. * The list of effect layers (highlights/glow) added to the scene
  49423. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49424. * @see http://doc.babylonjs.com/how_to/glow_layer
  49425. */
  49426. effectLayers: Array<EffectLayer>;
  49427. /**
  49428. * Removes the given effect layer from this scene.
  49429. * @param toRemove defines the effect layer to remove
  49430. * @returns the index of the removed effect layer
  49431. */
  49432. removeEffectLayer(toRemove: EffectLayer): number;
  49433. /**
  49434. * Adds the given effect layer to this scene
  49435. * @param newEffectLayer defines the effect layer to add
  49436. */
  49437. addEffectLayer(newEffectLayer: EffectLayer): void;
  49438. }
  49439. }
  49440. /**
  49441. * Defines the layer scene component responsible to manage any effect layers
  49442. * in a given scene.
  49443. */
  49444. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49445. /**
  49446. * The component name helpfull to identify the component in the list of scene components.
  49447. */
  49448. readonly name: string;
  49449. /**
  49450. * The scene the component belongs to.
  49451. */
  49452. scene: Scene;
  49453. private _engine;
  49454. private _renderEffects;
  49455. private _needStencil;
  49456. private _previousStencilState;
  49457. /**
  49458. * Creates a new instance of the component for the given scene
  49459. * @param scene Defines the scene to register the component in
  49460. */
  49461. constructor(scene: Scene);
  49462. /**
  49463. * Registers the component in a given scene
  49464. */
  49465. register(): void;
  49466. /**
  49467. * Rebuilds the elements related to this component in case of
  49468. * context lost for instance.
  49469. */
  49470. rebuild(): void;
  49471. /**
  49472. * Serializes the component data to the specified json object
  49473. * @param serializationObject The object to serialize to
  49474. */
  49475. serialize(serializationObject: any): void;
  49476. /**
  49477. * Adds all the elements from the container to the scene
  49478. * @param container the container holding the elements
  49479. */
  49480. addFromContainer(container: AbstractScene): void;
  49481. /**
  49482. * Removes all the elements in the container from the scene
  49483. * @param container contains the elements to remove
  49484. * @param dispose if the removed element should be disposed (default: false)
  49485. */
  49486. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49487. /**
  49488. * Disposes the component and the associated ressources.
  49489. */
  49490. dispose(): void;
  49491. private _isReadyForMesh;
  49492. private _renderMainTexture;
  49493. private _setStencil;
  49494. private _setStencilBack;
  49495. private _draw;
  49496. private _drawCamera;
  49497. private _drawRenderingGroup;
  49498. }
  49499. }
  49500. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  49501. /** @hidden */
  49502. export var glowMapMergePixelShader: {
  49503. name: string;
  49504. shader: string;
  49505. };
  49506. }
  49507. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  49508. /** @hidden */
  49509. export var glowMapMergeVertexShader: {
  49510. name: string;
  49511. shader: string;
  49512. };
  49513. }
  49514. declare module "babylonjs/Layers/glowLayer" {
  49515. import { Nullable } from "babylonjs/types";
  49516. import { Camera } from "babylonjs/Cameras/camera";
  49517. import { Scene } from "babylonjs/scene";
  49518. import { Color4 } from "babylonjs/Maths/math";
  49519. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49520. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49521. import { Mesh } from "babylonjs/Meshes/mesh";
  49522. import { Texture } from "babylonjs/Materials/Textures/texture";
  49523. import { Effect } from "babylonjs/Materials/effect";
  49524. import { Material } from "babylonjs/Materials/material";
  49525. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49526. import "babylonjs/Shaders/glowMapMerge.fragment";
  49527. import "babylonjs/Shaders/glowMapMerge.vertex";
  49528. import "babylonjs/Layers/effectLayerSceneComponent";
  49529. module "babylonjs/abstractScene" {
  49530. interface AbstractScene {
  49531. /**
  49532. * Return a the first highlight layer of the scene with a given name.
  49533. * @param name The name of the highlight layer to look for.
  49534. * @return The highlight layer if found otherwise null.
  49535. */
  49536. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49537. }
  49538. }
  49539. /**
  49540. * Glow layer options. This helps customizing the behaviour
  49541. * of the glow layer.
  49542. */
  49543. export interface IGlowLayerOptions {
  49544. /**
  49545. * Multiplication factor apply to the canvas size to compute the render target size
  49546. * used to generated the glowing objects (the smaller the faster).
  49547. */
  49548. mainTextureRatio: number;
  49549. /**
  49550. * Enforces a fixed size texture to ensure resize independant blur.
  49551. */
  49552. mainTextureFixedSize?: number;
  49553. /**
  49554. * How big is the kernel of the blur texture.
  49555. */
  49556. blurKernelSize: number;
  49557. /**
  49558. * The camera attached to the layer.
  49559. */
  49560. camera: Nullable<Camera>;
  49561. /**
  49562. * Enable MSAA by chosing the number of samples.
  49563. */
  49564. mainTextureSamples?: number;
  49565. /**
  49566. * The rendering group to draw the layer in.
  49567. */
  49568. renderingGroupId: number;
  49569. }
  49570. /**
  49571. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49572. *
  49573. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49574. * glowy meshes to your scene.
  49575. *
  49576. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49577. */
  49578. export class GlowLayer extends EffectLayer {
  49579. /**
  49580. * Effect Name of the layer.
  49581. */
  49582. static readonly EffectName: string;
  49583. /**
  49584. * The default blur kernel size used for the glow.
  49585. */
  49586. static DefaultBlurKernelSize: number;
  49587. /**
  49588. * The default texture size ratio used for the glow.
  49589. */
  49590. static DefaultTextureRatio: number;
  49591. /**
  49592. * Sets the kernel size of the blur.
  49593. */
  49594. /**
  49595. * Gets the kernel size of the blur.
  49596. */
  49597. blurKernelSize: number;
  49598. /**
  49599. * Sets the glow intensity.
  49600. */
  49601. /**
  49602. * Gets the glow intensity.
  49603. */
  49604. intensity: number;
  49605. private _options;
  49606. private _intensity;
  49607. private _horizontalBlurPostprocess1;
  49608. private _verticalBlurPostprocess1;
  49609. private _horizontalBlurPostprocess2;
  49610. private _verticalBlurPostprocess2;
  49611. private _blurTexture1;
  49612. private _blurTexture2;
  49613. private _postProcesses1;
  49614. private _postProcesses2;
  49615. private _includedOnlyMeshes;
  49616. private _excludedMeshes;
  49617. /**
  49618. * Callback used to let the user override the color selection on a per mesh basis
  49619. */
  49620. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49621. /**
  49622. * Callback used to let the user override the texture selection on a per mesh basis
  49623. */
  49624. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49625. /**
  49626. * Instantiates a new glow Layer and references it to the scene.
  49627. * @param name The name of the layer
  49628. * @param scene The scene to use the layer in
  49629. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49630. */
  49631. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49632. /**
  49633. * Get the effect name of the layer.
  49634. * @return The effect name
  49635. */
  49636. getEffectName(): string;
  49637. /**
  49638. * Create the merge effect. This is the shader use to blit the information back
  49639. * to the main canvas at the end of the scene rendering.
  49640. */
  49641. protected _createMergeEffect(): Effect;
  49642. /**
  49643. * Creates the render target textures and post processes used in the glow layer.
  49644. */
  49645. protected _createTextureAndPostProcesses(): void;
  49646. /**
  49647. * Checks for the readiness of the element composing the layer.
  49648. * @param subMesh the mesh to check for
  49649. * @param useInstances specify wether or not to use instances to render the mesh
  49650. * @param emissiveTexture the associated emissive texture used to generate the glow
  49651. * @return true if ready otherwise, false
  49652. */
  49653. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49654. /**
  49655. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49656. */
  49657. needStencil(): boolean;
  49658. /**
  49659. * Returns true if the mesh can be rendered, otherwise false.
  49660. * @param mesh The mesh to render
  49661. * @param material The material used on the mesh
  49662. * @returns true if it can be rendered otherwise false
  49663. */
  49664. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49665. /**
  49666. * Implementation specific of rendering the generating effect on the main canvas.
  49667. * @param effect The effect used to render through
  49668. */
  49669. protected _internalRender(effect: Effect): void;
  49670. /**
  49671. * Sets the required values for both the emissive texture and and the main color.
  49672. */
  49673. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49674. /**
  49675. * Returns true if the mesh should render, otherwise false.
  49676. * @param mesh The mesh to render
  49677. * @returns true if it should render otherwise false
  49678. */
  49679. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49680. /**
  49681. * Adds specific effects defines.
  49682. * @param defines The defines to add specifics to.
  49683. */
  49684. protected _addCustomEffectDefines(defines: string[]): void;
  49685. /**
  49686. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49687. * @param mesh The mesh to exclude from the glow layer
  49688. */
  49689. addExcludedMesh(mesh: Mesh): void;
  49690. /**
  49691. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49692. * @param mesh The mesh to remove
  49693. */
  49694. removeExcludedMesh(mesh: Mesh): void;
  49695. /**
  49696. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49697. * @param mesh The mesh to include in the glow layer
  49698. */
  49699. addIncludedOnlyMesh(mesh: Mesh): void;
  49700. /**
  49701. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49702. * @param mesh The mesh to remove
  49703. */
  49704. removeIncludedOnlyMesh(mesh: Mesh): void;
  49705. /**
  49706. * Determine if a given mesh will be used in the glow layer
  49707. * @param mesh The mesh to test
  49708. * @returns true if the mesh will be highlighted by the current glow layer
  49709. */
  49710. hasMesh(mesh: AbstractMesh): boolean;
  49711. /**
  49712. * Free any resources and references associated to a mesh.
  49713. * Internal use
  49714. * @param mesh The mesh to free.
  49715. * @hidden
  49716. */
  49717. _disposeMesh(mesh: Mesh): void;
  49718. /**
  49719. * Gets the class name of the effect layer
  49720. * @returns the string with the class name of the effect layer
  49721. */
  49722. getClassName(): string;
  49723. /**
  49724. * Serializes this glow layer
  49725. * @returns a serialized glow layer object
  49726. */
  49727. serialize(): any;
  49728. /**
  49729. * Creates a Glow Layer from parsed glow layer data
  49730. * @param parsedGlowLayer defines glow layer data
  49731. * @param scene defines the current scene
  49732. * @param rootUrl defines the root URL containing the glow layer information
  49733. * @returns a parsed Glow Layer
  49734. */
  49735. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49736. }
  49737. }
  49738. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  49739. /** @hidden */
  49740. export var glowBlurPostProcessPixelShader: {
  49741. name: string;
  49742. shader: string;
  49743. };
  49744. }
  49745. declare module "babylonjs/Layers/highlightLayer" {
  49746. import { Observable } from "babylonjs/Misc/observable";
  49747. import { Nullable } from "babylonjs/types";
  49748. import { Camera } from "babylonjs/Cameras/camera";
  49749. import { Scene } from "babylonjs/scene";
  49750. import { Color3, Color4 } from "babylonjs/Maths/math";
  49751. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49752. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49753. import { Mesh } from "babylonjs/Meshes/mesh";
  49754. import { Effect } from "babylonjs/Materials/effect";
  49755. import { Material } from "babylonjs/Materials/material";
  49756. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49757. import "babylonjs/Shaders/glowMapMerge.fragment";
  49758. import "babylonjs/Shaders/glowMapMerge.vertex";
  49759. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  49760. module "babylonjs/abstractScene" {
  49761. interface AbstractScene {
  49762. /**
  49763. * Return a the first highlight layer of the scene with a given name.
  49764. * @param name The name of the highlight layer to look for.
  49765. * @return The highlight layer if found otherwise null.
  49766. */
  49767. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49768. }
  49769. }
  49770. /**
  49771. * Highlight layer options. This helps customizing the behaviour
  49772. * of the highlight layer.
  49773. */
  49774. export interface IHighlightLayerOptions {
  49775. /**
  49776. * Multiplication factor apply to the canvas size to compute the render target size
  49777. * used to generated the glowing objects (the smaller the faster).
  49778. */
  49779. mainTextureRatio: number;
  49780. /**
  49781. * Enforces a fixed size texture to ensure resize independant blur.
  49782. */
  49783. mainTextureFixedSize?: number;
  49784. /**
  49785. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49786. * of the picture to blur (the smaller the faster).
  49787. */
  49788. blurTextureSizeRatio: number;
  49789. /**
  49790. * How big in texel of the blur texture is the vertical blur.
  49791. */
  49792. blurVerticalSize: number;
  49793. /**
  49794. * How big in texel of the blur texture is the horizontal blur.
  49795. */
  49796. blurHorizontalSize: number;
  49797. /**
  49798. * Alpha blending mode used to apply the blur. Default is combine.
  49799. */
  49800. alphaBlendingMode: number;
  49801. /**
  49802. * The camera attached to the layer.
  49803. */
  49804. camera: Nullable<Camera>;
  49805. /**
  49806. * Should we display highlight as a solid stroke?
  49807. */
  49808. isStroke?: boolean;
  49809. /**
  49810. * The rendering group to draw the layer in.
  49811. */
  49812. renderingGroupId: number;
  49813. }
  49814. /**
  49815. * The highlight layer Helps adding a glow effect around a mesh.
  49816. *
  49817. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49818. * glowy meshes to your scene.
  49819. *
  49820. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49821. */
  49822. export class HighlightLayer extends EffectLayer {
  49823. name: string;
  49824. /**
  49825. * Effect Name of the highlight layer.
  49826. */
  49827. static readonly EffectName: string;
  49828. /**
  49829. * The neutral color used during the preparation of the glow effect.
  49830. * This is black by default as the blend operation is a blend operation.
  49831. */
  49832. static NeutralColor: Color4;
  49833. /**
  49834. * Stencil value used for glowing meshes.
  49835. */
  49836. static GlowingMeshStencilReference: number;
  49837. /**
  49838. * Stencil value used for the other meshes in the scene.
  49839. */
  49840. static NormalMeshStencilReference: number;
  49841. /**
  49842. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49843. */
  49844. innerGlow: boolean;
  49845. /**
  49846. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49847. */
  49848. outerGlow: boolean;
  49849. /**
  49850. * Specifies the horizontal size of the blur.
  49851. */
  49852. /**
  49853. * Gets the horizontal size of the blur.
  49854. */
  49855. blurHorizontalSize: number;
  49856. /**
  49857. * Specifies the vertical size of the blur.
  49858. */
  49859. /**
  49860. * Gets the vertical size of the blur.
  49861. */
  49862. blurVerticalSize: number;
  49863. /**
  49864. * An event triggered when the highlight layer is being blurred.
  49865. */
  49866. onBeforeBlurObservable: Observable<HighlightLayer>;
  49867. /**
  49868. * An event triggered when the highlight layer has been blurred.
  49869. */
  49870. onAfterBlurObservable: Observable<HighlightLayer>;
  49871. private _instanceGlowingMeshStencilReference;
  49872. private _options;
  49873. private _downSamplePostprocess;
  49874. private _horizontalBlurPostprocess;
  49875. private _verticalBlurPostprocess;
  49876. private _blurTexture;
  49877. private _meshes;
  49878. private _excludedMeshes;
  49879. /**
  49880. * Instantiates a new highlight Layer and references it to the scene..
  49881. * @param name The name of the layer
  49882. * @param scene The scene to use the layer in
  49883. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49884. */
  49885. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49886. /**
  49887. * Get the effect name of the layer.
  49888. * @return The effect name
  49889. */
  49890. getEffectName(): string;
  49891. /**
  49892. * Create the merge effect. This is the shader use to blit the information back
  49893. * to the main canvas at the end of the scene rendering.
  49894. */
  49895. protected _createMergeEffect(): Effect;
  49896. /**
  49897. * Creates the render target textures and post processes used in the highlight layer.
  49898. */
  49899. protected _createTextureAndPostProcesses(): void;
  49900. /**
  49901. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49902. */
  49903. needStencil(): boolean;
  49904. /**
  49905. * Checks for the readiness of the element composing the layer.
  49906. * @param subMesh the mesh to check for
  49907. * @param useInstances specify wether or not to use instances to render the mesh
  49908. * @param emissiveTexture the associated emissive texture used to generate the glow
  49909. * @return true if ready otherwise, false
  49910. */
  49911. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49912. /**
  49913. * Implementation specific of rendering the generating effect on the main canvas.
  49914. * @param effect The effect used to render through
  49915. */
  49916. protected _internalRender(effect: Effect): void;
  49917. /**
  49918. * Returns true if the layer contains information to display, otherwise false.
  49919. */
  49920. shouldRender(): boolean;
  49921. /**
  49922. * Returns true if the mesh should render, otherwise false.
  49923. * @param mesh The mesh to render
  49924. * @returns true if it should render otherwise false
  49925. */
  49926. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49927. /**
  49928. * Sets the required values for both the emissive texture and and the main color.
  49929. */
  49930. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49931. /**
  49932. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49933. * @param mesh The mesh to exclude from the highlight layer
  49934. */
  49935. addExcludedMesh(mesh: Mesh): void;
  49936. /**
  49937. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49938. * @param mesh The mesh to highlight
  49939. */
  49940. removeExcludedMesh(mesh: Mesh): void;
  49941. /**
  49942. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49943. * @param mesh mesh to test
  49944. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49945. */
  49946. hasMesh(mesh: AbstractMesh): boolean;
  49947. /**
  49948. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49949. * @param mesh The mesh to highlight
  49950. * @param color The color of the highlight
  49951. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49952. */
  49953. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49954. /**
  49955. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49956. * @param mesh The mesh to highlight
  49957. */
  49958. removeMesh(mesh: Mesh): void;
  49959. /**
  49960. * Force the stencil to the normal expected value for none glowing parts
  49961. */
  49962. private _defaultStencilReference;
  49963. /**
  49964. * Free any resources and references associated to a mesh.
  49965. * Internal use
  49966. * @param mesh The mesh to free.
  49967. * @hidden
  49968. */
  49969. _disposeMesh(mesh: Mesh): void;
  49970. /**
  49971. * Dispose the highlight layer and free resources.
  49972. */
  49973. dispose(): void;
  49974. /**
  49975. * Gets the class name of the effect layer
  49976. * @returns the string with the class name of the effect layer
  49977. */
  49978. getClassName(): string;
  49979. /**
  49980. * Serializes this Highlight layer
  49981. * @returns a serialized Highlight layer object
  49982. */
  49983. serialize(): any;
  49984. /**
  49985. * Creates a Highlight layer from parsed Highlight layer data
  49986. * @param parsedHightlightLayer defines the Highlight layer data
  49987. * @param scene defines the current scene
  49988. * @param rootUrl defines the root URL containing the Highlight layer information
  49989. * @returns a parsed Highlight layer
  49990. */
  49991. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49992. }
  49993. }
  49994. declare module "babylonjs/Layers/layerSceneComponent" {
  49995. import { Scene } from "babylonjs/scene";
  49996. import { ISceneComponent } from "babylonjs/sceneComponent";
  49997. import { Layer } from "babylonjs/Layers/layer";
  49998. import { AbstractScene } from "babylonjs/abstractScene";
  49999. module "babylonjs/abstractScene" {
  50000. interface AbstractScene {
  50001. /**
  50002. * The list of layers (background and foreground) of the scene
  50003. */
  50004. layers: Array<Layer>;
  50005. }
  50006. }
  50007. /**
  50008. * Defines the layer scene component responsible to manage any layers
  50009. * in a given scene.
  50010. */
  50011. export class LayerSceneComponent implements ISceneComponent {
  50012. /**
  50013. * The component name helpfull to identify the component in the list of scene components.
  50014. */
  50015. readonly name: string;
  50016. /**
  50017. * The scene the component belongs to.
  50018. */
  50019. scene: Scene;
  50020. private _engine;
  50021. /**
  50022. * Creates a new instance of the component for the given scene
  50023. * @param scene Defines the scene to register the component in
  50024. */
  50025. constructor(scene: Scene);
  50026. /**
  50027. * Registers the component in a given scene
  50028. */
  50029. register(): void;
  50030. /**
  50031. * Rebuilds the elements related to this component in case of
  50032. * context lost for instance.
  50033. */
  50034. rebuild(): void;
  50035. /**
  50036. * Disposes the component and the associated ressources.
  50037. */
  50038. dispose(): void;
  50039. private _draw;
  50040. private _drawCameraPredicate;
  50041. private _drawCameraBackground;
  50042. private _drawCameraForeground;
  50043. private _drawRenderTargetPredicate;
  50044. private _drawRenderTargetBackground;
  50045. private _drawRenderTargetForeground;
  50046. /**
  50047. * Adds all the elements from the container to the scene
  50048. * @param container the container holding the elements
  50049. */
  50050. addFromContainer(container: AbstractScene): void;
  50051. /**
  50052. * Removes all the elements in the container from the scene
  50053. * @param container contains the elements to remove
  50054. * @param dispose if the removed element should be disposed (default: false)
  50055. */
  50056. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50057. }
  50058. }
  50059. declare module "babylonjs/Shaders/layer.fragment" {
  50060. /** @hidden */
  50061. export var layerPixelShader: {
  50062. name: string;
  50063. shader: string;
  50064. };
  50065. }
  50066. declare module "babylonjs/Shaders/layer.vertex" {
  50067. /** @hidden */
  50068. export var layerVertexShader: {
  50069. name: string;
  50070. shader: string;
  50071. };
  50072. }
  50073. declare module "babylonjs/Layers/layer" {
  50074. import { Observable } from "babylonjs/Misc/observable";
  50075. import { Nullable } from "babylonjs/types";
  50076. import { Scene } from "babylonjs/scene";
  50077. import { Vector2, Color4 } from "babylonjs/Maths/math";
  50078. import { Texture } from "babylonjs/Materials/Textures/texture";
  50079. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50080. import "babylonjs/Shaders/layer.fragment";
  50081. import "babylonjs/Shaders/layer.vertex";
  50082. /**
  50083. * This represents a full screen 2d layer.
  50084. * This can be useful to display a picture in the background of your scene for instance.
  50085. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50086. */
  50087. export class Layer {
  50088. /**
  50089. * Define the name of the layer.
  50090. */
  50091. name: string;
  50092. /**
  50093. * Define the texture the layer should display.
  50094. */
  50095. texture: Nullable<Texture>;
  50096. /**
  50097. * Is the layer in background or foreground.
  50098. */
  50099. isBackground: boolean;
  50100. /**
  50101. * Define the color of the layer (instead of texture).
  50102. */
  50103. color: Color4;
  50104. /**
  50105. * Define the scale of the layer in order to zoom in out of the texture.
  50106. */
  50107. scale: Vector2;
  50108. /**
  50109. * Define an offset for the layer in order to shift the texture.
  50110. */
  50111. offset: Vector2;
  50112. /**
  50113. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  50114. */
  50115. alphaBlendingMode: number;
  50116. /**
  50117. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  50118. * Alpha test will not mix with the background color in case of transparency.
  50119. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  50120. */
  50121. alphaTest: boolean;
  50122. /**
  50123. * Define a mask to restrict the layer to only some of the scene cameras.
  50124. */
  50125. layerMask: number;
  50126. /**
  50127. * Define the list of render target the layer is visible into.
  50128. */
  50129. renderTargetTextures: RenderTargetTexture[];
  50130. /**
  50131. * Define if the layer is only used in renderTarget or if it also
  50132. * renders in the main frame buffer of the canvas.
  50133. */
  50134. renderOnlyInRenderTargetTextures: boolean;
  50135. private _scene;
  50136. private _vertexBuffers;
  50137. private _indexBuffer;
  50138. private _effect;
  50139. private _alphaTestEffect;
  50140. /**
  50141. * An event triggered when the layer is disposed.
  50142. */
  50143. onDisposeObservable: Observable<Layer>;
  50144. private _onDisposeObserver;
  50145. /**
  50146. * Back compatibility with callback before the onDisposeObservable existed.
  50147. * The set callback will be triggered when the layer has been disposed.
  50148. */
  50149. onDispose: () => void;
  50150. /**
  50151. * An event triggered before rendering the scene
  50152. */
  50153. onBeforeRenderObservable: Observable<Layer>;
  50154. private _onBeforeRenderObserver;
  50155. /**
  50156. * Back compatibility with callback before the onBeforeRenderObservable existed.
  50157. * The set callback will be triggered just before rendering the layer.
  50158. */
  50159. onBeforeRender: () => void;
  50160. /**
  50161. * An event triggered after rendering the scene
  50162. */
  50163. onAfterRenderObservable: Observable<Layer>;
  50164. private _onAfterRenderObserver;
  50165. /**
  50166. * Back compatibility with callback before the onAfterRenderObservable existed.
  50167. * The set callback will be triggered just after rendering the layer.
  50168. */
  50169. onAfterRender: () => void;
  50170. /**
  50171. * Instantiates a new layer.
  50172. * This represents a full screen 2d layer.
  50173. * This can be useful to display a picture in the background of your scene for instance.
  50174. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50175. * @param name Define the name of the layer in the scene
  50176. * @param imgUrl Define the url of the texture to display in the layer
  50177. * @param scene Define the scene the layer belongs to
  50178. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  50179. * @param color Defines a color for the layer
  50180. */
  50181. constructor(
  50182. /**
  50183. * Define the name of the layer.
  50184. */
  50185. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  50186. private _createIndexBuffer;
  50187. /** @hidden */
  50188. _rebuild(): void;
  50189. /**
  50190. * Renders the layer in the scene.
  50191. */
  50192. render(): void;
  50193. /**
  50194. * Disposes and releases the associated ressources.
  50195. */
  50196. dispose(): void;
  50197. }
  50198. }
  50199. declare module "babylonjs/Layers/index" {
  50200. export * from "babylonjs/Layers/effectLayer";
  50201. export * from "babylonjs/Layers/effectLayerSceneComponent";
  50202. export * from "babylonjs/Layers/glowLayer";
  50203. export * from "babylonjs/Layers/highlightLayer";
  50204. export * from "babylonjs/Layers/layer";
  50205. export * from "babylonjs/Layers/layerSceneComponent";
  50206. }
  50207. declare module "babylonjs/Shaders/lensFlare.fragment" {
  50208. /** @hidden */
  50209. export var lensFlarePixelShader: {
  50210. name: string;
  50211. shader: string;
  50212. };
  50213. }
  50214. declare module "babylonjs/Shaders/lensFlare.vertex" {
  50215. /** @hidden */
  50216. export var lensFlareVertexShader: {
  50217. name: string;
  50218. shader: string;
  50219. };
  50220. }
  50221. declare module "babylonjs/LensFlares/lensFlareSystem" {
  50222. import { Scene } from "babylonjs/scene";
  50223. import { Vector3, Viewport } from "babylonjs/Maths/math";
  50224. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50225. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  50226. import "babylonjs/Shaders/lensFlare.fragment";
  50227. import "babylonjs/Shaders/lensFlare.vertex";
  50228. /**
  50229. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50230. * It is usually composed of several `lensFlare`.
  50231. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50232. */
  50233. export class LensFlareSystem {
  50234. /**
  50235. * Define the name of the lens flare system
  50236. */
  50237. name: string;
  50238. /**
  50239. * List of lens flares used in this system.
  50240. */
  50241. lensFlares: LensFlare[];
  50242. /**
  50243. * Define a limit from the border the lens flare can be visible.
  50244. */
  50245. borderLimit: number;
  50246. /**
  50247. * Define a viewport border we do not want to see the lens flare in.
  50248. */
  50249. viewportBorder: number;
  50250. /**
  50251. * Define a predicate which could limit the list of meshes able to occlude the effect.
  50252. */
  50253. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50254. /**
  50255. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  50256. */
  50257. layerMask: number;
  50258. /**
  50259. * Define the id of the lens flare system in the scene.
  50260. * (equal to name by default)
  50261. */
  50262. id: string;
  50263. private _scene;
  50264. private _emitter;
  50265. private _vertexBuffers;
  50266. private _indexBuffer;
  50267. private _effect;
  50268. private _positionX;
  50269. private _positionY;
  50270. private _isEnabled;
  50271. /** @hidden */
  50272. static _SceneComponentInitialization: (scene: Scene) => void;
  50273. /**
  50274. * Instantiates a lens flare system.
  50275. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50276. * It is usually composed of several `lensFlare`.
  50277. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50278. * @param name Define the name of the lens flare system in the scene
  50279. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  50280. * @param scene Define the scene the lens flare system belongs to
  50281. */
  50282. constructor(
  50283. /**
  50284. * Define the name of the lens flare system
  50285. */
  50286. name: string, emitter: any, scene: Scene);
  50287. /**
  50288. * Define if the lens flare system is enabled.
  50289. */
  50290. isEnabled: boolean;
  50291. /**
  50292. * Get the scene the effects belongs to.
  50293. * @returns the scene holding the lens flare system
  50294. */
  50295. getScene(): Scene;
  50296. /**
  50297. * Get the emitter of the lens flare system.
  50298. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50299. * @returns the emitter of the lens flare system
  50300. */
  50301. getEmitter(): any;
  50302. /**
  50303. * Set the emitter of the lens flare system.
  50304. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50305. * @param newEmitter Define the new emitter of the system
  50306. */
  50307. setEmitter(newEmitter: any): void;
  50308. /**
  50309. * Get the lens flare system emitter position.
  50310. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  50311. * @returns the position
  50312. */
  50313. getEmitterPosition(): Vector3;
  50314. /**
  50315. * @hidden
  50316. */
  50317. computeEffectivePosition(globalViewport: Viewport): boolean;
  50318. /** @hidden */
  50319. _isVisible(): boolean;
  50320. /**
  50321. * @hidden
  50322. */
  50323. render(): boolean;
  50324. /**
  50325. * Dispose and release the lens flare with its associated resources.
  50326. */
  50327. dispose(): void;
  50328. /**
  50329. * Parse a lens flare system from a JSON repressentation
  50330. * @param parsedLensFlareSystem Define the JSON to parse
  50331. * @param scene Define the scene the parsed system should be instantiated in
  50332. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  50333. * @returns the parsed system
  50334. */
  50335. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  50336. /**
  50337. * Serialize the current Lens Flare System into a JSON representation.
  50338. * @returns the serialized JSON
  50339. */
  50340. serialize(): any;
  50341. }
  50342. }
  50343. declare module "babylonjs/LensFlares/lensFlare" {
  50344. import { Nullable } from "babylonjs/types";
  50345. import { Color3 } from "babylonjs/Maths/math";
  50346. import { Texture } from "babylonjs/Materials/Textures/texture";
  50347. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  50348. /**
  50349. * This represents one of the lens effect in a `lensFlareSystem`.
  50350. * It controls one of the indiviual texture used in the effect.
  50351. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50352. */
  50353. export class LensFlare {
  50354. /**
  50355. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50356. */
  50357. size: number;
  50358. /**
  50359. * 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.
  50360. */
  50361. position: number;
  50362. /**
  50363. * Define the lens color.
  50364. */
  50365. color: Color3;
  50366. /**
  50367. * Define the lens texture.
  50368. */
  50369. texture: Nullable<Texture>;
  50370. /**
  50371. * Define the alpha mode to render this particular lens.
  50372. */
  50373. alphaMode: number;
  50374. private _system;
  50375. /**
  50376. * Creates a new Lens Flare.
  50377. * This represents one of the lens effect in a `lensFlareSystem`.
  50378. * It controls one of the indiviual texture used in the effect.
  50379. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50380. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  50381. * @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.
  50382. * @param color Define the lens color
  50383. * @param imgUrl Define the lens texture url
  50384. * @param system Define the `lensFlareSystem` this flare is part of
  50385. * @returns The newly created Lens Flare
  50386. */
  50387. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  50388. /**
  50389. * Instantiates a new Lens Flare.
  50390. * This represents one of the lens effect in a `lensFlareSystem`.
  50391. * It controls one of the indiviual texture used in the effect.
  50392. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50393. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  50394. * @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.
  50395. * @param color Define the lens color
  50396. * @param imgUrl Define the lens texture url
  50397. * @param system Define the `lensFlareSystem` this flare is part of
  50398. */
  50399. constructor(
  50400. /**
  50401. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50402. */
  50403. size: number,
  50404. /**
  50405. * 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.
  50406. */
  50407. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  50408. /**
  50409. * Dispose and release the lens flare with its associated resources.
  50410. */
  50411. dispose(): void;
  50412. }
  50413. }
  50414. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  50415. import { Nullable } from "babylonjs/types";
  50416. import { Scene } from "babylonjs/scene";
  50417. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50418. import { AbstractScene } from "babylonjs/abstractScene";
  50419. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  50420. module "babylonjs/abstractScene" {
  50421. interface AbstractScene {
  50422. /**
  50423. * The list of lens flare system added to the scene
  50424. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50425. */
  50426. lensFlareSystems: Array<LensFlareSystem>;
  50427. /**
  50428. * Removes the given lens flare system from this scene.
  50429. * @param toRemove The lens flare system to remove
  50430. * @returns The index of the removed lens flare system
  50431. */
  50432. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  50433. /**
  50434. * Adds the given lens flare system to this scene
  50435. * @param newLensFlareSystem The lens flare system to add
  50436. */
  50437. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  50438. /**
  50439. * Gets a lens flare system using its name
  50440. * @param name defines the name to look for
  50441. * @returns the lens flare system or null if not found
  50442. */
  50443. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  50444. /**
  50445. * Gets a lens flare system using its id
  50446. * @param id defines the id to look for
  50447. * @returns the lens flare system or null if not found
  50448. */
  50449. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  50450. }
  50451. }
  50452. /**
  50453. * Defines the lens flare scene component responsible to manage any lens flares
  50454. * in a given scene.
  50455. */
  50456. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  50457. /**
  50458. * The component name helpfull to identify the component in the list of scene components.
  50459. */
  50460. readonly name: string;
  50461. /**
  50462. * The scene the component belongs to.
  50463. */
  50464. scene: Scene;
  50465. /**
  50466. * Creates a new instance of the component for the given scene
  50467. * @param scene Defines the scene to register the component in
  50468. */
  50469. constructor(scene: Scene);
  50470. /**
  50471. * Registers the component in a given scene
  50472. */
  50473. register(): void;
  50474. /**
  50475. * Rebuilds the elements related to this component in case of
  50476. * context lost for instance.
  50477. */
  50478. rebuild(): void;
  50479. /**
  50480. * Adds all the elements from the container to the scene
  50481. * @param container the container holding the elements
  50482. */
  50483. addFromContainer(container: AbstractScene): void;
  50484. /**
  50485. * Removes all the elements in the container from the scene
  50486. * @param container contains the elements to remove
  50487. * @param dispose if the removed element should be disposed (default: false)
  50488. */
  50489. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50490. /**
  50491. * Serializes the component data to the specified json object
  50492. * @param serializationObject The object to serialize to
  50493. */
  50494. serialize(serializationObject: any): void;
  50495. /**
  50496. * Disposes the component and the associated ressources.
  50497. */
  50498. dispose(): void;
  50499. private _draw;
  50500. }
  50501. }
  50502. declare module "babylonjs/LensFlares/index" {
  50503. export * from "babylonjs/LensFlares/lensFlare";
  50504. export * from "babylonjs/LensFlares/lensFlareSystem";
  50505. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  50506. }
  50507. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  50508. import { Scene } from "babylonjs/scene";
  50509. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50510. import { AbstractScene } from "babylonjs/abstractScene";
  50511. /**
  50512. * Defines the shadow generator component responsible to manage any shadow generators
  50513. * in a given scene.
  50514. */
  50515. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  50516. /**
  50517. * The component name helpfull to identify the component in the list of scene components.
  50518. */
  50519. readonly name: string;
  50520. /**
  50521. * The scene the component belongs to.
  50522. */
  50523. scene: Scene;
  50524. /**
  50525. * Creates a new instance of the component for the given scene
  50526. * @param scene Defines the scene to register the component in
  50527. */
  50528. constructor(scene: Scene);
  50529. /**
  50530. * Registers the component in a given scene
  50531. */
  50532. register(): void;
  50533. /**
  50534. * Rebuilds the elements related to this component in case of
  50535. * context lost for instance.
  50536. */
  50537. rebuild(): void;
  50538. /**
  50539. * Serializes the component data to the specified json object
  50540. * @param serializationObject The object to serialize to
  50541. */
  50542. serialize(serializationObject: any): void;
  50543. /**
  50544. * Adds all the elements from the container to the scene
  50545. * @param container the container holding the elements
  50546. */
  50547. addFromContainer(container: AbstractScene): void;
  50548. /**
  50549. * Removes all the elements in the container from the scene
  50550. * @param container contains the elements to remove
  50551. * @param dispose if the removed element should be disposed (default: false)
  50552. */
  50553. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50554. /**
  50555. * Rebuilds the elements related to this component in case of
  50556. * context lost for instance.
  50557. */
  50558. dispose(): void;
  50559. private _gatherRenderTargets;
  50560. }
  50561. }
  50562. declare module "babylonjs/Lights/Shadows/index" {
  50563. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  50564. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  50565. }
  50566. declare module "babylonjs/Lights/pointLight" {
  50567. import { Scene } from "babylonjs/scene";
  50568. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50569. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50570. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50571. import { Effect } from "babylonjs/Materials/effect";
  50572. /**
  50573. * A point light is a light defined by an unique point in world space.
  50574. * The light is emitted in every direction from this point.
  50575. * A good example of a point light is a standard light bulb.
  50576. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50577. */
  50578. export class PointLight extends ShadowLight {
  50579. private _shadowAngle;
  50580. /**
  50581. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50582. * This specifies what angle the shadow will use to be created.
  50583. *
  50584. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50585. */
  50586. /**
  50587. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50588. * This specifies what angle the shadow will use to be created.
  50589. *
  50590. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50591. */
  50592. shadowAngle: number;
  50593. /**
  50594. * Gets the direction if it has been set.
  50595. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50596. */
  50597. /**
  50598. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50599. */
  50600. direction: Vector3;
  50601. /**
  50602. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50603. * A PointLight emits the light in every direction.
  50604. * It can cast shadows.
  50605. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50606. * ```javascript
  50607. * var pointLight = new PointLight("pl", camera.position, scene);
  50608. * ```
  50609. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50610. * @param name The light friendly name
  50611. * @param position The position of the point light in the scene
  50612. * @param scene The scene the lights belongs to
  50613. */
  50614. constructor(name: string, position: Vector3, scene: Scene);
  50615. /**
  50616. * Returns the string "PointLight"
  50617. * @returns the class name
  50618. */
  50619. getClassName(): string;
  50620. /**
  50621. * Returns the integer 0.
  50622. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50623. */
  50624. getTypeID(): number;
  50625. /**
  50626. * Specifies wether or not the shadowmap should be a cube texture.
  50627. * @returns true if the shadowmap needs to be a cube texture.
  50628. */
  50629. needCube(): boolean;
  50630. /**
  50631. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50632. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50633. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50634. */
  50635. getShadowDirection(faceIndex?: number): Vector3;
  50636. /**
  50637. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50638. * - fov = PI / 2
  50639. * - aspect ratio : 1.0
  50640. * - z-near and far equal to the active camera minZ and maxZ.
  50641. * Returns the PointLight.
  50642. */
  50643. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50644. protected _buildUniformLayout(): void;
  50645. /**
  50646. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50647. * @param effect The effect to update
  50648. * @param lightIndex The index of the light in the effect to update
  50649. * @returns The point light
  50650. */
  50651. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50652. /**
  50653. * Prepares the list of defines specific to the light type.
  50654. * @param defines the list of defines
  50655. * @param lightIndex defines the index of the light for the effect
  50656. */
  50657. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50658. }
  50659. }
  50660. declare module "babylonjs/Lights/index" {
  50661. export * from "babylonjs/Lights/light";
  50662. export * from "babylonjs/Lights/shadowLight";
  50663. export * from "babylonjs/Lights/Shadows/index";
  50664. export * from "babylonjs/Lights/directionalLight";
  50665. export * from "babylonjs/Lights/hemisphericLight";
  50666. export * from "babylonjs/Lights/pointLight";
  50667. export * from "babylonjs/Lights/spotLight";
  50668. }
  50669. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  50670. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  50671. /**
  50672. * Header information of HDR texture files.
  50673. */
  50674. export interface HDRInfo {
  50675. /**
  50676. * The height of the texture in pixels.
  50677. */
  50678. height: number;
  50679. /**
  50680. * The width of the texture in pixels.
  50681. */
  50682. width: number;
  50683. /**
  50684. * The index of the beginning of the data in the binary file.
  50685. */
  50686. dataPosition: number;
  50687. }
  50688. /**
  50689. * This groups tools to convert HDR texture to native colors array.
  50690. */
  50691. export class HDRTools {
  50692. private static Ldexp;
  50693. private static Rgbe2float;
  50694. private static readStringLine;
  50695. /**
  50696. * Reads header information from an RGBE texture stored in a native array.
  50697. * More information on this format are available here:
  50698. * https://en.wikipedia.org/wiki/RGBE_image_format
  50699. *
  50700. * @param uint8array The binary file stored in native array.
  50701. * @return The header information.
  50702. */
  50703. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50704. /**
  50705. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50706. * This RGBE texture needs to store the information as a panorama.
  50707. *
  50708. * More information on this format are available here:
  50709. * https://en.wikipedia.org/wiki/RGBE_image_format
  50710. *
  50711. * @param buffer The binary file stored in an array buffer.
  50712. * @param size The expected size of the extracted cubemap.
  50713. * @return The Cube Map information.
  50714. */
  50715. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50716. /**
  50717. * Returns the pixels data extracted from an RGBE texture.
  50718. * This pixels will be stored left to right up to down in the R G B order in one array.
  50719. *
  50720. * More information on this format are available here:
  50721. * https://en.wikipedia.org/wiki/RGBE_image_format
  50722. *
  50723. * @param uint8array The binary file stored in an array buffer.
  50724. * @param hdrInfo The header information of the file.
  50725. * @return The pixels data in RGB right to left up to down order.
  50726. */
  50727. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50728. private static RGBE_ReadPixels_RLE;
  50729. }
  50730. }
  50731. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  50732. import { Nullable } from "babylonjs/types";
  50733. import { Scene } from "babylonjs/scene";
  50734. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50735. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50736. import "babylonjs/Engines/Extensions/engine.rawTexture";
  50737. /**
  50738. * This represents a texture coming from an HDR input.
  50739. *
  50740. * The only supported format is currently panorama picture stored in RGBE format.
  50741. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50742. */
  50743. export class HDRCubeTexture extends BaseTexture {
  50744. private static _facesMapping;
  50745. private _generateHarmonics;
  50746. private _noMipmap;
  50747. private _textureMatrix;
  50748. private _size;
  50749. private _onLoad;
  50750. private _onError;
  50751. /**
  50752. * The texture URL.
  50753. */
  50754. url: string;
  50755. /**
  50756. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50757. */
  50758. coordinatesMode: number;
  50759. protected _isBlocking: boolean;
  50760. /**
  50761. * Sets wether or not the texture is blocking during loading.
  50762. */
  50763. /**
  50764. * Gets wether or not the texture is blocking during loading.
  50765. */
  50766. isBlocking: boolean;
  50767. protected _rotationY: number;
  50768. /**
  50769. * Sets texture matrix rotation angle around Y axis in radians.
  50770. */
  50771. /**
  50772. * Gets texture matrix rotation angle around Y axis radians.
  50773. */
  50774. rotationY: number;
  50775. /**
  50776. * Gets or sets the center of the bounding box associated with the cube texture
  50777. * It must define where the camera used to render the texture was set
  50778. */
  50779. boundingBoxPosition: Vector3;
  50780. private _boundingBoxSize;
  50781. /**
  50782. * Gets or sets the size of the bounding box associated with the cube texture
  50783. * When defined, the cubemap will switch to local mode
  50784. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50785. * @example https://www.babylonjs-playground.com/#RNASML
  50786. */
  50787. boundingBoxSize: Vector3;
  50788. /**
  50789. * Instantiates an HDRTexture from the following parameters.
  50790. *
  50791. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50792. * @param scene The scene the texture will be used in
  50793. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50794. * @param noMipmap Forces to not generate the mipmap if true
  50795. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50796. * @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)
  50797. * @param reserved Reserved flag for internal use.
  50798. */
  50799. 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>);
  50800. /**
  50801. * Get the current class name of the texture useful for serialization or dynamic coding.
  50802. * @returns "HDRCubeTexture"
  50803. */
  50804. getClassName(): string;
  50805. /**
  50806. * Occurs when the file is raw .hdr file.
  50807. */
  50808. private loadTexture;
  50809. clone(): HDRCubeTexture;
  50810. delayLoad(): void;
  50811. /**
  50812. * Get the texture reflection matrix used to rotate/transform the reflection.
  50813. * @returns the reflection matrix
  50814. */
  50815. getReflectionTextureMatrix(): Matrix;
  50816. /**
  50817. * Set the texture reflection matrix used to rotate/transform the reflection.
  50818. * @param value Define the reflection matrix to set
  50819. */
  50820. setReflectionTextureMatrix(value: Matrix): void;
  50821. /**
  50822. * Parses a JSON representation of an HDR Texture in order to create the texture
  50823. * @param parsedTexture Define the JSON representation
  50824. * @param scene Define the scene the texture should be created in
  50825. * @param rootUrl Define the root url in case we need to load relative dependencies
  50826. * @returns the newly created texture after parsing
  50827. */
  50828. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50829. serialize(): any;
  50830. }
  50831. }
  50832. declare module "babylonjs/Physics/physicsEngine" {
  50833. import { Nullable } from "babylonjs/types";
  50834. import { Vector3 } from "babylonjs/Maths/math";
  50835. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  50836. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  50837. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  50838. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50839. /**
  50840. * Class used to control physics engine
  50841. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50842. */
  50843. export class PhysicsEngine implements IPhysicsEngine {
  50844. private _physicsPlugin;
  50845. /**
  50846. * Global value used to control the smallest number supported by the simulation
  50847. */
  50848. static Epsilon: number;
  50849. private _impostors;
  50850. private _joints;
  50851. /**
  50852. * Gets the gravity vector used by the simulation
  50853. */
  50854. gravity: Vector3;
  50855. /**
  50856. * Factory used to create the default physics plugin.
  50857. * @returns The default physics plugin
  50858. */
  50859. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50860. /**
  50861. * Creates a new Physics Engine
  50862. * @param gravity defines the gravity vector used by the simulation
  50863. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50864. */
  50865. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50866. /**
  50867. * Sets the gravity vector used by the simulation
  50868. * @param gravity defines the gravity vector to use
  50869. */
  50870. setGravity(gravity: Vector3): void;
  50871. /**
  50872. * Set the time step of the physics engine.
  50873. * Default is 1/60.
  50874. * To slow it down, enter 1/600 for example.
  50875. * To speed it up, 1/30
  50876. * @param newTimeStep defines the new timestep to apply to this world.
  50877. */
  50878. setTimeStep(newTimeStep?: number): void;
  50879. /**
  50880. * Get the time step of the physics engine.
  50881. * @returns the current time step
  50882. */
  50883. getTimeStep(): number;
  50884. /**
  50885. * Release all resources
  50886. */
  50887. dispose(): void;
  50888. /**
  50889. * Gets the name of the current physics plugin
  50890. * @returns the name of the plugin
  50891. */
  50892. getPhysicsPluginName(): string;
  50893. /**
  50894. * Adding a new impostor for the impostor tracking.
  50895. * This will be done by the impostor itself.
  50896. * @param impostor the impostor to add
  50897. */
  50898. addImpostor(impostor: PhysicsImpostor): void;
  50899. /**
  50900. * Remove an impostor from the engine.
  50901. * This impostor and its mesh will not longer be updated by the physics engine.
  50902. * @param impostor the impostor to remove
  50903. */
  50904. removeImpostor(impostor: PhysicsImpostor): void;
  50905. /**
  50906. * Add a joint to the physics engine
  50907. * @param mainImpostor defines the main impostor to which the joint is added.
  50908. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50909. * @param joint defines the joint that will connect both impostors.
  50910. */
  50911. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50912. /**
  50913. * Removes a joint from the simulation
  50914. * @param mainImpostor defines the impostor used with the joint
  50915. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50916. * @param joint defines the joint to remove
  50917. */
  50918. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50919. /**
  50920. * Called by the scene. No need to call it.
  50921. * @param delta defines the timespam between frames
  50922. */
  50923. _step(delta: number): void;
  50924. /**
  50925. * Gets the current plugin used to run the simulation
  50926. * @returns current plugin
  50927. */
  50928. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50929. /**
  50930. * Gets the list of physic impostors
  50931. * @returns an array of PhysicsImpostor
  50932. */
  50933. getImpostors(): Array<PhysicsImpostor>;
  50934. /**
  50935. * Gets the impostor for a physics enabled object
  50936. * @param object defines the object impersonated by the impostor
  50937. * @returns the PhysicsImpostor or null if not found
  50938. */
  50939. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50940. /**
  50941. * Gets the impostor for a physics body object
  50942. * @param body defines physics body used by the impostor
  50943. * @returns the PhysicsImpostor or null if not found
  50944. */
  50945. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50946. /**
  50947. * Does a raycast in the physics world
  50948. * @param from when should the ray start?
  50949. * @param to when should the ray end?
  50950. * @returns PhysicsRaycastResult
  50951. */
  50952. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50953. }
  50954. }
  50955. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  50956. import { Nullable } from "babylonjs/types";
  50957. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  50958. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50959. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50960. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50961. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50962. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50963. /** @hidden */
  50964. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50965. private _useDeltaForWorldStep;
  50966. world: any;
  50967. name: string;
  50968. private _physicsMaterials;
  50969. private _fixedTimeStep;
  50970. private _cannonRaycastResult;
  50971. private _raycastResult;
  50972. private _removeAfterStep;
  50973. BJSCANNON: any;
  50974. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50975. setGravity(gravity: Vector3): void;
  50976. setTimeStep(timeStep: number): void;
  50977. getTimeStep(): number;
  50978. executeStep(delta: number): void;
  50979. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50980. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50981. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50982. private _processChildMeshes;
  50983. removePhysicsBody(impostor: PhysicsImpostor): void;
  50984. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50985. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50986. private _addMaterial;
  50987. private _checkWithEpsilon;
  50988. private _createShape;
  50989. private _createHeightmap;
  50990. private _minus90X;
  50991. private _plus90X;
  50992. private _tmpPosition;
  50993. private _tmpDeltaPosition;
  50994. private _tmpUnityRotation;
  50995. private _updatePhysicsBodyTransformation;
  50996. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50997. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50998. isSupported(): boolean;
  50999. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51000. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51001. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51002. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51003. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51004. getBodyMass(impostor: PhysicsImpostor): number;
  51005. getBodyFriction(impostor: PhysicsImpostor): number;
  51006. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51007. getBodyRestitution(impostor: PhysicsImpostor): number;
  51008. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51009. sleepBody(impostor: PhysicsImpostor): void;
  51010. wakeUpBody(impostor: PhysicsImpostor): void;
  51011. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  51012. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51013. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51014. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51015. getRadius(impostor: PhysicsImpostor): number;
  51016. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51017. dispose(): void;
  51018. private _extendNamespace;
  51019. /**
  51020. * Does a raycast in the physics world
  51021. * @param from when should the ray start?
  51022. * @param to when should the ray end?
  51023. * @returns PhysicsRaycastResult
  51024. */
  51025. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51026. }
  51027. }
  51028. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  51029. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51030. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51031. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51032. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51033. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  51034. import { Nullable } from "babylonjs/types";
  51035. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51036. /** @hidden */
  51037. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  51038. world: any;
  51039. name: string;
  51040. BJSOIMO: any;
  51041. private _raycastResult;
  51042. constructor(iterations?: number, oimoInjection?: any);
  51043. setGravity(gravity: Vector3): void;
  51044. setTimeStep(timeStep: number): void;
  51045. getTimeStep(): number;
  51046. private _tmpImpostorsArray;
  51047. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51048. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51049. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51050. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51051. private _tmpPositionVector;
  51052. removePhysicsBody(impostor: PhysicsImpostor): void;
  51053. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51054. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51055. isSupported(): boolean;
  51056. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51057. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51058. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51059. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51060. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51061. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51062. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51063. getBodyMass(impostor: PhysicsImpostor): number;
  51064. getBodyFriction(impostor: PhysicsImpostor): number;
  51065. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51066. getBodyRestitution(impostor: PhysicsImpostor): number;
  51067. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51068. sleepBody(impostor: PhysicsImpostor): void;
  51069. wakeUpBody(impostor: PhysicsImpostor): void;
  51070. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51071. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  51072. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  51073. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51074. getRadius(impostor: PhysicsImpostor): number;
  51075. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51076. dispose(): void;
  51077. /**
  51078. * Does a raycast in the physics world
  51079. * @param from when should the ray start?
  51080. * @param to when should the ray end?
  51081. * @returns PhysicsRaycastResult
  51082. */
  51083. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51084. }
  51085. }
  51086. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  51087. import { Nullable } from "babylonjs/types";
  51088. import { Scene } from "babylonjs/scene";
  51089. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  51090. import { Mesh } from "babylonjs/Meshes/mesh";
  51091. /**
  51092. * Class containing static functions to help procedurally build meshes
  51093. */
  51094. export class RibbonBuilder {
  51095. /**
  51096. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51097. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51098. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51099. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51100. * * 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
  51101. * * 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
  51102. * * 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
  51103. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51104. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51105. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51106. * * 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
  51107. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51108. * * 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
  51109. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51110. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51111. * @param name defines the name of the mesh
  51112. * @param options defines the options used to create the mesh
  51113. * @param scene defines the hosting scene
  51114. * @returns the ribbon mesh
  51115. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51116. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51117. */
  51118. static CreateRibbon(name: string, options: {
  51119. pathArray: Vector3[][];
  51120. closeArray?: boolean;
  51121. closePath?: boolean;
  51122. offset?: number;
  51123. updatable?: boolean;
  51124. sideOrientation?: number;
  51125. frontUVs?: Vector4;
  51126. backUVs?: Vector4;
  51127. instance?: Mesh;
  51128. invertUV?: boolean;
  51129. uvs?: Vector2[];
  51130. colors?: Color4[];
  51131. }, scene?: Nullable<Scene>): Mesh;
  51132. }
  51133. }
  51134. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  51135. import { Nullable } from "babylonjs/types";
  51136. import { Scene } from "babylonjs/scene";
  51137. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  51138. import { Mesh } from "babylonjs/Meshes/mesh";
  51139. /**
  51140. * Class containing static functions to help procedurally build meshes
  51141. */
  51142. export class ShapeBuilder {
  51143. /**
  51144. * 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.
  51145. * * 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.
  51146. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51147. * * 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.
  51148. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51149. * * 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
  51150. * * 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
  51151. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51152. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51153. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51154. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51155. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51156. * @param name defines the name of the mesh
  51157. * @param options defines the options used to create the mesh
  51158. * @param scene defines the hosting scene
  51159. * @returns the extruded shape mesh
  51160. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51161. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51162. */
  51163. static ExtrudeShape(name: string, options: {
  51164. shape: Vector3[];
  51165. path: Vector3[];
  51166. scale?: number;
  51167. rotation?: number;
  51168. cap?: number;
  51169. updatable?: boolean;
  51170. sideOrientation?: number;
  51171. frontUVs?: Vector4;
  51172. backUVs?: Vector4;
  51173. instance?: Mesh;
  51174. invertUV?: boolean;
  51175. }, scene?: Nullable<Scene>): Mesh;
  51176. /**
  51177. * Creates an custom extruded shape mesh.
  51178. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51179. * * 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.
  51180. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51181. * * 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
  51182. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51183. * * 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
  51184. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51185. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51186. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51187. * * 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
  51188. * * 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
  51189. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51190. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51191. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51192. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51194. * @param name defines the name of the mesh
  51195. * @param options defines the options used to create the mesh
  51196. * @param scene defines the hosting scene
  51197. * @returns the custom extruded shape mesh
  51198. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51199. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51200. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51201. */
  51202. static ExtrudeShapeCustom(name: string, options: {
  51203. shape: Vector3[];
  51204. path: Vector3[];
  51205. scaleFunction?: any;
  51206. rotationFunction?: any;
  51207. ribbonCloseArray?: boolean;
  51208. ribbonClosePath?: boolean;
  51209. cap?: number;
  51210. updatable?: boolean;
  51211. sideOrientation?: number;
  51212. frontUVs?: Vector4;
  51213. backUVs?: Vector4;
  51214. instance?: Mesh;
  51215. invertUV?: boolean;
  51216. }, scene?: Nullable<Scene>): Mesh;
  51217. private static _ExtrudeShapeGeneric;
  51218. }
  51219. }
  51220. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  51221. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  51222. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51223. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51224. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51225. import { Nullable } from "babylonjs/types";
  51226. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51227. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51228. /**
  51229. * AmmoJS Physics plugin
  51230. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51231. * @see https://github.com/kripken/ammo.js/
  51232. */
  51233. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51234. private _useDeltaForWorldStep;
  51235. /**
  51236. * Reference to the Ammo library
  51237. */
  51238. bjsAMMO: any;
  51239. /**
  51240. * Created ammoJS world which physics bodies are added to
  51241. */
  51242. world: any;
  51243. /**
  51244. * Name of the plugin
  51245. */
  51246. name: string;
  51247. private _timeStep;
  51248. private _fixedTimeStep;
  51249. private _maxSteps;
  51250. private _tmpQuaternion;
  51251. private _tmpAmmoTransform;
  51252. private _tmpAmmoQuaternion;
  51253. private _tmpAmmoConcreteContactResultCallback;
  51254. private _collisionConfiguration;
  51255. private _dispatcher;
  51256. private _overlappingPairCache;
  51257. private _solver;
  51258. private _softBodySolver;
  51259. private _tmpAmmoVectorA;
  51260. private _tmpAmmoVectorB;
  51261. private _tmpAmmoVectorC;
  51262. private _tmpAmmoVectorD;
  51263. private _tmpContactCallbackResult;
  51264. private _tmpAmmoVectorRCA;
  51265. private _tmpAmmoVectorRCB;
  51266. private _raycastResult;
  51267. private static readonly DISABLE_COLLISION_FLAG;
  51268. private static readonly KINEMATIC_FLAG;
  51269. private static readonly DISABLE_DEACTIVATION_FLAG;
  51270. /**
  51271. * Initializes the ammoJS plugin
  51272. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51273. * @param ammoInjection can be used to inject your own ammo reference
  51274. */
  51275. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  51276. /**
  51277. * Sets the gravity of the physics world (m/(s^2))
  51278. * @param gravity Gravity to set
  51279. */
  51280. setGravity(gravity: Vector3): void;
  51281. /**
  51282. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51283. * @param timeStep timestep to use in seconds
  51284. */
  51285. setTimeStep(timeStep: number): void;
  51286. /**
  51287. * 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)
  51288. * @param fixedTimeStep fixedTimeStep to use in seconds
  51289. */
  51290. setFixedTimeStep(fixedTimeStep: number): void;
  51291. /**
  51292. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51293. * @param maxSteps the maximum number of steps by the physics engine per frame
  51294. */
  51295. setMaxSteps(maxSteps: number): void;
  51296. /**
  51297. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51298. * @returns the current timestep in seconds
  51299. */
  51300. getTimeStep(): number;
  51301. private _isImpostorInContact;
  51302. private _isImpostorPairInContact;
  51303. private _stepSimulation;
  51304. /**
  51305. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51306. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51307. * After the step the babylon meshes are set to the position of the physics imposters
  51308. * @param delta amount of time to step forward
  51309. * @param impostors array of imposters to update before/after the step
  51310. */
  51311. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51312. /**
  51313. * Update babylon mesh to match physics world object
  51314. * @param impostor imposter to match
  51315. */
  51316. private _afterSoftStep;
  51317. /**
  51318. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51319. * @param impostor imposter to match
  51320. */
  51321. private _ropeStep;
  51322. /**
  51323. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51324. * @param impostor imposter to match
  51325. */
  51326. private _softbodyOrClothStep;
  51327. private _tmpVector;
  51328. private _tmpMatrix;
  51329. /**
  51330. * Applies an impulse on the imposter
  51331. * @param impostor imposter to apply impulse to
  51332. * @param force amount of force to be applied to the imposter
  51333. * @param contactPoint the location to apply the impulse on the imposter
  51334. */
  51335. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51336. /**
  51337. * Applies a force on the imposter
  51338. * @param impostor imposter to apply force
  51339. * @param force amount of force to be applied to the imposter
  51340. * @param contactPoint the location to apply the force on the imposter
  51341. */
  51342. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51343. /**
  51344. * Creates a physics body using the plugin
  51345. * @param impostor the imposter to create the physics body on
  51346. */
  51347. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51348. /**
  51349. * Removes the physics body from the imposter and disposes of the body's memory
  51350. * @param impostor imposter to remove the physics body from
  51351. */
  51352. removePhysicsBody(impostor: PhysicsImpostor): void;
  51353. /**
  51354. * Generates a joint
  51355. * @param impostorJoint the imposter joint to create the joint with
  51356. */
  51357. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51358. /**
  51359. * Removes a joint
  51360. * @param impostorJoint the imposter joint to remove the joint from
  51361. */
  51362. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51363. private _addMeshVerts;
  51364. /**
  51365. * Initialise the soft body vertices to match its object's (mesh) vertices
  51366. * Softbody vertices (nodes) are in world space and to match this
  51367. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  51368. * @param impostor to create the softbody for
  51369. */
  51370. private _softVertexData;
  51371. /**
  51372. * Create an impostor's soft body
  51373. * @param impostor to create the softbody for
  51374. */
  51375. private _createSoftbody;
  51376. /**
  51377. * Create cloth for an impostor
  51378. * @param impostor to create the softbody for
  51379. */
  51380. private _createCloth;
  51381. /**
  51382. * Create rope for an impostor
  51383. * @param impostor to create the softbody for
  51384. */
  51385. private _createRope;
  51386. private _addHullVerts;
  51387. private _createShape;
  51388. /**
  51389. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51390. * @param impostor imposter containing the physics body and babylon object
  51391. */
  51392. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51393. /**
  51394. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51395. * @param impostor imposter containing the physics body and babylon object
  51396. * @param newPosition new position
  51397. * @param newRotation new rotation
  51398. */
  51399. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51400. /**
  51401. * If this plugin is supported
  51402. * @returns true if its supported
  51403. */
  51404. isSupported(): boolean;
  51405. /**
  51406. * Sets the linear velocity of the physics body
  51407. * @param impostor imposter to set the velocity on
  51408. * @param velocity velocity to set
  51409. */
  51410. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51411. /**
  51412. * Sets the angular velocity of the physics body
  51413. * @param impostor imposter to set the velocity on
  51414. * @param velocity velocity to set
  51415. */
  51416. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51417. /**
  51418. * gets the linear velocity
  51419. * @param impostor imposter to get linear velocity from
  51420. * @returns linear velocity
  51421. */
  51422. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51423. /**
  51424. * gets the angular velocity
  51425. * @param impostor imposter to get angular velocity from
  51426. * @returns angular velocity
  51427. */
  51428. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51429. /**
  51430. * Sets the mass of physics body
  51431. * @param impostor imposter to set the mass on
  51432. * @param mass mass to set
  51433. */
  51434. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51435. /**
  51436. * Gets the mass of the physics body
  51437. * @param impostor imposter to get the mass from
  51438. * @returns mass
  51439. */
  51440. getBodyMass(impostor: PhysicsImpostor): number;
  51441. /**
  51442. * Gets friction of the impostor
  51443. * @param impostor impostor to get friction from
  51444. * @returns friction value
  51445. */
  51446. getBodyFriction(impostor: PhysicsImpostor): number;
  51447. /**
  51448. * Sets friction of the impostor
  51449. * @param impostor impostor to set friction on
  51450. * @param friction friction value
  51451. */
  51452. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51453. /**
  51454. * Gets restitution of the impostor
  51455. * @param impostor impostor to get restitution from
  51456. * @returns restitution value
  51457. */
  51458. getBodyRestitution(impostor: PhysicsImpostor): number;
  51459. /**
  51460. * Sets resitution of the impostor
  51461. * @param impostor impostor to set resitution on
  51462. * @param restitution resitution value
  51463. */
  51464. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51465. /**
  51466. * Gets pressure inside the impostor
  51467. * @param impostor impostor to get pressure from
  51468. * @returns pressure value
  51469. */
  51470. getBodyPressure(impostor: PhysicsImpostor): number;
  51471. /**
  51472. * Sets pressure inside a soft body impostor
  51473. * Cloth and rope must remain 0 pressure
  51474. * @param impostor impostor to set pressure on
  51475. * @param pressure pressure value
  51476. */
  51477. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  51478. /**
  51479. * Gets stiffness of the impostor
  51480. * @param impostor impostor to get stiffness from
  51481. * @returns pressure value
  51482. */
  51483. getBodyStiffness(impostor: PhysicsImpostor): number;
  51484. /**
  51485. * Sets stiffness of the impostor
  51486. * @param impostor impostor to set stiffness on
  51487. * @param stiffness stiffness value from 0 to 1
  51488. */
  51489. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  51490. /**
  51491. * Gets velocityIterations of the impostor
  51492. * @param impostor impostor to get velocity iterations from
  51493. * @returns velocityIterations value
  51494. */
  51495. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  51496. /**
  51497. * Sets velocityIterations of the impostor
  51498. * @param impostor impostor to set velocity iterations on
  51499. * @param velocityIterations velocityIterations value
  51500. */
  51501. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  51502. /**
  51503. * Gets positionIterations of the impostor
  51504. * @param impostor impostor to get position iterations from
  51505. * @returns positionIterations value
  51506. */
  51507. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  51508. /**
  51509. * Sets positionIterations of the impostor
  51510. * @param impostor impostor to set position on
  51511. * @param positionIterations positionIterations value
  51512. */
  51513. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  51514. /**
  51515. * Append an anchor to a cloth object
  51516. * @param impostor is the cloth impostor to add anchor to
  51517. * @param otherImpostor is the rigid impostor to anchor to
  51518. * @param width ratio across width from 0 to 1
  51519. * @param height ratio up height from 0 to 1
  51520. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  51521. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51522. */
  51523. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51524. /**
  51525. * Append an hook to a rope object
  51526. * @param impostor is the rope impostor to add hook to
  51527. * @param otherImpostor is the rigid impostor to hook to
  51528. * @param length ratio along the rope from 0 to 1
  51529. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  51530. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51531. */
  51532. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51533. /**
  51534. * Sleeps the physics body and stops it from being active
  51535. * @param impostor impostor to sleep
  51536. */
  51537. sleepBody(impostor: PhysicsImpostor): void;
  51538. /**
  51539. * Activates the physics body
  51540. * @param impostor impostor to activate
  51541. */
  51542. wakeUpBody(impostor: PhysicsImpostor): void;
  51543. /**
  51544. * Updates the distance parameters of the joint
  51545. * @param joint joint to update
  51546. * @param maxDistance maximum distance of the joint
  51547. * @param minDistance minimum distance of the joint
  51548. */
  51549. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51550. /**
  51551. * Sets a motor on the joint
  51552. * @param joint joint to set motor on
  51553. * @param speed speed of the motor
  51554. * @param maxForce maximum force of the motor
  51555. * @param motorIndex index of the motor
  51556. */
  51557. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51558. /**
  51559. * Sets the motors limit
  51560. * @param joint joint to set limit on
  51561. * @param upperLimit upper limit
  51562. * @param lowerLimit lower limit
  51563. */
  51564. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51565. /**
  51566. * Syncs the position and rotation of a mesh with the impostor
  51567. * @param mesh mesh to sync
  51568. * @param impostor impostor to update the mesh with
  51569. */
  51570. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51571. /**
  51572. * Gets the radius of the impostor
  51573. * @param impostor impostor to get radius from
  51574. * @returns the radius
  51575. */
  51576. getRadius(impostor: PhysicsImpostor): number;
  51577. /**
  51578. * Gets the box size of the impostor
  51579. * @param impostor impostor to get box size from
  51580. * @param result the resulting box size
  51581. */
  51582. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51583. /**
  51584. * Disposes of the impostor
  51585. */
  51586. dispose(): void;
  51587. /**
  51588. * Does a raycast in the physics world
  51589. * @param from when should the ray start?
  51590. * @param to when should the ray end?
  51591. * @returns PhysicsRaycastResult
  51592. */
  51593. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51594. }
  51595. }
  51596. declare module "babylonjs/Probes/reflectionProbe" {
  51597. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51598. import { Vector3 } from "babylonjs/Maths/math";
  51599. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51600. import { Nullable } from "babylonjs/types";
  51601. import { Scene } from "babylonjs/scene";
  51602. module "babylonjs/abstractScene" {
  51603. interface AbstractScene {
  51604. /**
  51605. * The list of reflection probes added to the scene
  51606. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51607. */
  51608. reflectionProbes: Array<ReflectionProbe>;
  51609. /**
  51610. * Removes the given reflection probe from this scene.
  51611. * @param toRemove The reflection probe to remove
  51612. * @returns The index of the removed reflection probe
  51613. */
  51614. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51615. /**
  51616. * Adds the given reflection probe to this scene.
  51617. * @param newReflectionProbe The reflection probe to add
  51618. */
  51619. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51620. }
  51621. }
  51622. /**
  51623. * Class used to generate realtime reflection / refraction cube textures
  51624. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51625. */
  51626. export class ReflectionProbe {
  51627. /** defines the name of the probe */
  51628. name: string;
  51629. private _scene;
  51630. private _renderTargetTexture;
  51631. private _projectionMatrix;
  51632. private _viewMatrix;
  51633. private _target;
  51634. private _add;
  51635. private _attachedMesh;
  51636. private _invertYAxis;
  51637. /** Gets or sets probe position (center of the cube map) */
  51638. position: Vector3;
  51639. /**
  51640. * Creates a new reflection probe
  51641. * @param name defines the name of the probe
  51642. * @param size defines the texture resolution (for each face)
  51643. * @param scene defines the hosting scene
  51644. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51645. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51646. */
  51647. constructor(
  51648. /** defines the name of the probe */
  51649. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51650. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51651. samples: number;
  51652. /** Gets or sets the refresh rate to use (on every frame by default) */
  51653. refreshRate: number;
  51654. /**
  51655. * Gets the hosting scene
  51656. * @returns a Scene
  51657. */
  51658. getScene(): Scene;
  51659. /** Gets the internal CubeTexture used to render to */
  51660. readonly cubeTexture: RenderTargetTexture;
  51661. /** Gets the list of meshes to render */
  51662. readonly renderList: Nullable<AbstractMesh[]>;
  51663. /**
  51664. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51665. * @param mesh defines the mesh to attach to
  51666. */
  51667. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51668. /**
  51669. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51670. * @param renderingGroupId The rendering group id corresponding to its index
  51671. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51672. */
  51673. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51674. /**
  51675. * Clean all associated resources
  51676. */
  51677. dispose(): void;
  51678. /**
  51679. * Converts the reflection probe information to a readable string for debug purpose.
  51680. * @param fullDetails Supports for multiple levels of logging within scene loading
  51681. * @returns the human readable reflection probe info
  51682. */
  51683. toString(fullDetails?: boolean): string;
  51684. /**
  51685. * Get the class name of the relfection probe.
  51686. * @returns "ReflectionProbe"
  51687. */
  51688. getClassName(): string;
  51689. /**
  51690. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51691. * @returns The JSON representation of the texture
  51692. */
  51693. serialize(): any;
  51694. /**
  51695. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51696. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51697. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51698. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51699. * @returns The parsed reflection probe if successful
  51700. */
  51701. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51702. }
  51703. }
  51704. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  51705. /** @hidden */
  51706. export var _BabylonLoaderRegistered: boolean;
  51707. }
  51708. declare module "babylonjs/Loading/Plugins/index" {
  51709. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  51710. }
  51711. declare module "babylonjs/Loading/index" {
  51712. export * from "babylonjs/Loading/loadingScreen";
  51713. export * from "babylonjs/Loading/Plugins/index";
  51714. export * from "babylonjs/Loading/sceneLoader";
  51715. export * from "babylonjs/Loading/sceneLoaderFlags";
  51716. }
  51717. declare module "babylonjs/Materials/Background/index" {
  51718. export * from "babylonjs/Materials/Background/backgroundMaterial";
  51719. }
  51720. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  51721. import { Scene } from "babylonjs/scene";
  51722. import { Color3 } from "babylonjs/Maths/math";
  51723. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51724. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51725. /**
  51726. * The Physically based simple base material of BJS.
  51727. *
  51728. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51729. * It is used as the base class for both the specGloss and metalRough conventions.
  51730. */
  51731. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51732. /**
  51733. * Number of Simultaneous lights allowed on the material.
  51734. */
  51735. maxSimultaneousLights: number;
  51736. /**
  51737. * If sets to true, disables all the lights affecting the material.
  51738. */
  51739. disableLighting: boolean;
  51740. /**
  51741. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51742. */
  51743. environmentTexture: BaseTexture;
  51744. /**
  51745. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51746. */
  51747. invertNormalMapX: boolean;
  51748. /**
  51749. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51750. */
  51751. invertNormalMapY: boolean;
  51752. /**
  51753. * Normal map used in the model.
  51754. */
  51755. normalTexture: BaseTexture;
  51756. /**
  51757. * Emissivie color used to self-illuminate the model.
  51758. */
  51759. emissiveColor: Color3;
  51760. /**
  51761. * Emissivie texture used to self-illuminate the model.
  51762. */
  51763. emissiveTexture: BaseTexture;
  51764. /**
  51765. * Occlusion Channel Strenght.
  51766. */
  51767. occlusionStrength: number;
  51768. /**
  51769. * Occlusion Texture of the material (adding extra occlusion effects).
  51770. */
  51771. occlusionTexture: BaseTexture;
  51772. /**
  51773. * Defines the alpha limits in alpha test mode.
  51774. */
  51775. alphaCutOff: number;
  51776. /**
  51777. * Gets the current double sided mode.
  51778. */
  51779. /**
  51780. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51781. */
  51782. doubleSided: boolean;
  51783. /**
  51784. * Stores the pre-calculated light information of a mesh in a texture.
  51785. */
  51786. lightmapTexture: BaseTexture;
  51787. /**
  51788. * If true, the light map contains occlusion information instead of lighting info.
  51789. */
  51790. useLightmapAsShadowmap: boolean;
  51791. /**
  51792. * Instantiates a new PBRMaterial instance.
  51793. *
  51794. * @param name The material name
  51795. * @param scene The scene the material will be use in.
  51796. */
  51797. constructor(name: string, scene: Scene);
  51798. getClassName(): string;
  51799. }
  51800. }
  51801. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  51802. import { Scene } from "babylonjs/scene";
  51803. import { Color3 } from "babylonjs/Maths/math";
  51804. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51805. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51806. /**
  51807. * The PBR material of BJS following the metal roughness convention.
  51808. *
  51809. * This fits to the PBR convention in the GLTF definition:
  51810. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51811. */
  51812. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51813. /**
  51814. * The base color has two different interpretations depending on the value of metalness.
  51815. * When the material is a metal, the base color is the specific measured reflectance value
  51816. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51817. * of the material.
  51818. */
  51819. baseColor: Color3;
  51820. /**
  51821. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51822. * well as opacity information in the alpha channel.
  51823. */
  51824. baseTexture: BaseTexture;
  51825. /**
  51826. * Specifies the metallic scalar value of the material.
  51827. * Can also be used to scale the metalness values of the metallic texture.
  51828. */
  51829. metallic: number;
  51830. /**
  51831. * Specifies the roughness scalar value of the material.
  51832. * Can also be used to scale the roughness values of the metallic texture.
  51833. */
  51834. roughness: number;
  51835. /**
  51836. * Texture containing both the metallic value in the B channel and the
  51837. * roughness value in the G channel to keep better precision.
  51838. */
  51839. metallicRoughnessTexture: BaseTexture;
  51840. /**
  51841. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51842. *
  51843. * @param name The material name
  51844. * @param scene The scene the material will be use in.
  51845. */
  51846. constructor(name: string, scene: Scene);
  51847. /**
  51848. * Return the currrent class name of the material.
  51849. */
  51850. getClassName(): string;
  51851. /**
  51852. * Makes a duplicate of the current material.
  51853. * @param name - name to use for the new material.
  51854. */
  51855. clone(name: string): PBRMetallicRoughnessMaterial;
  51856. /**
  51857. * Serialize the material to a parsable JSON object.
  51858. */
  51859. serialize(): any;
  51860. /**
  51861. * Parses a JSON object correponding to the serialize function.
  51862. */
  51863. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51864. }
  51865. }
  51866. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  51867. import { Scene } from "babylonjs/scene";
  51868. import { Color3 } from "babylonjs/Maths/math";
  51869. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51870. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51871. /**
  51872. * The PBR material of BJS following the specular glossiness convention.
  51873. *
  51874. * This fits to the PBR convention in the GLTF definition:
  51875. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51876. */
  51877. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51878. /**
  51879. * Specifies the diffuse color of the material.
  51880. */
  51881. diffuseColor: Color3;
  51882. /**
  51883. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51884. * channel.
  51885. */
  51886. diffuseTexture: BaseTexture;
  51887. /**
  51888. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51889. */
  51890. specularColor: Color3;
  51891. /**
  51892. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51893. */
  51894. glossiness: number;
  51895. /**
  51896. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51897. */
  51898. specularGlossinessTexture: BaseTexture;
  51899. /**
  51900. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51901. *
  51902. * @param name The material name
  51903. * @param scene The scene the material will be use in.
  51904. */
  51905. constructor(name: string, scene: Scene);
  51906. /**
  51907. * Return the currrent class name of the material.
  51908. */
  51909. getClassName(): string;
  51910. /**
  51911. * Makes a duplicate of the current material.
  51912. * @param name - name to use for the new material.
  51913. */
  51914. clone(name: string): PBRSpecularGlossinessMaterial;
  51915. /**
  51916. * Serialize the material to a parsable JSON object.
  51917. */
  51918. serialize(): any;
  51919. /**
  51920. * Parses a JSON object correponding to the serialize function.
  51921. */
  51922. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51923. }
  51924. }
  51925. declare module "babylonjs/Materials/PBR/index" {
  51926. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51927. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51928. export * from "babylonjs/Materials/PBR/pbrMaterial";
  51929. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  51930. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  51931. }
  51932. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  51933. import { Nullable } from "babylonjs/types";
  51934. import { Scene } from "babylonjs/scene";
  51935. import { Matrix } from "babylonjs/Maths/math";
  51936. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51937. /**
  51938. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51939. * It can help converting any input color in a desired output one. This can then be used to create effects
  51940. * from sepia, black and white to sixties or futuristic rendering...
  51941. *
  51942. * The only supported format is currently 3dl.
  51943. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51944. */
  51945. export class ColorGradingTexture extends BaseTexture {
  51946. /**
  51947. * The current texture matrix. (will always be identity in color grading texture)
  51948. */
  51949. private _textureMatrix;
  51950. /**
  51951. * The texture URL.
  51952. */
  51953. url: string;
  51954. /**
  51955. * Empty line regex stored for GC.
  51956. */
  51957. private static _noneEmptyLineRegex;
  51958. private _engine;
  51959. /**
  51960. * Instantiates a ColorGradingTexture from the following parameters.
  51961. *
  51962. * @param url The location of the color gradind data (currently only supporting 3dl)
  51963. * @param scene The scene the texture will be used in
  51964. */
  51965. constructor(url: string, scene: Scene);
  51966. /**
  51967. * Returns the texture matrix used in most of the material.
  51968. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51969. */
  51970. getTextureMatrix(): Matrix;
  51971. /**
  51972. * Occurs when the file being loaded is a .3dl LUT file.
  51973. */
  51974. private load3dlTexture;
  51975. /**
  51976. * Starts the loading process of the texture.
  51977. */
  51978. private loadTexture;
  51979. /**
  51980. * Clones the color gradind texture.
  51981. */
  51982. clone(): ColorGradingTexture;
  51983. /**
  51984. * Called during delayed load for textures.
  51985. */
  51986. delayLoad(): void;
  51987. /**
  51988. * Parses a color grading texture serialized by Babylon.
  51989. * @param parsedTexture The texture information being parsedTexture
  51990. * @param scene The scene to load the texture in
  51991. * @param rootUrl The root url of the data assets to load
  51992. * @return A color gradind texture
  51993. */
  51994. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51995. /**
  51996. * Serializes the LUT texture to json format.
  51997. */
  51998. serialize(): any;
  51999. }
  52000. }
  52001. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  52002. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52003. import { Scene } from "babylonjs/scene";
  52004. import { Nullable } from "babylonjs/types";
  52005. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52006. /**
  52007. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  52008. */
  52009. export class EquiRectangularCubeTexture extends BaseTexture {
  52010. /** The six faces of the cube. */
  52011. private static _FacesMapping;
  52012. private _noMipmap;
  52013. private _onLoad;
  52014. private _onError;
  52015. /** The size of the cubemap. */
  52016. private _size;
  52017. /** The buffer of the image. */
  52018. private _buffer;
  52019. /** The width of the input image. */
  52020. private _width;
  52021. /** The height of the input image. */
  52022. private _height;
  52023. /** The URL to the image. */
  52024. url: string;
  52025. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  52026. coordinatesMode: number;
  52027. /**
  52028. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  52029. * @param url The location of the image
  52030. * @param scene The scene the texture will be used in
  52031. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52032. * @param noMipmap Forces to not generate the mipmap if true
  52033. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  52034. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  52035. * @param onLoad — defines a callback called when texture is loaded
  52036. * @param onError — defines a callback called if there is an error
  52037. */
  52038. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  52039. /**
  52040. * Load the image data, by putting the image on a canvas and extracting its buffer.
  52041. */
  52042. private loadImage;
  52043. /**
  52044. * Convert the image buffer into a cubemap and create a CubeTexture.
  52045. */
  52046. private loadTexture;
  52047. /**
  52048. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  52049. * @param buffer The ArrayBuffer that should be converted.
  52050. * @returns The buffer as Float32Array.
  52051. */
  52052. private getFloat32ArrayFromArrayBuffer;
  52053. /**
  52054. * Get the current class name of the texture useful for serialization or dynamic coding.
  52055. * @returns "EquiRectangularCubeTexture"
  52056. */
  52057. getClassName(): string;
  52058. /**
  52059. * Create a clone of the current EquiRectangularCubeTexture and return it.
  52060. * @returns A clone of the current EquiRectangularCubeTexture.
  52061. */
  52062. clone(): EquiRectangularCubeTexture;
  52063. }
  52064. }
  52065. declare module "babylonjs/Misc/tga" {
  52066. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52067. /**
  52068. * Based on jsTGALoader - Javascript loader for TGA file
  52069. * By Vincent Thibault
  52070. * @see http://blog.robrowser.com/javascript-tga-loader.html
  52071. */
  52072. export class TGATools {
  52073. private static _TYPE_INDEXED;
  52074. private static _TYPE_RGB;
  52075. private static _TYPE_GREY;
  52076. private static _TYPE_RLE_INDEXED;
  52077. private static _TYPE_RLE_RGB;
  52078. private static _TYPE_RLE_GREY;
  52079. private static _ORIGIN_MASK;
  52080. private static _ORIGIN_SHIFT;
  52081. private static _ORIGIN_BL;
  52082. private static _ORIGIN_BR;
  52083. private static _ORIGIN_UL;
  52084. private static _ORIGIN_UR;
  52085. /**
  52086. * Gets the header of a TGA file
  52087. * @param data defines the TGA data
  52088. * @returns the header
  52089. */
  52090. static GetTGAHeader(data: Uint8Array): any;
  52091. /**
  52092. * Uploads TGA content to a Babylon Texture
  52093. * @hidden
  52094. */
  52095. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  52096. /** @hidden */
  52097. 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;
  52098. /** @hidden */
  52099. 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;
  52100. /** @hidden */
  52101. 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;
  52102. /** @hidden */
  52103. 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;
  52104. /** @hidden */
  52105. 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;
  52106. /** @hidden */
  52107. 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;
  52108. }
  52109. }
  52110. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  52111. import { Nullable } from "babylonjs/types";
  52112. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52113. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52114. /**
  52115. * Implementation of the TGA Texture Loader.
  52116. * @hidden
  52117. */
  52118. export class _TGATextureLoader implements IInternalTextureLoader {
  52119. /**
  52120. * Defines wether the loader supports cascade loading the different faces.
  52121. */
  52122. readonly supportCascades: boolean;
  52123. /**
  52124. * This returns if the loader support the current file information.
  52125. * @param extension defines the file extension of the file being loaded
  52126. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52127. * @param fallback defines the fallback internal texture if any
  52128. * @param isBase64 defines whether the texture is encoded as a base64
  52129. * @param isBuffer defines whether the texture data are stored as a buffer
  52130. * @returns true if the loader can load the specified file
  52131. */
  52132. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52133. /**
  52134. * Transform the url before loading if required.
  52135. * @param rootUrl the url of the texture
  52136. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52137. * @returns the transformed texture
  52138. */
  52139. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52140. /**
  52141. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52142. * @param rootUrl the url of the texture
  52143. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52144. * @returns the fallback texture
  52145. */
  52146. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52147. /**
  52148. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52149. * @param data contains the texture data
  52150. * @param texture defines the BabylonJS internal texture
  52151. * @param createPolynomials will be true if polynomials have been requested
  52152. * @param onLoad defines the callback to trigger once the texture is ready
  52153. * @param onError defines the callback to trigger in case of error
  52154. */
  52155. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52156. /**
  52157. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52158. * @param data contains the texture data
  52159. * @param texture defines the BabylonJS internal texture
  52160. * @param callback defines the method to call once ready to upload
  52161. */
  52162. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52163. }
  52164. }
  52165. declare module "babylonjs/Materials/Textures/Loaders/index" {
  52166. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  52167. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  52168. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  52169. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  52170. }
  52171. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  52172. import { Scene } from "babylonjs/scene";
  52173. import { Texture } from "babylonjs/Materials/Textures/texture";
  52174. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52175. /**
  52176. * 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.
  52177. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52178. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52179. */
  52180. export class CustomProceduralTexture extends ProceduralTexture {
  52181. private _animate;
  52182. private _time;
  52183. private _config;
  52184. private _texturePath;
  52185. /**
  52186. * Instantiates a new Custom Procedural Texture.
  52187. * 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.
  52188. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52189. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52190. * @param name Define the name of the texture
  52191. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  52192. * @param size Define the size of the texture to create
  52193. * @param scene Define the scene the texture belongs to
  52194. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  52195. * @param generateMipMaps Define if the texture should creates mip maps or not
  52196. */
  52197. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52198. private _loadJson;
  52199. /**
  52200. * Is the texture ready to be used ? (rendered at least once)
  52201. * @returns true if ready, otherwise, false.
  52202. */
  52203. isReady(): boolean;
  52204. /**
  52205. * Render the texture to its associated render target.
  52206. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  52207. */
  52208. render(useCameraPostProcess?: boolean): void;
  52209. /**
  52210. * Update the list of dependant textures samplers in the shader.
  52211. */
  52212. updateTextures(): void;
  52213. /**
  52214. * Update the uniform values of the procedural texture in the shader.
  52215. */
  52216. updateShaderUniforms(): void;
  52217. /**
  52218. * Define if the texture animates or not.
  52219. */
  52220. animate: boolean;
  52221. }
  52222. }
  52223. declare module "babylonjs/Shaders/noise.fragment" {
  52224. /** @hidden */
  52225. export var noisePixelShader: {
  52226. name: string;
  52227. shader: string;
  52228. };
  52229. }
  52230. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  52231. import { Nullable } from "babylonjs/types";
  52232. import { Scene } from "babylonjs/scene";
  52233. import { Texture } from "babylonjs/Materials/Textures/texture";
  52234. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52235. import "babylonjs/Shaders/noise.fragment";
  52236. /**
  52237. * Class used to generate noise procedural textures
  52238. */
  52239. export class NoiseProceduralTexture extends ProceduralTexture {
  52240. private _time;
  52241. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  52242. brightness: number;
  52243. /** Defines the number of octaves to process */
  52244. octaves: number;
  52245. /** Defines the level of persistence (0.8 by default) */
  52246. persistence: number;
  52247. /** Gets or sets animation speed factor (default is 1) */
  52248. animationSpeedFactor: number;
  52249. /**
  52250. * Creates a new NoiseProceduralTexture
  52251. * @param name defines the name fo the texture
  52252. * @param size defines the size of the texture (default is 256)
  52253. * @param scene defines the hosting scene
  52254. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  52255. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  52256. */
  52257. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52258. private _updateShaderUniforms;
  52259. protected _getDefines(): string;
  52260. /** Generate the current state of the procedural texture */
  52261. render(useCameraPostProcess?: boolean): void;
  52262. /**
  52263. * Serializes this noise procedural texture
  52264. * @returns a serialized noise procedural texture object
  52265. */
  52266. serialize(): any;
  52267. /**
  52268. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  52269. * @param parsedTexture defines parsed texture data
  52270. * @param scene defines the current scene
  52271. * @param rootUrl defines the root URL containing noise procedural texture information
  52272. * @returns a parsed NoiseProceduralTexture
  52273. */
  52274. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  52275. }
  52276. }
  52277. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  52278. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  52279. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  52280. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52281. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  52282. }
  52283. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  52284. import { Nullable } from "babylonjs/types";
  52285. import { Scene } from "babylonjs/scene";
  52286. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  52287. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52288. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  52289. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52290. /**
  52291. * Raw cube texture where the raw buffers are passed in
  52292. */
  52293. export class RawCubeTexture extends CubeTexture {
  52294. /**
  52295. * Creates a cube texture where the raw buffers are passed in.
  52296. * @param scene defines the scene the texture is attached to
  52297. * @param data defines the array of data to use to create each face
  52298. * @param size defines the size of the textures
  52299. * @param format defines the format of the data
  52300. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  52301. * @param generateMipMaps defines if the engine should generate the mip levels
  52302. * @param invertY defines if data must be stored with Y axis inverted
  52303. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  52304. * @param compression defines the compression used (null by default)
  52305. */
  52306. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  52307. /**
  52308. * Updates the raw cube texture.
  52309. * @param data defines the data to store
  52310. * @param format defines the data format
  52311. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  52312. * @param invertY defines if data must be stored with Y axis inverted
  52313. * @param compression defines the compression used (null by default)
  52314. * @param level defines which level of the texture to update
  52315. */
  52316. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  52317. /**
  52318. * Updates a raw cube texture with RGBD encoded data.
  52319. * @param data defines the array of data [mipmap][face] to use to create each face
  52320. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  52321. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52322. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52323. * @returns a promsie that resolves when the operation is complete
  52324. */
  52325. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  52326. /**
  52327. * Clones the raw cube texture.
  52328. * @return a new cube texture
  52329. */
  52330. clone(): CubeTexture;
  52331. /** @hidden */
  52332. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52333. }
  52334. }
  52335. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  52336. import { Scene } from "babylonjs/scene";
  52337. import { Texture } from "babylonjs/Materials/Textures/texture";
  52338. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52339. /**
  52340. * Class used to store 3D textures containing user data
  52341. */
  52342. export class RawTexture3D extends Texture {
  52343. /** Gets or sets the texture format to use */
  52344. format: number;
  52345. private _engine;
  52346. /**
  52347. * Create a new RawTexture3D
  52348. * @param data defines the data of the texture
  52349. * @param width defines the width of the texture
  52350. * @param height defines the height of the texture
  52351. * @param depth defines the depth of the texture
  52352. * @param format defines the texture format to use
  52353. * @param scene defines the hosting scene
  52354. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  52355. * @param invertY defines if texture must be stored with Y axis inverted
  52356. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52357. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  52358. */
  52359. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  52360. /** Gets or sets the texture format to use */
  52361. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  52362. /**
  52363. * Update the texture with new data
  52364. * @param data defines the data to store in the texture
  52365. */
  52366. update(data: ArrayBufferView): void;
  52367. }
  52368. }
  52369. declare module "babylonjs/Materials/Textures/refractionTexture" {
  52370. import { Scene } from "babylonjs/scene";
  52371. import { Plane } from "babylonjs/Maths/math";
  52372. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52373. /**
  52374. * Creates a refraction texture used by refraction channel of the standard material.
  52375. * It is like a mirror but to see through a material.
  52376. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52377. */
  52378. export class RefractionTexture extends RenderTargetTexture {
  52379. /**
  52380. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  52381. * 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.
  52382. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52383. */
  52384. refractionPlane: Plane;
  52385. /**
  52386. * Define how deep under the surface we should see.
  52387. */
  52388. depth: number;
  52389. /**
  52390. * Creates a refraction texture used by refraction channel of the standard material.
  52391. * It is like a mirror but to see through a material.
  52392. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52393. * @param name Define the texture name
  52394. * @param size Define the size of the underlying texture
  52395. * @param scene Define the scene the refraction belongs to
  52396. * @param generateMipMaps Define if we need to generate mips level for the refraction
  52397. */
  52398. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  52399. /**
  52400. * Clone the refraction texture.
  52401. * @returns the cloned texture
  52402. */
  52403. clone(): RefractionTexture;
  52404. /**
  52405. * Serialize the texture to a JSON representation you could use in Parse later on
  52406. * @returns the serialized JSON representation
  52407. */
  52408. serialize(): any;
  52409. }
  52410. }
  52411. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  52412. import { Nullable } from "babylonjs/types";
  52413. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52414. import { Matrix } from "babylonjs/Maths/math";
  52415. import { Engine } from "babylonjs/Engines/engine";
  52416. import { Scene } from "babylonjs/scene";
  52417. /**
  52418. * Defines the options related to the creation of an HtmlElementTexture
  52419. */
  52420. export interface IHtmlElementTextureOptions {
  52421. /**
  52422. * Defines wether mip maps should be created or not.
  52423. */
  52424. generateMipMaps?: boolean;
  52425. /**
  52426. * Defines the sampling mode of the texture.
  52427. */
  52428. samplingMode?: number;
  52429. /**
  52430. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  52431. */
  52432. engine: Nullable<Engine>;
  52433. /**
  52434. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  52435. */
  52436. scene: Nullable<Scene>;
  52437. }
  52438. /**
  52439. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  52440. * To be as efficient as possible depending on your constraints nothing aside the first upload
  52441. * is automatically managed.
  52442. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  52443. * in your application.
  52444. *
  52445. * As the update is not automatic, you need to call them manually.
  52446. */
  52447. export class HtmlElementTexture extends BaseTexture {
  52448. /**
  52449. * The texture URL.
  52450. */
  52451. element: HTMLVideoElement | HTMLCanvasElement;
  52452. private static readonly DefaultOptions;
  52453. private _textureMatrix;
  52454. private _engine;
  52455. private _isVideo;
  52456. private _generateMipMaps;
  52457. private _samplingMode;
  52458. /**
  52459. * Instantiates a HtmlElementTexture from the following parameters.
  52460. *
  52461. * @param name Defines the name of the texture
  52462. * @param element Defines the video or canvas the texture is filled with
  52463. * @param options Defines the other none mandatory texture creation options
  52464. */
  52465. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  52466. private _createInternalTexture;
  52467. /**
  52468. * Returns the texture matrix used in most of the material.
  52469. */
  52470. getTextureMatrix(): Matrix;
  52471. /**
  52472. * Updates the content of the texture.
  52473. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  52474. */
  52475. update(invertY?: Nullable<boolean>): void;
  52476. }
  52477. }
  52478. declare module "babylonjs/Materials/Textures/index" {
  52479. export * from "babylonjs/Materials/Textures/baseTexture";
  52480. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  52481. export * from "babylonjs/Materials/Textures/cubeTexture";
  52482. export * from "babylonjs/Materials/Textures/dynamicTexture";
  52483. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  52484. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  52485. export * from "babylonjs/Materials/Textures/internalTexture";
  52486. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  52487. export * from "babylonjs/Materials/Textures/Loaders/index";
  52488. export * from "babylonjs/Materials/Textures/mirrorTexture";
  52489. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  52490. export * from "babylonjs/Materials/Textures/Procedurals/index";
  52491. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  52492. export * from "babylonjs/Materials/Textures/rawTexture";
  52493. export * from "babylonjs/Materials/Textures/rawTexture3D";
  52494. export * from "babylonjs/Materials/Textures/refractionTexture";
  52495. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  52496. export * from "babylonjs/Materials/Textures/texture";
  52497. export * from "babylonjs/Materials/Textures/videoTexture";
  52498. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  52499. }
  52500. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  52501. /**
  52502. * Enum used to define the target of a block
  52503. */
  52504. export enum NodeMaterialBlockTargets {
  52505. /** Vertex shader */
  52506. Vertex = 1,
  52507. /** Fragment shader */
  52508. Fragment = 2,
  52509. /** Vertex and Fragment */
  52510. VertexAndFragment = 3
  52511. }
  52512. }
  52513. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  52514. /**
  52515. * Defines the kind of connection point for node based material
  52516. */
  52517. export enum NodeMaterialBlockConnectionPointTypes {
  52518. /** Float */
  52519. Float = 1,
  52520. /** Int */
  52521. Int = 2,
  52522. /** Vector2 */
  52523. Vector2 = 4,
  52524. /** Vector3 */
  52525. Vector3 = 8,
  52526. /** Vector4 */
  52527. Vector4 = 16,
  52528. /** Color3 */
  52529. Color3 = 32,
  52530. /** Color4 */
  52531. Color4 = 64,
  52532. /** Matrix */
  52533. Matrix = 128,
  52534. /** Texture */
  52535. Texture = 256,
  52536. /** Texture3D */
  52537. Texture3D = 512,
  52538. /** Vector3 or Color3 */
  52539. Vector3OrColor3 = 40,
  52540. /** Vector3 or Vector4 */
  52541. Vector3OrVector4 = 24,
  52542. /** Vector4 or Color4 */
  52543. Vector4OrColor4 = 80,
  52544. /** Color3 or Color4 */
  52545. Color3OrColor4 = 96,
  52546. /** Vector3 or Color3 */
  52547. Vector3OrColor3OrVector4OrColor4 = 120
  52548. }
  52549. }
  52550. declare module "babylonjs/Materials/Node/nodeMaterialWellKnownValues" {
  52551. /**
  52552. * Enum used to define well known values e.g. values automatically provided by the system
  52553. */
  52554. export enum NodeMaterialWellKnownValues {
  52555. /** World */
  52556. World = 1,
  52557. /** View */
  52558. View = 2,
  52559. /** Projection */
  52560. Projection = 3,
  52561. /** ViewProjection */
  52562. ViewProjection = 4,
  52563. /** WorldView */
  52564. WorldView = 5,
  52565. /** WorldViewProjection */
  52566. WorldViewProjection = 6,
  52567. /** Will be filled by the block itself */
  52568. Automatic = 7
  52569. }
  52570. }
  52571. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  52572. /**
  52573. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52574. */
  52575. export enum NodeMaterialBlockConnectionPointMode {
  52576. /** Value is an uniform */
  52577. Uniform = 0,
  52578. /** Value is a mesh attribute */
  52579. Attribute = 1,
  52580. /** Value is a varying between vertex and fragment shaders */
  52581. Varying = 2,
  52582. /** Mode is undefined */
  52583. Undefined = 3
  52584. }
  52585. }
  52586. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  52587. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  52588. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  52589. /**
  52590. * Class used to store shared data between 2 NodeMaterialBuildState
  52591. */
  52592. export class NodeMaterialBuildStateSharedData {
  52593. /**
  52594. * Gets the list of emitted varyings
  52595. */
  52596. varyings: string[];
  52597. /**
  52598. * Gets the varying declaration string
  52599. */
  52600. varyingDeclaration: string;
  52601. /**
  52602. * Uniform connection points
  52603. */
  52604. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  52605. /**
  52606. * Bindable blocks (Blocks that need to set data to the effect)
  52607. */
  52608. bindableBlocks: NodeMaterialBlock[];
  52609. /**
  52610. * List of blocks that can provide a compilation fallback
  52611. */
  52612. blocksWithFallbacks: NodeMaterialBlock[];
  52613. /**
  52614. * List of blocks that can provide a define update
  52615. */
  52616. blocksWithDefines: NodeMaterialBlock[];
  52617. /**
  52618. * List of blocks that can provide a repeatable content
  52619. */
  52620. repeatableContentBlocks: NodeMaterialBlock[];
  52621. /**
  52622. * List of blocks that can block the isReady function for the material
  52623. */
  52624. blockingBlocks: NodeMaterialBlock[];
  52625. /**
  52626. * Build Id used to avoid multiple recompilations
  52627. */
  52628. buildId: number;
  52629. /** List of emitted variables */
  52630. variableNames: {
  52631. [key: string]: number;
  52632. };
  52633. /** List of emitted defines */
  52634. defineNames: {
  52635. [key: string]: number;
  52636. };
  52637. /** Should emit comments? */
  52638. emitComments: boolean;
  52639. /** Emit build activity */
  52640. verbose: boolean;
  52641. /**
  52642. * Gets the compilation hints emitted at compilation time
  52643. */
  52644. hints: {
  52645. needWorldViewMatrix: boolean;
  52646. needWorldViewProjectionMatrix: boolean;
  52647. needAlphaBlending: boolean;
  52648. needAlphaTesting: boolean;
  52649. };
  52650. /**
  52651. * List of compilation checks
  52652. */
  52653. checks: {
  52654. emitVertex: boolean;
  52655. emitFragment: boolean;
  52656. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  52657. };
  52658. /** Creates a new shared data */
  52659. constructor();
  52660. /**
  52661. * Emits console errors and exceptions if there is a failing check
  52662. */
  52663. emitErrors(): void;
  52664. }
  52665. }
  52666. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  52667. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  52668. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  52669. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  52670. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  52671. /**
  52672. * Class used to store node based material build state
  52673. */
  52674. export class NodeMaterialBuildState {
  52675. /**
  52676. * Gets the list of emitted attributes
  52677. */
  52678. attributes: string[];
  52679. /**
  52680. * Gets the list of emitted uniforms
  52681. */
  52682. uniforms: string[];
  52683. /**
  52684. * Gets the list of emitted samplers
  52685. */
  52686. samplers: string[];
  52687. /**
  52688. * Gets the list of emitted functions
  52689. */
  52690. functions: {
  52691. [key: string]: string;
  52692. };
  52693. /**
  52694. * Gets the target of the compilation state
  52695. */
  52696. target: NodeMaterialBlockTargets;
  52697. /**
  52698. * Shared data between multiple NodeMaterialBuildState instances
  52699. */
  52700. sharedData: NodeMaterialBuildStateSharedData;
  52701. /** @hidden */
  52702. _vertexState: NodeMaterialBuildState;
  52703. private _attributeDeclaration;
  52704. private _uniformDeclaration;
  52705. private _samplerDeclaration;
  52706. private _varyingTransfer;
  52707. private _repeatableContentAnchorIndex;
  52708. /** @hidden */
  52709. _builtCompilationString: string;
  52710. /**
  52711. * Gets the emitted compilation strings
  52712. */
  52713. compilationString: string;
  52714. /**
  52715. * Finalize the compilation strings
  52716. * @param state defines the current compilation state
  52717. */
  52718. finalize(state: NodeMaterialBuildState): void;
  52719. /** @hidden */
  52720. readonly _repeatableContentAnchor: string;
  52721. /** @hidden */
  52722. _getFreeVariableName(prefix: string): string;
  52723. /** @hidden */
  52724. _getFreeDefineName(prefix: string): string;
  52725. /** @hidden */
  52726. _excludeVariableName(name: string): void;
  52727. /** @hidden */
  52728. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  52729. /** @hidden */
  52730. _emitFunction(name: string, code: string, comments: string): void;
  52731. /** @hidden */
  52732. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  52733. replaceStrings?: {
  52734. search: RegExp;
  52735. replace: string;
  52736. }[];
  52737. }): string;
  52738. /** @hidden */
  52739. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  52740. repeatKey?: string;
  52741. removeAttributes?: boolean;
  52742. removeUniforms?: boolean;
  52743. removeVaryings?: boolean;
  52744. removeIfDef?: boolean;
  52745. replaceStrings?: {
  52746. search: RegExp;
  52747. replace: string;
  52748. }[];
  52749. }): void;
  52750. /** @hidden */
  52751. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string): void;
  52752. private _emitDefine;
  52753. /** @hidden */
  52754. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  52755. }
  52756. }
  52757. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  52758. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  52759. /**
  52760. * Root class for all node material optimizers
  52761. */
  52762. export class NodeMaterialOptimizer {
  52763. /**
  52764. * Function used to optimize a NodeMaterial graph
  52765. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  52766. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  52767. */
  52768. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  52769. }
  52770. }
  52771. declare module "babylonjs/Materials/Node/Blocks/vector4TransformBlock" {
  52772. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  52773. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  52774. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  52775. /**
  52776. * Block used to transform a vector4 with a matrix
  52777. */
  52778. export class Vector4TransformBlock extends NodeMaterialBlock {
  52779. /**
  52780. * Defines the value to use to complement Vector3 to transform it to a Vector4
  52781. */
  52782. complementW: number;
  52783. /**
  52784. * Creates a new Vector4TransformBlock
  52785. * @param name defines the block name
  52786. */
  52787. constructor(name: string);
  52788. /**
  52789. * Gets the current class name
  52790. * @returns the class name
  52791. */
  52792. getClassName(): string;
  52793. /**
  52794. * Gets the vector input
  52795. */
  52796. readonly vector: NodeMaterialConnectionPoint;
  52797. /**
  52798. * Gets the matrix transform input
  52799. */
  52800. readonly transform: NodeMaterialConnectionPoint;
  52801. protected _buildBlock(state: NodeMaterialBuildState): this;
  52802. }
  52803. }
  52804. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  52805. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  52806. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  52807. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  52808. /**
  52809. * Block used to output the vertex position
  52810. */
  52811. export class VertexOutputBlock extends NodeMaterialBlock {
  52812. /**
  52813. * Creates a new VertexOutputBlock
  52814. * @param name defines the block name
  52815. */
  52816. constructor(name: string);
  52817. /**
  52818. * Gets the current class name
  52819. * @returns the class name
  52820. */
  52821. getClassName(): string;
  52822. /**
  52823. * Gets the vector input component
  52824. */
  52825. readonly vector: NodeMaterialConnectionPoint;
  52826. protected _buildBlock(state: NodeMaterialBuildState): this;
  52827. }
  52828. }
  52829. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  52830. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  52831. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  52832. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  52833. /**
  52834. * Block used to output the final color
  52835. */
  52836. export class FragmentOutputBlock extends NodeMaterialBlock {
  52837. /**
  52838. * Gets or sets a boolean indicating if this block will output an alpha value
  52839. */
  52840. alphaBlendingEnabled: boolean;
  52841. /**
  52842. * Create a new FragmentOutputBlock
  52843. * @param name defines the block name
  52844. */
  52845. constructor(name: string);
  52846. /**
  52847. * Gets the current class name
  52848. * @returns the class name
  52849. */
  52850. getClassName(): string;
  52851. /**
  52852. * Gets the color input component
  52853. */
  52854. readonly color: NodeMaterialConnectionPoint;
  52855. protected _buildBlock(state: NodeMaterialBuildState): this;
  52856. }
  52857. }
  52858. declare module "babylonjs/Materials/Node/nodeMaterial" {
  52859. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  52860. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  52861. import { Scene } from "babylonjs/scene";
  52862. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52863. import { Matrix } from "babylonjs/Maths/math";
  52864. import { Mesh } from "babylonjs/Meshes/mesh";
  52865. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52866. import { Observable } from "babylonjs/Misc/observable";
  52867. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52868. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  52869. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  52870. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  52871. import { Nullable } from "babylonjs/types";
  52872. /**
  52873. * Interface used to configure the node material editor
  52874. */
  52875. export interface INodeMaterialEditorOptions {
  52876. /** Define the URl to load node editor script */
  52877. editorURL?: string;
  52878. }
  52879. /** @hidden */
  52880. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  52881. /** BONES */
  52882. NUM_BONE_INFLUENCERS: number;
  52883. BonesPerMesh: number;
  52884. BONETEXTURE: boolean;
  52885. /** MORPH TARGETS */
  52886. MORPHTARGETS: boolean;
  52887. MORPHTARGETS_NORMAL: boolean;
  52888. MORPHTARGETS_TANGENT: boolean;
  52889. NUM_MORPH_INFLUENCERS: number;
  52890. /** IMAGE PROCESSING */
  52891. IMAGEPROCESSING: boolean;
  52892. VIGNETTE: boolean;
  52893. VIGNETTEBLENDMODEMULTIPLY: boolean;
  52894. VIGNETTEBLENDMODEOPAQUE: boolean;
  52895. TONEMAPPING: boolean;
  52896. TONEMAPPING_ACES: boolean;
  52897. CONTRAST: boolean;
  52898. EXPOSURE: boolean;
  52899. COLORCURVES: boolean;
  52900. COLORGRADING: boolean;
  52901. COLORGRADING3D: boolean;
  52902. SAMPLER3DGREENDEPTH: boolean;
  52903. SAMPLER3DBGRMAP: boolean;
  52904. IMAGEPROCESSINGPOSTPROCESS: boolean;
  52905. constructor();
  52906. setValue(name: string, value: boolean): void;
  52907. }
  52908. /**
  52909. * Class used to configure NodeMaterial
  52910. */
  52911. export interface INodeMaterialOptions {
  52912. /**
  52913. * Defines if blocks should emit comments
  52914. */
  52915. emitComments: boolean;
  52916. }
  52917. /**
  52918. * Class used to create a node based material built by assembling shader blocks
  52919. */
  52920. export class NodeMaterial extends PushMaterial {
  52921. private _options;
  52922. private _vertexCompilationState;
  52923. private _fragmentCompilationState;
  52924. private _sharedData;
  52925. private _buildId;
  52926. private _buildWasSuccessful;
  52927. private _cachedWorldViewMatrix;
  52928. private _cachedWorldViewProjectionMatrix;
  52929. private _textureConnectionPoints;
  52930. private _optimizers;
  52931. /** Define the URl to load node editor script */
  52932. static EditorURL: string;
  52933. private BJSNODEMATERIALEDITOR;
  52934. /** Get the inspector from bundle or global */
  52935. private _getGlobalNodeMaterialEditor;
  52936. /**
  52937. * Defines the maximum number of lights that can be used in the material
  52938. */
  52939. maxSimultaneousLights: number;
  52940. /**
  52941. * Observable raised when the material is built
  52942. */
  52943. onBuildObservable: Observable<NodeMaterial>;
  52944. /**
  52945. * Gets or sets the root nodes of the material vertex shader
  52946. */
  52947. _vertexOutputNodes: NodeMaterialBlock[];
  52948. /**
  52949. * Gets or sets the root nodes of the material fragment (pixel) shader
  52950. */
  52951. _fragmentOutputNodes: NodeMaterialBlock[];
  52952. /** Gets or sets options to control the node material overall behavior */
  52953. options: INodeMaterialOptions;
  52954. /**
  52955. * Default configuration related to image processing available in the standard Material.
  52956. */
  52957. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52958. /**
  52959. * Gets the image processing configuration used either in this material.
  52960. */
  52961. /**
  52962. * Sets the Default image processing configuration used either in the this material.
  52963. *
  52964. * If sets to null, the scene one is in use.
  52965. */
  52966. imageProcessingConfiguration: ImageProcessingConfiguration;
  52967. /**
  52968. * Create a new node based material
  52969. * @param name defines the material name
  52970. * @param scene defines the hosting scene
  52971. * @param options defines creation option
  52972. */
  52973. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  52974. /**
  52975. * Gets the current class name of the material e.g. "NodeMaterial"
  52976. * @returns the class name
  52977. */
  52978. getClassName(): string;
  52979. /**
  52980. * Keep track of the image processing observer to allow dispose and replace.
  52981. */
  52982. private _imageProcessingObserver;
  52983. /**
  52984. * Attaches a new image processing configuration to the Standard Material.
  52985. * @param configuration
  52986. */
  52987. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52988. /**
  52989. * Adds a new optimizer to the list of optimizers
  52990. * @param optimizer defines the optimizers to add
  52991. * @returns the current material
  52992. */
  52993. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52994. /**
  52995. * Remove an optimizer from the list of optimizers
  52996. * @param optimizer defines the optimizers to remove
  52997. * @returns the current material
  52998. */
  52999. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53000. /**
  53001. * Add a new block to the list of output nodes
  53002. * @param node defines the node to add
  53003. * @returns the current material
  53004. */
  53005. addOutputNode(node: NodeMaterialBlock): this;
  53006. /**
  53007. * Remove a block from the list of root nodes
  53008. * @param node defines the node to remove
  53009. * @returns the current material
  53010. */
  53011. removeOutputNode(node: NodeMaterialBlock): this;
  53012. private _addVertexOutputNode;
  53013. private _removeVertexOutputNode;
  53014. private _addFragmentOutputNode;
  53015. private _removeFragmentOutputNode;
  53016. /**
  53017. * Specifies if the material will require alpha blending
  53018. * @returns a boolean specifying if alpha blending is needed
  53019. */
  53020. needAlphaBlending(): boolean;
  53021. /**
  53022. * Specifies if this material should be rendered in alpha test mode
  53023. * @returns a boolean specifying if an alpha test is needed.
  53024. */
  53025. needAlphaTesting(): boolean;
  53026. private _initializeBlock;
  53027. private _resetDualBlocks;
  53028. /**
  53029. * Build the material and generates the inner effect
  53030. * @param verbose defines if the build should log activity
  53031. */
  53032. build(verbose?: boolean): void;
  53033. /**
  53034. * Runs an otpimization phase to try to improve the shader code
  53035. */
  53036. optimize(): void;
  53037. private _prepareDefinesForAttributes;
  53038. /**
  53039. * Get if the submesh is ready to be used and all its information available.
  53040. * Child classes can use it to update shaders
  53041. * @param mesh defines the mesh to check
  53042. * @param subMesh defines which submesh to check
  53043. * @param useInstances specifies that instances should be used
  53044. * @returns a boolean indicating that the submesh is ready or not
  53045. */
  53046. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53047. /**
  53048. * Binds the world matrix to the material
  53049. * @param world defines the world transformation matrix
  53050. */
  53051. bindOnlyWorldMatrix(world: Matrix): void;
  53052. /**
  53053. * Binds the submesh to this material by preparing the effect and shader to draw
  53054. * @param world defines the world transformation matrix
  53055. * @param mesh defines the mesh containing the submesh
  53056. * @param subMesh defines the submesh to bind the material to
  53057. */
  53058. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53059. /**
  53060. * Gets the active textures from the material
  53061. * @returns an array of textures
  53062. */
  53063. getActiveTextures(): BaseTexture[];
  53064. /**
  53065. * Specifies if the material uses a texture
  53066. * @param texture defines the texture to check against the material
  53067. * @returns a boolean specifying if the material uses the texture
  53068. */
  53069. hasTexture(texture: BaseTexture): boolean;
  53070. /**
  53071. * Disposes the material
  53072. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  53073. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  53074. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  53075. */
  53076. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  53077. /** Creates the node editor window. */
  53078. private _createNodeEditor;
  53079. /**
  53080. * Launch the node material editor
  53081. * @param config Define the configuration of the editor
  53082. * @return a promise fulfilled when the node editor is visible
  53083. */
  53084. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  53085. /**
  53086. * Clear the current material
  53087. */
  53088. clear(): void;
  53089. /**
  53090. * Clear the current material and set it to a default state
  53091. */
  53092. setToDefault(): void;
  53093. }
  53094. }
  53095. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  53096. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53097. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53098. import { Nullable } from "babylonjs/types";
  53099. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53100. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53101. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53103. import { Mesh } from "babylonjs/Meshes/mesh";
  53104. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53105. /**
  53106. * Defines a block that can be used inside a node based material
  53107. */
  53108. export class NodeMaterialBlock {
  53109. private _buildId;
  53110. private _target;
  53111. private _isFinalMerger;
  53112. /** @hidden */
  53113. _inputs: NodeMaterialConnectionPoint[];
  53114. /** @hidden */
  53115. _outputs: NodeMaterialConnectionPoint[];
  53116. /**
  53117. * Gets or sets the name of the block
  53118. */
  53119. name: string;
  53120. /**
  53121. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  53122. */
  53123. readonly isFinalMerger: boolean;
  53124. /**
  53125. * Gets or sets the build Id
  53126. */
  53127. buildId: number;
  53128. /**
  53129. * Gets or sets the target of the block
  53130. */
  53131. target: NodeMaterialBlockTargets;
  53132. /**
  53133. * Gets the list of input points
  53134. */
  53135. readonly inputs: NodeMaterialConnectionPoint[];
  53136. /** Gets the list of output points */
  53137. readonly outputs: NodeMaterialConnectionPoint[];
  53138. /**
  53139. * Find an input by its name
  53140. * @param name defines the name of the input to look for
  53141. * @returns the input or null if not found
  53142. */
  53143. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53144. /**
  53145. * Find an output by its name
  53146. * @param name defines the name of the outputto look for
  53147. * @returns the output or null if not found
  53148. */
  53149. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53150. /**
  53151. * Creates a new NodeMaterialBlock
  53152. * @param name defines the block name
  53153. * @param target defines the target of that block (Vertex by default)
  53154. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  53155. */
  53156. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  53157. /**
  53158. * Initialize the block and prepare the context for build
  53159. * @param state defines the state that will be used for the build
  53160. */
  53161. initialize(state: NodeMaterialBuildState): void;
  53162. /**
  53163. * Bind data to effect. Will only be called for blocks with isBindable === true
  53164. * @param effect defines the effect to bind data to
  53165. * @param nodeMaterial defines the hosting NodeMaterial
  53166. * @param mesh defines the mesh that will be rendered
  53167. */
  53168. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53169. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  53170. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  53171. protected _writeFloat(value: number): string;
  53172. /**
  53173. * Gets the current class name e.g. "NodeMaterialBlock"
  53174. * @returns the class name
  53175. */
  53176. getClassName(): string;
  53177. /**
  53178. * Register a new input. Must be called inside a block constructor
  53179. * @param name defines the connection point name
  53180. * @param type defines the connection point type
  53181. * @param isOptional defines a boolean indicating that this input can be omitted
  53182. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  53183. * @returns the current block
  53184. */
  53185. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  53186. /**
  53187. * Register a new output. Must be called inside a block constructor
  53188. * @param name defines the connection point name
  53189. * @param type defines the connection point type
  53190. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  53191. * @returns the current block
  53192. */
  53193. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  53194. /**
  53195. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  53196. * @param forOutput defines an optional connection point to check compatibility with
  53197. * @returns the first available input or null
  53198. */
  53199. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  53200. /**
  53201. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  53202. * @param forBlock defines an optional block to check compatibility with
  53203. * @returns the first available input or null
  53204. */
  53205. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  53206. /**
  53207. * Connect current block with another block
  53208. * @param other defines the block to connect with
  53209. * @param options define the various options to help pick the right connections
  53210. * @returns the current block
  53211. */
  53212. connectTo(other: NodeMaterialBlock, options?: {
  53213. input?: string;
  53214. output?: string;
  53215. outputSwizzle?: string;
  53216. }): this | undefined;
  53217. protected _buildBlock(state: NodeMaterialBuildState): void;
  53218. /**
  53219. * Add potential fallbacks if shader compilation fails
  53220. * @param mesh defines the mesh to be rendered
  53221. * @param fallbacks defines the current prioritized list of fallbacks
  53222. */
  53223. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53224. /**
  53225. * Update defines for shader compilation
  53226. * @param mesh defines the mesh to be rendered
  53227. * @param nodeMaterial defines the node material requesting the update
  53228. * @param defines defines the material defines to update
  53229. * @param useInstances specifies that instances should be used
  53230. */
  53231. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53232. /**
  53233. * Lets the block try to connect some inputs automatically
  53234. */
  53235. autoConfigure(): void;
  53236. /**
  53237. * Function called when a block is declared as repeatable content generator
  53238. * @param vertexShaderState defines the current compilation state for the vertex shader
  53239. * @param fragmentShaderState defines the current compilation state for the fragment shader
  53240. * @param mesh defines the mesh to be rendered
  53241. * @param defines defines the material defines to update
  53242. */
  53243. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53244. /**
  53245. * Checks if the block is ready
  53246. * @param mesh defines the mesh to be rendered
  53247. * @param nodeMaterial defines the node material requesting the update
  53248. * @param defines defines the material defines to update
  53249. * @param useInstances specifies that instances should be used
  53250. * @returns true if the block is ready
  53251. */
  53252. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  53253. /**
  53254. * Compile the current node and generate the shader code
  53255. * @param state defines the current compilation state (uniforms, samplers, current string)
  53256. * @returns the current block
  53257. */
  53258. build(state: NodeMaterialBuildState): this | undefined;
  53259. }
  53260. }
  53261. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  53262. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53263. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53264. import { Nullable } from "babylonjs/types";
  53265. import { Effect } from "babylonjs/Materials/effect";
  53266. import { NodeMaterialWellKnownValues } from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  53267. import { Scene } from "babylonjs/scene";
  53268. import { Matrix } from "babylonjs/Maths/math";
  53269. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53270. /**
  53271. * Defines a connection point for a block
  53272. */
  53273. export class NodeMaterialConnectionPoint {
  53274. /** @hidden */
  53275. _ownerBlock: NodeMaterialBlock;
  53276. /** @hidden */
  53277. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53278. private _associatedVariableName;
  53279. private _endpoints;
  53280. private _storedValue;
  53281. private _valueCallback;
  53282. private _mode;
  53283. /** @hidden */
  53284. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  53285. /** @hidden */
  53286. _needToEmitVarying: boolean;
  53287. /**
  53288. * Gets or sets the connection point type (default is float)
  53289. */
  53290. type: NodeMaterialBlockConnectionPointTypes;
  53291. /**
  53292. * Gets or sets the connection point name
  53293. */
  53294. name: string;
  53295. /**
  53296. * Gets or sets the swizzle to apply to this connection point when reading or writing
  53297. */
  53298. swizzle: string;
  53299. /**
  53300. * Gets or sets a boolean indicating that this connection point can be omitted
  53301. */
  53302. isOptional: boolean;
  53303. /**
  53304. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  53305. */
  53306. define: string;
  53307. /** Gets or sets the target of that connection point */
  53308. target: NodeMaterialBlockTargets;
  53309. /**
  53310. * Gets or sets the value of that point.
  53311. * Please note that this value will be ignored if valueCallback is defined
  53312. */
  53313. value: any;
  53314. /**
  53315. * Gets or sets a callback used to get the value of that point.
  53316. * Please note that setting this value will force the connection point to ignore the value property
  53317. */
  53318. valueCallback: () => any;
  53319. /**
  53320. * Gets or sets the associated variable name in the shader
  53321. */
  53322. associatedVariableName: string;
  53323. /**
  53324. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53325. * In this case the connection point name must be the name of the uniform to use.
  53326. * Can only be set on inputs
  53327. */
  53328. isUniform: boolean;
  53329. /**
  53330. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53331. * In this case the connection point name must be the name of the attribute to use
  53332. * Can only be set on inputs
  53333. */
  53334. isAttribute: boolean;
  53335. /**
  53336. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53337. * Can only be set on exit points
  53338. */
  53339. isVarying: boolean;
  53340. /** Get the other side of the connection (if any) */
  53341. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53342. /** Get the block that owns this connection point */
  53343. readonly ownerBlock: NodeMaterialBlock;
  53344. /** Get the block connected on the other side of this connection (if any) */
  53345. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  53346. /** Get the block connected on the endpoints of this connection (if any) */
  53347. readonly connectedBlocks: Array<NodeMaterialBlock>;
  53348. /**
  53349. * Creates a new connection point
  53350. * @param name defines the connection point name
  53351. * @param ownerBlock defines the block hosting this connection point
  53352. */
  53353. constructor(name: string, ownerBlock: NodeMaterialBlock);
  53354. /**
  53355. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  53356. * @returns the class name
  53357. */
  53358. getClassName(): string;
  53359. /**
  53360. * Set the source of this connection point to a vertex attribute
  53361. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  53362. * @returns the current connection point
  53363. */
  53364. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  53365. /**
  53366. * Set the source of this connection point to a well known value
  53367. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  53368. * @returns the current connection point
  53369. */
  53370. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  53371. /**
  53372. * Gets a boolean indicating that the current connection point is a well known value
  53373. */
  53374. readonly isWellKnownValue: boolean;
  53375. /**
  53376. * Gets or sets the current well known value or null if not defined as well know value
  53377. */
  53378. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  53379. private _getTypeLength;
  53380. /**
  53381. * Connect this point to another connection point
  53382. * @param connectionPoint defines the other connection point
  53383. * @returns the current connection point
  53384. */
  53385. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53386. /**
  53387. * Disconnect this point from one of his endpoint
  53388. * @param endpoint defines the other connection point
  53389. * @returns the current connection point
  53390. */
  53391. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53392. /**
  53393. * When connection point is an uniform, this function will send its value to the effect
  53394. * @param effect defines the effect to transmit value to
  53395. * @param world defines the world matrix
  53396. * @param worldView defines the worldxview matrix
  53397. * @param worldViewProjection defines the worldxviewxprojection matrix
  53398. */
  53399. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53400. /**
  53401. * When connection point is an uniform, this function will send its value to the effect
  53402. * @param effect defines the effect to transmit value to
  53403. * @param scene defines the hosting scene
  53404. */
  53405. transmit(effect: Effect, scene: Scene): void;
  53406. }
  53407. }
  53408. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  53409. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53410. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53411. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53412. import { Mesh } from "babylonjs/Meshes/mesh";
  53413. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53414. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53415. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53416. /**
  53417. * Block used to add support for vertex skinning (bones)
  53418. */
  53419. export class BonesBlock extends NodeMaterialBlock {
  53420. /**
  53421. * Creates a new BonesBlock
  53422. * @param name defines the block name
  53423. */
  53424. constructor(name: string);
  53425. /**
  53426. * Initialize the block and prepare the context for build
  53427. * @param state defines the state that will be used for the build
  53428. */
  53429. initialize(state: NodeMaterialBuildState): void;
  53430. /**
  53431. * Gets the current class name
  53432. * @returns the class name
  53433. */
  53434. getClassName(): string;
  53435. /**
  53436. * Gets the matrix indices input component
  53437. */
  53438. readonly matricesIndices: NodeMaterialConnectionPoint;
  53439. /**
  53440. * Gets the matrix weights input component
  53441. */
  53442. readonly matricesWeights: NodeMaterialConnectionPoint;
  53443. /**
  53444. * Gets the extra matrix indices input component
  53445. */
  53446. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  53447. /**
  53448. * Gets the extra matrix weights input component
  53449. */
  53450. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  53451. /**
  53452. * Gets the world input component
  53453. */
  53454. readonly world: NodeMaterialConnectionPoint;
  53455. autoConfigure(): void;
  53456. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53457. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53458. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53459. protected _buildBlock(state: NodeMaterialBuildState): this;
  53460. }
  53461. }
  53462. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  53463. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53464. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53465. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53466. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53467. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53468. /**
  53469. * Block used to add support for instances
  53470. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  53471. */
  53472. export class InstancesBlock extends NodeMaterialBlock {
  53473. /**
  53474. * Creates a new InstancesBlock
  53475. * @param name defines the block name
  53476. */
  53477. constructor(name: string);
  53478. /**
  53479. * Gets the current class name
  53480. * @returns the class name
  53481. */
  53482. getClassName(): string;
  53483. /**
  53484. * Gets the first world row input component
  53485. */
  53486. readonly world0: NodeMaterialConnectionPoint;
  53487. /**
  53488. * Gets the second world row input component
  53489. */
  53490. readonly world1: NodeMaterialConnectionPoint;
  53491. /**
  53492. * Gets the third world row input component
  53493. */
  53494. readonly world2: NodeMaterialConnectionPoint;
  53495. /**
  53496. * Gets the forth world row input component
  53497. */
  53498. readonly world3: NodeMaterialConnectionPoint;
  53499. /**
  53500. * Gets the world input component
  53501. */
  53502. readonly world: NodeMaterialConnectionPoint;
  53503. /**
  53504. * Gets the output component
  53505. */
  53506. readonly output: NodeMaterialConnectionPoint;
  53507. autoConfigure(): void;
  53508. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53509. protected _buildBlock(state: NodeMaterialBuildState): this;
  53510. }
  53511. }
  53512. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  53513. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53514. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53515. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53516. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53517. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53518. import { Effect } from "babylonjs/Materials/effect";
  53519. import { Mesh } from "babylonjs/Meshes/mesh";
  53520. /**
  53521. * Block used to add morph targets support to vertex shader
  53522. */
  53523. export class MorphTargetsBlock extends NodeMaterialBlock {
  53524. private _repeatableContentAnchor;
  53525. private _repeatebleContentGenerated;
  53526. /**
  53527. * Create a new MorphTargetsBlock
  53528. * @param name defines the block name
  53529. */
  53530. constructor(name: string);
  53531. /**
  53532. * Gets the current class name
  53533. * @returns the class name
  53534. */
  53535. getClassName(): string;
  53536. /**
  53537. * Gets the position input component
  53538. */
  53539. readonly position: NodeMaterialConnectionPoint;
  53540. /**
  53541. * Gets the normal input component
  53542. */
  53543. readonly normal: NodeMaterialConnectionPoint;
  53544. /**
  53545. * Gets the tangent input component
  53546. */
  53547. readonly tangent: NodeMaterialConnectionPoint;
  53548. /**
  53549. * Gets the position output component
  53550. */
  53551. readonly positionOutput: NodeMaterialConnectionPoint;
  53552. /**
  53553. * Gets the normal output component
  53554. */
  53555. readonly normalOutput: NodeMaterialConnectionPoint;
  53556. /**
  53557. * Gets the tangent output component
  53558. */
  53559. readonly tangentOutput: NodeMaterialConnectionPoint;
  53560. initialize(state: NodeMaterialBuildState): void;
  53561. autoConfigure(): void;
  53562. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53563. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53564. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53565. protected _buildBlock(state: NodeMaterialBuildState): this;
  53566. }
  53567. }
  53568. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  53569. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  53570. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  53571. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  53572. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  53573. }
  53574. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  53575. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53576. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53577. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53578. /**
  53579. * Block used to add an alpha test in the fragment shader
  53580. */
  53581. export class AlphaTestBlock extends NodeMaterialBlock {
  53582. /**
  53583. * Gets or sets the alpha value where alpha testing happens
  53584. */
  53585. alphaCutOff: number;
  53586. /**
  53587. * Create a new AlphaTestBlock
  53588. * @param name defines the block name
  53589. */
  53590. constructor(name: string);
  53591. /**
  53592. * Gets the current class name
  53593. * @returns the class name
  53594. */
  53595. getClassName(): string;
  53596. /**
  53597. * Gets the color input component
  53598. */
  53599. readonly color: NodeMaterialConnectionPoint;
  53600. protected _buildBlock(state: NodeMaterialBuildState): this;
  53601. }
  53602. }
  53603. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock" {
  53604. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53605. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53606. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53607. /**
  53608. * Block used to create a Color4 out of 4 inputs (one for each component)
  53609. */
  53610. export class RGBAMergerBlock extends NodeMaterialBlock {
  53611. /**
  53612. * Create a new RGBAMergerBlock
  53613. * @param name defines the block name
  53614. */
  53615. constructor(name: string);
  53616. /**
  53617. * Gets the current class name
  53618. * @returns the class name
  53619. */
  53620. getClassName(): string;
  53621. /**
  53622. * Gets the R input component
  53623. */
  53624. readonly r: NodeMaterialConnectionPoint;
  53625. /**
  53626. * Gets the G input component
  53627. */
  53628. readonly g: NodeMaterialConnectionPoint;
  53629. /**
  53630. * Gets the B input component
  53631. */
  53632. readonly b: NodeMaterialConnectionPoint;
  53633. /**
  53634. * Gets the RGB input component
  53635. */
  53636. readonly rgb: NodeMaterialConnectionPoint;
  53637. /**
  53638. * Gets the R input component
  53639. */
  53640. readonly a: NodeMaterialConnectionPoint;
  53641. protected _buildBlock(state: NodeMaterialBuildState): this;
  53642. }
  53643. }
  53644. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock" {
  53645. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53646. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53647. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53648. /**
  53649. * Block used to create a Color3 out of 3 inputs (one for each component)
  53650. */
  53651. export class RGBMergerBlock extends NodeMaterialBlock {
  53652. /**
  53653. * Create a new RGBMergerBlock
  53654. * @param name defines the block name
  53655. */
  53656. constructor(name: string);
  53657. /**
  53658. * Gets the current class name
  53659. * @returns the class name
  53660. */
  53661. getClassName(): string;
  53662. /**
  53663. * Gets the R component input
  53664. */
  53665. readonly r: NodeMaterialConnectionPoint;
  53666. /**
  53667. * Gets the G component input
  53668. */
  53669. readonly g: NodeMaterialConnectionPoint;
  53670. /**
  53671. * Gets the B component input
  53672. */
  53673. readonly b: NodeMaterialConnectionPoint;
  53674. protected _buildBlock(state: NodeMaterialBuildState): this;
  53675. }
  53676. }
  53677. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock" {
  53678. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53679. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53680. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53681. /**
  53682. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  53683. */
  53684. export class RGBASplitterBlock extends NodeMaterialBlock {
  53685. /**
  53686. * Create a new RGBASplitterBlock
  53687. * @param name defines the block name
  53688. */
  53689. constructor(name: string);
  53690. /**
  53691. * Gets the current class name
  53692. * @returns the class name
  53693. */
  53694. getClassName(): string;
  53695. /**
  53696. * Gets the input component
  53697. */
  53698. readonly input: NodeMaterialConnectionPoint;
  53699. protected _buildBlock(state: NodeMaterialBuildState): this;
  53700. }
  53701. }
  53702. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock" {
  53703. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53704. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53705. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53706. /**
  53707. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  53708. */
  53709. export class RGBSplitterBlock extends NodeMaterialBlock {
  53710. /**
  53711. * Create a new RGBSplitterBlock
  53712. * @param name defines the block name
  53713. */
  53714. constructor(name: string);
  53715. /**
  53716. * Gets the current class name
  53717. * @returns the class name
  53718. */
  53719. getClassName(): string;
  53720. /**
  53721. * Gets the input component
  53722. */
  53723. readonly input: NodeMaterialConnectionPoint;
  53724. protected _buildBlock(state: NodeMaterialBuildState): this;
  53725. }
  53726. }
  53727. declare module "babylonjs/Materials/Node/Blocks/Fragment/textureBlock" {
  53728. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53729. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53730. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53731. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53732. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53733. /**
  53734. * Block used to read a texture from a sampler
  53735. */
  53736. export class TextureBlock extends NodeMaterialBlock {
  53737. private _defineName;
  53738. /**
  53739. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  53740. */
  53741. autoConnectTextureMatrix: boolean;
  53742. /**
  53743. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  53744. */
  53745. autoSelectUV: boolean;
  53746. /**
  53747. * Create a new TextureBlock
  53748. * @param name defines the block name
  53749. */
  53750. constructor(name: string);
  53751. /**
  53752. * Gets the current class name
  53753. * @returns the class name
  53754. */
  53755. getClassName(): string;
  53756. /**
  53757. * Gets the uv input component
  53758. */
  53759. readonly uv: NodeMaterialConnectionPoint;
  53760. /**
  53761. * Gets the texture information input component
  53762. */
  53763. readonly textureInfo: NodeMaterialConnectionPoint;
  53764. /**
  53765. * Gets the transformed uv input component
  53766. */
  53767. readonly transformedUV: NodeMaterialConnectionPoint;
  53768. /**
  53769. * Gets the texture input component
  53770. */
  53771. readonly texture: NodeMaterialConnectionPoint;
  53772. /**
  53773. * Gets the texture transform input component
  53774. */
  53775. readonly textureTransform: NodeMaterialConnectionPoint;
  53776. autoConfigure(): void;
  53777. initialize(state: NodeMaterialBuildState): void;
  53778. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53779. isReady(): boolean;
  53780. private _injectVertexCode;
  53781. protected _buildBlock(state: NodeMaterialBuildState): this;
  53782. }
  53783. }
  53784. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  53785. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53786. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53787. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53788. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53789. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53790. import { Effect } from "babylonjs/Materials/effect";
  53791. import { Mesh } from "babylonjs/Meshes/mesh";
  53792. /**
  53793. * Block used to add image processing support to fragment shader
  53794. */
  53795. export class ImageProcessingBlock extends NodeMaterialBlock {
  53796. /**
  53797. * Create a new ImageProcessingBlock
  53798. * @param name defines the block name
  53799. */
  53800. constructor(name: string);
  53801. /**
  53802. * Gets the current class name
  53803. * @returns the class name
  53804. */
  53805. getClassName(): string;
  53806. /**
  53807. * Gets the color input component
  53808. */
  53809. readonly color: NodeMaterialConnectionPoint;
  53810. /**
  53811. * Initialize the block and prepare the context for build
  53812. * @param state defines the state that will be used for the build
  53813. */
  53814. initialize(state: NodeMaterialBuildState): void;
  53815. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  53816. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53817. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53818. protected _buildBlock(state: NodeMaterialBuildState): this;
  53819. }
  53820. }
  53821. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  53822. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  53823. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  53824. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock";
  53825. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock";
  53826. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock";
  53827. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock";
  53828. export * from "babylonjs/Materials/Node/Blocks/Fragment/textureBlock";
  53829. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  53830. }
  53831. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  53832. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53833. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53834. import { Mesh } from "babylonjs/Meshes/mesh";
  53835. import { Effect } from "babylonjs/Materials/effect";
  53836. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53837. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53838. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53839. /**
  53840. * Block used to add support for scene fog
  53841. */
  53842. export class FogBlock extends NodeMaterialBlock {
  53843. /**
  53844. * Create a new FogBlock
  53845. * @param name defines the block name
  53846. */
  53847. constructor(name: string);
  53848. /**
  53849. * Gets the current class name
  53850. * @returns the class name
  53851. */
  53852. getClassName(): string;
  53853. /**
  53854. * Gets the world position input component
  53855. */
  53856. readonly worldPosition: NodeMaterialConnectionPoint;
  53857. /**
  53858. * Gets the view input component
  53859. */
  53860. readonly view: NodeMaterialConnectionPoint;
  53861. /**
  53862. * Gets the color input component
  53863. */
  53864. readonly color: NodeMaterialConnectionPoint;
  53865. /**
  53866. * Gets the fog color input component
  53867. */
  53868. readonly fogColor: NodeMaterialConnectionPoint;
  53869. /**
  53870. * Gets the for parameter input component
  53871. */
  53872. readonly fogParameters: NodeMaterialConnectionPoint;
  53873. autoConfigure(): void;
  53874. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53875. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53876. protected _buildBlock(state: NodeMaterialBuildState): this;
  53877. }
  53878. }
  53879. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  53880. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  53881. }
  53882. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  53883. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53884. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53885. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53886. /**
  53887. * Block used to multiply 2 vector4
  53888. */
  53889. export class MultiplyBlock extends NodeMaterialBlock {
  53890. /**
  53891. * Creates a new MultiplyBlock
  53892. * @param name defines the block name
  53893. */
  53894. constructor(name: string);
  53895. /**
  53896. * Gets the current class name
  53897. * @returns the class name
  53898. */
  53899. getClassName(): string;
  53900. /**
  53901. * Gets the left operand input component
  53902. */
  53903. readonly left: NodeMaterialConnectionPoint;
  53904. /**
  53905. * Gets the right operand input component
  53906. */
  53907. readonly right: NodeMaterialConnectionPoint;
  53908. protected _buildBlock(state: NodeMaterialBuildState): this;
  53909. }
  53910. }
  53911. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  53912. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53913. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53914. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53915. /**
  53916. * Block used to add 2 vector4
  53917. */
  53918. export class AddBlock extends NodeMaterialBlock {
  53919. /**
  53920. * Creates a new AddBlock
  53921. * @param name defines the block name
  53922. */
  53923. constructor(name: string);
  53924. /**
  53925. * Gets the current class name
  53926. * @returns the class name
  53927. */
  53928. getClassName(): string;
  53929. /**
  53930. * Gets the left operand input component
  53931. */
  53932. readonly left: NodeMaterialConnectionPoint;
  53933. /**
  53934. * Gets the right operand input component
  53935. */
  53936. readonly right: NodeMaterialConnectionPoint;
  53937. protected _buildBlock(state: NodeMaterialBuildState): this;
  53938. }
  53939. }
  53940. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  53941. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53942. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53943. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53944. /**
  53945. * Block used to clamp a float
  53946. */
  53947. export class ClampBlock extends NodeMaterialBlock {
  53948. /** Gets or sets the minimum range */
  53949. minimum: number;
  53950. /** Gets or sets the maximum range */
  53951. maximum: number;
  53952. /**
  53953. * Creates a new ClampBlock
  53954. * @param name defines the block name
  53955. */
  53956. constructor(name: string);
  53957. /**
  53958. * Gets the current class name
  53959. * @returns the class name
  53960. */
  53961. getClassName(): string;
  53962. /**
  53963. * Gets the value input component
  53964. */
  53965. readonly value: NodeMaterialConnectionPoint;
  53966. protected _buildBlock(state: NodeMaterialBuildState): this;
  53967. }
  53968. }
  53969. declare module "babylonjs/Materials/Node/Blocks/vector2TransformBlock" {
  53970. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53971. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53972. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53973. /**
  53974. * Block used to transform a vector2 with a matrix
  53975. */
  53976. export class Vector2TransformBlock extends NodeMaterialBlock {
  53977. /**
  53978. * Defines the value to use to complement Vector2 to transform it to a Vector4
  53979. */
  53980. complementZ: number;
  53981. /**
  53982. * Defines the value to use to complement Vector2 to transform it to a Vector4
  53983. */
  53984. complementW: number;
  53985. /**
  53986. * Creates a new Vector2TransformBlock
  53987. * @param name defines the block name
  53988. */
  53989. constructor(name: string);
  53990. /**
  53991. * Gets the vector input
  53992. */
  53993. readonly vector: NodeMaterialConnectionPoint;
  53994. /**
  53995. * Gets the matrix transform input
  53996. */
  53997. readonly transform: NodeMaterialConnectionPoint;
  53998. /**
  53999. * Gets the current class name
  54000. * @returns the class name
  54001. */
  54002. getClassName(): string;
  54003. protected _buildBlock(state: NodeMaterialBuildState): this;
  54004. }
  54005. }
  54006. declare module "babylonjs/Materials/Node/Blocks/vector3TransformBlock" {
  54007. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54008. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54009. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54010. /**
  54011. * Block used to transform a vector3 with a matrix
  54012. */
  54013. export class Vector3TransformBlock extends NodeMaterialBlock {
  54014. /**
  54015. * Defines the value to use to complement Vector3 to transform it to a Vector4
  54016. */
  54017. complement: number;
  54018. /**
  54019. * Creates a new Vector3TransformBlock
  54020. * @param name defines the block name
  54021. */
  54022. constructor(name: string);
  54023. /**
  54024. * Gets the vector input
  54025. */
  54026. readonly vector: NodeMaterialConnectionPoint;
  54027. /**
  54028. * Gets the matrix transform input
  54029. */
  54030. readonly transform: NodeMaterialConnectionPoint;
  54031. /**
  54032. * Gets the current class name
  54033. * @returns the class name
  54034. */
  54035. getClassName(): string;
  54036. protected _buildBlock(state: NodeMaterialBuildState): this;
  54037. }
  54038. }
  54039. declare module "babylonjs/Materials/Node/Blocks/matrixMultiplicationBlock" {
  54040. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54041. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54042. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54043. /**
  54044. * Block used to multiply two matrices
  54045. */
  54046. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  54047. /**
  54048. * Creates a new MatrixMultiplicationBlock
  54049. * @param name defines the block name
  54050. */
  54051. constructor(name: string);
  54052. /**
  54053. * Gets the left operand
  54054. */
  54055. readonly left: NodeMaterialConnectionPoint;
  54056. /**
  54057. * Gets the right operand
  54058. */
  54059. readonly right: NodeMaterialConnectionPoint;
  54060. /**
  54061. * Gets the current class name
  54062. * @returns the class name
  54063. */
  54064. getClassName(): string;
  54065. protected _buildBlock(state: NodeMaterialBuildState): this;
  54066. }
  54067. }
  54068. declare module "babylonjs/Materials/Node/Blocks/index" {
  54069. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  54070. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  54071. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  54072. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  54073. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  54074. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  54075. export * from "babylonjs/Materials/Node/Blocks/vector2TransformBlock";
  54076. export * from "babylonjs/Materials/Node/Blocks/vector3TransformBlock";
  54077. export * from "babylonjs/Materials/Node/Blocks/vector4TransformBlock";
  54078. export * from "babylonjs/Materials/Node/Blocks/matrixMultiplicationBlock";
  54079. }
  54080. declare module "babylonjs/Materials/Node/Optimizers/index" {
  54081. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  54082. }
  54083. declare module "babylonjs/Materials/Node/index" {
  54084. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54085. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54086. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54087. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  54088. export * from "babylonjs/Materials/Node/nodeMaterial";
  54089. export * from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  54090. export * from "babylonjs/Materials/Node/Blocks/index";
  54091. export * from "babylonjs/Materials/Node/Optimizers/index";
  54092. }
  54093. declare module "babylonjs/Materials/index" {
  54094. export * from "babylonjs/Materials/Background/index";
  54095. export * from "babylonjs/Materials/colorCurves";
  54096. export * from "babylonjs/Materials/effect";
  54097. export * from "babylonjs/Materials/fresnelParameters";
  54098. export * from "babylonjs/Materials/imageProcessingConfiguration";
  54099. export * from "babylonjs/Materials/material";
  54100. export * from "babylonjs/Materials/materialDefines";
  54101. export * from "babylonjs/Materials/materialHelper";
  54102. export * from "babylonjs/Materials/multiMaterial";
  54103. export * from "babylonjs/Materials/PBR/index";
  54104. export * from "babylonjs/Materials/pushMaterial";
  54105. export * from "babylonjs/Materials/shaderMaterial";
  54106. export * from "babylonjs/Materials/standardMaterial";
  54107. export * from "babylonjs/Materials/Textures/index";
  54108. export * from "babylonjs/Materials/uniformBuffer";
  54109. export * from "babylonjs/Materials/materialFlags";
  54110. export * from "babylonjs/Materials/Node/index";
  54111. }
  54112. declare module "babylonjs/Maths/index" {
  54113. export * from "babylonjs/Maths/math.scalar";
  54114. export * from "babylonjs/Maths/math";
  54115. export * from "babylonjs/Maths/sphericalPolynomial";
  54116. }
  54117. declare module "babylonjs/Misc/workerPool" {
  54118. import { IDisposable } from "babylonjs/scene";
  54119. /**
  54120. * Helper class to push actions to a pool of workers.
  54121. */
  54122. export class WorkerPool implements IDisposable {
  54123. private _workerInfos;
  54124. private _pendingActions;
  54125. /**
  54126. * Constructor
  54127. * @param workers Array of workers to use for actions
  54128. */
  54129. constructor(workers: Array<Worker>);
  54130. /**
  54131. * Terminates all workers and clears any pending actions.
  54132. */
  54133. dispose(): void;
  54134. /**
  54135. * Pushes an action to the worker pool. If all the workers are active, the action will be
  54136. * pended until a worker has completed its action.
  54137. * @param action The action to perform. Call onComplete when the action is complete.
  54138. */
  54139. push(action: (worker: Worker, onComplete: () => void) => void): void;
  54140. private _execute;
  54141. }
  54142. }
  54143. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  54144. import { IDisposable } from "babylonjs/scene";
  54145. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  54146. /**
  54147. * Configuration for Draco compression
  54148. */
  54149. export interface IDracoCompressionConfiguration {
  54150. /**
  54151. * Configuration for the decoder.
  54152. */
  54153. decoder: {
  54154. /**
  54155. * The url to the WebAssembly module.
  54156. */
  54157. wasmUrl?: string;
  54158. /**
  54159. * The url to the WebAssembly binary.
  54160. */
  54161. wasmBinaryUrl?: string;
  54162. /**
  54163. * The url to the fallback JavaScript module.
  54164. */
  54165. fallbackUrl?: string;
  54166. };
  54167. }
  54168. /**
  54169. * Draco compression (https://google.github.io/draco/)
  54170. *
  54171. * This class wraps the Draco module.
  54172. *
  54173. * **Encoder**
  54174. *
  54175. * The encoder is not currently implemented.
  54176. *
  54177. * **Decoder**
  54178. *
  54179. * 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.
  54180. *
  54181. * To update the configuration, use the following code:
  54182. * ```javascript
  54183. * DracoCompression.Configuration = {
  54184. * decoder: {
  54185. * wasmUrl: "<url to the WebAssembly library>",
  54186. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  54187. * fallbackUrl: "<url to the fallback JavaScript library>",
  54188. * }
  54189. * };
  54190. * ```
  54191. *
  54192. * 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.
  54193. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  54194. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  54195. *
  54196. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  54197. * ```javascript
  54198. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  54199. * ```
  54200. *
  54201. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  54202. */
  54203. export class DracoCompression implements IDisposable {
  54204. private _workerPoolPromise?;
  54205. private _decoderModulePromise?;
  54206. /**
  54207. * The configuration. Defaults to the following urls:
  54208. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  54209. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  54210. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  54211. */
  54212. static Configuration: IDracoCompressionConfiguration;
  54213. /**
  54214. * Returns true if the decoder configuration is available.
  54215. */
  54216. static readonly DecoderAvailable: boolean;
  54217. /**
  54218. * Default number of workers to create when creating the draco compression object.
  54219. */
  54220. static DefaultNumWorkers: number;
  54221. private static GetDefaultNumWorkers;
  54222. private static _Default;
  54223. /**
  54224. * Default instance for the draco compression object.
  54225. */
  54226. static readonly Default: DracoCompression;
  54227. /**
  54228. * Constructor
  54229. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  54230. */
  54231. constructor(numWorkers?: number);
  54232. /**
  54233. * Stop all async operations and release resources.
  54234. */
  54235. dispose(): void;
  54236. /**
  54237. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  54238. * @returns a promise that resolves when ready
  54239. */
  54240. whenReadyAsync(): Promise<void>;
  54241. /**
  54242. * Decode Draco compressed mesh data to vertex data.
  54243. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  54244. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  54245. * @returns A promise that resolves with the decoded vertex data
  54246. */
  54247. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  54248. [kind: string]: number;
  54249. }): Promise<VertexData>;
  54250. }
  54251. }
  54252. declare module "babylonjs/Meshes/Compression/index" {
  54253. export * from "babylonjs/Meshes/Compression/dracoCompression";
  54254. }
  54255. declare module "babylonjs/Meshes/csg" {
  54256. import { Nullable } from "babylonjs/types";
  54257. import { Scene } from "babylonjs/scene";
  54258. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  54259. import { Mesh } from "babylonjs/Meshes/mesh";
  54260. import { Material } from "babylonjs/Materials/material";
  54261. /**
  54262. * Class for building Constructive Solid Geometry
  54263. */
  54264. export class CSG {
  54265. private polygons;
  54266. /**
  54267. * The world matrix
  54268. */
  54269. matrix: Matrix;
  54270. /**
  54271. * Stores the position
  54272. */
  54273. position: Vector3;
  54274. /**
  54275. * Stores the rotation
  54276. */
  54277. rotation: Vector3;
  54278. /**
  54279. * Stores the rotation quaternion
  54280. */
  54281. rotationQuaternion: Nullable<Quaternion>;
  54282. /**
  54283. * Stores the scaling vector
  54284. */
  54285. scaling: Vector3;
  54286. /**
  54287. * Convert the Mesh to CSG
  54288. * @param mesh The Mesh to convert to CSG
  54289. * @returns A new CSG from the Mesh
  54290. */
  54291. static FromMesh(mesh: Mesh): CSG;
  54292. /**
  54293. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  54294. * @param polygons Polygons used to construct a CSG solid
  54295. */
  54296. private static FromPolygons;
  54297. /**
  54298. * Clones, or makes a deep copy, of the CSG
  54299. * @returns A new CSG
  54300. */
  54301. clone(): CSG;
  54302. /**
  54303. * Unions this CSG with another CSG
  54304. * @param csg The CSG to union against this CSG
  54305. * @returns The unioned CSG
  54306. */
  54307. union(csg: CSG): CSG;
  54308. /**
  54309. * Unions this CSG with another CSG in place
  54310. * @param csg The CSG to union against this CSG
  54311. */
  54312. unionInPlace(csg: CSG): void;
  54313. /**
  54314. * Subtracts this CSG with another CSG
  54315. * @param csg The CSG to subtract against this CSG
  54316. * @returns A new CSG
  54317. */
  54318. subtract(csg: CSG): CSG;
  54319. /**
  54320. * Subtracts this CSG with another CSG in place
  54321. * @param csg The CSG to subtact against this CSG
  54322. */
  54323. subtractInPlace(csg: CSG): void;
  54324. /**
  54325. * Intersect this CSG with another CSG
  54326. * @param csg The CSG to intersect against this CSG
  54327. * @returns A new CSG
  54328. */
  54329. intersect(csg: CSG): CSG;
  54330. /**
  54331. * Intersects this CSG with another CSG in place
  54332. * @param csg The CSG to intersect against this CSG
  54333. */
  54334. intersectInPlace(csg: CSG): void;
  54335. /**
  54336. * Return a new CSG solid with solid and empty space switched. This solid is
  54337. * not modified.
  54338. * @returns A new CSG solid with solid and empty space switched
  54339. */
  54340. inverse(): CSG;
  54341. /**
  54342. * Inverses the CSG in place
  54343. */
  54344. inverseInPlace(): void;
  54345. /**
  54346. * This is used to keep meshes transformations so they can be restored
  54347. * when we build back a Babylon Mesh
  54348. * NB : All CSG operations are performed in world coordinates
  54349. * @param csg The CSG to copy the transform attributes from
  54350. * @returns This CSG
  54351. */
  54352. copyTransformAttributes(csg: CSG): CSG;
  54353. /**
  54354. * Build Raw mesh from CSG
  54355. * Coordinates here are in world space
  54356. * @param name The name of the mesh geometry
  54357. * @param scene The Scene
  54358. * @param keepSubMeshes Specifies if the submeshes should be kept
  54359. * @returns A new Mesh
  54360. */
  54361. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  54362. /**
  54363. * Build Mesh from CSG taking material and transforms into account
  54364. * @param name The name of the Mesh
  54365. * @param material The material of the Mesh
  54366. * @param scene The Scene
  54367. * @param keepSubMeshes Specifies if submeshes should be kept
  54368. * @returns The new Mesh
  54369. */
  54370. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  54371. }
  54372. }
  54373. declare module "babylonjs/Meshes/trailMesh" {
  54374. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54375. import { Mesh } from "babylonjs/Meshes/mesh";
  54376. import { Scene } from "babylonjs/scene";
  54377. /**
  54378. * Class used to create a trail following a mesh
  54379. */
  54380. export class TrailMesh extends Mesh {
  54381. private _generator;
  54382. private _autoStart;
  54383. private _running;
  54384. private _diameter;
  54385. private _length;
  54386. private _sectionPolygonPointsCount;
  54387. private _sectionVectors;
  54388. private _sectionNormalVectors;
  54389. private _beforeRenderObserver;
  54390. /**
  54391. * @constructor
  54392. * @param name The value used by scene.getMeshByName() to do a lookup.
  54393. * @param generator The mesh to generate a trail.
  54394. * @param scene The scene to add this mesh to.
  54395. * @param diameter Diameter of trailing mesh. Default is 1.
  54396. * @param length Length of trailing mesh. Default is 60.
  54397. * @param autoStart Automatically start trailing mesh. Default true.
  54398. */
  54399. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  54400. /**
  54401. * "TrailMesh"
  54402. * @returns "TrailMesh"
  54403. */
  54404. getClassName(): string;
  54405. private _createMesh;
  54406. /**
  54407. * Start trailing mesh.
  54408. */
  54409. start(): void;
  54410. /**
  54411. * Stop trailing mesh.
  54412. */
  54413. stop(): void;
  54414. /**
  54415. * Update trailing mesh geometry.
  54416. */
  54417. update(): void;
  54418. /**
  54419. * Returns a new TrailMesh object.
  54420. * @param name is a string, the name given to the new mesh
  54421. * @param newGenerator use new generator object for cloned trail mesh
  54422. * @returns a new mesh
  54423. */
  54424. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  54425. /**
  54426. * Serializes this trail mesh
  54427. * @param serializationObject object to write serialization to
  54428. */
  54429. serialize(serializationObject: any): void;
  54430. /**
  54431. * Parses a serialized trail mesh
  54432. * @param parsedMesh the serialized mesh
  54433. * @param scene the scene to create the trail mesh in
  54434. * @returns the created trail mesh
  54435. */
  54436. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  54437. }
  54438. }
  54439. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  54440. import { Nullable } from "babylonjs/types";
  54441. import { Scene } from "babylonjs/scene";
  54442. import { Vector4, Color4 } from "babylonjs/Maths/math";
  54443. import { Mesh } from "babylonjs/Meshes/mesh";
  54444. /**
  54445. * Class containing static functions to help procedurally build meshes
  54446. */
  54447. export class TiledBoxBuilder {
  54448. /**
  54449. * Creates a box mesh
  54450. * 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)
  54451. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54452. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54453. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54455. * @param name defines the name of the mesh
  54456. * @param options defines the options used to create the mesh
  54457. * @param scene defines the hosting scene
  54458. * @returns the box mesh
  54459. */
  54460. static CreateTiledBox(name: string, options: {
  54461. pattern?: number;
  54462. width?: number;
  54463. height?: number;
  54464. depth?: number;
  54465. tileSize?: number;
  54466. tileWidth?: number;
  54467. tileHeight?: number;
  54468. alignHorizontal?: number;
  54469. alignVertical?: number;
  54470. faceUV?: Vector4[];
  54471. faceColors?: Color4[];
  54472. sideOrientation?: number;
  54473. updatable?: boolean;
  54474. }, scene?: Nullable<Scene>): Mesh;
  54475. }
  54476. }
  54477. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  54478. import { Vector4 } from "babylonjs/Maths/math";
  54479. import { Mesh } from "babylonjs/Meshes/mesh";
  54480. /**
  54481. * Class containing static functions to help procedurally build meshes
  54482. */
  54483. export class TorusKnotBuilder {
  54484. /**
  54485. * Creates a torus knot mesh
  54486. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  54487. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  54488. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  54489. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  54490. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54491. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54492. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54493. * @param name defines the name of the mesh
  54494. * @param options defines the options used to create the mesh
  54495. * @param scene defines the hosting scene
  54496. * @returns the torus knot mesh
  54497. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  54498. */
  54499. static CreateTorusKnot(name: string, options: {
  54500. radius?: number;
  54501. tube?: number;
  54502. radialSegments?: number;
  54503. tubularSegments?: number;
  54504. p?: number;
  54505. q?: number;
  54506. updatable?: boolean;
  54507. sideOrientation?: number;
  54508. frontUVs?: Vector4;
  54509. backUVs?: Vector4;
  54510. }, scene: any): Mesh;
  54511. }
  54512. }
  54513. declare module "babylonjs/Meshes/polygonMesh" {
  54514. import { Scene } from "babylonjs/scene";
  54515. import { Vector2, Path2 } from "babylonjs/Maths/math";
  54516. import { Mesh } from "babylonjs/Meshes/mesh";
  54517. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  54518. /**
  54519. * Polygon
  54520. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  54521. */
  54522. export class Polygon {
  54523. /**
  54524. * Creates a rectangle
  54525. * @param xmin bottom X coord
  54526. * @param ymin bottom Y coord
  54527. * @param xmax top X coord
  54528. * @param ymax top Y coord
  54529. * @returns points that make the resulting rectation
  54530. */
  54531. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  54532. /**
  54533. * Creates a circle
  54534. * @param radius radius of circle
  54535. * @param cx scale in x
  54536. * @param cy scale in y
  54537. * @param numberOfSides number of sides that make up the circle
  54538. * @returns points that make the resulting circle
  54539. */
  54540. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  54541. /**
  54542. * Creates a polygon from input string
  54543. * @param input Input polygon data
  54544. * @returns the parsed points
  54545. */
  54546. static Parse(input: string): Vector2[];
  54547. /**
  54548. * Starts building a polygon from x and y coordinates
  54549. * @param x x coordinate
  54550. * @param y y coordinate
  54551. * @returns the started path2
  54552. */
  54553. static StartingAt(x: number, y: number): Path2;
  54554. }
  54555. /**
  54556. * Builds a polygon
  54557. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  54558. */
  54559. export class PolygonMeshBuilder {
  54560. private _points;
  54561. private _outlinepoints;
  54562. private _holes;
  54563. private _name;
  54564. private _scene;
  54565. private _epoints;
  54566. private _eholes;
  54567. private _addToepoint;
  54568. /**
  54569. * Babylon reference to the earcut plugin.
  54570. */
  54571. bjsEarcut: any;
  54572. /**
  54573. * Creates a PolygonMeshBuilder
  54574. * @param name name of the builder
  54575. * @param contours Path of the polygon
  54576. * @param scene scene to add to when creating the mesh
  54577. * @param earcutInjection can be used to inject your own earcut reference
  54578. */
  54579. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  54580. /**
  54581. * Adds a whole within the polygon
  54582. * @param hole Array of points defining the hole
  54583. * @returns this
  54584. */
  54585. addHole(hole: Vector2[]): PolygonMeshBuilder;
  54586. /**
  54587. * Creates the polygon
  54588. * @param updatable If the mesh should be updatable
  54589. * @param depth The depth of the mesh created
  54590. * @returns the created mesh
  54591. */
  54592. build(updatable?: boolean, depth?: number): Mesh;
  54593. /**
  54594. * Creates the polygon
  54595. * @param depth The depth of the mesh created
  54596. * @returns the created VertexData
  54597. */
  54598. buildVertexData(depth?: number): VertexData;
  54599. /**
  54600. * Adds a side to the polygon
  54601. * @param positions points that make the polygon
  54602. * @param normals normals of the polygon
  54603. * @param uvs uvs of the polygon
  54604. * @param indices indices of the polygon
  54605. * @param bounds bounds of the polygon
  54606. * @param points points of the polygon
  54607. * @param depth depth of the polygon
  54608. * @param flip flip of the polygon
  54609. */
  54610. private addSide;
  54611. }
  54612. }
  54613. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  54614. import { Scene } from "babylonjs/scene";
  54615. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  54616. import { Mesh } from "babylonjs/Meshes/mesh";
  54617. import { Nullable } from "babylonjs/types";
  54618. /**
  54619. * Class containing static functions to help procedurally build meshes
  54620. */
  54621. export class PolygonBuilder {
  54622. /**
  54623. * Creates a polygon mesh
  54624. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  54625. * * 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
  54626. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54627. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54628. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  54629. * * Remember you can only change the shape positions, not their number when updating a polygon
  54630. * @param name defines the name of the mesh
  54631. * @param options defines the options used to create the mesh
  54632. * @param scene defines the hosting scene
  54633. * @param earcutInjection can be used to inject your own earcut reference
  54634. * @returns the polygon mesh
  54635. */
  54636. static CreatePolygon(name: string, options: {
  54637. shape: Vector3[];
  54638. holes?: Vector3[][];
  54639. depth?: number;
  54640. faceUV?: Vector4[];
  54641. faceColors?: Color4[];
  54642. updatable?: boolean;
  54643. sideOrientation?: number;
  54644. frontUVs?: Vector4;
  54645. backUVs?: Vector4;
  54646. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54647. /**
  54648. * Creates an extruded polygon mesh, with depth in the Y direction.
  54649. * * 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)
  54650. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54651. * @param name defines the name of the mesh
  54652. * @param options defines the options used to create the mesh
  54653. * @param scene defines the hosting scene
  54654. * @param earcutInjection can be used to inject your own earcut reference
  54655. * @returns the polygon mesh
  54656. */
  54657. static ExtrudePolygon(name: string, options: {
  54658. shape: Vector3[];
  54659. holes?: Vector3[][];
  54660. depth?: number;
  54661. faceUV?: Vector4[];
  54662. faceColors?: Color4[];
  54663. updatable?: boolean;
  54664. sideOrientation?: number;
  54665. frontUVs?: Vector4;
  54666. backUVs?: Vector4;
  54667. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54668. }
  54669. }
  54670. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  54671. import { Scene } from "babylonjs/scene";
  54672. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  54673. import { Mesh } from "babylonjs/Meshes/mesh";
  54674. import { Nullable } from "babylonjs/types";
  54675. /**
  54676. * Class containing static functions to help procedurally build meshes
  54677. */
  54678. export class LatheBuilder {
  54679. /**
  54680. * Creates lathe mesh.
  54681. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  54682. * * 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
  54683. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  54684. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  54685. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  54686. * * 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
  54687. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  54688. * * 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
  54689. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54690. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54691. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54692. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54693. * @param name defines the name of the mesh
  54694. * @param options defines the options used to create the mesh
  54695. * @param scene defines the hosting scene
  54696. * @returns the lathe mesh
  54697. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  54698. */
  54699. static CreateLathe(name: string, options: {
  54700. shape: Vector3[];
  54701. radius?: number;
  54702. tessellation?: number;
  54703. clip?: number;
  54704. arc?: number;
  54705. closed?: boolean;
  54706. updatable?: boolean;
  54707. sideOrientation?: number;
  54708. frontUVs?: Vector4;
  54709. backUVs?: Vector4;
  54710. cap?: number;
  54711. invertUV?: boolean;
  54712. }, scene?: Nullable<Scene>): Mesh;
  54713. }
  54714. }
  54715. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  54716. import { Nullable } from "babylonjs/types";
  54717. import { Scene } from "babylonjs/scene";
  54718. import { Vector4 } from "babylonjs/Maths/math";
  54719. import { Mesh } from "babylonjs/Meshes/mesh";
  54720. /**
  54721. * Class containing static functions to help procedurally build meshes
  54722. */
  54723. export class TiledPlaneBuilder {
  54724. /**
  54725. * Creates a tiled plane mesh
  54726. * * The parameter `pattern` will, depending on value, do nothing or
  54727. * * * flip (reflect about central vertical) alternate tiles across and up
  54728. * * * flip every tile on alternate rows
  54729. * * * rotate (180 degs) alternate tiles across and up
  54730. * * * rotate every tile on alternate rows
  54731. * * * flip and rotate alternate tiles across and up
  54732. * * * flip and rotate every tile on alternate rows
  54733. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  54734. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  54735. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54736. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54737. * * 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)
  54738. * * 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)
  54739. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54740. * @param name defines the name of the mesh
  54741. * @param options defines the options used to create the mesh
  54742. * @param scene defines the hosting scene
  54743. * @returns the box mesh
  54744. */
  54745. static CreateTiledPlane(name: string, options: {
  54746. pattern?: number;
  54747. tileSize?: number;
  54748. tileWidth?: number;
  54749. tileHeight?: number;
  54750. size?: number;
  54751. width?: number;
  54752. height?: number;
  54753. alignHorizontal?: number;
  54754. alignVertical?: number;
  54755. sideOrientation?: number;
  54756. frontUVs?: Vector4;
  54757. backUVs?: Vector4;
  54758. updatable?: boolean;
  54759. }, scene?: Nullable<Scene>): Mesh;
  54760. }
  54761. }
  54762. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  54763. import { Nullable } from "babylonjs/types";
  54764. import { Scene } from "babylonjs/scene";
  54765. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  54766. import { Mesh } from "babylonjs/Meshes/mesh";
  54767. /**
  54768. * Class containing static functions to help procedurally build meshes
  54769. */
  54770. export class TubeBuilder {
  54771. /**
  54772. * Creates a tube mesh.
  54773. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54774. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  54775. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  54776. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  54777. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  54778. * * 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)
  54779. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  54780. * * 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
  54781. * * 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
  54782. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54783. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54784. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54786. * @param name defines the name of the mesh
  54787. * @param options defines the options used to create the mesh
  54788. * @param scene defines the hosting scene
  54789. * @returns the tube mesh
  54790. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54791. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  54792. */
  54793. static CreateTube(name: string, options: {
  54794. path: Vector3[];
  54795. radius?: number;
  54796. tessellation?: number;
  54797. radiusFunction?: {
  54798. (i: number, distance: number): number;
  54799. };
  54800. cap?: number;
  54801. arc?: number;
  54802. updatable?: boolean;
  54803. sideOrientation?: number;
  54804. frontUVs?: Vector4;
  54805. backUVs?: Vector4;
  54806. instance?: Mesh;
  54807. invertUV?: boolean;
  54808. }, scene?: Nullable<Scene>): Mesh;
  54809. }
  54810. }
  54811. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  54812. import { Scene } from "babylonjs/scene";
  54813. import { Vector4 } from "babylonjs/Maths/math";
  54814. import { Mesh } from "babylonjs/Meshes/mesh";
  54815. import { Nullable } from "babylonjs/types";
  54816. /**
  54817. * Class containing static functions to help procedurally build meshes
  54818. */
  54819. export class IcoSphereBuilder {
  54820. /**
  54821. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  54822. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  54823. * * 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`)
  54824. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  54825. * * 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
  54826. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54827. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54828. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54829. * @param name defines the name of the mesh
  54830. * @param options defines the options used to create the mesh
  54831. * @param scene defines the hosting scene
  54832. * @returns the icosahedron mesh
  54833. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  54834. */
  54835. static CreateIcoSphere(name: string, options: {
  54836. radius?: number;
  54837. radiusX?: number;
  54838. radiusY?: number;
  54839. radiusZ?: number;
  54840. flat?: boolean;
  54841. subdivisions?: number;
  54842. sideOrientation?: number;
  54843. frontUVs?: Vector4;
  54844. backUVs?: Vector4;
  54845. updatable?: boolean;
  54846. }, scene?: Nullable<Scene>): Mesh;
  54847. }
  54848. }
  54849. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  54850. import { Vector3 } from "babylonjs/Maths/math";
  54851. import { Mesh } from "babylonjs/Meshes/mesh";
  54852. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54853. /**
  54854. * Class containing static functions to help procedurally build meshes
  54855. */
  54856. export class DecalBuilder {
  54857. /**
  54858. * Creates a decal mesh.
  54859. * 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
  54860. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  54861. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  54862. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  54863. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  54864. * @param name defines the name of the mesh
  54865. * @param sourceMesh defines the mesh where the decal must be applied
  54866. * @param options defines the options used to create the mesh
  54867. * @param scene defines the hosting scene
  54868. * @returns the decal mesh
  54869. * @see https://doc.babylonjs.com/how_to/decals
  54870. */
  54871. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  54872. position?: Vector3;
  54873. normal?: Vector3;
  54874. size?: Vector3;
  54875. angle?: number;
  54876. }): Mesh;
  54877. }
  54878. }
  54879. declare module "babylonjs/Meshes/meshBuilder" {
  54880. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  54881. import { Nullable } from "babylonjs/types";
  54882. import { Scene } from "babylonjs/scene";
  54883. import { Mesh } from "babylonjs/Meshes/mesh";
  54884. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  54885. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  54886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54887. /**
  54888. * Class containing static functions to help procedurally build meshes
  54889. */
  54890. export class MeshBuilder {
  54891. /**
  54892. * Creates a box mesh
  54893. * * The parameter `size` sets the size (float) of each box side (default 1)
  54894. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  54895. * * 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)
  54896. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54897. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54898. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54900. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54901. * @param name defines the name of the mesh
  54902. * @param options defines the options used to create the mesh
  54903. * @param scene defines the hosting scene
  54904. * @returns the box mesh
  54905. */
  54906. static CreateBox(name: string, options: {
  54907. size?: number;
  54908. width?: number;
  54909. height?: number;
  54910. depth?: number;
  54911. faceUV?: Vector4[];
  54912. faceColors?: Color4[];
  54913. sideOrientation?: number;
  54914. frontUVs?: Vector4;
  54915. backUVs?: Vector4;
  54916. updatable?: boolean;
  54917. }, scene?: Nullable<Scene>): Mesh;
  54918. /**
  54919. * Creates a tiled box mesh
  54920. * * faceTiles sets the pattern, tile size and number of tiles for a face
  54921. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54922. * @param name defines the name of the mesh
  54923. * @param options defines the options used to create the mesh
  54924. * @param scene defines the hosting scene
  54925. * @returns the tiled box mesh
  54926. */
  54927. static CreateTiledBox(name: string, options: {
  54928. pattern?: number;
  54929. size?: number;
  54930. width?: number;
  54931. height?: number;
  54932. depth: number;
  54933. tileSize?: number;
  54934. tileWidth?: number;
  54935. tileHeight?: number;
  54936. faceUV?: Vector4[];
  54937. faceColors?: Color4[];
  54938. alignHorizontal?: number;
  54939. alignVertical?: number;
  54940. sideOrientation?: number;
  54941. updatable?: boolean;
  54942. }, scene?: Nullable<Scene>): Mesh;
  54943. /**
  54944. * Creates a sphere mesh
  54945. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  54946. * * 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`)
  54947. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  54948. * * 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
  54949. * * 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)
  54950. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54951. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54952. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54953. * @param name defines the name of the mesh
  54954. * @param options defines the options used to create the mesh
  54955. * @param scene defines the hosting scene
  54956. * @returns the sphere mesh
  54957. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  54958. */
  54959. static CreateSphere(name: string, options: {
  54960. segments?: number;
  54961. diameter?: number;
  54962. diameterX?: number;
  54963. diameterY?: number;
  54964. diameterZ?: number;
  54965. arc?: number;
  54966. slice?: number;
  54967. sideOrientation?: number;
  54968. frontUVs?: Vector4;
  54969. backUVs?: Vector4;
  54970. updatable?: boolean;
  54971. }, scene?: Nullable<Scene>): Mesh;
  54972. /**
  54973. * Creates a plane polygonal mesh. By default, this is a disc
  54974. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  54975. * * 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
  54976. * * 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
  54977. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54978. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54979. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54980. * @param name defines the name of the mesh
  54981. * @param options defines the options used to create the mesh
  54982. * @param scene defines the hosting scene
  54983. * @returns the plane polygonal mesh
  54984. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  54985. */
  54986. static CreateDisc(name: string, options: {
  54987. radius?: number;
  54988. tessellation?: number;
  54989. arc?: number;
  54990. updatable?: boolean;
  54991. sideOrientation?: number;
  54992. frontUVs?: Vector4;
  54993. backUVs?: Vector4;
  54994. }, scene?: Nullable<Scene>): Mesh;
  54995. /**
  54996. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  54997. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  54998. * * 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`)
  54999. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55000. * * 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
  55001. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55002. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55003. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55004. * @param name defines the name of the mesh
  55005. * @param options defines the options used to create the mesh
  55006. * @param scene defines the hosting scene
  55007. * @returns the icosahedron mesh
  55008. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55009. */
  55010. static CreateIcoSphere(name: string, options: {
  55011. radius?: number;
  55012. radiusX?: number;
  55013. radiusY?: number;
  55014. radiusZ?: number;
  55015. flat?: boolean;
  55016. subdivisions?: number;
  55017. sideOrientation?: number;
  55018. frontUVs?: Vector4;
  55019. backUVs?: Vector4;
  55020. updatable?: boolean;
  55021. }, scene?: Nullable<Scene>): Mesh;
  55022. /**
  55023. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55024. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55025. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55026. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55027. * * 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
  55028. * * 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
  55029. * * 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
  55030. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55031. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55032. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55033. * * 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
  55034. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55035. * * 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
  55036. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55038. * @param name defines the name of the mesh
  55039. * @param options defines the options used to create the mesh
  55040. * @param scene defines the hosting scene
  55041. * @returns the ribbon mesh
  55042. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55043. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55044. */
  55045. static CreateRibbon(name: string, options: {
  55046. pathArray: Vector3[][];
  55047. closeArray?: boolean;
  55048. closePath?: boolean;
  55049. offset?: number;
  55050. updatable?: boolean;
  55051. sideOrientation?: number;
  55052. frontUVs?: Vector4;
  55053. backUVs?: Vector4;
  55054. instance?: Mesh;
  55055. invertUV?: boolean;
  55056. uvs?: Vector2[];
  55057. colors?: Color4[];
  55058. }, scene?: Nullable<Scene>): Mesh;
  55059. /**
  55060. * Creates a cylinder or a cone mesh
  55061. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  55062. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  55063. * * 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.
  55064. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  55065. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  55066. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  55067. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  55068. * * 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).
  55069. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  55070. * * 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).
  55071. * * 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
  55072. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  55073. * * 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
  55074. * * 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.
  55075. * * If `enclose` is false, a ring surface is one element.
  55076. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  55077. * * 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
  55078. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55079. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55081. * @param name defines the name of the mesh
  55082. * @param options defines the options used to create the mesh
  55083. * @param scene defines the hosting scene
  55084. * @returns the cylinder mesh
  55085. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  55086. */
  55087. static CreateCylinder(name: string, options: {
  55088. height?: number;
  55089. diameterTop?: number;
  55090. diameterBottom?: number;
  55091. diameter?: number;
  55092. tessellation?: number;
  55093. subdivisions?: number;
  55094. arc?: number;
  55095. faceColors?: Color4[];
  55096. faceUV?: Vector4[];
  55097. updatable?: boolean;
  55098. hasRings?: boolean;
  55099. enclose?: boolean;
  55100. cap?: number;
  55101. sideOrientation?: number;
  55102. frontUVs?: Vector4;
  55103. backUVs?: Vector4;
  55104. }, scene?: Nullable<Scene>): Mesh;
  55105. /**
  55106. * Creates a torus mesh
  55107. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  55108. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  55109. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  55110. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55111. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55112. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55113. * @param name defines the name of the mesh
  55114. * @param options defines the options used to create the mesh
  55115. * @param scene defines the hosting scene
  55116. * @returns the torus mesh
  55117. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  55118. */
  55119. static CreateTorus(name: string, options: {
  55120. diameter?: number;
  55121. thickness?: number;
  55122. tessellation?: number;
  55123. updatable?: boolean;
  55124. sideOrientation?: number;
  55125. frontUVs?: Vector4;
  55126. backUVs?: Vector4;
  55127. }, scene?: Nullable<Scene>): Mesh;
  55128. /**
  55129. * Creates a torus knot mesh
  55130. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55131. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55132. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55133. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55134. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55135. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55137. * @param name defines the name of the mesh
  55138. * @param options defines the options used to create the mesh
  55139. * @param scene defines the hosting scene
  55140. * @returns the torus knot mesh
  55141. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55142. */
  55143. static CreateTorusKnot(name: string, options: {
  55144. radius?: number;
  55145. tube?: number;
  55146. radialSegments?: number;
  55147. tubularSegments?: number;
  55148. p?: number;
  55149. q?: number;
  55150. updatable?: boolean;
  55151. sideOrientation?: number;
  55152. frontUVs?: Vector4;
  55153. backUVs?: Vector4;
  55154. }, scene?: Nullable<Scene>): Mesh;
  55155. /**
  55156. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  55157. * * 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
  55158. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  55159. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  55160. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  55161. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  55162. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55163. * * 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
  55164. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  55165. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55166. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  55167. * @param name defines the name of the new line system
  55168. * @param options defines the options used to create the line system
  55169. * @param scene defines the hosting scene
  55170. * @returns a new line system mesh
  55171. */
  55172. static CreateLineSystem(name: string, options: {
  55173. lines: Vector3[][];
  55174. updatable?: boolean;
  55175. instance?: Nullable<LinesMesh>;
  55176. colors?: Nullable<Color4[][]>;
  55177. useVertexAlpha?: boolean;
  55178. }, scene: Nullable<Scene>): LinesMesh;
  55179. /**
  55180. * Creates a line mesh
  55181. * 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
  55182. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55183. * * The parameter `points` is an array successive Vector3
  55184. * * 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
  55185. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55186. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55187. * * When updating an instance, remember that only point positions can change, not the number of points
  55188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55189. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55190. * @param name defines the name of the new line system
  55191. * @param options defines the options used to create the line system
  55192. * @param scene defines the hosting scene
  55193. * @returns a new line mesh
  55194. */
  55195. static CreateLines(name: string, options: {
  55196. points: Vector3[];
  55197. updatable?: boolean;
  55198. instance?: Nullable<LinesMesh>;
  55199. colors?: Color4[];
  55200. useVertexAlpha?: boolean;
  55201. }, scene?: Nullable<Scene>): LinesMesh;
  55202. /**
  55203. * Creates a dashed line mesh
  55204. * * 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
  55205. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55206. * * The parameter `points` is an array successive Vector3
  55207. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55208. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55209. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55210. * * 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
  55211. * * When updating an instance, remember that only point positions can change, not the number of points
  55212. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55213. * @param name defines the name of the mesh
  55214. * @param options defines the options used to create the mesh
  55215. * @param scene defines the hosting scene
  55216. * @returns the dashed line mesh
  55217. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55218. */
  55219. static CreateDashedLines(name: string, options: {
  55220. points: Vector3[];
  55221. dashSize?: number;
  55222. gapSize?: number;
  55223. dashNb?: number;
  55224. updatable?: boolean;
  55225. instance?: LinesMesh;
  55226. }, scene?: Nullable<Scene>): LinesMesh;
  55227. /**
  55228. * 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.
  55229. * * 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.
  55230. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55231. * * 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.
  55232. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55233. * * 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
  55234. * * 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
  55235. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55236. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55237. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55238. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55240. * @param name defines the name of the mesh
  55241. * @param options defines the options used to create the mesh
  55242. * @param scene defines the hosting scene
  55243. * @returns the extruded shape mesh
  55244. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55245. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55246. */
  55247. static ExtrudeShape(name: string, options: {
  55248. shape: Vector3[];
  55249. path: Vector3[];
  55250. scale?: number;
  55251. rotation?: number;
  55252. cap?: number;
  55253. updatable?: boolean;
  55254. sideOrientation?: number;
  55255. frontUVs?: Vector4;
  55256. backUVs?: Vector4;
  55257. instance?: Mesh;
  55258. invertUV?: boolean;
  55259. }, scene?: Nullable<Scene>): Mesh;
  55260. /**
  55261. * Creates an custom extruded shape mesh.
  55262. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55263. * * 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.
  55264. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55265. * * 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
  55266. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55267. * * 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
  55268. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55269. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55270. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55271. * * 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
  55272. * * 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
  55273. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55274. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55275. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55276. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55277. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55278. * @param name defines the name of the mesh
  55279. * @param options defines the options used to create the mesh
  55280. * @param scene defines the hosting scene
  55281. * @returns the custom extruded shape mesh
  55282. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55283. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55284. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55285. */
  55286. static ExtrudeShapeCustom(name: string, options: {
  55287. shape: Vector3[];
  55288. path: Vector3[];
  55289. scaleFunction?: any;
  55290. rotationFunction?: any;
  55291. ribbonCloseArray?: boolean;
  55292. ribbonClosePath?: boolean;
  55293. cap?: number;
  55294. updatable?: boolean;
  55295. sideOrientation?: number;
  55296. frontUVs?: Vector4;
  55297. backUVs?: Vector4;
  55298. instance?: Mesh;
  55299. invertUV?: boolean;
  55300. }, scene?: Nullable<Scene>): Mesh;
  55301. /**
  55302. * Creates lathe mesh.
  55303. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55304. * * 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
  55305. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55306. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55307. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55308. * * 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
  55309. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55310. * * 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
  55311. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55312. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55313. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55314. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55315. * @param name defines the name of the mesh
  55316. * @param options defines the options used to create the mesh
  55317. * @param scene defines the hosting scene
  55318. * @returns the lathe mesh
  55319. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55320. */
  55321. static CreateLathe(name: string, options: {
  55322. shape: Vector3[];
  55323. radius?: number;
  55324. tessellation?: number;
  55325. clip?: number;
  55326. arc?: number;
  55327. closed?: boolean;
  55328. updatable?: boolean;
  55329. sideOrientation?: number;
  55330. frontUVs?: Vector4;
  55331. backUVs?: Vector4;
  55332. cap?: number;
  55333. invertUV?: boolean;
  55334. }, scene?: Nullable<Scene>): Mesh;
  55335. /**
  55336. * Creates a tiled plane mesh
  55337. * * You can set a limited pattern arrangement with the tiles
  55338. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55339. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55341. * @param name defines the name of the mesh
  55342. * @param options defines the options used to create the mesh
  55343. * @param scene defines the hosting scene
  55344. * @returns the plane mesh
  55345. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55346. */
  55347. static CreateTiledPlane(name: string, options: {
  55348. pattern?: number;
  55349. tileSize?: number;
  55350. tileWidth?: number;
  55351. tileHeight?: number;
  55352. size?: number;
  55353. width?: number;
  55354. height?: number;
  55355. alignHorizontal?: number;
  55356. alignVertical?: number;
  55357. sideOrientation?: number;
  55358. frontUVs?: Vector4;
  55359. backUVs?: Vector4;
  55360. updatable?: boolean;
  55361. }, scene?: Nullable<Scene>): Mesh;
  55362. /**
  55363. * Creates a plane mesh
  55364. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  55365. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  55366. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  55367. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55368. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55370. * @param name defines the name of the mesh
  55371. * @param options defines the options used to create the mesh
  55372. * @param scene defines the hosting scene
  55373. * @returns the plane mesh
  55374. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55375. */
  55376. static CreatePlane(name: string, options: {
  55377. size?: number;
  55378. width?: number;
  55379. height?: number;
  55380. sideOrientation?: number;
  55381. frontUVs?: Vector4;
  55382. backUVs?: Vector4;
  55383. updatable?: boolean;
  55384. sourcePlane?: Plane;
  55385. }, scene?: Nullable<Scene>): Mesh;
  55386. /**
  55387. * Creates a ground mesh
  55388. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  55389. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  55390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55391. * @param name defines the name of the mesh
  55392. * @param options defines the options used to create the mesh
  55393. * @param scene defines the hosting scene
  55394. * @returns the ground mesh
  55395. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  55396. */
  55397. static CreateGround(name: string, options: {
  55398. width?: number;
  55399. height?: number;
  55400. subdivisions?: number;
  55401. subdivisionsX?: number;
  55402. subdivisionsY?: number;
  55403. updatable?: boolean;
  55404. }, scene?: Nullable<Scene>): Mesh;
  55405. /**
  55406. * Creates a tiled ground mesh
  55407. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  55408. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  55409. * * 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
  55410. * * 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
  55411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55412. * @param name defines the name of the mesh
  55413. * @param options defines the options used to create the mesh
  55414. * @param scene defines the hosting scene
  55415. * @returns the tiled ground mesh
  55416. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  55417. */
  55418. static CreateTiledGround(name: string, options: {
  55419. xmin: number;
  55420. zmin: number;
  55421. xmax: number;
  55422. zmax: number;
  55423. subdivisions?: {
  55424. w: number;
  55425. h: number;
  55426. };
  55427. precision?: {
  55428. w: number;
  55429. h: number;
  55430. };
  55431. updatable?: boolean;
  55432. }, scene?: Nullable<Scene>): Mesh;
  55433. /**
  55434. * Creates a ground mesh from a height map
  55435. * * The parameter `url` sets the URL of the height map image resource.
  55436. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  55437. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  55438. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  55439. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  55440. * * 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.
  55441. * * 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).
  55442. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  55443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55444. * @param name defines the name of the mesh
  55445. * @param url defines the url to the height map
  55446. * @param options defines the options used to create the mesh
  55447. * @param scene defines the hosting scene
  55448. * @returns the ground mesh
  55449. * @see https://doc.babylonjs.com/babylon101/height_map
  55450. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  55451. */
  55452. static CreateGroundFromHeightMap(name: string, url: string, options: {
  55453. width?: number;
  55454. height?: number;
  55455. subdivisions?: number;
  55456. minHeight?: number;
  55457. maxHeight?: number;
  55458. colorFilter?: Color3;
  55459. alphaFilter?: number;
  55460. updatable?: boolean;
  55461. onReady?: (mesh: GroundMesh) => void;
  55462. }, scene?: Nullable<Scene>): GroundMesh;
  55463. /**
  55464. * Creates a polygon mesh
  55465. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55466. * * 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
  55467. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55468. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55469. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  55470. * * Remember you can only change the shape positions, not their number when updating a polygon
  55471. * @param name defines the name of the mesh
  55472. * @param options defines the options used to create the mesh
  55473. * @param scene defines the hosting scene
  55474. * @param earcutInjection can be used to inject your own earcut reference
  55475. * @returns the polygon mesh
  55476. */
  55477. static CreatePolygon(name: string, options: {
  55478. shape: Vector3[];
  55479. holes?: Vector3[][];
  55480. depth?: number;
  55481. faceUV?: Vector4[];
  55482. faceColors?: Color4[];
  55483. updatable?: boolean;
  55484. sideOrientation?: number;
  55485. frontUVs?: Vector4;
  55486. backUVs?: Vector4;
  55487. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55488. /**
  55489. * Creates an extruded polygon mesh, with depth in the Y direction.
  55490. * * 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)
  55491. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55492. * @param name defines the name of the mesh
  55493. * @param options defines the options used to create the mesh
  55494. * @param scene defines the hosting scene
  55495. * @param earcutInjection can be used to inject your own earcut reference
  55496. * @returns the polygon mesh
  55497. */
  55498. static ExtrudePolygon(name: string, options: {
  55499. shape: Vector3[];
  55500. holes?: Vector3[][];
  55501. depth?: number;
  55502. faceUV?: Vector4[];
  55503. faceColors?: Color4[];
  55504. updatable?: boolean;
  55505. sideOrientation?: number;
  55506. frontUVs?: Vector4;
  55507. backUVs?: Vector4;
  55508. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55509. /**
  55510. * Creates a tube mesh.
  55511. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55512. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55513. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55514. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55515. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55516. * * 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)
  55517. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55518. * * 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
  55519. * * 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
  55520. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55521. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55522. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55523. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55524. * @param name defines the name of the mesh
  55525. * @param options defines the options used to create the mesh
  55526. * @param scene defines the hosting scene
  55527. * @returns the tube mesh
  55528. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55529. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55530. */
  55531. static CreateTube(name: string, options: {
  55532. path: Vector3[];
  55533. radius?: number;
  55534. tessellation?: number;
  55535. radiusFunction?: {
  55536. (i: number, distance: number): number;
  55537. };
  55538. cap?: number;
  55539. arc?: number;
  55540. updatable?: boolean;
  55541. sideOrientation?: number;
  55542. frontUVs?: Vector4;
  55543. backUVs?: Vector4;
  55544. instance?: Mesh;
  55545. invertUV?: boolean;
  55546. }, scene?: Nullable<Scene>): Mesh;
  55547. /**
  55548. * Creates a polyhedron mesh
  55549. * * 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
  55550. * * The parameter `size` (positive float, default 1) sets the polygon size
  55551. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55552. * * 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`
  55553. * * 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
  55554. * * 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)`)
  55555. * * 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
  55556. * * 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
  55557. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55558. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55559. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55560. * @param name defines the name of the mesh
  55561. * @param options defines the options used to create the mesh
  55562. * @param scene defines the hosting scene
  55563. * @returns the polyhedron mesh
  55564. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55565. */
  55566. static CreatePolyhedron(name: string, options: {
  55567. type?: number;
  55568. size?: number;
  55569. sizeX?: number;
  55570. sizeY?: number;
  55571. sizeZ?: number;
  55572. custom?: any;
  55573. faceUV?: Vector4[];
  55574. faceColors?: Color4[];
  55575. flat?: boolean;
  55576. updatable?: boolean;
  55577. sideOrientation?: number;
  55578. frontUVs?: Vector4;
  55579. backUVs?: Vector4;
  55580. }, scene?: Nullable<Scene>): Mesh;
  55581. /**
  55582. * Creates a decal mesh.
  55583. * 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
  55584. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55585. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55586. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55587. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55588. * @param name defines the name of the mesh
  55589. * @param sourceMesh defines the mesh where the decal must be applied
  55590. * @param options defines the options used to create the mesh
  55591. * @param scene defines the hosting scene
  55592. * @returns the decal mesh
  55593. * @see https://doc.babylonjs.com/how_to/decals
  55594. */
  55595. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55596. position?: Vector3;
  55597. normal?: Vector3;
  55598. size?: Vector3;
  55599. angle?: number;
  55600. }): Mesh;
  55601. }
  55602. }
  55603. declare module "babylonjs/Meshes/meshSimplification" {
  55604. import { Mesh } from "babylonjs/Meshes/mesh";
  55605. /**
  55606. * A simplifier interface for future simplification implementations
  55607. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55608. */
  55609. export interface ISimplifier {
  55610. /**
  55611. * Simplification of a given mesh according to the given settings.
  55612. * Since this requires computation, it is assumed that the function runs async.
  55613. * @param settings The settings of the simplification, including quality and distance
  55614. * @param successCallback A callback that will be called after the mesh was simplified.
  55615. * @param errorCallback in case of an error, this callback will be called. optional.
  55616. */
  55617. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  55618. }
  55619. /**
  55620. * Expected simplification settings.
  55621. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  55622. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55623. */
  55624. export interface ISimplificationSettings {
  55625. /**
  55626. * Gets or sets the expected quality
  55627. */
  55628. quality: number;
  55629. /**
  55630. * Gets or sets the distance when this optimized version should be used
  55631. */
  55632. distance: number;
  55633. /**
  55634. * Gets an already optimized mesh
  55635. */
  55636. optimizeMesh?: boolean;
  55637. }
  55638. /**
  55639. * Class used to specify simplification options
  55640. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55641. */
  55642. export class SimplificationSettings implements ISimplificationSettings {
  55643. /** expected quality */
  55644. quality: number;
  55645. /** distance when this optimized version should be used */
  55646. distance: number;
  55647. /** already optimized mesh */
  55648. optimizeMesh?: boolean | undefined;
  55649. /**
  55650. * Creates a SimplificationSettings
  55651. * @param quality expected quality
  55652. * @param distance distance when this optimized version should be used
  55653. * @param optimizeMesh already optimized mesh
  55654. */
  55655. constructor(
  55656. /** expected quality */
  55657. quality: number,
  55658. /** distance when this optimized version should be used */
  55659. distance: number,
  55660. /** already optimized mesh */
  55661. optimizeMesh?: boolean | undefined);
  55662. }
  55663. /**
  55664. * Interface used to define a simplification task
  55665. */
  55666. export interface ISimplificationTask {
  55667. /**
  55668. * Array of settings
  55669. */
  55670. settings: Array<ISimplificationSettings>;
  55671. /**
  55672. * Simplification type
  55673. */
  55674. simplificationType: SimplificationType;
  55675. /**
  55676. * Mesh to simplify
  55677. */
  55678. mesh: Mesh;
  55679. /**
  55680. * Callback called on success
  55681. */
  55682. successCallback?: () => void;
  55683. /**
  55684. * Defines if parallel processing can be used
  55685. */
  55686. parallelProcessing: boolean;
  55687. }
  55688. /**
  55689. * Queue used to order the simplification tasks
  55690. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55691. */
  55692. export class SimplificationQueue {
  55693. private _simplificationArray;
  55694. /**
  55695. * Gets a boolean indicating that the process is still running
  55696. */
  55697. running: boolean;
  55698. /**
  55699. * Creates a new queue
  55700. */
  55701. constructor();
  55702. /**
  55703. * Adds a new simplification task
  55704. * @param task defines a task to add
  55705. */
  55706. addTask(task: ISimplificationTask): void;
  55707. /**
  55708. * Execute next task
  55709. */
  55710. executeNext(): void;
  55711. /**
  55712. * Execute a simplification task
  55713. * @param task defines the task to run
  55714. */
  55715. runSimplification(task: ISimplificationTask): void;
  55716. private getSimplifier;
  55717. }
  55718. /**
  55719. * The implemented types of simplification
  55720. * At the moment only Quadratic Error Decimation is implemented
  55721. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55722. */
  55723. export enum SimplificationType {
  55724. /** Quadratic error decimation */
  55725. QUADRATIC = 0
  55726. }
  55727. }
  55728. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  55729. import { Scene } from "babylonjs/scene";
  55730. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  55731. import { ISceneComponent } from "babylonjs/sceneComponent";
  55732. module "babylonjs/scene" {
  55733. interface Scene {
  55734. /** @hidden (Backing field) */
  55735. _simplificationQueue: SimplificationQueue;
  55736. /**
  55737. * Gets or sets the simplification queue attached to the scene
  55738. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55739. */
  55740. simplificationQueue: SimplificationQueue;
  55741. }
  55742. }
  55743. module "babylonjs/Meshes/mesh" {
  55744. interface Mesh {
  55745. /**
  55746. * Simplify the mesh according to the given array of settings.
  55747. * Function will return immediately and will simplify async
  55748. * @param settings a collection of simplification settings
  55749. * @param parallelProcessing should all levels calculate parallel or one after the other
  55750. * @param simplificationType the type of simplification to run
  55751. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  55752. * @returns the current mesh
  55753. */
  55754. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  55755. }
  55756. }
  55757. /**
  55758. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  55759. * created in a scene
  55760. */
  55761. export class SimplicationQueueSceneComponent implements ISceneComponent {
  55762. /**
  55763. * The component name helpfull to identify the component in the list of scene components.
  55764. */
  55765. readonly name: string;
  55766. /**
  55767. * The scene the component belongs to.
  55768. */
  55769. scene: Scene;
  55770. /**
  55771. * Creates a new instance of the component for the given scene
  55772. * @param scene Defines the scene to register the component in
  55773. */
  55774. constructor(scene: Scene);
  55775. /**
  55776. * Registers the component in a given scene
  55777. */
  55778. register(): void;
  55779. /**
  55780. * Rebuilds the elements related to this component in case of
  55781. * context lost for instance.
  55782. */
  55783. rebuild(): void;
  55784. /**
  55785. * Disposes the component and the associated ressources
  55786. */
  55787. dispose(): void;
  55788. private _beforeCameraUpdate;
  55789. }
  55790. }
  55791. declare module "babylonjs/Meshes/Builders/index" {
  55792. export * from "babylonjs/Meshes/Builders/boxBuilder";
  55793. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  55794. export * from "babylonjs/Meshes/Builders/discBuilder";
  55795. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  55796. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  55797. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  55798. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  55799. export * from "babylonjs/Meshes/Builders/torusBuilder";
  55800. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  55801. export * from "babylonjs/Meshes/Builders/linesBuilder";
  55802. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  55803. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  55804. export * from "babylonjs/Meshes/Builders/latheBuilder";
  55805. export * from "babylonjs/Meshes/Builders/planeBuilder";
  55806. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  55807. export * from "babylonjs/Meshes/Builders/groundBuilder";
  55808. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  55809. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  55810. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  55811. export * from "babylonjs/Meshes/Builders/decalBuilder";
  55812. }
  55813. declare module "babylonjs/Meshes/index" {
  55814. export * from "babylonjs/Meshes/abstractMesh";
  55815. export * from "babylonjs/Meshes/buffer";
  55816. export * from "babylonjs/Meshes/Compression/index";
  55817. export * from "babylonjs/Meshes/csg";
  55818. export * from "babylonjs/Meshes/geometry";
  55819. export * from "babylonjs/Meshes/groundMesh";
  55820. export * from "babylonjs/Meshes/trailMesh";
  55821. export * from "babylonjs/Meshes/instancedMesh";
  55822. export * from "babylonjs/Meshes/linesMesh";
  55823. export * from "babylonjs/Meshes/mesh";
  55824. export * from "babylonjs/Meshes/mesh.vertexData";
  55825. export * from "babylonjs/Meshes/meshBuilder";
  55826. export * from "babylonjs/Meshes/meshSimplification";
  55827. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  55828. export * from "babylonjs/Meshes/polygonMesh";
  55829. export * from "babylonjs/Meshes/subMesh";
  55830. export * from "babylonjs/Meshes/meshLODLevel";
  55831. export * from "babylonjs/Meshes/transformNode";
  55832. export * from "babylonjs/Meshes/Builders/index";
  55833. export * from "babylonjs/Meshes/dataBuffer";
  55834. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  55835. }
  55836. declare module "babylonjs/Morph/index" {
  55837. export * from "babylonjs/Morph/morphTarget";
  55838. export * from "babylonjs/Morph/morphTargetManager";
  55839. }
  55840. declare module "babylonjs/Offline/database" {
  55841. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  55842. /**
  55843. * Class used to enable access to IndexedDB
  55844. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  55845. */
  55846. export class Database implements IOfflineProvider {
  55847. private _callbackManifestChecked;
  55848. private _currentSceneUrl;
  55849. private _db;
  55850. private _enableSceneOffline;
  55851. private _enableTexturesOffline;
  55852. private _manifestVersionFound;
  55853. private _mustUpdateRessources;
  55854. private _hasReachedQuota;
  55855. private _isSupported;
  55856. private _idbFactory;
  55857. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  55858. private static IsUASupportingBlobStorage;
  55859. /**
  55860. * Gets a boolean indicating if Database storate is enabled (off by default)
  55861. */
  55862. static IDBStorageEnabled: boolean;
  55863. /**
  55864. * Gets a boolean indicating if scene must be saved in the database
  55865. */
  55866. readonly enableSceneOffline: boolean;
  55867. /**
  55868. * Gets a boolean indicating if textures must be saved in the database
  55869. */
  55870. readonly enableTexturesOffline: boolean;
  55871. /**
  55872. * Creates a new Database
  55873. * @param urlToScene defines the url to load the scene
  55874. * @param callbackManifestChecked defines the callback to use when manifest is checked
  55875. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  55876. */
  55877. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  55878. private static _ParseURL;
  55879. private static _ReturnFullUrlLocation;
  55880. private _checkManifestFile;
  55881. /**
  55882. * Open the database and make it available
  55883. * @param successCallback defines the callback to call on success
  55884. * @param errorCallback defines the callback to call on error
  55885. */
  55886. open(successCallback: () => void, errorCallback: () => void): void;
  55887. /**
  55888. * Loads an image from the database
  55889. * @param url defines the url to load from
  55890. * @param image defines the target DOM image
  55891. */
  55892. loadImage(url: string, image: HTMLImageElement): void;
  55893. private _loadImageFromDBAsync;
  55894. private _saveImageIntoDBAsync;
  55895. private _checkVersionFromDB;
  55896. private _loadVersionFromDBAsync;
  55897. private _saveVersionIntoDBAsync;
  55898. /**
  55899. * Loads a file from database
  55900. * @param url defines the URL to load from
  55901. * @param sceneLoaded defines a callback to call on success
  55902. * @param progressCallBack defines a callback to call when progress changed
  55903. * @param errorCallback defines a callback to call on error
  55904. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  55905. */
  55906. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  55907. private _loadFileAsync;
  55908. private _saveFileAsync;
  55909. /**
  55910. * Validates if xhr data is correct
  55911. * @param xhr defines the request to validate
  55912. * @param dataType defines the expected data type
  55913. * @returns true if data is correct
  55914. */
  55915. private static _ValidateXHRData;
  55916. }
  55917. }
  55918. declare module "babylonjs/Offline/index" {
  55919. export * from "babylonjs/Offline/database";
  55920. export * from "babylonjs/Offline/IOfflineProvider";
  55921. }
  55922. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  55923. /** @hidden */
  55924. export var gpuUpdateParticlesPixelShader: {
  55925. name: string;
  55926. shader: string;
  55927. };
  55928. }
  55929. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  55930. /** @hidden */
  55931. export var gpuUpdateParticlesVertexShader: {
  55932. name: string;
  55933. shader: string;
  55934. };
  55935. }
  55936. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  55937. /** @hidden */
  55938. export var clipPlaneFragmentDeclaration2: {
  55939. name: string;
  55940. shader: string;
  55941. };
  55942. }
  55943. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  55944. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  55945. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  55946. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55947. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  55948. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  55949. /** @hidden */
  55950. export var gpuRenderParticlesPixelShader: {
  55951. name: string;
  55952. shader: string;
  55953. };
  55954. }
  55955. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  55956. /** @hidden */
  55957. export var clipPlaneVertexDeclaration2: {
  55958. name: string;
  55959. shader: string;
  55960. };
  55961. }
  55962. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  55963. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  55964. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  55965. /** @hidden */
  55966. export var gpuRenderParticlesVertexShader: {
  55967. name: string;
  55968. shader: string;
  55969. };
  55970. }
  55971. declare module "babylonjs/Particles/gpuParticleSystem" {
  55972. import { Nullable } from "babylonjs/types";
  55973. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  55974. import { Observable } from "babylonjs/Misc/observable";
  55975. import { Color4, Color3 } from "babylonjs/Maths/math";
  55976. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  55977. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  55978. import { Scene, IDisposable } from "babylonjs/scene";
  55979. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  55980. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  55981. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  55982. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  55983. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  55984. /**
  55985. * This represents a GPU particle system in Babylon
  55986. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  55987. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  55988. */
  55989. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  55990. /**
  55991. * The layer mask we are rendering the particles through.
  55992. */
  55993. layerMask: number;
  55994. private _capacity;
  55995. private _activeCount;
  55996. private _currentActiveCount;
  55997. private _accumulatedCount;
  55998. private _renderEffect;
  55999. private _updateEffect;
  56000. private _buffer0;
  56001. private _buffer1;
  56002. private _spriteBuffer;
  56003. private _updateVAO;
  56004. private _renderVAO;
  56005. private _targetIndex;
  56006. private _sourceBuffer;
  56007. private _targetBuffer;
  56008. private _engine;
  56009. private _currentRenderId;
  56010. private _started;
  56011. private _stopped;
  56012. private _timeDelta;
  56013. private _randomTexture;
  56014. private _randomTexture2;
  56015. private _attributesStrideSize;
  56016. private _updateEffectOptions;
  56017. private _randomTextureSize;
  56018. private _actualFrame;
  56019. private readonly _rawTextureWidth;
  56020. /**
  56021. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  56022. */
  56023. static readonly IsSupported: boolean;
  56024. /**
  56025. * An event triggered when the system is disposed.
  56026. */
  56027. onDisposeObservable: Observable<GPUParticleSystem>;
  56028. /**
  56029. * Gets the maximum number of particles active at the same time.
  56030. * @returns The max number of active particles.
  56031. */
  56032. getCapacity(): number;
  56033. /**
  56034. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  56035. * to override the particles.
  56036. */
  56037. forceDepthWrite: boolean;
  56038. /**
  56039. * Gets or set the number of active particles
  56040. */
  56041. activeParticleCount: number;
  56042. private _preWarmDone;
  56043. /**
  56044. * Is this system ready to be used/rendered
  56045. * @return true if the system is ready
  56046. */
  56047. isReady(): boolean;
  56048. /**
  56049. * Gets if the system has been started. (Note: this will still be true after stop is called)
  56050. * @returns True if it has been started, otherwise false.
  56051. */
  56052. isStarted(): boolean;
  56053. /**
  56054. * Starts the particle system and begins to emit
  56055. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  56056. */
  56057. start(delay?: number): void;
  56058. /**
  56059. * Stops the particle system.
  56060. */
  56061. stop(): void;
  56062. /**
  56063. * Remove all active particles
  56064. */
  56065. reset(): void;
  56066. /**
  56067. * Returns the string "GPUParticleSystem"
  56068. * @returns a string containing the class name
  56069. */
  56070. getClassName(): string;
  56071. private _colorGradientsTexture;
  56072. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  56073. /**
  56074. * Adds a new color gradient
  56075. * @param gradient defines the gradient to use (between 0 and 1)
  56076. * @param color1 defines the color to affect to the specified gradient
  56077. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  56078. * @returns the current particle system
  56079. */
  56080. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  56081. /**
  56082. * Remove a specific color gradient
  56083. * @param gradient defines the gradient to remove
  56084. * @returns the current particle system
  56085. */
  56086. removeColorGradient(gradient: number): GPUParticleSystem;
  56087. private _angularSpeedGradientsTexture;
  56088. private _sizeGradientsTexture;
  56089. private _velocityGradientsTexture;
  56090. private _limitVelocityGradientsTexture;
  56091. private _dragGradientsTexture;
  56092. private _addFactorGradient;
  56093. /**
  56094. * Adds a new size gradient
  56095. * @param gradient defines the gradient to use (between 0 and 1)
  56096. * @param factor defines the size factor to affect to the specified gradient
  56097. * @returns the current particle system
  56098. */
  56099. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  56100. /**
  56101. * Remove a specific size gradient
  56102. * @param gradient defines the gradient to remove
  56103. * @returns the current particle system
  56104. */
  56105. removeSizeGradient(gradient: number): GPUParticleSystem;
  56106. /**
  56107. * Adds a new angular speed gradient
  56108. * @param gradient defines the gradient to use (between 0 and 1)
  56109. * @param factor defines the angular speed to affect to the specified gradient
  56110. * @returns the current particle system
  56111. */
  56112. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  56113. /**
  56114. * Remove a specific angular speed gradient
  56115. * @param gradient defines the gradient to remove
  56116. * @returns the current particle system
  56117. */
  56118. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  56119. /**
  56120. * Adds a new velocity gradient
  56121. * @param gradient defines the gradient to use (between 0 and 1)
  56122. * @param factor defines the velocity to affect to the specified gradient
  56123. * @returns the current particle system
  56124. */
  56125. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56126. /**
  56127. * Remove a specific velocity gradient
  56128. * @param gradient defines the gradient to remove
  56129. * @returns the current particle system
  56130. */
  56131. removeVelocityGradient(gradient: number): GPUParticleSystem;
  56132. /**
  56133. * Adds a new limit velocity gradient
  56134. * @param gradient defines the gradient to use (between 0 and 1)
  56135. * @param factor defines the limit velocity value to affect to the specified gradient
  56136. * @returns the current particle system
  56137. */
  56138. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56139. /**
  56140. * Remove a specific limit velocity gradient
  56141. * @param gradient defines the gradient to remove
  56142. * @returns the current particle system
  56143. */
  56144. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  56145. /**
  56146. * Adds a new drag gradient
  56147. * @param gradient defines the gradient to use (between 0 and 1)
  56148. * @param factor defines the drag value to affect to the specified gradient
  56149. * @returns the current particle system
  56150. */
  56151. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  56152. /**
  56153. * Remove a specific drag gradient
  56154. * @param gradient defines the gradient to remove
  56155. * @returns the current particle system
  56156. */
  56157. removeDragGradient(gradient: number): GPUParticleSystem;
  56158. /**
  56159. * Not supported by GPUParticleSystem
  56160. * @param gradient defines the gradient to use (between 0 and 1)
  56161. * @param factor defines the emit rate value to affect to the specified gradient
  56162. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56163. * @returns the current particle system
  56164. */
  56165. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56166. /**
  56167. * Not supported by GPUParticleSystem
  56168. * @param gradient defines the gradient to remove
  56169. * @returns the current particle system
  56170. */
  56171. removeEmitRateGradient(gradient: number): IParticleSystem;
  56172. /**
  56173. * Not supported by GPUParticleSystem
  56174. * @param gradient defines the gradient to use (between 0 and 1)
  56175. * @param factor defines the start size value to affect to the specified gradient
  56176. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56177. * @returns the current particle system
  56178. */
  56179. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56180. /**
  56181. * Not supported by GPUParticleSystem
  56182. * @param gradient defines the gradient to remove
  56183. * @returns the current particle system
  56184. */
  56185. removeStartSizeGradient(gradient: number): IParticleSystem;
  56186. /**
  56187. * Not supported by GPUParticleSystem
  56188. * @param gradient defines the gradient to use (between 0 and 1)
  56189. * @param min defines the color remap minimal range
  56190. * @param max defines the color remap maximal range
  56191. * @returns the current particle system
  56192. */
  56193. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56194. /**
  56195. * Not supported by GPUParticleSystem
  56196. * @param gradient defines the gradient to remove
  56197. * @returns the current particle system
  56198. */
  56199. removeColorRemapGradient(): IParticleSystem;
  56200. /**
  56201. * Not supported by GPUParticleSystem
  56202. * @param gradient defines the gradient to use (between 0 and 1)
  56203. * @param min defines the alpha remap minimal range
  56204. * @param max defines the alpha remap maximal range
  56205. * @returns the current particle system
  56206. */
  56207. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56208. /**
  56209. * Not supported by GPUParticleSystem
  56210. * @param gradient defines the gradient to remove
  56211. * @returns the current particle system
  56212. */
  56213. removeAlphaRemapGradient(): IParticleSystem;
  56214. /**
  56215. * Not supported by GPUParticleSystem
  56216. * @param gradient defines the gradient to use (between 0 and 1)
  56217. * @param color defines the color to affect to the specified gradient
  56218. * @returns the current particle system
  56219. */
  56220. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  56221. /**
  56222. * Not supported by GPUParticleSystem
  56223. * @param gradient defines the gradient to remove
  56224. * @returns the current particle system
  56225. */
  56226. removeRampGradient(): IParticleSystem;
  56227. /**
  56228. * Not supported by GPUParticleSystem
  56229. * @returns the list of ramp gradients
  56230. */
  56231. getRampGradients(): Nullable<Array<Color3Gradient>>;
  56232. /**
  56233. * Not supported by GPUParticleSystem
  56234. * Gets or sets a boolean indicating that ramp gradients must be used
  56235. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  56236. */
  56237. useRampGradients: boolean;
  56238. /**
  56239. * Not supported by GPUParticleSystem
  56240. * @param gradient defines the gradient to use (between 0 and 1)
  56241. * @param factor defines the life time factor to affect to the specified gradient
  56242. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56243. * @returns the current particle system
  56244. */
  56245. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56246. /**
  56247. * Not supported by GPUParticleSystem
  56248. * @param gradient defines the gradient to remove
  56249. * @returns the current particle system
  56250. */
  56251. removeLifeTimeGradient(gradient: number): IParticleSystem;
  56252. /**
  56253. * Instantiates a GPU particle system.
  56254. * 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.
  56255. * @param name The name of the particle system
  56256. * @param options The options used to create the system
  56257. * @param scene The scene the particle system belongs to
  56258. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  56259. */
  56260. constructor(name: string, options: Partial<{
  56261. capacity: number;
  56262. randomTextureSize: number;
  56263. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  56264. protected _reset(): void;
  56265. private _createUpdateVAO;
  56266. private _createRenderVAO;
  56267. private _initialize;
  56268. /** @hidden */
  56269. _recreateUpdateEffect(): void;
  56270. /** @hidden */
  56271. _recreateRenderEffect(): void;
  56272. /**
  56273. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  56274. * @param preWarm defines if we are in the pre-warmimg phase
  56275. */
  56276. animate(preWarm?: boolean): void;
  56277. private _createFactorGradientTexture;
  56278. private _createSizeGradientTexture;
  56279. private _createAngularSpeedGradientTexture;
  56280. private _createVelocityGradientTexture;
  56281. private _createLimitVelocityGradientTexture;
  56282. private _createDragGradientTexture;
  56283. private _createColorGradientTexture;
  56284. /**
  56285. * Renders the particle system in its current state
  56286. * @param preWarm defines if the system should only update the particles but not render them
  56287. * @returns the current number of particles
  56288. */
  56289. render(preWarm?: boolean): number;
  56290. /**
  56291. * Rebuilds the particle system
  56292. */
  56293. rebuild(): void;
  56294. private _releaseBuffers;
  56295. private _releaseVAOs;
  56296. /**
  56297. * Disposes the particle system and free the associated resources
  56298. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  56299. */
  56300. dispose(disposeTexture?: boolean): void;
  56301. /**
  56302. * Clones the particle system.
  56303. * @param name The name of the cloned object
  56304. * @param newEmitter The new emitter to use
  56305. * @returns the cloned particle system
  56306. */
  56307. clone(name: string, newEmitter: any): GPUParticleSystem;
  56308. /**
  56309. * Serializes the particle system to a JSON object.
  56310. * @returns the JSON object
  56311. */
  56312. serialize(): any;
  56313. /**
  56314. * Parses a JSON object to create a GPU particle system.
  56315. * @param parsedParticleSystem The JSON object to parse
  56316. * @param scene The scene to create the particle system in
  56317. * @param rootUrl The root url to use to load external dependencies like texture
  56318. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  56319. * @returns the parsed GPU particle system
  56320. */
  56321. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  56322. }
  56323. }
  56324. declare module "babylonjs/Particles/particleSystemSet" {
  56325. import { Nullable } from "babylonjs/types";
  56326. import { Color3 } from "babylonjs/Maths/math";
  56327. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56328. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56329. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56330. import { Scene, IDisposable } from "babylonjs/scene";
  56331. /**
  56332. * Represents a set of particle systems working together to create a specific effect
  56333. */
  56334. export class ParticleSystemSet implements IDisposable {
  56335. private _emitterCreationOptions;
  56336. private _emitterNode;
  56337. /**
  56338. * Gets the particle system list
  56339. */
  56340. systems: IParticleSystem[];
  56341. /**
  56342. * Gets the emitter node used with this set
  56343. */
  56344. readonly emitterNode: Nullable<TransformNode>;
  56345. /**
  56346. * Creates a new emitter mesh as a sphere
  56347. * @param options defines the options used to create the sphere
  56348. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  56349. * @param scene defines the hosting scene
  56350. */
  56351. setEmitterAsSphere(options: {
  56352. diameter: number;
  56353. segments: number;
  56354. color: Color3;
  56355. }, renderingGroupId: number, scene: Scene): void;
  56356. /**
  56357. * Starts all particle systems of the set
  56358. * @param emitter defines an optional mesh to use as emitter for the particle systems
  56359. */
  56360. start(emitter?: AbstractMesh): void;
  56361. /**
  56362. * Release all associated resources
  56363. */
  56364. dispose(): void;
  56365. /**
  56366. * Serialize the set into a JSON compatible object
  56367. * @returns a JSON compatible representation of the set
  56368. */
  56369. serialize(): any;
  56370. /**
  56371. * Parse a new ParticleSystemSet from a serialized source
  56372. * @param data defines a JSON compatible representation of the set
  56373. * @param scene defines the hosting scene
  56374. * @param gpu defines if we want GPU particles or CPU particles
  56375. * @returns a new ParticleSystemSet
  56376. */
  56377. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  56378. }
  56379. }
  56380. declare module "babylonjs/Particles/particleHelper" {
  56381. import { Nullable } from "babylonjs/types";
  56382. import { Scene } from "babylonjs/scene";
  56383. import { Vector3 } from "babylonjs/Maths/math";
  56384. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56385. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56386. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  56387. /**
  56388. * This class is made for on one-liner static method to help creating particle system set.
  56389. */
  56390. export class ParticleHelper {
  56391. /**
  56392. * Gets or sets base Assets URL
  56393. */
  56394. static BaseAssetsUrl: string;
  56395. /**
  56396. * Create a default particle system that you can tweak
  56397. * @param emitter defines the emitter to use
  56398. * @param capacity defines the system capacity (default is 500 particles)
  56399. * @param scene defines the hosting scene
  56400. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  56401. * @returns the new Particle system
  56402. */
  56403. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  56404. /**
  56405. * This is the main static method (one-liner) of this helper to create different particle systems
  56406. * @param type This string represents the type to the particle system to create
  56407. * @param scene The scene where the particle system should live
  56408. * @param gpu If the system will use gpu
  56409. * @returns the ParticleSystemSet created
  56410. */
  56411. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  56412. /**
  56413. * Static function used to export a particle system to a ParticleSystemSet variable.
  56414. * Please note that the emitter shape is not exported
  56415. * @param systems defines the particle systems to export
  56416. * @returns the created particle system set
  56417. */
  56418. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  56419. }
  56420. }
  56421. declare module "babylonjs/Particles/particleSystemComponent" {
  56422. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56423. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  56424. import "babylonjs/Shaders/particles.vertex";
  56425. module "babylonjs/Engines/engine" {
  56426. interface Engine {
  56427. /**
  56428. * Create an effect to use with particle systems.
  56429. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  56430. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  56431. * @param uniformsNames defines a list of attribute names
  56432. * @param samplers defines an array of string used to represent textures
  56433. * @param defines defines the string containing the defines to use to compile the shaders
  56434. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  56435. * @param onCompiled defines a function to call when the effect creation is successful
  56436. * @param onError defines a function to call when the effect creation has failed
  56437. * @returns the new Effect
  56438. */
  56439. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  56440. }
  56441. }
  56442. module "babylonjs/Meshes/mesh" {
  56443. interface Mesh {
  56444. /**
  56445. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  56446. * @returns an array of IParticleSystem
  56447. */
  56448. getEmittedParticleSystems(): IParticleSystem[];
  56449. /**
  56450. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  56451. * @returns an array of IParticleSystem
  56452. */
  56453. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  56454. }
  56455. }
  56456. /**
  56457. * @hidden
  56458. */
  56459. export var _IDoNeedToBeInTheBuild: number;
  56460. }
  56461. declare module "babylonjs/Particles/index" {
  56462. export * from "babylonjs/Particles/baseParticleSystem";
  56463. export * from "babylonjs/Particles/EmitterTypes/index";
  56464. export * from "babylonjs/Particles/gpuParticleSystem";
  56465. export * from "babylonjs/Particles/IParticleSystem";
  56466. export * from "babylonjs/Particles/particle";
  56467. export * from "babylonjs/Particles/particleHelper";
  56468. export * from "babylonjs/Particles/particleSystem";
  56469. export * from "babylonjs/Particles/particleSystemComponent";
  56470. export * from "babylonjs/Particles/particleSystemSet";
  56471. export * from "babylonjs/Particles/solidParticle";
  56472. export * from "babylonjs/Particles/solidParticleSystem";
  56473. export * from "babylonjs/Particles/subEmitter";
  56474. }
  56475. declare module "babylonjs/Physics/physicsEngineComponent" {
  56476. import { Nullable } from "babylonjs/types";
  56477. import { Observable, Observer } from "babylonjs/Misc/observable";
  56478. import { Vector3 } from "babylonjs/Maths/math";
  56479. import { Mesh } from "babylonjs/Meshes/mesh";
  56480. import { ISceneComponent } from "babylonjs/sceneComponent";
  56481. import { Scene } from "babylonjs/scene";
  56482. import { Node } from "babylonjs/node";
  56483. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  56484. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56485. module "babylonjs/scene" {
  56486. interface Scene {
  56487. /** @hidden (Backing field) */
  56488. _physicsEngine: Nullable<IPhysicsEngine>;
  56489. /**
  56490. * Gets the current physics engine
  56491. * @returns a IPhysicsEngine or null if none attached
  56492. */
  56493. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  56494. /**
  56495. * Enables physics to the current scene
  56496. * @param gravity defines the scene's gravity for the physics engine
  56497. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  56498. * @return a boolean indicating if the physics engine was initialized
  56499. */
  56500. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  56501. /**
  56502. * Disables and disposes the physics engine associated with the scene
  56503. */
  56504. disablePhysicsEngine(): void;
  56505. /**
  56506. * Gets a boolean indicating if there is an active physics engine
  56507. * @returns a boolean indicating if there is an active physics engine
  56508. */
  56509. isPhysicsEnabled(): boolean;
  56510. /**
  56511. * Deletes a physics compound impostor
  56512. * @param compound defines the compound to delete
  56513. */
  56514. deleteCompoundImpostor(compound: any): void;
  56515. /**
  56516. * An event triggered when physic simulation is about to be run
  56517. */
  56518. onBeforePhysicsObservable: Observable<Scene>;
  56519. /**
  56520. * An event triggered when physic simulation has been done
  56521. */
  56522. onAfterPhysicsObservable: Observable<Scene>;
  56523. }
  56524. }
  56525. module "babylonjs/Meshes/abstractMesh" {
  56526. interface AbstractMesh {
  56527. /** @hidden */
  56528. _physicsImpostor: Nullable<PhysicsImpostor>;
  56529. /**
  56530. * Gets or sets impostor used for physic simulation
  56531. * @see http://doc.babylonjs.com/features/physics_engine
  56532. */
  56533. physicsImpostor: Nullable<PhysicsImpostor>;
  56534. /**
  56535. * Gets the current physics impostor
  56536. * @see http://doc.babylonjs.com/features/physics_engine
  56537. * @returns a physics impostor or null
  56538. */
  56539. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  56540. /** Apply a physic impulse to the mesh
  56541. * @param force defines the force to apply
  56542. * @param contactPoint defines where to apply the force
  56543. * @returns the current mesh
  56544. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  56545. */
  56546. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  56547. /**
  56548. * Creates a physic joint between two meshes
  56549. * @param otherMesh defines the other mesh to use
  56550. * @param pivot1 defines the pivot to use on this mesh
  56551. * @param pivot2 defines the pivot to use on the other mesh
  56552. * @param options defines additional options (can be plugin dependent)
  56553. * @returns the current mesh
  56554. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  56555. */
  56556. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  56557. /** @hidden */
  56558. _disposePhysicsObserver: Nullable<Observer<Node>>;
  56559. }
  56560. }
  56561. /**
  56562. * Defines the physics engine scene component responsible to manage a physics engine
  56563. */
  56564. export class PhysicsEngineSceneComponent implements ISceneComponent {
  56565. /**
  56566. * The component name helpful to identify the component in the list of scene components.
  56567. */
  56568. readonly name: string;
  56569. /**
  56570. * The scene the component belongs to.
  56571. */
  56572. scene: Scene;
  56573. /**
  56574. * Creates a new instance of the component for the given scene
  56575. * @param scene Defines the scene to register the component in
  56576. */
  56577. constructor(scene: Scene);
  56578. /**
  56579. * Registers the component in a given scene
  56580. */
  56581. register(): void;
  56582. /**
  56583. * Rebuilds the elements related to this component in case of
  56584. * context lost for instance.
  56585. */
  56586. rebuild(): void;
  56587. /**
  56588. * Disposes the component and the associated ressources
  56589. */
  56590. dispose(): void;
  56591. }
  56592. }
  56593. declare module "babylonjs/Physics/physicsHelper" {
  56594. import { Nullable } from "babylonjs/types";
  56595. import { Vector3 } from "babylonjs/Maths/math";
  56596. import { Mesh } from "babylonjs/Meshes/mesh";
  56597. import { Scene } from "babylonjs/scene";
  56598. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56599. /**
  56600. * A helper for physics simulations
  56601. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56602. */
  56603. export class PhysicsHelper {
  56604. private _scene;
  56605. private _physicsEngine;
  56606. /**
  56607. * Initializes the Physics helper
  56608. * @param scene Babylon.js scene
  56609. */
  56610. constructor(scene: Scene);
  56611. /**
  56612. * Applies a radial explosion impulse
  56613. * @param origin the origin of the explosion
  56614. * @param radiusOrEventOptions the radius or the options of radial explosion
  56615. * @param strength the explosion strength
  56616. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56617. * @returns A physics radial explosion event, or null
  56618. */
  56619. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  56620. /**
  56621. * Applies a radial explosion force
  56622. * @param origin the origin of the explosion
  56623. * @param radiusOrEventOptions the radius or the options of radial explosion
  56624. * @param strength the explosion strength
  56625. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56626. * @returns A physics radial explosion event, or null
  56627. */
  56628. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  56629. /**
  56630. * Creates a gravitational field
  56631. * @param origin the origin of the explosion
  56632. * @param radiusOrEventOptions the radius or the options of radial explosion
  56633. * @param strength the explosion strength
  56634. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56635. * @returns A physics gravitational field event, or null
  56636. */
  56637. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  56638. /**
  56639. * Creates a physics updraft event
  56640. * @param origin the origin of the updraft
  56641. * @param radiusOrEventOptions the radius or the options of the updraft
  56642. * @param strength the strength of the updraft
  56643. * @param height the height of the updraft
  56644. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  56645. * @returns A physics updraft event, or null
  56646. */
  56647. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  56648. /**
  56649. * Creates a physics vortex event
  56650. * @param origin the of the vortex
  56651. * @param radiusOrEventOptions the radius or the options of the vortex
  56652. * @param strength the strength of the vortex
  56653. * @param height the height of the vortex
  56654. * @returns a Physics vortex event, or null
  56655. * A physics vortex event or null
  56656. */
  56657. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  56658. }
  56659. /**
  56660. * Represents a physics radial explosion event
  56661. */
  56662. class PhysicsRadialExplosionEvent {
  56663. private _scene;
  56664. private _options;
  56665. private _sphere;
  56666. private _dataFetched;
  56667. /**
  56668. * Initializes a radial explosioin event
  56669. * @param _scene BabylonJS scene
  56670. * @param _options The options for the vortex event
  56671. */
  56672. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  56673. /**
  56674. * Returns the data related to the radial explosion event (sphere).
  56675. * @returns The radial explosion event data
  56676. */
  56677. getData(): PhysicsRadialExplosionEventData;
  56678. /**
  56679. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  56680. * @param impostor A physics imposter
  56681. * @param origin the origin of the explosion
  56682. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  56683. */
  56684. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  56685. /**
  56686. * Triggers affecterd impostors callbacks
  56687. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  56688. */
  56689. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  56690. /**
  56691. * Disposes the sphere.
  56692. * @param force Specifies if the sphere should be disposed by force
  56693. */
  56694. dispose(force?: boolean): void;
  56695. /*** Helpers ***/
  56696. private _prepareSphere;
  56697. private _intersectsWithSphere;
  56698. }
  56699. /**
  56700. * Represents a gravitational field event
  56701. */
  56702. class PhysicsGravitationalFieldEvent {
  56703. private _physicsHelper;
  56704. private _scene;
  56705. private _origin;
  56706. private _options;
  56707. private _tickCallback;
  56708. private _sphere;
  56709. private _dataFetched;
  56710. /**
  56711. * Initializes the physics gravitational field event
  56712. * @param _physicsHelper A physics helper
  56713. * @param _scene BabylonJS scene
  56714. * @param _origin The origin position of the gravitational field event
  56715. * @param _options The options for the vortex event
  56716. */
  56717. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  56718. /**
  56719. * Returns the data related to the gravitational field event (sphere).
  56720. * @returns A gravitational field event
  56721. */
  56722. getData(): PhysicsGravitationalFieldEventData;
  56723. /**
  56724. * Enables the gravitational field.
  56725. */
  56726. enable(): void;
  56727. /**
  56728. * Disables the gravitational field.
  56729. */
  56730. disable(): void;
  56731. /**
  56732. * Disposes the sphere.
  56733. * @param force The force to dispose from the gravitational field event
  56734. */
  56735. dispose(force?: boolean): void;
  56736. private _tick;
  56737. }
  56738. /**
  56739. * Represents a physics updraft event
  56740. */
  56741. class PhysicsUpdraftEvent {
  56742. private _scene;
  56743. private _origin;
  56744. private _options;
  56745. private _physicsEngine;
  56746. private _originTop;
  56747. private _originDirection;
  56748. private _tickCallback;
  56749. private _cylinder;
  56750. private _cylinderPosition;
  56751. private _dataFetched;
  56752. /**
  56753. * Initializes the physics updraft event
  56754. * @param _scene BabylonJS scene
  56755. * @param _origin The origin position of the updraft
  56756. * @param _options The options for the updraft event
  56757. */
  56758. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  56759. /**
  56760. * Returns the data related to the updraft event (cylinder).
  56761. * @returns A physics updraft event
  56762. */
  56763. getData(): PhysicsUpdraftEventData;
  56764. /**
  56765. * Enables the updraft.
  56766. */
  56767. enable(): void;
  56768. /**
  56769. * Disables the updraft.
  56770. */
  56771. disable(): void;
  56772. /**
  56773. * Disposes the cylinder.
  56774. * @param force Specifies if the updraft should be disposed by force
  56775. */
  56776. dispose(force?: boolean): void;
  56777. private getImpostorHitData;
  56778. private _tick;
  56779. /*** Helpers ***/
  56780. private _prepareCylinder;
  56781. private _intersectsWithCylinder;
  56782. }
  56783. /**
  56784. * Represents a physics vortex event
  56785. */
  56786. class PhysicsVortexEvent {
  56787. private _scene;
  56788. private _origin;
  56789. private _options;
  56790. private _physicsEngine;
  56791. private _originTop;
  56792. private _tickCallback;
  56793. private _cylinder;
  56794. private _cylinderPosition;
  56795. private _dataFetched;
  56796. /**
  56797. * Initializes the physics vortex event
  56798. * @param _scene The BabylonJS scene
  56799. * @param _origin The origin position of the vortex
  56800. * @param _options The options for the vortex event
  56801. */
  56802. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  56803. /**
  56804. * Returns the data related to the vortex event (cylinder).
  56805. * @returns The physics vortex event data
  56806. */
  56807. getData(): PhysicsVortexEventData;
  56808. /**
  56809. * Enables the vortex.
  56810. */
  56811. enable(): void;
  56812. /**
  56813. * Disables the cortex.
  56814. */
  56815. disable(): void;
  56816. /**
  56817. * Disposes the sphere.
  56818. * @param force
  56819. */
  56820. dispose(force?: boolean): void;
  56821. private getImpostorHitData;
  56822. private _tick;
  56823. /*** Helpers ***/
  56824. private _prepareCylinder;
  56825. private _intersectsWithCylinder;
  56826. }
  56827. /**
  56828. * Options fot the radial explosion event
  56829. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56830. */
  56831. export class PhysicsRadialExplosionEventOptions {
  56832. /**
  56833. * The radius of the sphere for the radial explosion.
  56834. */
  56835. radius: number;
  56836. /**
  56837. * The strenth of the explosion.
  56838. */
  56839. strength: number;
  56840. /**
  56841. * The strenght of the force in correspondence to the distance of the affected object
  56842. */
  56843. falloff: PhysicsRadialImpulseFalloff;
  56844. /**
  56845. * Sphere options for the radial explosion.
  56846. */
  56847. sphere: {
  56848. segments: number;
  56849. diameter: number;
  56850. };
  56851. /**
  56852. * Sphere options for the radial explosion.
  56853. */
  56854. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  56855. }
  56856. /**
  56857. * Options fot the updraft event
  56858. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56859. */
  56860. export class PhysicsUpdraftEventOptions {
  56861. /**
  56862. * The radius of the cylinder for the vortex
  56863. */
  56864. radius: number;
  56865. /**
  56866. * The strenth of the updraft.
  56867. */
  56868. strength: number;
  56869. /**
  56870. * The height of the cylinder for the updraft.
  56871. */
  56872. height: number;
  56873. /**
  56874. * The mode for the the updraft.
  56875. */
  56876. updraftMode: PhysicsUpdraftMode;
  56877. }
  56878. /**
  56879. * Options fot the vortex event
  56880. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56881. */
  56882. export class PhysicsVortexEventOptions {
  56883. /**
  56884. * The radius of the cylinder for the vortex
  56885. */
  56886. radius: number;
  56887. /**
  56888. * The strenth of the vortex.
  56889. */
  56890. strength: number;
  56891. /**
  56892. * The height of the cylinder for the vortex.
  56893. */
  56894. height: number;
  56895. /**
  56896. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  56897. */
  56898. centripetalForceThreshold: number;
  56899. /**
  56900. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  56901. */
  56902. centripetalForceMultiplier: number;
  56903. /**
  56904. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  56905. */
  56906. centrifugalForceMultiplier: number;
  56907. /**
  56908. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  56909. */
  56910. updraftForceMultiplier: number;
  56911. }
  56912. /**
  56913. * The strenght of the force in correspondence to the distance of the affected object
  56914. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56915. */
  56916. export enum PhysicsRadialImpulseFalloff {
  56917. /** Defines that impulse is constant in strength across it's whole radius */
  56918. Constant = 0,
  56919. /** Defines that impulse gets weaker if it's further from the origin */
  56920. Linear = 1
  56921. }
  56922. /**
  56923. * The strength of the force in correspondence to the distance of the affected object
  56924. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56925. */
  56926. export enum PhysicsUpdraftMode {
  56927. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  56928. Center = 0,
  56929. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  56930. Perpendicular = 1
  56931. }
  56932. /**
  56933. * Interface for a physics hit data
  56934. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56935. */
  56936. export interface PhysicsHitData {
  56937. /**
  56938. * The force applied at the contact point
  56939. */
  56940. force: Vector3;
  56941. /**
  56942. * The contact point
  56943. */
  56944. contactPoint: Vector3;
  56945. /**
  56946. * The distance from the origin to the contact point
  56947. */
  56948. distanceFromOrigin: number;
  56949. }
  56950. /**
  56951. * Interface for radial explosion event data
  56952. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56953. */
  56954. export interface PhysicsRadialExplosionEventData {
  56955. /**
  56956. * A sphere used for the radial explosion event
  56957. */
  56958. sphere: Mesh;
  56959. }
  56960. /**
  56961. * Interface for gravitational field event data
  56962. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56963. */
  56964. export interface PhysicsGravitationalFieldEventData {
  56965. /**
  56966. * A sphere mesh used for the gravitational field event
  56967. */
  56968. sphere: Mesh;
  56969. }
  56970. /**
  56971. * Interface for updraft event data
  56972. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56973. */
  56974. export interface PhysicsUpdraftEventData {
  56975. /**
  56976. * A cylinder used for the updraft event
  56977. */
  56978. cylinder: Mesh;
  56979. }
  56980. /**
  56981. * Interface for vortex event data
  56982. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56983. */
  56984. export interface PhysicsVortexEventData {
  56985. /**
  56986. * A cylinder used for the vortex event
  56987. */
  56988. cylinder: Mesh;
  56989. }
  56990. /**
  56991. * Interface for an affected physics impostor
  56992. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56993. */
  56994. export interface PhysicsAffectedImpostorWithData {
  56995. /**
  56996. * The impostor affected by the effect
  56997. */
  56998. impostor: PhysicsImpostor;
  56999. /**
  57000. * The data about the hit/horce from the explosion
  57001. */
  57002. hitData: PhysicsHitData;
  57003. }
  57004. }
  57005. declare module "babylonjs/Physics/Plugins/index" {
  57006. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  57007. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  57008. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  57009. }
  57010. declare module "babylonjs/Physics/index" {
  57011. export * from "babylonjs/Physics/IPhysicsEngine";
  57012. export * from "babylonjs/Physics/physicsEngine";
  57013. export * from "babylonjs/Physics/physicsEngineComponent";
  57014. export * from "babylonjs/Physics/physicsHelper";
  57015. export * from "babylonjs/Physics/physicsImpostor";
  57016. export * from "babylonjs/Physics/physicsJoint";
  57017. export * from "babylonjs/Physics/Plugins/index";
  57018. }
  57019. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  57020. /** @hidden */
  57021. export var blackAndWhitePixelShader: {
  57022. name: string;
  57023. shader: string;
  57024. };
  57025. }
  57026. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  57027. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57028. import { Camera } from "babylonjs/Cameras/camera";
  57029. import { Engine } from "babylonjs/Engines/engine";
  57030. import "babylonjs/Shaders/blackAndWhite.fragment";
  57031. /**
  57032. * Post process used to render in black and white
  57033. */
  57034. export class BlackAndWhitePostProcess extends PostProcess {
  57035. /**
  57036. * Linear about to convert he result to black and white (default: 1)
  57037. */
  57038. degree: number;
  57039. /**
  57040. * Creates a black and white post process
  57041. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  57042. * @param name The name of the effect.
  57043. * @param options The required width/height ratio to downsize to before computing the render pass.
  57044. * @param camera The camera to apply the render pass to.
  57045. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57046. * @param engine The engine which the post process will be applied. (default: current engine)
  57047. * @param reusable If the post process can be reused on the same frame. (default: false)
  57048. */
  57049. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57050. }
  57051. }
  57052. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  57053. import { Nullable } from "babylonjs/types";
  57054. import { Camera } from "babylonjs/Cameras/camera";
  57055. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57056. import { Engine } from "babylonjs/Engines/engine";
  57057. /**
  57058. * This represents a set of one or more post processes in Babylon.
  57059. * A post process can be used to apply a shader to a texture after it is rendered.
  57060. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57061. */
  57062. export class PostProcessRenderEffect {
  57063. private _postProcesses;
  57064. private _getPostProcesses;
  57065. private _singleInstance;
  57066. private _cameras;
  57067. private _indicesForCamera;
  57068. /**
  57069. * Name of the effect
  57070. * @hidden
  57071. */
  57072. _name: string;
  57073. /**
  57074. * Instantiates a post process render effect.
  57075. * A post process can be used to apply a shader to a texture after it is rendered.
  57076. * @param engine The engine the effect is tied to
  57077. * @param name The name of the effect
  57078. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  57079. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  57080. */
  57081. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  57082. /**
  57083. * Checks if all the post processes in the effect are supported.
  57084. */
  57085. readonly isSupported: boolean;
  57086. /**
  57087. * Updates the current state of the effect
  57088. * @hidden
  57089. */
  57090. _update(): void;
  57091. /**
  57092. * Attaches the effect on cameras
  57093. * @param cameras The camera to attach to.
  57094. * @hidden
  57095. */
  57096. _attachCameras(cameras: Camera): void;
  57097. /**
  57098. * Attaches the effect on cameras
  57099. * @param cameras The camera to attach to.
  57100. * @hidden
  57101. */
  57102. _attachCameras(cameras: Camera[]): void;
  57103. /**
  57104. * Detaches the effect on cameras
  57105. * @param cameras The camera to detatch from.
  57106. * @hidden
  57107. */
  57108. _detachCameras(cameras: Camera): void;
  57109. /**
  57110. * Detatches the effect on cameras
  57111. * @param cameras The camera to detatch from.
  57112. * @hidden
  57113. */
  57114. _detachCameras(cameras: Camera[]): void;
  57115. /**
  57116. * Enables the effect on given cameras
  57117. * @param cameras The camera to enable.
  57118. * @hidden
  57119. */
  57120. _enable(cameras: Camera): void;
  57121. /**
  57122. * Enables the effect on given cameras
  57123. * @param cameras The camera to enable.
  57124. * @hidden
  57125. */
  57126. _enable(cameras: Nullable<Camera[]>): void;
  57127. /**
  57128. * Disables the effect on the given cameras
  57129. * @param cameras The camera to disable.
  57130. * @hidden
  57131. */
  57132. _disable(cameras: Camera): void;
  57133. /**
  57134. * Disables the effect on the given cameras
  57135. * @param cameras The camera to disable.
  57136. * @hidden
  57137. */
  57138. _disable(cameras: Nullable<Camera[]>): void;
  57139. /**
  57140. * Gets a list of the post processes contained in the effect.
  57141. * @param camera The camera to get the post processes on.
  57142. * @returns The list of the post processes in the effect.
  57143. */
  57144. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  57145. }
  57146. }
  57147. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  57148. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57149. /** @hidden */
  57150. export var extractHighlightsPixelShader: {
  57151. name: string;
  57152. shader: string;
  57153. };
  57154. }
  57155. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  57156. import { Nullable } from "babylonjs/types";
  57157. import { Camera } from "babylonjs/Cameras/camera";
  57158. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57159. import { Engine } from "babylonjs/Engines/engine";
  57160. import "babylonjs/Shaders/extractHighlights.fragment";
  57161. /**
  57162. * 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.
  57163. */
  57164. export class ExtractHighlightsPostProcess extends PostProcess {
  57165. /**
  57166. * The luminance threshold, pixels below this value will be set to black.
  57167. */
  57168. threshold: number;
  57169. /** @hidden */
  57170. _exposure: number;
  57171. /**
  57172. * Post process which has the input texture to be used when performing highlight extraction
  57173. * @hidden
  57174. */
  57175. _inputPostProcess: Nullable<PostProcess>;
  57176. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57177. }
  57178. }
  57179. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  57180. /** @hidden */
  57181. export var bloomMergePixelShader: {
  57182. name: string;
  57183. shader: string;
  57184. };
  57185. }
  57186. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  57187. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57188. import { Nullable } from "babylonjs/types";
  57189. import { Engine } from "babylonjs/Engines/engine";
  57190. import { Camera } from "babylonjs/Cameras/camera";
  57191. import "babylonjs/Shaders/bloomMerge.fragment";
  57192. /**
  57193. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57194. */
  57195. export class BloomMergePostProcess extends PostProcess {
  57196. /** Weight of the bloom to be added to the original input. */
  57197. weight: number;
  57198. /**
  57199. * Creates a new instance of @see BloomMergePostProcess
  57200. * @param name The name of the effect.
  57201. * @param originalFromInput Post process which's input will be used for the merge.
  57202. * @param blurred Blurred highlights post process which's output will be used.
  57203. * @param weight Weight of the bloom to be added to the original input.
  57204. * @param options The required width/height ratio to downsize to before computing the render pass.
  57205. * @param camera The camera to apply the render pass to.
  57206. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57207. * @param engine The engine which the post process will be applied. (default: current engine)
  57208. * @param reusable If the post process can be reused on the same frame. (default: false)
  57209. * @param textureType Type of textures used when performing the post process. (default: 0)
  57210. * @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)
  57211. */
  57212. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  57213. /** Weight of the bloom to be added to the original input. */
  57214. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57215. }
  57216. }
  57217. declare module "babylonjs/PostProcesses/bloomEffect" {
  57218. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  57219. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57220. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  57221. import { Camera } from "babylonjs/Cameras/camera";
  57222. import { Scene } from "babylonjs/scene";
  57223. /**
  57224. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  57225. */
  57226. export class BloomEffect extends PostProcessRenderEffect {
  57227. private bloomScale;
  57228. /**
  57229. * @hidden Internal
  57230. */
  57231. _effects: Array<PostProcess>;
  57232. /**
  57233. * @hidden Internal
  57234. */
  57235. _downscale: ExtractHighlightsPostProcess;
  57236. private _blurX;
  57237. private _blurY;
  57238. private _merge;
  57239. /**
  57240. * The luminance threshold to find bright areas of the image to bloom.
  57241. */
  57242. threshold: number;
  57243. /**
  57244. * The strength of the bloom.
  57245. */
  57246. weight: number;
  57247. /**
  57248. * Specifies the size of the bloom blur kernel, relative to the final output size
  57249. */
  57250. kernel: number;
  57251. /**
  57252. * Creates a new instance of @see BloomEffect
  57253. * @param scene The scene the effect belongs to.
  57254. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  57255. * @param bloomKernel The size of the kernel to be used when applying the blur.
  57256. * @param bloomWeight The the strength of bloom.
  57257. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57258. * @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)
  57259. */
  57260. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  57261. /**
  57262. * Disposes each of the internal effects for a given camera.
  57263. * @param camera The camera to dispose the effect on.
  57264. */
  57265. disposeEffects(camera: Camera): void;
  57266. /**
  57267. * @hidden Internal
  57268. */
  57269. _updateEffects(): void;
  57270. /**
  57271. * Internal
  57272. * @returns if all the contained post processes are ready.
  57273. * @hidden
  57274. */
  57275. _isReady(): boolean;
  57276. }
  57277. }
  57278. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  57279. /** @hidden */
  57280. export var chromaticAberrationPixelShader: {
  57281. name: string;
  57282. shader: string;
  57283. };
  57284. }
  57285. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  57286. import { Vector2 } from "babylonjs/Maths/math";
  57287. import { Nullable } from "babylonjs/types";
  57288. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57289. import { Camera } from "babylonjs/Cameras/camera";
  57290. import { Engine } from "babylonjs/Engines/engine";
  57291. import "babylonjs/Shaders/chromaticAberration.fragment";
  57292. /**
  57293. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  57294. */
  57295. export class ChromaticAberrationPostProcess extends PostProcess {
  57296. /**
  57297. * The amount of seperation of rgb channels (default: 30)
  57298. */
  57299. aberrationAmount: number;
  57300. /**
  57301. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  57302. */
  57303. radialIntensity: number;
  57304. /**
  57305. * 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))
  57306. */
  57307. direction: Vector2;
  57308. /**
  57309. * 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))
  57310. */
  57311. centerPosition: Vector2;
  57312. /**
  57313. * Creates a new instance ChromaticAberrationPostProcess
  57314. * @param name The name of the effect.
  57315. * @param screenWidth The width of the screen to apply the effect on.
  57316. * @param screenHeight The height of the screen to apply the effect on.
  57317. * @param options The required width/height ratio to downsize to before computing the render pass.
  57318. * @param camera The camera to apply the render pass to.
  57319. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57320. * @param engine The engine which the post process will be applied. (default: current engine)
  57321. * @param reusable If the post process can be reused on the same frame. (default: false)
  57322. * @param textureType Type of textures used when performing the post process. (default: 0)
  57323. * @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)
  57324. */
  57325. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57326. }
  57327. }
  57328. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  57329. /** @hidden */
  57330. export var circleOfConfusionPixelShader: {
  57331. name: string;
  57332. shader: string;
  57333. };
  57334. }
  57335. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  57336. import { Nullable } from "babylonjs/types";
  57337. import { Engine } from "babylonjs/Engines/engine";
  57338. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57339. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57340. import { Camera } from "babylonjs/Cameras/camera";
  57341. import "babylonjs/Shaders/circleOfConfusion.fragment";
  57342. /**
  57343. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  57344. */
  57345. export class CircleOfConfusionPostProcess extends PostProcess {
  57346. /**
  57347. * 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.
  57348. */
  57349. lensSize: number;
  57350. /**
  57351. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57352. */
  57353. fStop: number;
  57354. /**
  57355. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57356. */
  57357. focusDistance: number;
  57358. /**
  57359. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  57360. */
  57361. focalLength: number;
  57362. private _depthTexture;
  57363. /**
  57364. * Creates a new instance CircleOfConfusionPostProcess
  57365. * @param name The name of the effect.
  57366. * @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.
  57367. * @param options The required width/height ratio to downsize to before computing the render pass.
  57368. * @param camera The camera to apply the render pass to.
  57369. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57370. * @param engine The engine which the post process will be applied. (default: current engine)
  57371. * @param reusable If the post process can be reused on the same frame. (default: false)
  57372. * @param textureType Type of textures used when performing the post process. (default: 0)
  57373. * @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)
  57374. */
  57375. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57376. /**
  57377. * 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.
  57378. */
  57379. depthTexture: RenderTargetTexture;
  57380. }
  57381. }
  57382. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  57383. /** @hidden */
  57384. export var colorCorrectionPixelShader: {
  57385. name: string;
  57386. shader: string;
  57387. };
  57388. }
  57389. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  57390. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57391. import { Engine } from "babylonjs/Engines/engine";
  57392. import { Camera } from "babylonjs/Cameras/camera";
  57393. import "babylonjs/Shaders/colorCorrection.fragment";
  57394. /**
  57395. *
  57396. * This post-process allows the modification of rendered colors by using
  57397. * a 'look-up table' (LUT). This effect is also called Color Grading.
  57398. *
  57399. * The object needs to be provided an url to a texture containing the color
  57400. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  57401. * Use an image editing software to tweak the LUT to match your needs.
  57402. *
  57403. * For an example of a color LUT, see here:
  57404. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  57405. * For explanations on color grading, see here:
  57406. * @see http://udn.epicgames.com/Three/ColorGrading.html
  57407. *
  57408. */
  57409. export class ColorCorrectionPostProcess extends PostProcess {
  57410. private _colorTableTexture;
  57411. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57412. }
  57413. }
  57414. declare module "babylonjs/Shaders/convolution.fragment" {
  57415. /** @hidden */
  57416. export var convolutionPixelShader: {
  57417. name: string;
  57418. shader: string;
  57419. };
  57420. }
  57421. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  57422. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57423. import { Nullable } from "babylonjs/types";
  57424. import { Camera } from "babylonjs/Cameras/camera";
  57425. import { Engine } from "babylonjs/Engines/engine";
  57426. import "babylonjs/Shaders/convolution.fragment";
  57427. /**
  57428. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  57429. * input texture to perform effects such as edge detection or sharpening
  57430. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  57431. */
  57432. export class ConvolutionPostProcess extends PostProcess {
  57433. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  57434. kernel: number[];
  57435. /**
  57436. * Creates a new instance ConvolutionPostProcess
  57437. * @param name The name of the effect.
  57438. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  57439. * @param options The required width/height ratio to downsize to before computing the render pass.
  57440. * @param camera The camera to apply the render pass to.
  57441. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57442. * @param engine The engine which the post process will be applied. (default: current engine)
  57443. * @param reusable If the post process can be reused on the same frame. (default: false)
  57444. * @param textureType Type of textures used when performing the post process. (default: 0)
  57445. */
  57446. constructor(name: string,
  57447. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  57448. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57449. /**
  57450. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57451. */
  57452. static EdgeDetect0Kernel: number[];
  57453. /**
  57454. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57455. */
  57456. static EdgeDetect1Kernel: number[];
  57457. /**
  57458. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57459. */
  57460. static EdgeDetect2Kernel: number[];
  57461. /**
  57462. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57463. */
  57464. static SharpenKernel: number[];
  57465. /**
  57466. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57467. */
  57468. static EmbossKernel: number[];
  57469. /**
  57470. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57471. */
  57472. static GaussianKernel: number[];
  57473. }
  57474. }
  57475. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  57476. import { Nullable } from "babylonjs/types";
  57477. import { Vector2 } from "babylonjs/Maths/math";
  57478. import { Camera } from "babylonjs/Cameras/camera";
  57479. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57480. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  57481. import { Engine } from "babylonjs/Engines/engine";
  57482. import { Scene } from "babylonjs/scene";
  57483. /**
  57484. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  57485. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  57486. * based on samples that have a large difference in distance than the center pixel.
  57487. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  57488. */
  57489. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  57490. direction: Vector2;
  57491. /**
  57492. * Creates a new instance CircleOfConfusionPostProcess
  57493. * @param name The name of the effect.
  57494. * @param scene The scene the effect belongs to.
  57495. * @param direction The direction the blur should be applied.
  57496. * @param kernel The size of the kernel used to blur.
  57497. * @param options The required width/height ratio to downsize to before computing the render pass.
  57498. * @param camera The camera to apply the render pass to.
  57499. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  57500. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  57501. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57502. * @param engine The engine which the post process will be applied. (default: current engine)
  57503. * @param reusable If the post process can be reused on the same frame. (default: false)
  57504. * @param textureType Type of textures used when performing the post process. (default: 0)
  57505. * @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)
  57506. */
  57507. 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);
  57508. }
  57509. }
  57510. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  57511. /** @hidden */
  57512. export var depthOfFieldMergePixelShader: {
  57513. name: string;
  57514. shader: string;
  57515. };
  57516. }
  57517. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  57518. import { Nullable } from "babylonjs/types";
  57519. import { Camera } from "babylonjs/Cameras/camera";
  57520. import { Effect } from "babylonjs/Materials/effect";
  57521. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57522. import { Engine } from "babylonjs/Engines/engine";
  57523. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  57524. /**
  57525. * Options to be set when merging outputs from the default pipeline.
  57526. */
  57527. export class DepthOfFieldMergePostProcessOptions {
  57528. /**
  57529. * The original image to merge on top of
  57530. */
  57531. originalFromInput: PostProcess;
  57532. /**
  57533. * Parameters to perform the merge of the depth of field effect
  57534. */
  57535. depthOfField?: {
  57536. circleOfConfusion: PostProcess;
  57537. blurSteps: Array<PostProcess>;
  57538. };
  57539. /**
  57540. * Parameters to perform the merge of bloom effect
  57541. */
  57542. bloom?: {
  57543. blurred: PostProcess;
  57544. weight: number;
  57545. };
  57546. }
  57547. /**
  57548. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57549. */
  57550. export class DepthOfFieldMergePostProcess extends PostProcess {
  57551. private blurSteps;
  57552. /**
  57553. * Creates a new instance of DepthOfFieldMergePostProcess
  57554. * @param name The name of the effect.
  57555. * @param originalFromInput Post process which's input will be used for the merge.
  57556. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  57557. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  57558. * @param options The required width/height ratio to downsize to before computing the render pass.
  57559. * @param camera The camera to apply the render pass to.
  57560. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57561. * @param engine The engine which the post process will be applied. (default: current engine)
  57562. * @param reusable If the post process can be reused on the same frame. (default: false)
  57563. * @param textureType Type of textures used when performing the post process. (default: 0)
  57564. * @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)
  57565. */
  57566. 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);
  57567. /**
  57568. * Updates the effect with the current post process compile time values and recompiles the shader.
  57569. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  57570. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  57571. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  57572. * @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
  57573. * @param onCompiled Called when the shader has been compiled.
  57574. * @param onError Called if there is an error when compiling a shader.
  57575. */
  57576. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  57577. }
  57578. }
  57579. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  57580. import { Nullable } from "babylonjs/types";
  57581. import { Camera } from "babylonjs/Cameras/camera";
  57582. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57583. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57584. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  57585. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  57586. import { Scene } from "babylonjs/scene";
  57587. /**
  57588. * Specifies the level of max blur that should be applied when using the depth of field effect
  57589. */
  57590. export enum DepthOfFieldEffectBlurLevel {
  57591. /**
  57592. * Subtle blur
  57593. */
  57594. Low = 0,
  57595. /**
  57596. * Medium blur
  57597. */
  57598. Medium = 1,
  57599. /**
  57600. * Large blur
  57601. */
  57602. High = 2
  57603. }
  57604. /**
  57605. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  57606. */
  57607. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  57608. private _circleOfConfusion;
  57609. /**
  57610. * @hidden Internal, blurs from high to low
  57611. */
  57612. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  57613. private _depthOfFieldBlurY;
  57614. private _dofMerge;
  57615. /**
  57616. * @hidden Internal post processes in depth of field effect
  57617. */
  57618. _effects: Array<PostProcess>;
  57619. /**
  57620. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  57621. */
  57622. focalLength: number;
  57623. /**
  57624. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57625. */
  57626. fStop: number;
  57627. /**
  57628. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57629. */
  57630. focusDistance: number;
  57631. /**
  57632. * 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.
  57633. */
  57634. lensSize: number;
  57635. /**
  57636. * Creates a new instance DepthOfFieldEffect
  57637. * @param scene The scene the effect belongs to.
  57638. * @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.
  57639. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57640. * @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)
  57641. */
  57642. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  57643. /**
  57644. * Get the current class name of the current effet
  57645. * @returns "DepthOfFieldEffect"
  57646. */
  57647. getClassName(): string;
  57648. /**
  57649. * 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.
  57650. */
  57651. depthTexture: RenderTargetTexture;
  57652. /**
  57653. * Disposes each of the internal effects for a given camera.
  57654. * @param camera The camera to dispose the effect on.
  57655. */
  57656. disposeEffects(camera: Camera): void;
  57657. /**
  57658. * @hidden Internal
  57659. */
  57660. _updateEffects(): void;
  57661. /**
  57662. * Internal
  57663. * @returns if all the contained post processes are ready.
  57664. * @hidden
  57665. */
  57666. _isReady(): boolean;
  57667. }
  57668. }
  57669. declare module "babylonjs/Shaders/displayPass.fragment" {
  57670. /** @hidden */
  57671. export var displayPassPixelShader: {
  57672. name: string;
  57673. shader: string;
  57674. };
  57675. }
  57676. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  57677. import { Nullable } from "babylonjs/types";
  57678. import { Camera } from "babylonjs/Cameras/camera";
  57679. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57680. import { Engine } from "babylonjs/Engines/engine";
  57681. import "babylonjs/Shaders/displayPass.fragment";
  57682. /**
  57683. * DisplayPassPostProcess which produces an output the same as it's input
  57684. */
  57685. export class DisplayPassPostProcess extends PostProcess {
  57686. /**
  57687. * Creates the DisplayPassPostProcess
  57688. * @param name The name of the effect.
  57689. * @param options The required width/height ratio to downsize to before computing the render pass.
  57690. * @param camera The camera to apply the render pass to.
  57691. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57692. * @param engine The engine which the post process will be applied. (default: current engine)
  57693. * @param reusable If the post process can be reused on the same frame. (default: false)
  57694. */
  57695. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57696. }
  57697. }
  57698. declare module "babylonjs/Shaders/filter.fragment" {
  57699. /** @hidden */
  57700. export var filterPixelShader: {
  57701. name: string;
  57702. shader: string;
  57703. };
  57704. }
  57705. declare module "babylonjs/PostProcesses/filterPostProcess" {
  57706. import { Nullable } from "babylonjs/types";
  57707. import { Matrix } from "babylonjs/Maths/math";
  57708. import { Camera } from "babylonjs/Cameras/camera";
  57709. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57710. import { Engine } from "babylonjs/Engines/engine";
  57711. import "babylonjs/Shaders/filter.fragment";
  57712. /**
  57713. * Applies a kernel filter to the image
  57714. */
  57715. export class FilterPostProcess extends PostProcess {
  57716. /** The matrix to be applied to the image */
  57717. kernelMatrix: Matrix;
  57718. /**
  57719. *
  57720. * @param name The name of the effect.
  57721. * @param kernelMatrix The matrix to be applied to the image
  57722. * @param options The required width/height ratio to downsize to before computing the render pass.
  57723. * @param camera The camera to apply the render pass to.
  57724. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57725. * @param engine The engine which the post process will be applied. (default: current engine)
  57726. * @param reusable If the post process can be reused on the same frame. (default: false)
  57727. */
  57728. constructor(name: string,
  57729. /** The matrix to be applied to the image */
  57730. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57731. }
  57732. }
  57733. declare module "babylonjs/Shaders/fxaa.fragment" {
  57734. /** @hidden */
  57735. export var fxaaPixelShader: {
  57736. name: string;
  57737. shader: string;
  57738. };
  57739. }
  57740. declare module "babylonjs/Shaders/fxaa.vertex" {
  57741. /** @hidden */
  57742. export var fxaaVertexShader: {
  57743. name: string;
  57744. shader: string;
  57745. };
  57746. }
  57747. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  57748. import { Nullable } from "babylonjs/types";
  57749. import { Camera } from "babylonjs/Cameras/camera";
  57750. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57751. import { Engine } from "babylonjs/Engines/engine";
  57752. import "babylonjs/Shaders/fxaa.fragment";
  57753. import "babylonjs/Shaders/fxaa.vertex";
  57754. /**
  57755. * Fxaa post process
  57756. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  57757. */
  57758. export class FxaaPostProcess extends PostProcess {
  57759. /** @hidden */
  57760. texelWidth: number;
  57761. /** @hidden */
  57762. texelHeight: number;
  57763. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57764. private _getDefines;
  57765. }
  57766. }
  57767. declare module "babylonjs/Shaders/grain.fragment" {
  57768. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57769. /** @hidden */
  57770. export var grainPixelShader: {
  57771. name: string;
  57772. shader: string;
  57773. };
  57774. }
  57775. declare module "babylonjs/PostProcesses/grainPostProcess" {
  57776. import { Nullable } from "babylonjs/types";
  57777. import { Camera } from "babylonjs/Cameras/camera";
  57778. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57779. import { Engine } from "babylonjs/Engines/engine";
  57780. import "babylonjs/Shaders/grain.fragment";
  57781. /**
  57782. * The GrainPostProcess adds noise to the image at mid luminance levels
  57783. */
  57784. export class GrainPostProcess extends PostProcess {
  57785. /**
  57786. * The intensity of the grain added (default: 30)
  57787. */
  57788. intensity: number;
  57789. /**
  57790. * If the grain should be randomized on every frame
  57791. */
  57792. animated: boolean;
  57793. /**
  57794. * Creates a new instance of @see GrainPostProcess
  57795. * @param name The name of the effect.
  57796. * @param options The required width/height ratio to downsize to before computing the render pass.
  57797. * @param camera The camera to apply the render pass to.
  57798. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57799. * @param engine The engine which the post process will be applied. (default: current engine)
  57800. * @param reusable If the post process can be reused on the same frame. (default: false)
  57801. * @param textureType Type of textures used when performing the post process. (default: 0)
  57802. * @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)
  57803. */
  57804. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57805. }
  57806. }
  57807. declare module "babylonjs/Shaders/highlights.fragment" {
  57808. /** @hidden */
  57809. export var highlightsPixelShader: {
  57810. name: string;
  57811. shader: string;
  57812. };
  57813. }
  57814. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  57815. import { Nullable } from "babylonjs/types";
  57816. import { Camera } from "babylonjs/Cameras/camera";
  57817. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57818. import { Engine } from "babylonjs/Engines/engine";
  57819. import "babylonjs/Shaders/highlights.fragment";
  57820. /**
  57821. * Extracts highlights from the image
  57822. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  57823. */
  57824. export class HighlightsPostProcess extends PostProcess {
  57825. /**
  57826. * Extracts highlights from the image
  57827. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  57828. * @param name The name of the effect.
  57829. * @param options The required width/height ratio to downsize to before computing the render pass.
  57830. * @param camera The camera to apply the render pass to.
  57831. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57832. * @param engine The engine which the post process will be applied. (default: current engine)
  57833. * @param reusable If the post process can be reused on the same frame. (default: false)
  57834. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  57835. */
  57836. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57837. }
  57838. }
  57839. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  57840. /** @hidden */
  57841. export var mrtFragmentDeclaration: {
  57842. name: string;
  57843. shader: string;
  57844. };
  57845. }
  57846. declare module "babylonjs/Shaders/geometry.fragment" {
  57847. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  57848. /** @hidden */
  57849. export var geometryPixelShader: {
  57850. name: string;
  57851. shader: string;
  57852. };
  57853. }
  57854. declare module "babylonjs/Shaders/geometry.vertex" {
  57855. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57856. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57857. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57858. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57859. /** @hidden */
  57860. export var geometryVertexShader: {
  57861. name: string;
  57862. shader: string;
  57863. };
  57864. }
  57865. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  57866. import { Matrix } from "babylonjs/Maths/math";
  57867. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57868. import { Mesh } from "babylonjs/Meshes/mesh";
  57869. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  57870. import { Effect } from "babylonjs/Materials/effect";
  57871. import { Scene } from "babylonjs/scene";
  57872. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57873. import "babylonjs/Shaders/geometry.fragment";
  57874. import "babylonjs/Shaders/geometry.vertex";
  57875. /** @hidden */
  57876. interface ISavedTransformationMatrix {
  57877. world: Matrix;
  57878. viewProjection: Matrix;
  57879. }
  57880. /**
  57881. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  57882. */
  57883. export class GeometryBufferRenderer {
  57884. /**
  57885. * Constant used to retrieve the position texture index in the G-Buffer textures array
  57886. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  57887. */
  57888. static readonly POSITION_TEXTURE_TYPE: number;
  57889. /**
  57890. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  57891. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  57892. */
  57893. static readonly VELOCITY_TEXTURE_TYPE: number;
  57894. /**
  57895. * Dictionary used to store the previous transformation matrices of each rendered mesh
  57896. * in order to compute objects velocities when enableVelocity is set to "true"
  57897. * @hidden
  57898. */
  57899. _previousTransformationMatrices: {
  57900. [index: number]: ISavedTransformationMatrix;
  57901. };
  57902. /**
  57903. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  57904. * in order to compute objects velocities when enableVelocity is set to "true"
  57905. * @hidden
  57906. */
  57907. _previousBonesTransformationMatrices: {
  57908. [index: number]: Float32Array;
  57909. };
  57910. /**
  57911. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  57912. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  57913. */
  57914. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  57915. private _scene;
  57916. private _multiRenderTarget;
  57917. private _ratio;
  57918. private _enablePosition;
  57919. private _enableVelocity;
  57920. private _positionIndex;
  57921. private _velocityIndex;
  57922. protected _effect: Effect;
  57923. protected _cachedDefines: string;
  57924. /**
  57925. * Set the render list (meshes to be rendered) used in the G buffer.
  57926. */
  57927. renderList: Mesh[];
  57928. /**
  57929. * Gets wether or not G buffer are supported by the running hardware.
  57930. * This requires draw buffer supports
  57931. */
  57932. readonly isSupported: boolean;
  57933. /**
  57934. * Returns the index of the given texture type in the G-Buffer textures array
  57935. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  57936. * @returns the index of the given texture type in the G-Buffer textures array
  57937. */
  57938. getTextureIndex(textureType: number): number;
  57939. /**
  57940. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  57941. */
  57942. /**
  57943. * Sets whether or not objects positions are enabled for the G buffer.
  57944. */
  57945. enablePosition: boolean;
  57946. /**
  57947. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  57948. */
  57949. /**
  57950. * Sets wether or not objects velocities are enabled for the G buffer.
  57951. */
  57952. enableVelocity: boolean;
  57953. /**
  57954. * Gets the scene associated with the buffer.
  57955. */
  57956. readonly scene: Scene;
  57957. /**
  57958. * Gets the ratio used by the buffer during its creation.
  57959. * How big is the buffer related to the main canvas.
  57960. */
  57961. readonly ratio: number;
  57962. /** @hidden */
  57963. static _SceneComponentInitialization: (scene: Scene) => void;
  57964. /**
  57965. * Creates a new G Buffer for the scene
  57966. * @param scene The scene the buffer belongs to
  57967. * @param ratio How big is the buffer related to the main canvas.
  57968. */
  57969. constructor(scene: Scene, ratio?: number);
  57970. /**
  57971. * Checks wether everything is ready to render a submesh to the G buffer.
  57972. * @param subMesh the submesh to check readiness for
  57973. * @param useInstances is the mesh drawn using instance or not
  57974. * @returns true if ready otherwise false
  57975. */
  57976. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57977. /**
  57978. * Gets the current underlying G Buffer.
  57979. * @returns the buffer
  57980. */
  57981. getGBuffer(): MultiRenderTarget;
  57982. /**
  57983. * Gets the number of samples used to render the buffer (anti aliasing).
  57984. */
  57985. /**
  57986. * Sets the number of samples used to render the buffer (anti aliasing).
  57987. */
  57988. samples: number;
  57989. /**
  57990. * Disposes the renderer and frees up associated resources.
  57991. */
  57992. dispose(): void;
  57993. protected _createRenderTargets(): void;
  57994. private _copyBonesTransformationMatrices;
  57995. }
  57996. }
  57997. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  57998. import { Nullable } from "babylonjs/types";
  57999. import { Scene } from "babylonjs/scene";
  58000. import { ISceneComponent } from "babylonjs/sceneComponent";
  58001. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  58002. module "babylonjs/scene" {
  58003. interface Scene {
  58004. /** @hidden (Backing field) */
  58005. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58006. /**
  58007. * Gets or Sets the current geometry buffer associated to the scene.
  58008. */
  58009. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58010. /**
  58011. * Enables a GeometryBufferRender and associates it with the scene
  58012. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  58013. * @returns the GeometryBufferRenderer
  58014. */
  58015. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  58016. /**
  58017. * Disables the GeometryBufferRender associated with the scene
  58018. */
  58019. disableGeometryBufferRenderer(): void;
  58020. }
  58021. }
  58022. /**
  58023. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  58024. * in several rendering techniques.
  58025. */
  58026. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  58027. /**
  58028. * The component name helpful to identify the component in the list of scene components.
  58029. */
  58030. readonly name: string;
  58031. /**
  58032. * The scene the component belongs to.
  58033. */
  58034. scene: Scene;
  58035. /**
  58036. * Creates a new instance of the component for the given scene
  58037. * @param scene Defines the scene to register the component in
  58038. */
  58039. constructor(scene: Scene);
  58040. /**
  58041. * Registers the component in a given scene
  58042. */
  58043. register(): void;
  58044. /**
  58045. * Rebuilds the elements related to this component in case of
  58046. * context lost for instance.
  58047. */
  58048. rebuild(): void;
  58049. /**
  58050. * Disposes the component and the associated ressources
  58051. */
  58052. dispose(): void;
  58053. private _gatherRenderTargets;
  58054. }
  58055. }
  58056. declare module "babylonjs/Shaders/motionBlur.fragment" {
  58057. /** @hidden */
  58058. export var motionBlurPixelShader: {
  58059. name: string;
  58060. shader: string;
  58061. };
  58062. }
  58063. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  58064. import { Nullable } from "babylonjs/types";
  58065. import { Camera } from "babylonjs/Cameras/camera";
  58066. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58067. import { Scene } from "babylonjs/scene";
  58068. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58069. import "babylonjs/Animations/animatable";
  58070. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  58071. import "babylonjs/Shaders/motionBlur.fragment";
  58072. import { Engine } from "babylonjs/Engines/engine";
  58073. /**
  58074. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  58075. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  58076. * As an example, all you have to do is to create the post-process:
  58077. * var mb = new BABYLON.MotionBlurPostProcess(
  58078. * 'mb', // The name of the effect.
  58079. * scene, // The scene containing the objects to blur according to their velocity.
  58080. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  58081. * camera // The camera to apply the render pass to.
  58082. * );
  58083. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  58084. */
  58085. export class MotionBlurPostProcess extends PostProcess {
  58086. /**
  58087. * Defines how much the image is blurred by the movement. Default value is equal to 1
  58088. */
  58089. motionStrength: number;
  58090. /**
  58091. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  58092. */
  58093. /**
  58094. * Sets the number of iterations to be used for motion blur quality
  58095. */
  58096. motionBlurSamples: number;
  58097. private _motionBlurSamples;
  58098. private _geometryBufferRenderer;
  58099. /**
  58100. * Creates a new instance MotionBlurPostProcess
  58101. * @param name The name of the effect.
  58102. * @param scene The scene containing the objects to blur according to their velocity.
  58103. * @param options The required width/height ratio to downsize to before computing the render pass.
  58104. * @param camera The camera to apply the render pass to.
  58105. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58106. * @param engine The engine which the post process will be applied. (default: current engine)
  58107. * @param reusable If the post process can be reused on the same frame. (default: false)
  58108. * @param textureType Type of textures used when performing the post process. (default: 0)
  58109. * @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)
  58110. */
  58111. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58112. /**
  58113. * Excludes the given skinned mesh from computing bones velocities.
  58114. * 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.
  58115. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  58116. */
  58117. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58118. /**
  58119. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  58120. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  58121. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  58122. */
  58123. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58124. /**
  58125. * Disposes the post process.
  58126. * @param camera The camera to dispose the post process on.
  58127. */
  58128. dispose(camera?: Camera): void;
  58129. }
  58130. }
  58131. declare module "babylonjs/Shaders/refraction.fragment" {
  58132. /** @hidden */
  58133. export var refractionPixelShader: {
  58134. name: string;
  58135. shader: string;
  58136. };
  58137. }
  58138. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  58139. import { Color3 } from "babylonjs/Maths/math";
  58140. import { Camera } from "babylonjs/Cameras/camera";
  58141. import { Texture } from "babylonjs/Materials/Textures/texture";
  58142. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58143. import { Engine } from "babylonjs/Engines/engine";
  58144. import "babylonjs/Shaders/refraction.fragment";
  58145. /**
  58146. * Post process which applies a refractin texture
  58147. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58148. */
  58149. export class RefractionPostProcess extends PostProcess {
  58150. /** the base color of the refraction (used to taint the rendering) */
  58151. color: Color3;
  58152. /** simulated refraction depth */
  58153. depth: number;
  58154. /** the coefficient of the base color (0 to remove base color tainting) */
  58155. colorLevel: number;
  58156. private _refTexture;
  58157. private _ownRefractionTexture;
  58158. /**
  58159. * Gets or sets the refraction texture
  58160. * Please note that you are responsible for disposing the texture if you set it manually
  58161. */
  58162. refractionTexture: Texture;
  58163. /**
  58164. * Initializes the RefractionPostProcess
  58165. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58166. * @param name The name of the effect.
  58167. * @param refractionTextureUrl Url of the refraction texture to use
  58168. * @param color the base color of the refraction (used to taint the rendering)
  58169. * @param depth simulated refraction depth
  58170. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  58171. * @param camera The camera to apply the render pass to.
  58172. * @param options The required width/height ratio to downsize to before computing the render pass.
  58173. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58174. * @param engine The engine which the post process will be applied. (default: current engine)
  58175. * @param reusable If the post process can be reused on the same frame. (default: false)
  58176. */
  58177. constructor(name: string, refractionTextureUrl: string,
  58178. /** the base color of the refraction (used to taint the rendering) */
  58179. color: Color3,
  58180. /** simulated refraction depth */
  58181. depth: number,
  58182. /** the coefficient of the base color (0 to remove base color tainting) */
  58183. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58184. /**
  58185. * Disposes of the post process
  58186. * @param camera Camera to dispose post process on
  58187. */
  58188. dispose(camera: Camera): void;
  58189. }
  58190. }
  58191. declare module "babylonjs/Shaders/sharpen.fragment" {
  58192. /** @hidden */
  58193. export var sharpenPixelShader: {
  58194. name: string;
  58195. shader: string;
  58196. };
  58197. }
  58198. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  58199. import { Nullable } from "babylonjs/types";
  58200. import { Camera } from "babylonjs/Cameras/camera";
  58201. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58202. import "babylonjs/Shaders/sharpen.fragment";
  58203. import { Engine } from "babylonjs/Engines/engine";
  58204. /**
  58205. * The SharpenPostProcess applies a sharpen kernel to every pixel
  58206. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58207. */
  58208. export class SharpenPostProcess extends PostProcess {
  58209. /**
  58210. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  58211. */
  58212. colorAmount: number;
  58213. /**
  58214. * How much sharpness should be applied (default: 0.3)
  58215. */
  58216. edgeAmount: number;
  58217. /**
  58218. * Creates a new instance ConvolutionPostProcess
  58219. * @param name The name of the effect.
  58220. * @param options The required width/height ratio to downsize to before computing the render pass.
  58221. * @param camera The camera to apply the render pass to.
  58222. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58223. * @param engine The engine which the post process will be applied. (default: current engine)
  58224. * @param reusable If the post process can be reused on the same frame. (default: false)
  58225. * @param textureType Type of textures used when performing the post process. (default: 0)
  58226. * @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)
  58227. */
  58228. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58229. }
  58230. }
  58231. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  58232. import { Nullable } from "babylonjs/types";
  58233. import { Camera } from "babylonjs/Cameras/camera";
  58234. import { Engine } from "babylonjs/Engines/engine";
  58235. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  58236. import { IInspectable } from "babylonjs/Misc/iInspectable";
  58237. /**
  58238. * PostProcessRenderPipeline
  58239. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58240. */
  58241. export class PostProcessRenderPipeline {
  58242. private engine;
  58243. private _renderEffects;
  58244. private _renderEffectsForIsolatedPass;
  58245. /**
  58246. * List of inspectable custom properties (used by the Inspector)
  58247. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  58248. */
  58249. inspectableCustomProperties: IInspectable[];
  58250. /**
  58251. * @hidden
  58252. */
  58253. protected _cameras: Camera[];
  58254. /** @hidden */
  58255. _name: string;
  58256. /**
  58257. * Gets pipeline name
  58258. */
  58259. readonly name: string;
  58260. /**
  58261. * Initializes a PostProcessRenderPipeline
  58262. * @param engine engine to add the pipeline to
  58263. * @param name name of the pipeline
  58264. */
  58265. constructor(engine: Engine, name: string);
  58266. /**
  58267. * Gets the class name
  58268. * @returns "PostProcessRenderPipeline"
  58269. */
  58270. getClassName(): string;
  58271. /**
  58272. * If all the render effects in the pipeline are supported
  58273. */
  58274. readonly isSupported: boolean;
  58275. /**
  58276. * Adds an effect to the pipeline
  58277. * @param renderEffect the effect to add
  58278. */
  58279. addEffect(renderEffect: PostProcessRenderEffect): void;
  58280. /** @hidden */
  58281. _rebuild(): void;
  58282. /** @hidden */
  58283. _enableEffect(renderEffectName: string, cameras: Camera): void;
  58284. /** @hidden */
  58285. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  58286. /** @hidden */
  58287. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58288. /** @hidden */
  58289. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58290. /** @hidden */
  58291. _attachCameras(cameras: Camera, unique: boolean): void;
  58292. /** @hidden */
  58293. _attachCameras(cameras: Camera[], unique: boolean): void;
  58294. /** @hidden */
  58295. _detachCameras(cameras: Camera): void;
  58296. /** @hidden */
  58297. _detachCameras(cameras: Nullable<Camera[]>): void;
  58298. /** @hidden */
  58299. _update(): void;
  58300. /** @hidden */
  58301. _reset(): void;
  58302. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  58303. /**
  58304. * Disposes of the pipeline
  58305. */
  58306. dispose(): void;
  58307. }
  58308. }
  58309. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  58310. import { Camera } from "babylonjs/Cameras/camera";
  58311. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  58312. /**
  58313. * PostProcessRenderPipelineManager class
  58314. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58315. */
  58316. export class PostProcessRenderPipelineManager {
  58317. private _renderPipelines;
  58318. /**
  58319. * Initializes a PostProcessRenderPipelineManager
  58320. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58321. */
  58322. constructor();
  58323. /**
  58324. * Gets the list of supported render pipelines
  58325. */
  58326. readonly supportedPipelines: PostProcessRenderPipeline[];
  58327. /**
  58328. * Adds a pipeline to the manager
  58329. * @param renderPipeline The pipeline to add
  58330. */
  58331. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  58332. /**
  58333. * Attaches a camera to the pipeline
  58334. * @param renderPipelineName The name of the pipeline to attach to
  58335. * @param cameras the camera to attach
  58336. * @param unique if the camera can be attached multiple times to the pipeline
  58337. */
  58338. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  58339. /**
  58340. * Detaches a camera from the pipeline
  58341. * @param renderPipelineName The name of the pipeline to detach from
  58342. * @param cameras the camera to detach
  58343. */
  58344. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  58345. /**
  58346. * Enables an effect by name on a pipeline
  58347. * @param renderPipelineName the name of the pipeline to enable the effect in
  58348. * @param renderEffectName the name of the effect to enable
  58349. * @param cameras the cameras that the effect should be enabled on
  58350. */
  58351. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58352. /**
  58353. * Disables an effect by name on a pipeline
  58354. * @param renderPipelineName the name of the pipeline to disable the effect in
  58355. * @param renderEffectName the name of the effect to disable
  58356. * @param cameras the cameras that the effect should be disabled on
  58357. */
  58358. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58359. /**
  58360. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  58361. */
  58362. update(): void;
  58363. /** @hidden */
  58364. _rebuild(): void;
  58365. /**
  58366. * Disposes of the manager and pipelines
  58367. */
  58368. dispose(): void;
  58369. }
  58370. }
  58371. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  58372. import { ISceneComponent } from "babylonjs/sceneComponent";
  58373. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  58374. import { Scene } from "babylonjs/scene";
  58375. module "babylonjs/scene" {
  58376. interface Scene {
  58377. /** @hidden (Backing field) */
  58378. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58379. /**
  58380. * Gets the postprocess render pipeline manager
  58381. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58382. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58383. */
  58384. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58385. }
  58386. }
  58387. /**
  58388. * Defines the Render Pipeline scene component responsible to rendering pipelines
  58389. */
  58390. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  58391. /**
  58392. * The component name helpfull to identify the component in the list of scene components.
  58393. */
  58394. readonly name: string;
  58395. /**
  58396. * The scene the component belongs to.
  58397. */
  58398. scene: Scene;
  58399. /**
  58400. * Creates a new instance of the component for the given scene
  58401. * @param scene Defines the scene to register the component in
  58402. */
  58403. constructor(scene: Scene);
  58404. /**
  58405. * Registers the component in a given scene
  58406. */
  58407. register(): void;
  58408. /**
  58409. * Rebuilds the elements related to this component in case of
  58410. * context lost for instance.
  58411. */
  58412. rebuild(): void;
  58413. /**
  58414. * Disposes the component and the associated ressources
  58415. */
  58416. dispose(): void;
  58417. private _gatherRenderTargets;
  58418. }
  58419. }
  58420. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  58421. import { Nullable } from "babylonjs/types";
  58422. import { IAnimatable } from "babylonjs/Misc/tools";
  58423. import { Camera } from "babylonjs/Cameras/camera";
  58424. import { IDisposable } from "babylonjs/scene";
  58425. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  58426. import { Scene } from "babylonjs/scene";
  58427. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  58428. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  58429. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  58430. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  58431. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  58432. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  58433. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  58434. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  58435. import { Animation } from "babylonjs/Animations/animation";
  58436. /**
  58437. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  58438. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58439. */
  58440. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  58441. private _scene;
  58442. private _camerasToBeAttached;
  58443. /**
  58444. * ID of the sharpen post process,
  58445. */
  58446. private readonly SharpenPostProcessId;
  58447. /**
  58448. * @ignore
  58449. * ID of the image processing post process;
  58450. */
  58451. readonly ImageProcessingPostProcessId: string;
  58452. /**
  58453. * @ignore
  58454. * ID of the Fast Approximate Anti-Aliasing post process;
  58455. */
  58456. readonly FxaaPostProcessId: string;
  58457. /**
  58458. * ID of the chromatic aberration post process,
  58459. */
  58460. private readonly ChromaticAberrationPostProcessId;
  58461. /**
  58462. * ID of the grain post process
  58463. */
  58464. private readonly GrainPostProcessId;
  58465. /**
  58466. * Sharpen post process which will apply a sharpen convolution to enhance edges
  58467. */
  58468. sharpen: SharpenPostProcess;
  58469. private _sharpenEffect;
  58470. private bloom;
  58471. /**
  58472. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  58473. */
  58474. depthOfField: DepthOfFieldEffect;
  58475. /**
  58476. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  58477. */
  58478. fxaa: FxaaPostProcess;
  58479. /**
  58480. * Image post processing pass used to perform operations such as tone mapping or color grading.
  58481. */
  58482. imageProcessing: ImageProcessingPostProcess;
  58483. /**
  58484. * Chromatic aberration post process which will shift rgb colors in the image
  58485. */
  58486. chromaticAberration: ChromaticAberrationPostProcess;
  58487. private _chromaticAberrationEffect;
  58488. /**
  58489. * Grain post process which add noise to the image
  58490. */
  58491. grain: GrainPostProcess;
  58492. private _grainEffect;
  58493. /**
  58494. * Glow post process which adds a glow to emissive areas of the image
  58495. */
  58496. private _glowLayer;
  58497. /**
  58498. * Animations which can be used to tweak settings over a period of time
  58499. */
  58500. animations: Animation[];
  58501. private _imageProcessingConfigurationObserver;
  58502. private _sharpenEnabled;
  58503. private _bloomEnabled;
  58504. private _depthOfFieldEnabled;
  58505. private _depthOfFieldBlurLevel;
  58506. private _fxaaEnabled;
  58507. private _imageProcessingEnabled;
  58508. private _defaultPipelineTextureType;
  58509. private _bloomScale;
  58510. private _chromaticAberrationEnabled;
  58511. private _grainEnabled;
  58512. private _buildAllowed;
  58513. /**
  58514. * Gets active scene
  58515. */
  58516. readonly scene: Scene;
  58517. /**
  58518. * Enable or disable the sharpen process from the pipeline
  58519. */
  58520. sharpenEnabled: boolean;
  58521. private _resizeObserver;
  58522. private _hardwareScaleLevel;
  58523. private _bloomKernel;
  58524. /**
  58525. * Specifies the size of the bloom blur kernel, relative to the final output size
  58526. */
  58527. bloomKernel: number;
  58528. /**
  58529. * Specifies the weight of the bloom in the final rendering
  58530. */
  58531. private _bloomWeight;
  58532. /**
  58533. * Specifies the luma threshold for the area that will be blurred by the bloom
  58534. */
  58535. private _bloomThreshold;
  58536. private _hdr;
  58537. /**
  58538. * The strength of the bloom.
  58539. */
  58540. bloomWeight: number;
  58541. /**
  58542. * The strength of the bloom.
  58543. */
  58544. bloomThreshold: number;
  58545. /**
  58546. * The scale of the bloom, lower value will provide better performance.
  58547. */
  58548. bloomScale: number;
  58549. /**
  58550. * Enable or disable the bloom from the pipeline
  58551. */
  58552. bloomEnabled: boolean;
  58553. private _rebuildBloom;
  58554. /**
  58555. * If the depth of field is enabled.
  58556. */
  58557. depthOfFieldEnabled: boolean;
  58558. /**
  58559. * Blur level of the depth of field effect. (Higher blur will effect performance)
  58560. */
  58561. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  58562. /**
  58563. * If the anti aliasing is enabled.
  58564. */
  58565. fxaaEnabled: boolean;
  58566. private _samples;
  58567. /**
  58568. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  58569. */
  58570. samples: number;
  58571. /**
  58572. * If image processing is enabled.
  58573. */
  58574. imageProcessingEnabled: boolean;
  58575. /**
  58576. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  58577. */
  58578. glowLayerEnabled: boolean;
  58579. /**
  58580. * Gets the glow layer (or null if not defined)
  58581. */
  58582. readonly glowLayer: Nullable<GlowLayer>;
  58583. /**
  58584. * Enable or disable the chromaticAberration process from the pipeline
  58585. */
  58586. chromaticAberrationEnabled: boolean;
  58587. /**
  58588. * Enable or disable the grain process from the pipeline
  58589. */
  58590. grainEnabled: boolean;
  58591. /**
  58592. * @constructor
  58593. * @param name - The rendering pipeline name (default: "")
  58594. * @param hdr - If high dynamic range textures should be used (default: true)
  58595. * @param scene - The scene linked to this pipeline (default: the last created scene)
  58596. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  58597. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  58598. */
  58599. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  58600. /**
  58601. * Get the class name
  58602. * @returns "DefaultRenderingPipeline"
  58603. */
  58604. getClassName(): string;
  58605. /**
  58606. * Force the compilation of the entire pipeline.
  58607. */
  58608. prepare(): void;
  58609. private _hasCleared;
  58610. private _prevPostProcess;
  58611. private _prevPrevPostProcess;
  58612. private _setAutoClearAndTextureSharing;
  58613. private _depthOfFieldSceneObserver;
  58614. private _buildPipeline;
  58615. private _disposePostProcesses;
  58616. /**
  58617. * Adds a camera to the pipeline
  58618. * @param camera the camera to be added
  58619. */
  58620. addCamera(camera: Camera): void;
  58621. /**
  58622. * Removes a camera from the pipeline
  58623. * @param camera the camera to remove
  58624. */
  58625. removeCamera(camera: Camera): void;
  58626. /**
  58627. * Dispose of the pipeline and stop all post processes
  58628. */
  58629. dispose(): void;
  58630. /**
  58631. * Serialize the rendering pipeline (Used when exporting)
  58632. * @returns the serialized object
  58633. */
  58634. serialize(): any;
  58635. /**
  58636. * Parse the serialized pipeline
  58637. * @param source Source pipeline.
  58638. * @param scene The scene to load the pipeline to.
  58639. * @param rootUrl The URL of the serialized pipeline.
  58640. * @returns An instantiated pipeline from the serialized object.
  58641. */
  58642. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  58643. }
  58644. }
  58645. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  58646. /** @hidden */
  58647. export var lensHighlightsPixelShader: {
  58648. name: string;
  58649. shader: string;
  58650. };
  58651. }
  58652. declare module "babylonjs/Shaders/depthOfField.fragment" {
  58653. /** @hidden */
  58654. export var depthOfFieldPixelShader: {
  58655. name: string;
  58656. shader: string;
  58657. };
  58658. }
  58659. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  58660. import { Camera } from "babylonjs/Cameras/camera";
  58661. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  58662. import { Scene } from "babylonjs/scene";
  58663. import "babylonjs/Shaders/chromaticAberration.fragment";
  58664. import "babylonjs/Shaders/lensHighlights.fragment";
  58665. import "babylonjs/Shaders/depthOfField.fragment";
  58666. /**
  58667. * BABYLON.JS Chromatic Aberration GLSL Shader
  58668. * Author: Olivier Guyot
  58669. * Separates very slightly R, G and B colors on the edges of the screen
  58670. * Inspired by Francois Tarlier & Martins Upitis
  58671. */
  58672. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  58673. /**
  58674. * @ignore
  58675. * The chromatic aberration PostProcess id in the pipeline
  58676. */
  58677. LensChromaticAberrationEffect: string;
  58678. /**
  58679. * @ignore
  58680. * The highlights enhancing PostProcess id in the pipeline
  58681. */
  58682. HighlightsEnhancingEffect: string;
  58683. /**
  58684. * @ignore
  58685. * The depth-of-field PostProcess id in the pipeline
  58686. */
  58687. LensDepthOfFieldEffect: string;
  58688. private _scene;
  58689. private _depthTexture;
  58690. private _grainTexture;
  58691. private _chromaticAberrationPostProcess;
  58692. private _highlightsPostProcess;
  58693. private _depthOfFieldPostProcess;
  58694. private _edgeBlur;
  58695. private _grainAmount;
  58696. private _chromaticAberration;
  58697. private _distortion;
  58698. private _highlightsGain;
  58699. private _highlightsThreshold;
  58700. private _dofDistance;
  58701. private _dofAperture;
  58702. private _dofDarken;
  58703. private _dofPentagon;
  58704. private _blurNoise;
  58705. /**
  58706. * @constructor
  58707. *
  58708. * Effect parameters are as follow:
  58709. * {
  58710. * chromatic_aberration: number; // from 0 to x (1 for realism)
  58711. * edge_blur: number; // from 0 to x (1 for realism)
  58712. * distortion: number; // from 0 to x (1 for realism)
  58713. * grain_amount: number; // from 0 to 1
  58714. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  58715. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  58716. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  58717. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  58718. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  58719. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  58720. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  58721. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  58722. * }
  58723. * Note: if an effect parameter is unset, effect is disabled
  58724. *
  58725. * @param name The rendering pipeline name
  58726. * @param parameters - An object containing all parameters (see above)
  58727. * @param scene The scene linked to this pipeline
  58728. * @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)
  58729. * @param cameras The array of cameras that the rendering pipeline will be attached to
  58730. */
  58731. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  58732. /**
  58733. * Get the class name
  58734. * @returns "LensRenderingPipeline"
  58735. */
  58736. getClassName(): string;
  58737. /**
  58738. * Gets associated scene
  58739. */
  58740. readonly scene: Scene;
  58741. /**
  58742. * Gets or sets the edge blur
  58743. */
  58744. edgeBlur: number;
  58745. /**
  58746. * Gets or sets the grain amount
  58747. */
  58748. grainAmount: number;
  58749. /**
  58750. * Gets or sets the chromatic aberration amount
  58751. */
  58752. chromaticAberration: number;
  58753. /**
  58754. * Gets or sets the depth of field aperture
  58755. */
  58756. dofAperture: number;
  58757. /**
  58758. * Gets or sets the edge distortion
  58759. */
  58760. edgeDistortion: number;
  58761. /**
  58762. * Gets or sets the depth of field distortion
  58763. */
  58764. dofDistortion: number;
  58765. /**
  58766. * Gets or sets the darken out of focus amount
  58767. */
  58768. darkenOutOfFocus: number;
  58769. /**
  58770. * Gets or sets a boolean indicating if blur noise is enabled
  58771. */
  58772. blurNoise: boolean;
  58773. /**
  58774. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  58775. */
  58776. pentagonBokeh: boolean;
  58777. /**
  58778. * Gets or sets the highlight grain amount
  58779. */
  58780. highlightsGain: number;
  58781. /**
  58782. * Gets or sets the highlight threshold
  58783. */
  58784. highlightsThreshold: number;
  58785. /**
  58786. * Sets the amount of blur at the edges
  58787. * @param amount blur amount
  58788. */
  58789. setEdgeBlur(amount: number): void;
  58790. /**
  58791. * Sets edge blur to 0
  58792. */
  58793. disableEdgeBlur(): void;
  58794. /**
  58795. * Sets the amout of grain
  58796. * @param amount Amount of grain
  58797. */
  58798. setGrainAmount(amount: number): void;
  58799. /**
  58800. * Set grain amount to 0
  58801. */
  58802. disableGrain(): void;
  58803. /**
  58804. * Sets the chromatic aberration amount
  58805. * @param amount amount of chromatic aberration
  58806. */
  58807. setChromaticAberration(amount: number): void;
  58808. /**
  58809. * Sets chromatic aberration amount to 0
  58810. */
  58811. disableChromaticAberration(): void;
  58812. /**
  58813. * Sets the EdgeDistortion amount
  58814. * @param amount amount of EdgeDistortion
  58815. */
  58816. setEdgeDistortion(amount: number): void;
  58817. /**
  58818. * Sets edge distortion to 0
  58819. */
  58820. disableEdgeDistortion(): void;
  58821. /**
  58822. * Sets the FocusDistance amount
  58823. * @param amount amount of FocusDistance
  58824. */
  58825. setFocusDistance(amount: number): void;
  58826. /**
  58827. * Disables depth of field
  58828. */
  58829. disableDepthOfField(): void;
  58830. /**
  58831. * Sets the Aperture amount
  58832. * @param amount amount of Aperture
  58833. */
  58834. setAperture(amount: number): void;
  58835. /**
  58836. * Sets the DarkenOutOfFocus amount
  58837. * @param amount amount of DarkenOutOfFocus
  58838. */
  58839. setDarkenOutOfFocus(amount: number): void;
  58840. private _pentagonBokehIsEnabled;
  58841. /**
  58842. * Creates a pentagon bokeh effect
  58843. */
  58844. enablePentagonBokeh(): void;
  58845. /**
  58846. * Disables the pentagon bokeh effect
  58847. */
  58848. disablePentagonBokeh(): void;
  58849. /**
  58850. * Enables noise blur
  58851. */
  58852. enableNoiseBlur(): void;
  58853. /**
  58854. * Disables noise blur
  58855. */
  58856. disableNoiseBlur(): void;
  58857. /**
  58858. * Sets the HighlightsGain amount
  58859. * @param amount amount of HighlightsGain
  58860. */
  58861. setHighlightsGain(amount: number): void;
  58862. /**
  58863. * Sets the HighlightsThreshold amount
  58864. * @param amount amount of HighlightsThreshold
  58865. */
  58866. setHighlightsThreshold(amount: number): void;
  58867. /**
  58868. * Disables highlights
  58869. */
  58870. disableHighlights(): void;
  58871. /**
  58872. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  58873. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  58874. */
  58875. dispose(disableDepthRender?: boolean): void;
  58876. private _createChromaticAberrationPostProcess;
  58877. private _createHighlightsPostProcess;
  58878. private _createDepthOfFieldPostProcess;
  58879. private _createGrainTexture;
  58880. }
  58881. }
  58882. declare module "babylonjs/Shaders/ssao2.fragment" {
  58883. /** @hidden */
  58884. export var ssao2PixelShader: {
  58885. name: string;
  58886. shader: string;
  58887. };
  58888. }
  58889. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  58890. /** @hidden */
  58891. export var ssaoCombinePixelShader: {
  58892. name: string;
  58893. shader: string;
  58894. };
  58895. }
  58896. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  58897. import { Camera } from "babylonjs/Cameras/camera";
  58898. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  58899. import { Scene } from "babylonjs/scene";
  58900. import "babylonjs/Shaders/ssao2.fragment";
  58901. import "babylonjs/Shaders/ssaoCombine.fragment";
  58902. /**
  58903. * Render pipeline to produce ssao effect
  58904. */
  58905. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  58906. /**
  58907. * @ignore
  58908. * The PassPostProcess id in the pipeline that contains the original scene color
  58909. */
  58910. SSAOOriginalSceneColorEffect: string;
  58911. /**
  58912. * @ignore
  58913. * The SSAO PostProcess id in the pipeline
  58914. */
  58915. SSAORenderEffect: string;
  58916. /**
  58917. * @ignore
  58918. * The horizontal blur PostProcess id in the pipeline
  58919. */
  58920. SSAOBlurHRenderEffect: string;
  58921. /**
  58922. * @ignore
  58923. * The vertical blur PostProcess id in the pipeline
  58924. */
  58925. SSAOBlurVRenderEffect: string;
  58926. /**
  58927. * @ignore
  58928. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  58929. */
  58930. SSAOCombineRenderEffect: string;
  58931. /**
  58932. * The output strength of the SSAO post-process. Default value is 1.0.
  58933. */
  58934. totalStrength: number;
  58935. /**
  58936. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  58937. */
  58938. maxZ: number;
  58939. /**
  58940. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  58941. */
  58942. minZAspect: number;
  58943. private _samples;
  58944. /**
  58945. * Number of samples used for the SSAO calculations. Default value is 8
  58946. */
  58947. samples: number;
  58948. private _textureSamples;
  58949. /**
  58950. * Number of samples to use for antialiasing
  58951. */
  58952. textureSamples: number;
  58953. /**
  58954. * Ratio object used for SSAO ratio and blur ratio
  58955. */
  58956. private _ratio;
  58957. /**
  58958. * Dynamically generated sphere sampler.
  58959. */
  58960. private _sampleSphere;
  58961. /**
  58962. * Blur filter offsets
  58963. */
  58964. private _samplerOffsets;
  58965. private _expensiveBlur;
  58966. /**
  58967. * If bilateral blur should be used
  58968. */
  58969. expensiveBlur: boolean;
  58970. /**
  58971. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  58972. */
  58973. radius: number;
  58974. /**
  58975. * The base color of the SSAO post-process
  58976. * The final result is "base + ssao" between [0, 1]
  58977. */
  58978. base: number;
  58979. /**
  58980. * Support test.
  58981. */
  58982. static readonly IsSupported: boolean;
  58983. private _scene;
  58984. private _depthTexture;
  58985. private _normalTexture;
  58986. private _randomTexture;
  58987. private _originalColorPostProcess;
  58988. private _ssaoPostProcess;
  58989. private _blurHPostProcess;
  58990. private _blurVPostProcess;
  58991. private _ssaoCombinePostProcess;
  58992. private _firstUpdate;
  58993. /**
  58994. * Gets active scene
  58995. */
  58996. readonly scene: Scene;
  58997. /**
  58998. * @constructor
  58999. * @param name The rendering pipeline name
  59000. * @param scene The scene linked to this pipeline
  59001. * @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 }
  59002. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59003. */
  59004. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59005. /**
  59006. * Get the class name
  59007. * @returns "SSAO2RenderingPipeline"
  59008. */
  59009. getClassName(): string;
  59010. /**
  59011. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59012. */
  59013. dispose(disableGeometryBufferRenderer?: boolean): void;
  59014. private _createBlurPostProcess;
  59015. /** @hidden */
  59016. _rebuild(): void;
  59017. private _bits;
  59018. private _radicalInverse_VdC;
  59019. private _hammersley;
  59020. private _hemisphereSample_uniform;
  59021. private _generateHemisphere;
  59022. private _createSSAOPostProcess;
  59023. private _createSSAOCombinePostProcess;
  59024. private _createRandomTexture;
  59025. /**
  59026. * Serialize the rendering pipeline (Used when exporting)
  59027. * @returns the serialized object
  59028. */
  59029. serialize(): any;
  59030. /**
  59031. * Parse the serialized pipeline
  59032. * @param source Source pipeline.
  59033. * @param scene The scene to load the pipeline to.
  59034. * @param rootUrl The URL of the serialized pipeline.
  59035. * @returns An instantiated pipeline from the serialized object.
  59036. */
  59037. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  59038. }
  59039. }
  59040. declare module "babylonjs/Shaders/ssao.fragment" {
  59041. /** @hidden */
  59042. export var ssaoPixelShader: {
  59043. name: string;
  59044. shader: string;
  59045. };
  59046. }
  59047. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  59048. import { Camera } from "babylonjs/Cameras/camera";
  59049. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59050. import { Scene } from "babylonjs/scene";
  59051. import "babylonjs/Shaders/ssao.fragment";
  59052. import "babylonjs/Shaders/ssaoCombine.fragment";
  59053. /**
  59054. * Render pipeline to produce ssao effect
  59055. */
  59056. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  59057. /**
  59058. * @ignore
  59059. * The PassPostProcess id in the pipeline that contains the original scene color
  59060. */
  59061. SSAOOriginalSceneColorEffect: string;
  59062. /**
  59063. * @ignore
  59064. * The SSAO PostProcess id in the pipeline
  59065. */
  59066. SSAORenderEffect: string;
  59067. /**
  59068. * @ignore
  59069. * The horizontal blur PostProcess id in the pipeline
  59070. */
  59071. SSAOBlurHRenderEffect: string;
  59072. /**
  59073. * @ignore
  59074. * The vertical blur PostProcess id in the pipeline
  59075. */
  59076. SSAOBlurVRenderEffect: string;
  59077. /**
  59078. * @ignore
  59079. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59080. */
  59081. SSAOCombineRenderEffect: string;
  59082. /**
  59083. * The output strength of the SSAO post-process. Default value is 1.0.
  59084. */
  59085. totalStrength: number;
  59086. /**
  59087. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  59088. */
  59089. radius: number;
  59090. /**
  59091. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  59092. * Must not be equal to fallOff and superior to fallOff.
  59093. * Default value is 0.0075
  59094. */
  59095. area: number;
  59096. /**
  59097. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  59098. * Must not be equal to area and inferior to area.
  59099. * Default value is 0.000001
  59100. */
  59101. fallOff: number;
  59102. /**
  59103. * The base color of the SSAO post-process
  59104. * The final result is "base + ssao" between [0, 1]
  59105. */
  59106. base: number;
  59107. private _scene;
  59108. private _depthTexture;
  59109. private _randomTexture;
  59110. private _originalColorPostProcess;
  59111. private _ssaoPostProcess;
  59112. private _blurHPostProcess;
  59113. private _blurVPostProcess;
  59114. private _ssaoCombinePostProcess;
  59115. private _firstUpdate;
  59116. /**
  59117. * Gets active scene
  59118. */
  59119. readonly scene: Scene;
  59120. /**
  59121. * @constructor
  59122. * @param name - The rendering pipeline name
  59123. * @param scene - The scene linked to this pipeline
  59124. * @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 }
  59125. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  59126. */
  59127. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59128. /**
  59129. * Get the class name
  59130. * @returns "SSAORenderingPipeline"
  59131. */
  59132. getClassName(): string;
  59133. /**
  59134. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59135. */
  59136. dispose(disableDepthRender?: boolean): void;
  59137. private _createBlurPostProcess;
  59138. /** @hidden */
  59139. _rebuild(): void;
  59140. private _createSSAOPostProcess;
  59141. private _createSSAOCombinePostProcess;
  59142. private _createRandomTexture;
  59143. }
  59144. }
  59145. declare module "babylonjs/Shaders/standard.fragment" {
  59146. /** @hidden */
  59147. export var standardPixelShader: {
  59148. name: string;
  59149. shader: string;
  59150. };
  59151. }
  59152. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  59153. import { Nullable } from "babylonjs/types";
  59154. import { IAnimatable } from "babylonjs/Misc/tools";
  59155. import { Camera } from "babylonjs/Cameras/camera";
  59156. import { Texture } from "babylonjs/Materials/Textures/texture";
  59157. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59158. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59159. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  59160. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  59161. import { IDisposable } from "babylonjs/scene";
  59162. import { SpotLight } from "babylonjs/Lights/spotLight";
  59163. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  59164. import { Scene } from "babylonjs/scene";
  59165. import { Animation } from "babylonjs/Animations/animation";
  59166. import "babylonjs/Shaders/standard.fragment";
  59167. /**
  59168. * Standard rendering pipeline
  59169. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59170. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  59171. */
  59172. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59173. /**
  59174. * Public members
  59175. */
  59176. /**
  59177. * Post-process which contains the original scene color before the pipeline applies all the effects
  59178. */
  59179. originalPostProcess: Nullable<PostProcess>;
  59180. /**
  59181. * Post-process used to down scale an image x4
  59182. */
  59183. downSampleX4PostProcess: Nullable<PostProcess>;
  59184. /**
  59185. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  59186. */
  59187. brightPassPostProcess: Nullable<PostProcess>;
  59188. /**
  59189. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  59190. */
  59191. blurHPostProcesses: PostProcess[];
  59192. /**
  59193. * Post-process array storing all the vertical blur post-processes used by the pipeline
  59194. */
  59195. blurVPostProcesses: PostProcess[];
  59196. /**
  59197. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  59198. */
  59199. textureAdderPostProcess: Nullable<PostProcess>;
  59200. /**
  59201. * Post-process used to create volumetric lighting effect
  59202. */
  59203. volumetricLightPostProcess: Nullable<PostProcess>;
  59204. /**
  59205. * Post-process used to smooth the previous volumetric light post-process on the X axis
  59206. */
  59207. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  59208. /**
  59209. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  59210. */
  59211. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  59212. /**
  59213. * Post-process used to merge the volumetric light effect and the real scene color
  59214. */
  59215. volumetricLightMergePostProces: Nullable<PostProcess>;
  59216. /**
  59217. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  59218. */
  59219. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  59220. /**
  59221. * Base post-process used to calculate the average luminance of the final image for HDR
  59222. */
  59223. luminancePostProcess: Nullable<PostProcess>;
  59224. /**
  59225. * Post-processes used to create down sample post-processes in order to get
  59226. * the average luminance of the final image for HDR
  59227. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  59228. */
  59229. luminanceDownSamplePostProcesses: PostProcess[];
  59230. /**
  59231. * Post-process used to create a HDR effect (light adaptation)
  59232. */
  59233. hdrPostProcess: Nullable<PostProcess>;
  59234. /**
  59235. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  59236. */
  59237. textureAdderFinalPostProcess: Nullable<PostProcess>;
  59238. /**
  59239. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  59240. */
  59241. lensFlareFinalPostProcess: Nullable<PostProcess>;
  59242. /**
  59243. * Post-process used to merge the final HDR post-process and the real scene color
  59244. */
  59245. hdrFinalPostProcess: Nullable<PostProcess>;
  59246. /**
  59247. * Post-process used to create a lens flare effect
  59248. */
  59249. lensFlarePostProcess: Nullable<PostProcess>;
  59250. /**
  59251. * Post-process that merges the result of the lens flare post-process and the real scene color
  59252. */
  59253. lensFlareComposePostProcess: Nullable<PostProcess>;
  59254. /**
  59255. * Post-process used to create a motion blur effect
  59256. */
  59257. motionBlurPostProcess: Nullable<PostProcess>;
  59258. /**
  59259. * Post-process used to create a depth of field effect
  59260. */
  59261. depthOfFieldPostProcess: Nullable<PostProcess>;
  59262. /**
  59263. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59264. */
  59265. fxaaPostProcess: Nullable<FxaaPostProcess>;
  59266. /**
  59267. * Represents the brightness threshold in order to configure the illuminated surfaces
  59268. */
  59269. brightThreshold: number;
  59270. /**
  59271. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  59272. */
  59273. blurWidth: number;
  59274. /**
  59275. * Sets if the blur for highlighted surfaces must be only horizontal
  59276. */
  59277. horizontalBlur: boolean;
  59278. /**
  59279. * Gets the overall exposure used by the pipeline
  59280. */
  59281. /**
  59282. * Sets the overall exposure used by the pipeline
  59283. */
  59284. exposure: number;
  59285. /**
  59286. * Texture used typically to simulate "dirty" on camera lens
  59287. */
  59288. lensTexture: Nullable<Texture>;
  59289. /**
  59290. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  59291. */
  59292. volumetricLightCoefficient: number;
  59293. /**
  59294. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  59295. */
  59296. volumetricLightPower: number;
  59297. /**
  59298. * Used the set the blur intensity to smooth the volumetric lights
  59299. */
  59300. volumetricLightBlurScale: number;
  59301. /**
  59302. * Light (spot or directional) used to generate the volumetric lights rays
  59303. * The source light must have a shadow generate so the pipeline can get its
  59304. * depth map
  59305. */
  59306. sourceLight: Nullable<SpotLight | DirectionalLight>;
  59307. /**
  59308. * For eye adaptation, represents the minimum luminance the eye can see
  59309. */
  59310. hdrMinimumLuminance: number;
  59311. /**
  59312. * For eye adaptation, represents the decrease luminance speed
  59313. */
  59314. hdrDecreaseRate: number;
  59315. /**
  59316. * For eye adaptation, represents the increase luminance speed
  59317. */
  59318. hdrIncreaseRate: number;
  59319. /**
  59320. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59321. */
  59322. /**
  59323. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59324. */
  59325. hdrAutoExposure: boolean;
  59326. /**
  59327. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  59328. */
  59329. lensColorTexture: Nullable<Texture>;
  59330. /**
  59331. * The overall strengh for the lens flare effect
  59332. */
  59333. lensFlareStrength: number;
  59334. /**
  59335. * Dispersion coefficient for lens flare ghosts
  59336. */
  59337. lensFlareGhostDispersal: number;
  59338. /**
  59339. * Main lens flare halo width
  59340. */
  59341. lensFlareHaloWidth: number;
  59342. /**
  59343. * Based on the lens distortion effect, defines how much the lens flare result
  59344. * is distorted
  59345. */
  59346. lensFlareDistortionStrength: number;
  59347. /**
  59348. * Lens star texture must be used to simulate rays on the flares and is available
  59349. * in the documentation
  59350. */
  59351. lensStarTexture: Nullable<Texture>;
  59352. /**
  59353. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  59354. * flare effect by taking account of the dirt texture
  59355. */
  59356. lensFlareDirtTexture: Nullable<Texture>;
  59357. /**
  59358. * Represents the focal length for the depth of field effect
  59359. */
  59360. depthOfFieldDistance: number;
  59361. /**
  59362. * Represents the blur intensity for the blurred part of the depth of field effect
  59363. */
  59364. depthOfFieldBlurWidth: number;
  59365. /**
  59366. * Gets how much the image is blurred by the movement while using the motion blur post-process
  59367. */
  59368. /**
  59369. * Sets how much the image is blurred by the movement while using the motion blur post-process
  59370. */
  59371. motionStrength: number;
  59372. /**
  59373. * Gets wether or not the motion blur post-process is object based or screen based.
  59374. */
  59375. /**
  59376. * Sets wether or not the motion blur post-process should be object based or screen based
  59377. */
  59378. objectBasedMotionBlur: boolean;
  59379. /**
  59380. * List of animations for the pipeline (IAnimatable implementation)
  59381. */
  59382. animations: Animation[];
  59383. /**
  59384. * Private members
  59385. */
  59386. private _scene;
  59387. private _currentDepthOfFieldSource;
  59388. private _basePostProcess;
  59389. private _fixedExposure;
  59390. private _currentExposure;
  59391. private _hdrAutoExposure;
  59392. private _hdrCurrentLuminance;
  59393. private _motionStrength;
  59394. private _isObjectBasedMotionBlur;
  59395. private _floatTextureType;
  59396. private _ratio;
  59397. private _bloomEnabled;
  59398. private _depthOfFieldEnabled;
  59399. private _vlsEnabled;
  59400. private _lensFlareEnabled;
  59401. private _hdrEnabled;
  59402. private _motionBlurEnabled;
  59403. private _fxaaEnabled;
  59404. private _motionBlurSamples;
  59405. private _volumetricLightStepsCount;
  59406. private _samples;
  59407. /**
  59408. * @ignore
  59409. * Specifies if the bloom pipeline is enabled
  59410. */
  59411. BloomEnabled: boolean;
  59412. /**
  59413. * @ignore
  59414. * Specifies if the depth of field pipeline is enabed
  59415. */
  59416. DepthOfFieldEnabled: boolean;
  59417. /**
  59418. * @ignore
  59419. * Specifies if the lens flare pipeline is enabed
  59420. */
  59421. LensFlareEnabled: boolean;
  59422. /**
  59423. * @ignore
  59424. * Specifies if the HDR pipeline is enabled
  59425. */
  59426. HDREnabled: boolean;
  59427. /**
  59428. * @ignore
  59429. * Specifies if the volumetric lights scattering effect is enabled
  59430. */
  59431. VLSEnabled: boolean;
  59432. /**
  59433. * @ignore
  59434. * Specifies if the motion blur effect is enabled
  59435. */
  59436. MotionBlurEnabled: boolean;
  59437. /**
  59438. * Specifies if anti-aliasing is enabled
  59439. */
  59440. fxaaEnabled: boolean;
  59441. /**
  59442. * Specifies the number of steps used to calculate the volumetric lights
  59443. * Typically in interval [50, 200]
  59444. */
  59445. volumetricLightStepsCount: number;
  59446. /**
  59447. * Specifies the number of samples used for the motion blur effect
  59448. * Typically in interval [16, 64]
  59449. */
  59450. motionBlurSamples: number;
  59451. /**
  59452. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59453. */
  59454. samples: number;
  59455. /**
  59456. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59457. * @constructor
  59458. * @param name The rendering pipeline name
  59459. * @param scene The scene linked to this pipeline
  59460. * @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)
  59461. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  59462. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59463. */
  59464. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  59465. private _buildPipeline;
  59466. private _createDownSampleX4PostProcess;
  59467. private _createBrightPassPostProcess;
  59468. private _createBlurPostProcesses;
  59469. private _createTextureAdderPostProcess;
  59470. private _createVolumetricLightPostProcess;
  59471. private _createLuminancePostProcesses;
  59472. private _createHdrPostProcess;
  59473. private _createLensFlarePostProcess;
  59474. private _createDepthOfFieldPostProcess;
  59475. private _createMotionBlurPostProcess;
  59476. private _getDepthTexture;
  59477. private _disposePostProcesses;
  59478. /**
  59479. * Dispose of the pipeline and stop all post processes
  59480. */
  59481. dispose(): void;
  59482. /**
  59483. * Serialize the rendering pipeline (Used when exporting)
  59484. * @returns the serialized object
  59485. */
  59486. serialize(): any;
  59487. /**
  59488. * Parse the serialized pipeline
  59489. * @param source Source pipeline.
  59490. * @param scene The scene to load the pipeline to.
  59491. * @param rootUrl The URL of the serialized pipeline.
  59492. * @returns An instantiated pipeline from the serialized object.
  59493. */
  59494. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  59495. /**
  59496. * Luminance steps
  59497. */
  59498. static LuminanceSteps: number;
  59499. }
  59500. }
  59501. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  59502. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  59503. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  59504. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  59505. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  59506. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  59507. }
  59508. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  59509. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  59510. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  59511. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59512. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  59513. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  59514. }
  59515. declare module "babylonjs/Shaders/tonemap.fragment" {
  59516. /** @hidden */
  59517. export var tonemapPixelShader: {
  59518. name: string;
  59519. shader: string;
  59520. };
  59521. }
  59522. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  59523. import { Camera } from "babylonjs/Cameras/camera";
  59524. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59525. import "babylonjs/Shaders/tonemap.fragment";
  59526. import { Engine } from "babylonjs/Engines/engine";
  59527. /** Defines operator used for tonemapping */
  59528. export enum TonemappingOperator {
  59529. /** Hable */
  59530. Hable = 0,
  59531. /** Reinhard */
  59532. Reinhard = 1,
  59533. /** HejiDawson */
  59534. HejiDawson = 2,
  59535. /** Photographic */
  59536. Photographic = 3
  59537. }
  59538. /**
  59539. * Defines a post process to apply tone mapping
  59540. */
  59541. export class TonemapPostProcess extends PostProcess {
  59542. private _operator;
  59543. /** Defines the required exposure adjustement */
  59544. exposureAdjustment: number;
  59545. /**
  59546. * Creates a new TonemapPostProcess
  59547. * @param name defines the name of the postprocess
  59548. * @param _operator defines the operator to use
  59549. * @param exposureAdjustment defines the required exposure adjustement
  59550. * @param camera defines the camera to use (can be null)
  59551. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  59552. * @param engine defines the hosting engine (can be ignore if camera is set)
  59553. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59554. */
  59555. constructor(name: string, _operator: TonemappingOperator,
  59556. /** Defines the required exposure adjustement */
  59557. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  59558. }
  59559. }
  59560. declare module "babylonjs/Shaders/depth.vertex" {
  59561. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59562. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59563. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59564. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59565. /** @hidden */
  59566. export var depthVertexShader: {
  59567. name: string;
  59568. shader: string;
  59569. };
  59570. }
  59571. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  59572. /** @hidden */
  59573. export var volumetricLightScatteringPixelShader: {
  59574. name: string;
  59575. shader: string;
  59576. };
  59577. }
  59578. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  59579. /** @hidden */
  59580. export var volumetricLightScatteringPassPixelShader: {
  59581. name: string;
  59582. shader: string;
  59583. };
  59584. }
  59585. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  59586. import { Vector3 } from "babylonjs/Maths/math";
  59587. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59588. import { Mesh } from "babylonjs/Meshes/mesh";
  59589. import { Camera } from "babylonjs/Cameras/camera";
  59590. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59591. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59592. import { Scene } from "babylonjs/scene";
  59593. import "babylonjs/Meshes/Builders/planeBuilder";
  59594. import "babylonjs/Shaders/depth.vertex";
  59595. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  59596. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  59597. import { Engine } from "babylonjs/Engines/engine";
  59598. /**
  59599. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  59600. */
  59601. export class VolumetricLightScatteringPostProcess extends PostProcess {
  59602. private _volumetricLightScatteringPass;
  59603. private _volumetricLightScatteringRTT;
  59604. private _viewPort;
  59605. private _screenCoordinates;
  59606. private _cachedDefines;
  59607. /**
  59608. * If not undefined, the mesh position is computed from the attached node position
  59609. */
  59610. attachedNode: {
  59611. position: Vector3;
  59612. };
  59613. /**
  59614. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  59615. */
  59616. customMeshPosition: Vector3;
  59617. /**
  59618. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  59619. */
  59620. useCustomMeshPosition: boolean;
  59621. /**
  59622. * If the post-process should inverse the light scattering direction
  59623. */
  59624. invert: boolean;
  59625. /**
  59626. * The internal mesh used by the post-process
  59627. */
  59628. mesh: Mesh;
  59629. /**
  59630. * @hidden
  59631. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  59632. */
  59633. useDiffuseColor: boolean;
  59634. /**
  59635. * Array containing the excluded meshes not rendered in the internal pass
  59636. */
  59637. excludedMeshes: AbstractMesh[];
  59638. /**
  59639. * Controls the overall intensity of the post-process
  59640. */
  59641. exposure: number;
  59642. /**
  59643. * Dissipates each sample's contribution in range [0, 1]
  59644. */
  59645. decay: number;
  59646. /**
  59647. * Controls the overall intensity of each sample
  59648. */
  59649. weight: number;
  59650. /**
  59651. * Controls the density of each sample
  59652. */
  59653. density: number;
  59654. /**
  59655. * @constructor
  59656. * @param name The post-process name
  59657. * @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)
  59658. * @param camera The camera that the post-process will be attached to
  59659. * @param mesh The mesh used to create the light scattering
  59660. * @param samples The post-process quality, default 100
  59661. * @param samplingModeThe post-process filtering mode
  59662. * @param engine The babylon engine
  59663. * @param reusable If the post-process is reusable
  59664. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  59665. */
  59666. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  59667. /**
  59668. * Returns the string "VolumetricLightScatteringPostProcess"
  59669. * @returns "VolumetricLightScatteringPostProcess"
  59670. */
  59671. getClassName(): string;
  59672. private _isReady;
  59673. /**
  59674. * Sets the new light position for light scattering effect
  59675. * @param position The new custom light position
  59676. */
  59677. setCustomMeshPosition(position: Vector3): void;
  59678. /**
  59679. * Returns the light position for light scattering effect
  59680. * @return Vector3 The custom light position
  59681. */
  59682. getCustomMeshPosition(): Vector3;
  59683. /**
  59684. * Disposes the internal assets and detaches the post-process from the camera
  59685. */
  59686. dispose(camera: Camera): void;
  59687. /**
  59688. * Returns the render target texture used by the post-process
  59689. * @return the render target texture used by the post-process
  59690. */
  59691. getPass(): RenderTargetTexture;
  59692. private _meshExcluded;
  59693. private _createPass;
  59694. private _updateMeshScreenCoordinates;
  59695. /**
  59696. * Creates a default mesh for the Volumeric Light Scattering post-process
  59697. * @param name The mesh name
  59698. * @param scene The scene where to create the mesh
  59699. * @return the default mesh
  59700. */
  59701. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  59702. }
  59703. }
  59704. declare module "babylonjs/PostProcesses/index" {
  59705. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  59706. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  59707. export * from "babylonjs/PostProcesses/bloomEffect";
  59708. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  59709. export * from "babylonjs/PostProcesses/blurPostProcess";
  59710. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  59711. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  59712. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  59713. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  59714. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  59715. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  59716. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  59717. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  59718. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  59719. export * from "babylonjs/PostProcesses/filterPostProcess";
  59720. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  59721. export * from "babylonjs/PostProcesses/grainPostProcess";
  59722. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  59723. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  59724. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  59725. export * from "babylonjs/PostProcesses/passPostProcess";
  59726. export * from "babylonjs/PostProcesses/postProcess";
  59727. export * from "babylonjs/PostProcesses/postProcessManager";
  59728. export * from "babylonjs/PostProcesses/refractionPostProcess";
  59729. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  59730. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  59731. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  59732. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  59733. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  59734. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  59735. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  59736. }
  59737. declare module "babylonjs/Probes/index" {
  59738. export * from "babylonjs/Probes/reflectionProbe";
  59739. }
  59740. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  59741. import { Scene } from "babylonjs/scene";
  59742. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59743. import { Color3 } from "babylonjs/Maths/math";
  59744. import { SmartArray } from "babylonjs/Misc/smartArray";
  59745. import { ISceneComponent } from "babylonjs/sceneComponent";
  59746. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  59747. import "babylonjs/Meshes/Builders/boxBuilder";
  59748. import "babylonjs/Shaders/color.fragment";
  59749. import "babylonjs/Shaders/color.vertex";
  59750. module "babylonjs/scene" {
  59751. interface Scene {
  59752. /** @hidden (Backing field) */
  59753. _boundingBoxRenderer: BoundingBoxRenderer;
  59754. /** @hidden (Backing field) */
  59755. _forceShowBoundingBoxes: boolean;
  59756. /**
  59757. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  59758. */
  59759. forceShowBoundingBoxes: boolean;
  59760. /**
  59761. * Gets the bounding box renderer associated with the scene
  59762. * @returns a BoundingBoxRenderer
  59763. */
  59764. getBoundingBoxRenderer(): BoundingBoxRenderer;
  59765. }
  59766. }
  59767. module "babylonjs/Meshes/abstractMesh" {
  59768. interface AbstractMesh {
  59769. /** @hidden (Backing field) */
  59770. _showBoundingBox: boolean;
  59771. /**
  59772. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  59773. */
  59774. showBoundingBox: boolean;
  59775. }
  59776. }
  59777. /**
  59778. * Component responsible of rendering the bounding box of the meshes in a scene.
  59779. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  59780. */
  59781. export class BoundingBoxRenderer implements ISceneComponent {
  59782. /**
  59783. * The component name helpfull to identify the component in the list of scene components.
  59784. */
  59785. readonly name: string;
  59786. /**
  59787. * The scene the component belongs to.
  59788. */
  59789. scene: Scene;
  59790. /**
  59791. * Color of the bounding box lines placed in front of an object
  59792. */
  59793. frontColor: Color3;
  59794. /**
  59795. * Color of the bounding box lines placed behind an object
  59796. */
  59797. backColor: Color3;
  59798. /**
  59799. * Defines if the renderer should show the back lines or not
  59800. */
  59801. showBackLines: boolean;
  59802. /**
  59803. * @hidden
  59804. */
  59805. renderList: SmartArray<BoundingBox>;
  59806. private _colorShader;
  59807. private _vertexBuffers;
  59808. private _indexBuffer;
  59809. private _fillIndexBuffer;
  59810. private _fillIndexData;
  59811. /**
  59812. * Instantiates a new bounding box renderer in a scene.
  59813. * @param scene the scene the renderer renders in
  59814. */
  59815. constructor(scene: Scene);
  59816. /**
  59817. * Registers the component in a given scene
  59818. */
  59819. register(): void;
  59820. private _evaluateSubMesh;
  59821. private _activeMesh;
  59822. private _prepareRessources;
  59823. private _createIndexBuffer;
  59824. /**
  59825. * Rebuilds the elements related to this component in case of
  59826. * context lost for instance.
  59827. */
  59828. rebuild(): void;
  59829. /**
  59830. * @hidden
  59831. */
  59832. reset(): void;
  59833. /**
  59834. * Render the bounding boxes of a specific rendering group
  59835. * @param renderingGroupId defines the rendering group to render
  59836. */
  59837. render(renderingGroupId: number): void;
  59838. /**
  59839. * In case of occlusion queries, we can render the occlusion bounding box through this method
  59840. * @param mesh Define the mesh to render the occlusion bounding box for
  59841. */
  59842. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  59843. /**
  59844. * Dispose and release the resources attached to this renderer.
  59845. */
  59846. dispose(): void;
  59847. }
  59848. }
  59849. declare module "babylonjs/Shaders/depth.fragment" {
  59850. /** @hidden */
  59851. export var depthPixelShader: {
  59852. name: string;
  59853. shader: string;
  59854. };
  59855. }
  59856. declare module "babylonjs/Rendering/depthRenderer" {
  59857. import { Nullable } from "babylonjs/types";
  59858. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59859. import { Scene } from "babylonjs/scene";
  59860. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59861. import { Camera } from "babylonjs/Cameras/camera";
  59862. import "babylonjs/Shaders/depth.fragment";
  59863. import "babylonjs/Shaders/depth.vertex";
  59864. /**
  59865. * This represents a depth renderer in Babylon.
  59866. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  59867. */
  59868. export class DepthRenderer {
  59869. private _scene;
  59870. private _depthMap;
  59871. private _effect;
  59872. private _cachedDefines;
  59873. private _camera;
  59874. /**
  59875. * Specifiess that the depth renderer will only be used within
  59876. * the camera it is created for.
  59877. * This can help forcing its rendering during the camera processing.
  59878. */
  59879. useOnlyInActiveCamera: boolean;
  59880. /** @hidden */
  59881. static _SceneComponentInitialization: (scene: Scene) => void;
  59882. /**
  59883. * Instantiates a depth renderer
  59884. * @param scene The scene the renderer belongs to
  59885. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  59886. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  59887. */
  59888. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  59889. /**
  59890. * Creates the depth rendering effect and checks if the effect is ready.
  59891. * @param subMesh The submesh to be used to render the depth map of
  59892. * @param useInstances If multiple world instances should be used
  59893. * @returns if the depth renderer is ready to render the depth map
  59894. */
  59895. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59896. /**
  59897. * Gets the texture which the depth map will be written to.
  59898. * @returns The depth map texture
  59899. */
  59900. getDepthMap(): RenderTargetTexture;
  59901. /**
  59902. * Disposes of the depth renderer.
  59903. */
  59904. dispose(): void;
  59905. }
  59906. }
  59907. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  59908. import { Nullable } from "babylonjs/types";
  59909. import { Scene } from "babylonjs/scene";
  59910. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  59911. import { Camera } from "babylonjs/Cameras/camera";
  59912. import { ISceneComponent } from "babylonjs/sceneComponent";
  59913. module "babylonjs/scene" {
  59914. interface Scene {
  59915. /** @hidden (Backing field) */
  59916. _depthRenderer: {
  59917. [id: string]: DepthRenderer;
  59918. };
  59919. /**
  59920. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  59921. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  59922. * @returns the created depth renderer
  59923. */
  59924. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  59925. /**
  59926. * Disables a depth renderer for a given camera
  59927. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  59928. */
  59929. disableDepthRenderer(camera?: Nullable<Camera>): void;
  59930. }
  59931. }
  59932. /**
  59933. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  59934. * in several rendering techniques.
  59935. */
  59936. export class DepthRendererSceneComponent implements ISceneComponent {
  59937. /**
  59938. * The component name helpfull to identify the component in the list of scene components.
  59939. */
  59940. readonly name: string;
  59941. /**
  59942. * The scene the component belongs to.
  59943. */
  59944. scene: Scene;
  59945. /**
  59946. * Creates a new instance of the component for the given scene
  59947. * @param scene Defines the scene to register the component in
  59948. */
  59949. constructor(scene: Scene);
  59950. /**
  59951. * Registers the component in a given scene
  59952. */
  59953. register(): void;
  59954. /**
  59955. * Rebuilds the elements related to this component in case of
  59956. * context lost for instance.
  59957. */
  59958. rebuild(): void;
  59959. /**
  59960. * Disposes the component and the associated ressources
  59961. */
  59962. dispose(): void;
  59963. private _gatherRenderTargets;
  59964. private _gatherActiveCameraRenderTargets;
  59965. }
  59966. }
  59967. declare module "babylonjs/Shaders/outline.fragment" {
  59968. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  59969. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  59970. /** @hidden */
  59971. export var outlinePixelShader: {
  59972. name: string;
  59973. shader: string;
  59974. };
  59975. }
  59976. declare module "babylonjs/Shaders/outline.vertex" {
  59977. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59978. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59979. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  59980. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59981. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59982. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  59983. /** @hidden */
  59984. export var outlineVertexShader: {
  59985. name: string;
  59986. shader: string;
  59987. };
  59988. }
  59989. declare module "babylonjs/Rendering/outlineRenderer" {
  59990. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59991. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  59992. import { Scene } from "babylonjs/scene";
  59993. import { ISceneComponent } from "babylonjs/sceneComponent";
  59994. import "babylonjs/Shaders/outline.fragment";
  59995. import "babylonjs/Shaders/outline.vertex";
  59996. module "babylonjs/scene" {
  59997. interface Scene {
  59998. /** @hidden */
  59999. _outlineRenderer: OutlineRenderer;
  60000. /**
  60001. * Gets the outline renderer associated with the scene
  60002. * @returns a OutlineRenderer
  60003. */
  60004. getOutlineRenderer(): OutlineRenderer;
  60005. }
  60006. }
  60007. module "babylonjs/Meshes/abstractMesh" {
  60008. interface AbstractMesh {
  60009. /** @hidden (Backing field) */
  60010. _renderOutline: boolean;
  60011. /**
  60012. * Gets or sets a boolean indicating if the outline must be rendered as well
  60013. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  60014. */
  60015. renderOutline: boolean;
  60016. /** @hidden (Backing field) */
  60017. _renderOverlay: boolean;
  60018. /**
  60019. * Gets or sets a boolean indicating if the overlay must be rendered as well
  60020. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  60021. */
  60022. renderOverlay: boolean;
  60023. }
  60024. }
  60025. /**
  60026. * This class is responsible to draw bothe outline/overlay of meshes.
  60027. * It should not be used directly but through the available method on mesh.
  60028. */
  60029. export class OutlineRenderer implements ISceneComponent {
  60030. /**
  60031. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  60032. */
  60033. private static _StencilReference;
  60034. /**
  60035. * The name of the component. Each component must have a unique name.
  60036. */
  60037. name: string;
  60038. /**
  60039. * The scene the component belongs to.
  60040. */
  60041. scene: Scene;
  60042. /**
  60043. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  60044. */
  60045. zOffset: number;
  60046. private _engine;
  60047. private _effect;
  60048. private _cachedDefines;
  60049. private _savedDepthWrite;
  60050. /**
  60051. * Instantiates a new outline renderer. (There could be only one per scene).
  60052. * @param scene Defines the scene it belongs to
  60053. */
  60054. constructor(scene: Scene);
  60055. /**
  60056. * Register the component to one instance of a scene.
  60057. */
  60058. register(): void;
  60059. /**
  60060. * Rebuilds the elements related to this component in case of
  60061. * context lost for instance.
  60062. */
  60063. rebuild(): void;
  60064. /**
  60065. * Disposes the component and the associated ressources.
  60066. */
  60067. dispose(): void;
  60068. /**
  60069. * Renders the outline in the canvas.
  60070. * @param subMesh Defines the sumesh to render
  60071. * @param batch Defines the batch of meshes in case of instances
  60072. * @param useOverlay Defines if the rendering is for the overlay or the outline
  60073. */
  60074. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  60075. /**
  60076. * Returns whether or not the outline renderer is ready for a given submesh.
  60077. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  60078. * @param subMesh Defines the submesh to check readyness for
  60079. * @param useInstances Defines wheter wee are trying to render instances or not
  60080. * @returns true if ready otherwise false
  60081. */
  60082. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60083. private _beforeRenderingMesh;
  60084. private _afterRenderingMesh;
  60085. }
  60086. }
  60087. declare module "babylonjs/Rendering/index" {
  60088. export * from "babylonjs/Rendering/boundingBoxRenderer";
  60089. export * from "babylonjs/Rendering/depthRenderer";
  60090. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  60091. export * from "babylonjs/Rendering/edgesRenderer";
  60092. export * from "babylonjs/Rendering/geometryBufferRenderer";
  60093. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  60094. export * from "babylonjs/Rendering/outlineRenderer";
  60095. export * from "babylonjs/Rendering/renderingGroup";
  60096. export * from "babylonjs/Rendering/renderingManager";
  60097. export * from "babylonjs/Rendering/utilityLayerRenderer";
  60098. }
  60099. declare module "babylonjs/Sprites/index" {
  60100. export * from "babylonjs/Sprites/sprite";
  60101. export * from "babylonjs/Sprites/spriteManager";
  60102. export * from "babylonjs/Sprites/spriteSceneComponent";
  60103. }
  60104. declare module "babylonjs/Misc/assetsManager" {
  60105. import { Scene } from "babylonjs/scene";
  60106. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60107. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60108. import { Skeleton } from "babylonjs/Bones/skeleton";
  60109. import { Observable } from "babylonjs/Misc/observable";
  60110. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60111. import { Texture } from "babylonjs/Materials/Textures/texture";
  60112. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  60113. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  60114. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  60115. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  60116. /**
  60117. * Defines the list of states available for a task inside a AssetsManager
  60118. */
  60119. export enum AssetTaskState {
  60120. /**
  60121. * Initialization
  60122. */
  60123. INIT = 0,
  60124. /**
  60125. * Running
  60126. */
  60127. RUNNING = 1,
  60128. /**
  60129. * Done
  60130. */
  60131. DONE = 2,
  60132. /**
  60133. * Error
  60134. */
  60135. ERROR = 3
  60136. }
  60137. /**
  60138. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  60139. */
  60140. export abstract class AbstractAssetTask {
  60141. /**
  60142. * Task name
  60143. */ name: string;
  60144. /**
  60145. * Callback called when the task is successful
  60146. */
  60147. onSuccess: (task: any) => void;
  60148. /**
  60149. * Callback called when the task is not successful
  60150. */
  60151. onError: (task: any, message?: string, exception?: any) => void;
  60152. /**
  60153. * Creates a new AssetsManager
  60154. * @param name defines the name of the task
  60155. */
  60156. constructor(
  60157. /**
  60158. * Task name
  60159. */ name: string);
  60160. private _isCompleted;
  60161. private _taskState;
  60162. private _errorObject;
  60163. /**
  60164. * Get if the task is completed
  60165. */
  60166. readonly isCompleted: boolean;
  60167. /**
  60168. * Gets the current state of the task
  60169. */
  60170. readonly taskState: AssetTaskState;
  60171. /**
  60172. * Gets the current error object (if task is in error)
  60173. */
  60174. readonly errorObject: {
  60175. message?: string;
  60176. exception?: any;
  60177. };
  60178. /**
  60179. * Internal only
  60180. * @hidden
  60181. */
  60182. _setErrorObject(message?: string, exception?: any): void;
  60183. /**
  60184. * Execute the current task
  60185. * @param scene defines the scene where you want your assets to be loaded
  60186. * @param onSuccess is a callback called when the task is successfully executed
  60187. * @param onError is a callback called if an error occurs
  60188. */
  60189. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60190. /**
  60191. * Execute the current task
  60192. * @param scene defines the scene where you want your assets to be loaded
  60193. * @param onSuccess is a callback called when the task is successfully executed
  60194. * @param onError is a callback called if an error occurs
  60195. */
  60196. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60197. /**
  60198. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  60199. * This can be used with failed tasks that have the reason for failure fixed.
  60200. */
  60201. reset(): void;
  60202. private onErrorCallback;
  60203. private onDoneCallback;
  60204. }
  60205. /**
  60206. * Define the interface used by progress events raised during assets loading
  60207. */
  60208. export interface IAssetsProgressEvent {
  60209. /**
  60210. * Defines the number of remaining tasks to process
  60211. */
  60212. remainingCount: number;
  60213. /**
  60214. * Defines the total number of tasks
  60215. */
  60216. totalCount: number;
  60217. /**
  60218. * Defines the task that was just processed
  60219. */
  60220. task: AbstractAssetTask;
  60221. }
  60222. /**
  60223. * Class used to share progress information about assets loading
  60224. */
  60225. export class AssetsProgressEvent implements IAssetsProgressEvent {
  60226. /**
  60227. * Defines the number of remaining tasks to process
  60228. */
  60229. remainingCount: number;
  60230. /**
  60231. * Defines the total number of tasks
  60232. */
  60233. totalCount: number;
  60234. /**
  60235. * Defines the task that was just processed
  60236. */
  60237. task: AbstractAssetTask;
  60238. /**
  60239. * Creates a AssetsProgressEvent
  60240. * @param remainingCount defines the number of remaining tasks to process
  60241. * @param totalCount defines the total number of tasks
  60242. * @param task defines the task that was just processed
  60243. */
  60244. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  60245. }
  60246. /**
  60247. * Define a task used by AssetsManager to load meshes
  60248. */
  60249. export class MeshAssetTask extends AbstractAssetTask {
  60250. /**
  60251. * Defines the name of the task
  60252. */
  60253. name: string;
  60254. /**
  60255. * Defines the list of mesh's names you want to load
  60256. */
  60257. meshesNames: any;
  60258. /**
  60259. * Defines the root url to use as a base to load your meshes and associated resources
  60260. */
  60261. rootUrl: string;
  60262. /**
  60263. * Defines the filename of the scene to load from
  60264. */
  60265. sceneFilename: string;
  60266. /**
  60267. * Gets the list of loaded meshes
  60268. */
  60269. loadedMeshes: Array<AbstractMesh>;
  60270. /**
  60271. * Gets the list of loaded particle systems
  60272. */
  60273. loadedParticleSystems: Array<IParticleSystem>;
  60274. /**
  60275. * Gets the list of loaded skeletons
  60276. */
  60277. loadedSkeletons: Array<Skeleton>;
  60278. /**
  60279. * Gets the list of loaded animation groups
  60280. */
  60281. loadedAnimationGroups: Array<AnimationGroup>;
  60282. /**
  60283. * Callback called when the task is successful
  60284. */
  60285. onSuccess: (task: MeshAssetTask) => void;
  60286. /**
  60287. * Callback called when the task is successful
  60288. */
  60289. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  60290. /**
  60291. * Creates a new MeshAssetTask
  60292. * @param name defines the name of the task
  60293. * @param meshesNames defines the list of mesh's names you want to load
  60294. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  60295. * @param sceneFilename defines the filename of the scene to load from
  60296. */
  60297. constructor(
  60298. /**
  60299. * Defines the name of the task
  60300. */
  60301. name: string,
  60302. /**
  60303. * Defines the list of mesh's names you want to load
  60304. */
  60305. meshesNames: any,
  60306. /**
  60307. * Defines the root url to use as a base to load your meshes and associated resources
  60308. */
  60309. rootUrl: string,
  60310. /**
  60311. * Defines the filename of the scene to load from
  60312. */
  60313. sceneFilename: string);
  60314. /**
  60315. * Execute the current task
  60316. * @param scene defines the scene where you want your assets to be loaded
  60317. * @param onSuccess is a callback called when the task is successfully executed
  60318. * @param onError is a callback called if an error occurs
  60319. */
  60320. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60321. }
  60322. /**
  60323. * Define a task used by AssetsManager to load text content
  60324. */
  60325. export class TextFileAssetTask extends AbstractAssetTask {
  60326. /**
  60327. * Defines the name of the task
  60328. */
  60329. name: string;
  60330. /**
  60331. * Defines the location of the file to load
  60332. */
  60333. url: string;
  60334. /**
  60335. * Gets the loaded text string
  60336. */
  60337. text: string;
  60338. /**
  60339. * Callback called when the task is successful
  60340. */
  60341. onSuccess: (task: TextFileAssetTask) => void;
  60342. /**
  60343. * Callback called when the task is successful
  60344. */
  60345. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  60346. /**
  60347. * Creates a new TextFileAssetTask object
  60348. * @param name defines the name of the task
  60349. * @param url defines the location of the file to load
  60350. */
  60351. constructor(
  60352. /**
  60353. * Defines the name of the task
  60354. */
  60355. name: string,
  60356. /**
  60357. * Defines the location of the file to load
  60358. */
  60359. url: string);
  60360. /**
  60361. * Execute the current task
  60362. * @param scene defines the scene where you want your assets to be loaded
  60363. * @param onSuccess is a callback called when the task is successfully executed
  60364. * @param onError is a callback called if an error occurs
  60365. */
  60366. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60367. }
  60368. /**
  60369. * Define a task used by AssetsManager to load binary data
  60370. */
  60371. export class BinaryFileAssetTask extends AbstractAssetTask {
  60372. /**
  60373. * Defines the name of the task
  60374. */
  60375. name: string;
  60376. /**
  60377. * Defines the location of the file to load
  60378. */
  60379. url: string;
  60380. /**
  60381. * Gets the lodaded data (as an array buffer)
  60382. */
  60383. data: ArrayBuffer;
  60384. /**
  60385. * Callback called when the task is successful
  60386. */
  60387. onSuccess: (task: BinaryFileAssetTask) => void;
  60388. /**
  60389. * Callback called when the task is successful
  60390. */
  60391. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  60392. /**
  60393. * Creates a new BinaryFileAssetTask object
  60394. * @param name defines the name of the new task
  60395. * @param url defines the location of the file to load
  60396. */
  60397. constructor(
  60398. /**
  60399. * Defines the name of the task
  60400. */
  60401. name: string,
  60402. /**
  60403. * Defines the location of the file to load
  60404. */
  60405. url: string);
  60406. /**
  60407. * Execute the current task
  60408. * @param scene defines the scene where you want your assets to be loaded
  60409. * @param onSuccess is a callback called when the task is successfully executed
  60410. * @param onError is a callback called if an error occurs
  60411. */
  60412. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60413. }
  60414. /**
  60415. * Define a task used by AssetsManager to load images
  60416. */
  60417. export class ImageAssetTask extends AbstractAssetTask {
  60418. /**
  60419. * Defines the name of the task
  60420. */
  60421. name: string;
  60422. /**
  60423. * Defines the location of the image to load
  60424. */
  60425. url: string;
  60426. /**
  60427. * Gets the loaded images
  60428. */
  60429. image: HTMLImageElement;
  60430. /**
  60431. * Callback called when the task is successful
  60432. */
  60433. onSuccess: (task: ImageAssetTask) => void;
  60434. /**
  60435. * Callback called when the task is successful
  60436. */
  60437. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  60438. /**
  60439. * Creates a new ImageAssetTask
  60440. * @param name defines the name of the task
  60441. * @param url defines the location of the image to load
  60442. */
  60443. constructor(
  60444. /**
  60445. * Defines the name of the task
  60446. */
  60447. name: string,
  60448. /**
  60449. * Defines the location of the image to load
  60450. */
  60451. url: string);
  60452. /**
  60453. * Execute the current task
  60454. * @param scene defines the scene where you want your assets to be loaded
  60455. * @param onSuccess is a callback called when the task is successfully executed
  60456. * @param onError is a callback called if an error occurs
  60457. */
  60458. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60459. }
  60460. /**
  60461. * Defines the interface used by texture loading tasks
  60462. */
  60463. export interface ITextureAssetTask<TEX extends BaseTexture> {
  60464. /**
  60465. * Gets the loaded texture
  60466. */
  60467. texture: TEX;
  60468. }
  60469. /**
  60470. * Define a task used by AssetsManager to load 2D textures
  60471. */
  60472. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  60473. /**
  60474. * Defines the name of the task
  60475. */
  60476. name: string;
  60477. /**
  60478. * Defines the location of the file to load
  60479. */
  60480. url: string;
  60481. /**
  60482. * Defines if mipmap should not be generated (default is false)
  60483. */
  60484. noMipmap?: boolean | undefined;
  60485. /**
  60486. * Defines if texture must be inverted on Y axis (default is false)
  60487. */
  60488. invertY?: boolean | undefined;
  60489. /**
  60490. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60491. */
  60492. samplingMode: number;
  60493. /**
  60494. * Gets the loaded texture
  60495. */
  60496. texture: Texture;
  60497. /**
  60498. * Callback called when the task is successful
  60499. */
  60500. onSuccess: (task: TextureAssetTask) => void;
  60501. /**
  60502. * Callback called when the task is successful
  60503. */
  60504. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  60505. /**
  60506. * Creates a new TextureAssetTask object
  60507. * @param name defines the name of the task
  60508. * @param url defines the location of the file to load
  60509. * @param noMipmap defines if mipmap should not be generated (default is false)
  60510. * @param invertY defines if texture must be inverted on Y axis (default is false)
  60511. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60512. */
  60513. constructor(
  60514. /**
  60515. * Defines the name of the task
  60516. */
  60517. name: string,
  60518. /**
  60519. * Defines the location of the file to load
  60520. */
  60521. url: string,
  60522. /**
  60523. * Defines if mipmap should not be generated (default is false)
  60524. */
  60525. noMipmap?: boolean | undefined,
  60526. /**
  60527. * Defines if texture must be inverted on Y axis (default is false)
  60528. */
  60529. invertY?: boolean | undefined,
  60530. /**
  60531. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60532. */
  60533. samplingMode?: number);
  60534. /**
  60535. * Execute the current task
  60536. * @param scene defines the scene where you want your assets to be loaded
  60537. * @param onSuccess is a callback called when the task is successfully executed
  60538. * @param onError is a callback called if an error occurs
  60539. */
  60540. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60541. }
  60542. /**
  60543. * Define a task used by AssetsManager to load cube textures
  60544. */
  60545. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  60546. /**
  60547. * Defines the name of the task
  60548. */
  60549. name: string;
  60550. /**
  60551. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60552. */
  60553. url: string;
  60554. /**
  60555. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60556. */
  60557. extensions?: string[] | undefined;
  60558. /**
  60559. * Defines if mipmaps should not be generated (default is false)
  60560. */
  60561. noMipmap?: boolean | undefined;
  60562. /**
  60563. * Defines the explicit list of files (undefined by default)
  60564. */
  60565. files?: string[] | undefined;
  60566. /**
  60567. * Gets the loaded texture
  60568. */
  60569. texture: CubeTexture;
  60570. /**
  60571. * Callback called when the task is successful
  60572. */
  60573. onSuccess: (task: CubeTextureAssetTask) => void;
  60574. /**
  60575. * Callback called when the task is successful
  60576. */
  60577. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  60578. /**
  60579. * Creates a new CubeTextureAssetTask
  60580. * @param name defines the name of the task
  60581. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60582. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60583. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60584. * @param files defines the explicit list of files (undefined by default)
  60585. */
  60586. constructor(
  60587. /**
  60588. * Defines the name of the task
  60589. */
  60590. name: string,
  60591. /**
  60592. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60593. */
  60594. url: string,
  60595. /**
  60596. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60597. */
  60598. extensions?: string[] | undefined,
  60599. /**
  60600. * Defines if mipmaps should not be generated (default is false)
  60601. */
  60602. noMipmap?: boolean | undefined,
  60603. /**
  60604. * Defines the explicit list of files (undefined by default)
  60605. */
  60606. files?: string[] | undefined);
  60607. /**
  60608. * Execute the current task
  60609. * @param scene defines the scene where you want your assets to be loaded
  60610. * @param onSuccess is a callback called when the task is successfully executed
  60611. * @param onError is a callback called if an error occurs
  60612. */
  60613. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60614. }
  60615. /**
  60616. * Define a task used by AssetsManager to load HDR cube textures
  60617. */
  60618. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  60619. /**
  60620. * Defines the name of the task
  60621. */
  60622. name: string;
  60623. /**
  60624. * Defines the location of the file to load
  60625. */
  60626. url: string;
  60627. /**
  60628. * Defines the desired size (the more it increases the longer the generation will be)
  60629. */
  60630. size: number;
  60631. /**
  60632. * Defines if mipmaps should not be generated (default is false)
  60633. */
  60634. noMipmap: boolean;
  60635. /**
  60636. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60637. */
  60638. generateHarmonics: boolean;
  60639. /**
  60640. * 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)
  60641. */
  60642. gammaSpace: boolean;
  60643. /**
  60644. * Internal Use Only
  60645. */
  60646. reserved: boolean;
  60647. /**
  60648. * Gets the loaded texture
  60649. */
  60650. texture: HDRCubeTexture;
  60651. /**
  60652. * Callback called when the task is successful
  60653. */
  60654. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  60655. /**
  60656. * Callback called when the task is successful
  60657. */
  60658. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  60659. /**
  60660. * Creates a new HDRCubeTextureAssetTask object
  60661. * @param name defines the name of the task
  60662. * @param url defines the location of the file to load
  60663. * @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.
  60664. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60665. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60666. * @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)
  60667. * @param reserved Internal use only
  60668. */
  60669. constructor(
  60670. /**
  60671. * Defines the name of the task
  60672. */
  60673. name: string,
  60674. /**
  60675. * Defines the location of the file to load
  60676. */
  60677. url: string,
  60678. /**
  60679. * Defines the desired size (the more it increases the longer the generation will be)
  60680. */
  60681. size: number,
  60682. /**
  60683. * Defines if mipmaps should not be generated (default is false)
  60684. */
  60685. noMipmap?: boolean,
  60686. /**
  60687. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60688. */
  60689. generateHarmonics?: boolean,
  60690. /**
  60691. * 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)
  60692. */
  60693. gammaSpace?: boolean,
  60694. /**
  60695. * Internal Use Only
  60696. */
  60697. reserved?: boolean);
  60698. /**
  60699. * Execute the current task
  60700. * @param scene defines the scene where you want your assets to be loaded
  60701. * @param onSuccess is a callback called when the task is successfully executed
  60702. * @param onError is a callback called if an error occurs
  60703. */
  60704. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60705. }
  60706. /**
  60707. * Define a task used by AssetsManager to load Equirectangular cube textures
  60708. */
  60709. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  60710. /**
  60711. * Defines the name of the task
  60712. */
  60713. name: string;
  60714. /**
  60715. * Defines the location of the file to load
  60716. */
  60717. url: string;
  60718. /**
  60719. * Defines the desired size (the more it increases the longer the generation will be)
  60720. */
  60721. size: number;
  60722. /**
  60723. * Defines if mipmaps should not be generated (default is false)
  60724. */
  60725. noMipmap: boolean;
  60726. /**
  60727. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  60728. * but the standard material would require them in Gamma space) (default is true)
  60729. */
  60730. gammaSpace: boolean;
  60731. /**
  60732. * Gets the loaded texture
  60733. */
  60734. texture: EquiRectangularCubeTexture;
  60735. /**
  60736. * Callback called when the task is successful
  60737. */
  60738. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  60739. /**
  60740. * Callback called when the task is successful
  60741. */
  60742. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  60743. /**
  60744. * Creates a new EquiRectangularCubeTextureAssetTask object
  60745. * @param name defines the name of the task
  60746. * @param url defines the location of the file to load
  60747. * @param size defines the desired size (the more it increases the longer the generation will be)
  60748. * If the size is omitted this implies you are using a preprocessed cubemap.
  60749. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60750. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  60751. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  60752. * (default is true)
  60753. */
  60754. constructor(
  60755. /**
  60756. * Defines the name of the task
  60757. */
  60758. name: string,
  60759. /**
  60760. * Defines the location of the file to load
  60761. */
  60762. url: string,
  60763. /**
  60764. * Defines the desired size (the more it increases the longer the generation will be)
  60765. */
  60766. size: number,
  60767. /**
  60768. * Defines if mipmaps should not be generated (default is false)
  60769. */
  60770. noMipmap?: boolean,
  60771. /**
  60772. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  60773. * but the standard material would require them in Gamma space) (default is true)
  60774. */
  60775. gammaSpace?: boolean);
  60776. /**
  60777. * Execute the current task
  60778. * @param scene defines the scene where you want your assets to be loaded
  60779. * @param onSuccess is a callback called when the task is successfully executed
  60780. * @param onError is a callback called if an error occurs
  60781. */
  60782. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60783. }
  60784. /**
  60785. * This class can be used to easily import assets into a scene
  60786. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  60787. */
  60788. export class AssetsManager {
  60789. private _scene;
  60790. private _isLoading;
  60791. protected _tasks: AbstractAssetTask[];
  60792. protected _waitingTasksCount: number;
  60793. protected _totalTasksCount: number;
  60794. /**
  60795. * Callback called when all tasks are processed
  60796. */
  60797. onFinish: (tasks: AbstractAssetTask[]) => void;
  60798. /**
  60799. * Callback called when a task is successful
  60800. */
  60801. onTaskSuccess: (task: AbstractAssetTask) => void;
  60802. /**
  60803. * Callback called when a task had an error
  60804. */
  60805. onTaskError: (task: AbstractAssetTask) => void;
  60806. /**
  60807. * Callback called when a task is done (whatever the result is)
  60808. */
  60809. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  60810. /**
  60811. * Observable called when all tasks are processed
  60812. */
  60813. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  60814. /**
  60815. * Observable called when a task had an error
  60816. */
  60817. onTaskErrorObservable: Observable<AbstractAssetTask>;
  60818. /**
  60819. * Observable called when all tasks were executed
  60820. */
  60821. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  60822. /**
  60823. * Observable called when a task is done (whatever the result is)
  60824. */
  60825. onProgressObservable: Observable<IAssetsProgressEvent>;
  60826. /**
  60827. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  60828. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  60829. */
  60830. useDefaultLoadingScreen: boolean;
  60831. /**
  60832. * Creates a new AssetsManager
  60833. * @param scene defines the scene to work on
  60834. */
  60835. constructor(scene: Scene);
  60836. /**
  60837. * Add a MeshAssetTask to the list of active tasks
  60838. * @param taskName defines the name of the new task
  60839. * @param meshesNames defines the name of meshes to load
  60840. * @param rootUrl defines the root url to use to locate files
  60841. * @param sceneFilename defines the filename of the scene file
  60842. * @returns a new MeshAssetTask object
  60843. */
  60844. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  60845. /**
  60846. * Add a TextFileAssetTask to the list of active tasks
  60847. * @param taskName defines the name of the new task
  60848. * @param url defines the url of the file to load
  60849. * @returns a new TextFileAssetTask object
  60850. */
  60851. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  60852. /**
  60853. * Add a BinaryFileAssetTask to the list of active tasks
  60854. * @param taskName defines the name of the new task
  60855. * @param url defines the url of the file to load
  60856. * @returns a new BinaryFileAssetTask object
  60857. */
  60858. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  60859. /**
  60860. * Add a ImageAssetTask to the list of active tasks
  60861. * @param taskName defines the name of the new task
  60862. * @param url defines the url of the file to load
  60863. * @returns a new ImageAssetTask object
  60864. */
  60865. addImageTask(taskName: string, url: string): ImageAssetTask;
  60866. /**
  60867. * Add a TextureAssetTask to the list of active tasks
  60868. * @param taskName defines the name of the new task
  60869. * @param url defines the url of the file to load
  60870. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60871. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  60872. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60873. * @returns a new TextureAssetTask object
  60874. */
  60875. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  60876. /**
  60877. * Add a CubeTextureAssetTask to the list of active tasks
  60878. * @param taskName defines the name of the new task
  60879. * @param url defines the url of the file to load
  60880. * @param extensions defines the extension to use to load the cube map (can be null)
  60881. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60882. * @param files defines the list of files to load (can be null)
  60883. * @returns a new CubeTextureAssetTask object
  60884. */
  60885. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  60886. /**
  60887. *
  60888. * Add a HDRCubeTextureAssetTask to the list of active tasks
  60889. * @param taskName defines the name of the new task
  60890. * @param url defines the url of the file to load
  60891. * @param size defines the size you want for the cubemap (can be null)
  60892. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60893. * @param generateHarmonics defines if you want to automatically generate (true by default)
  60894. * @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)
  60895. * @param reserved Internal use only
  60896. * @returns a new HDRCubeTextureAssetTask object
  60897. */
  60898. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  60899. /**
  60900. *
  60901. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  60902. * @param taskName defines the name of the new task
  60903. * @param url defines the url of the file to load
  60904. * @param size defines the size you want for the cubemap (can be null)
  60905. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60906. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  60907. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  60908. * @returns a new EquiRectangularCubeTextureAssetTask object
  60909. */
  60910. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  60911. /**
  60912. * Remove a task from the assets manager.
  60913. * @param task the task to remove
  60914. */
  60915. removeTask(task: AbstractAssetTask): void;
  60916. private _decreaseWaitingTasksCount;
  60917. private _runTask;
  60918. /**
  60919. * Reset the AssetsManager and remove all tasks
  60920. * @return the current instance of the AssetsManager
  60921. */
  60922. reset(): AssetsManager;
  60923. /**
  60924. * Start the loading process
  60925. * @return the current instance of the AssetsManager
  60926. */
  60927. load(): AssetsManager;
  60928. /**
  60929. * Start the loading process as an async operation
  60930. * @return a promise returning the list of failed tasks
  60931. */
  60932. loadAsync(): Promise<void>;
  60933. }
  60934. }
  60935. declare module "babylonjs/Misc/deferred" {
  60936. /**
  60937. * Wrapper class for promise with external resolve and reject.
  60938. */
  60939. export class Deferred<T> {
  60940. /**
  60941. * The promise associated with this deferred object.
  60942. */
  60943. readonly promise: Promise<T>;
  60944. private _resolve;
  60945. private _reject;
  60946. /**
  60947. * The resolve method of the promise associated with this deferred object.
  60948. */
  60949. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  60950. /**
  60951. * The reject method of the promise associated with this deferred object.
  60952. */
  60953. readonly reject: (reason?: any) => void;
  60954. /**
  60955. * Constructor for this deferred object.
  60956. */
  60957. constructor();
  60958. }
  60959. }
  60960. declare module "babylonjs/Misc/meshExploder" {
  60961. import { Mesh } from "babylonjs/Meshes/mesh";
  60962. /**
  60963. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  60964. */
  60965. export class MeshExploder {
  60966. private _centerMesh;
  60967. private _meshes;
  60968. private _meshesOrigins;
  60969. private _toCenterVectors;
  60970. private _scaledDirection;
  60971. private _newPosition;
  60972. private _centerPosition;
  60973. /**
  60974. * Explodes meshes from a center mesh.
  60975. * @param meshes The meshes to explode.
  60976. * @param centerMesh The mesh to be center of explosion.
  60977. */
  60978. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  60979. private _setCenterMesh;
  60980. /**
  60981. * Get class name
  60982. * @returns "MeshExploder"
  60983. */
  60984. getClassName(): string;
  60985. /**
  60986. * "Exploded meshes"
  60987. * @returns Array of meshes with the centerMesh at index 0.
  60988. */
  60989. getMeshes(): Array<Mesh>;
  60990. /**
  60991. * Explodes meshes giving a specific direction
  60992. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  60993. */
  60994. explode(direction?: number): void;
  60995. }
  60996. }
  60997. declare module "babylonjs/Misc/filesInput" {
  60998. import { Engine } from "babylonjs/Engines/engine";
  60999. import { Scene } from "babylonjs/scene";
  61000. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  61001. /**
  61002. * Class used to help managing file picking and drag'n'drop
  61003. */
  61004. export class FilesInput {
  61005. /**
  61006. * List of files ready to be loaded
  61007. */
  61008. static readonly FilesToLoad: {
  61009. [key: string]: File;
  61010. };
  61011. /**
  61012. * Callback called when a file is processed
  61013. */
  61014. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  61015. private _engine;
  61016. private _currentScene;
  61017. private _sceneLoadedCallback;
  61018. private _progressCallback;
  61019. private _additionalRenderLoopLogicCallback;
  61020. private _textureLoadingCallback;
  61021. private _startingProcessingFilesCallback;
  61022. private _onReloadCallback;
  61023. private _errorCallback;
  61024. private _elementToMonitor;
  61025. private _sceneFileToLoad;
  61026. private _filesToLoad;
  61027. /**
  61028. * Creates a new FilesInput
  61029. * @param engine defines the rendering engine
  61030. * @param scene defines the hosting scene
  61031. * @param sceneLoadedCallback callback called when scene is loaded
  61032. * @param progressCallback callback called to track progress
  61033. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  61034. * @param textureLoadingCallback callback called when a texture is loading
  61035. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  61036. * @param onReloadCallback callback called when a reload is requested
  61037. * @param errorCallback callback call if an error occurs
  61038. */
  61039. 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);
  61040. private _dragEnterHandler;
  61041. private _dragOverHandler;
  61042. private _dropHandler;
  61043. /**
  61044. * Calls this function to listen to drag'n'drop events on a specific DOM element
  61045. * @param elementToMonitor defines the DOM element to track
  61046. */
  61047. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  61048. /**
  61049. * Release all associated resources
  61050. */
  61051. dispose(): void;
  61052. private renderFunction;
  61053. private drag;
  61054. private drop;
  61055. private _traverseFolder;
  61056. private _processFiles;
  61057. /**
  61058. * Load files from a drop event
  61059. * @param event defines the drop event to use as source
  61060. */
  61061. loadFiles(event: any): void;
  61062. private _processReload;
  61063. /**
  61064. * Reload the current scene from the loaded files
  61065. */
  61066. reload(): void;
  61067. }
  61068. }
  61069. declare module "babylonjs/Misc/HighDynamicRange/index" {
  61070. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  61071. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  61072. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  61073. }
  61074. declare module "babylonjs/Misc/sceneOptimizer" {
  61075. import { Scene, IDisposable } from "babylonjs/scene";
  61076. import { Observable } from "babylonjs/Misc/observable";
  61077. /**
  61078. * Defines the root class used to create scene optimization to use with SceneOptimizer
  61079. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61080. */
  61081. export class SceneOptimization {
  61082. /**
  61083. * Defines the priority of this optimization (0 by default which means first in the list)
  61084. */
  61085. priority: number;
  61086. /**
  61087. * Gets a string describing the action executed by the current optimization
  61088. * @returns description string
  61089. */
  61090. getDescription(): string;
  61091. /**
  61092. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61093. * @param scene defines the current scene where to apply this optimization
  61094. * @param optimizer defines the current optimizer
  61095. * @returns true if everything that can be done was applied
  61096. */
  61097. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61098. /**
  61099. * Creates the SceneOptimization object
  61100. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61101. * @param desc defines the description associated with the optimization
  61102. */
  61103. constructor(
  61104. /**
  61105. * Defines the priority of this optimization (0 by default which means first in the list)
  61106. */
  61107. priority?: number);
  61108. }
  61109. /**
  61110. * Defines an optimization used to reduce the size of render target textures
  61111. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61112. */
  61113. export class TextureOptimization extends SceneOptimization {
  61114. /**
  61115. * Defines the priority of this optimization (0 by default which means first in the list)
  61116. */
  61117. priority: number;
  61118. /**
  61119. * 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
  61120. */
  61121. maximumSize: number;
  61122. /**
  61123. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61124. */
  61125. step: number;
  61126. /**
  61127. * Gets a string describing the action executed by the current optimization
  61128. * @returns description string
  61129. */
  61130. getDescription(): string;
  61131. /**
  61132. * Creates the TextureOptimization object
  61133. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61134. * @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
  61135. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61136. */
  61137. constructor(
  61138. /**
  61139. * Defines the priority of this optimization (0 by default which means first in the list)
  61140. */
  61141. priority?: number,
  61142. /**
  61143. * 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
  61144. */
  61145. maximumSize?: number,
  61146. /**
  61147. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61148. */
  61149. step?: number);
  61150. /**
  61151. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61152. * @param scene defines the current scene where to apply this optimization
  61153. * @param optimizer defines the current optimizer
  61154. * @returns true if everything that can be done was applied
  61155. */
  61156. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61157. }
  61158. /**
  61159. * Defines an optimization used to increase or decrease the rendering resolution
  61160. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61161. */
  61162. export class HardwareScalingOptimization extends SceneOptimization {
  61163. /**
  61164. * Defines the priority of this optimization (0 by default which means first in the list)
  61165. */
  61166. priority: number;
  61167. /**
  61168. * Defines the maximum scale to use (2 by default)
  61169. */
  61170. maximumScale: number;
  61171. /**
  61172. * Defines the step to use between two passes (0.5 by default)
  61173. */
  61174. step: number;
  61175. private _currentScale;
  61176. private _directionOffset;
  61177. /**
  61178. * Gets a string describing the action executed by the current optimization
  61179. * @return description string
  61180. */
  61181. getDescription(): string;
  61182. /**
  61183. * Creates the HardwareScalingOptimization object
  61184. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61185. * @param maximumScale defines the maximum scale to use (2 by default)
  61186. * @param step defines the step to use between two passes (0.5 by default)
  61187. */
  61188. constructor(
  61189. /**
  61190. * Defines the priority of this optimization (0 by default which means first in the list)
  61191. */
  61192. priority?: number,
  61193. /**
  61194. * Defines the maximum scale to use (2 by default)
  61195. */
  61196. maximumScale?: number,
  61197. /**
  61198. * Defines the step to use between two passes (0.5 by default)
  61199. */
  61200. step?: number);
  61201. /**
  61202. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61203. * @param scene defines the current scene where to apply this optimization
  61204. * @param optimizer defines the current optimizer
  61205. * @returns true if everything that can be done was applied
  61206. */
  61207. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61208. }
  61209. /**
  61210. * Defines an optimization used to remove shadows
  61211. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61212. */
  61213. export class ShadowsOptimization extends SceneOptimization {
  61214. /**
  61215. * Gets a string describing the action executed by the current optimization
  61216. * @return description string
  61217. */
  61218. getDescription(): string;
  61219. /**
  61220. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61221. * @param scene defines the current scene where to apply this optimization
  61222. * @param optimizer defines the current optimizer
  61223. * @returns true if everything that can be done was applied
  61224. */
  61225. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61226. }
  61227. /**
  61228. * Defines an optimization used to turn post-processes off
  61229. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61230. */
  61231. export class PostProcessesOptimization extends SceneOptimization {
  61232. /**
  61233. * Gets a string describing the action executed by the current optimization
  61234. * @return description string
  61235. */
  61236. getDescription(): string;
  61237. /**
  61238. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61239. * @param scene defines the current scene where to apply this optimization
  61240. * @param optimizer defines the current optimizer
  61241. * @returns true if everything that can be done was applied
  61242. */
  61243. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61244. }
  61245. /**
  61246. * Defines an optimization used to turn lens flares off
  61247. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61248. */
  61249. export class LensFlaresOptimization extends SceneOptimization {
  61250. /**
  61251. * Gets a string describing the action executed by the current optimization
  61252. * @return description string
  61253. */
  61254. getDescription(): string;
  61255. /**
  61256. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61257. * @param scene defines the current scene where to apply this optimization
  61258. * @param optimizer defines the current optimizer
  61259. * @returns true if everything that can be done was applied
  61260. */
  61261. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61262. }
  61263. /**
  61264. * Defines an optimization based on user defined callback.
  61265. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61266. */
  61267. export class CustomOptimization extends SceneOptimization {
  61268. /**
  61269. * Callback called to apply the custom optimization.
  61270. */
  61271. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  61272. /**
  61273. * Callback called to get custom description
  61274. */
  61275. onGetDescription: () => string;
  61276. /**
  61277. * Gets a string describing the action executed by the current optimization
  61278. * @returns description string
  61279. */
  61280. getDescription(): string;
  61281. /**
  61282. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61283. * @param scene defines the current scene where to apply this optimization
  61284. * @param optimizer defines the current optimizer
  61285. * @returns true if everything that can be done was applied
  61286. */
  61287. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61288. }
  61289. /**
  61290. * Defines an optimization used to turn particles off
  61291. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61292. */
  61293. export class ParticlesOptimization extends SceneOptimization {
  61294. /**
  61295. * Gets a string describing the action executed by the current optimization
  61296. * @return description string
  61297. */
  61298. getDescription(): string;
  61299. /**
  61300. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61301. * @param scene defines the current scene where to apply this optimization
  61302. * @param optimizer defines the current optimizer
  61303. * @returns true if everything that can be done was applied
  61304. */
  61305. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61306. }
  61307. /**
  61308. * Defines an optimization used to turn render targets off
  61309. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61310. */
  61311. export class RenderTargetsOptimization extends SceneOptimization {
  61312. /**
  61313. * Gets a string describing the action executed by the current optimization
  61314. * @return description string
  61315. */
  61316. getDescription(): string;
  61317. /**
  61318. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61319. * @param scene defines the current scene where to apply this optimization
  61320. * @param optimizer defines the current optimizer
  61321. * @returns true if everything that can be done was applied
  61322. */
  61323. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61324. }
  61325. /**
  61326. * Defines an optimization used to merge meshes with compatible materials
  61327. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61328. */
  61329. export class MergeMeshesOptimization extends SceneOptimization {
  61330. private static _UpdateSelectionTree;
  61331. /**
  61332. * Gets or sets a boolean which defines if optimization octree has to be updated
  61333. */
  61334. /**
  61335. * Gets or sets a boolean which defines if optimization octree has to be updated
  61336. */
  61337. static UpdateSelectionTree: boolean;
  61338. /**
  61339. * Gets a string describing the action executed by the current optimization
  61340. * @return description string
  61341. */
  61342. getDescription(): string;
  61343. private _canBeMerged;
  61344. /**
  61345. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61346. * @param scene defines the current scene where to apply this optimization
  61347. * @param optimizer defines the current optimizer
  61348. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  61349. * @returns true if everything that can be done was applied
  61350. */
  61351. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  61352. }
  61353. /**
  61354. * Defines a list of options used by SceneOptimizer
  61355. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61356. */
  61357. export class SceneOptimizerOptions {
  61358. /**
  61359. * Defines the target frame rate to reach (60 by default)
  61360. */
  61361. targetFrameRate: number;
  61362. /**
  61363. * Defines the interval between two checkes (2000ms by default)
  61364. */
  61365. trackerDuration: number;
  61366. /**
  61367. * Gets the list of optimizations to apply
  61368. */
  61369. optimizations: SceneOptimization[];
  61370. /**
  61371. * Creates a new list of options used by SceneOptimizer
  61372. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  61373. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  61374. */
  61375. constructor(
  61376. /**
  61377. * Defines the target frame rate to reach (60 by default)
  61378. */
  61379. targetFrameRate?: number,
  61380. /**
  61381. * Defines the interval between two checkes (2000ms by default)
  61382. */
  61383. trackerDuration?: number);
  61384. /**
  61385. * Add a new optimization
  61386. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  61387. * @returns the current SceneOptimizerOptions
  61388. */
  61389. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  61390. /**
  61391. * Add a new custom optimization
  61392. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  61393. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  61394. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61395. * @returns the current SceneOptimizerOptions
  61396. */
  61397. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  61398. /**
  61399. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  61400. * @param targetFrameRate defines the target frame rate (60 by default)
  61401. * @returns a SceneOptimizerOptions object
  61402. */
  61403. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61404. /**
  61405. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  61406. * @param targetFrameRate defines the target frame rate (60 by default)
  61407. * @returns a SceneOptimizerOptions object
  61408. */
  61409. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61410. /**
  61411. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  61412. * @param targetFrameRate defines the target frame rate (60 by default)
  61413. * @returns a SceneOptimizerOptions object
  61414. */
  61415. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61416. }
  61417. /**
  61418. * Class used to run optimizations in order to reach a target frame rate
  61419. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61420. */
  61421. export class SceneOptimizer implements IDisposable {
  61422. private _isRunning;
  61423. private _options;
  61424. private _scene;
  61425. private _currentPriorityLevel;
  61426. private _targetFrameRate;
  61427. private _trackerDuration;
  61428. private _currentFrameRate;
  61429. private _sceneDisposeObserver;
  61430. private _improvementMode;
  61431. /**
  61432. * Defines an observable called when the optimizer reaches the target frame rate
  61433. */
  61434. onSuccessObservable: Observable<SceneOptimizer>;
  61435. /**
  61436. * Defines an observable called when the optimizer enables an optimization
  61437. */
  61438. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  61439. /**
  61440. * Defines an observable called when the optimizer is not able to reach the target frame rate
  61441. */
  61442. onFailureObservable: Observable<SceneOptimizer>;
  61443. /**
  61444. * Gets a boolean indicating if the optimizer is in improvement mode
  61445. */
  61446. readonly isInImprovementMode: boolean;
  61447. /**
  61448. * Gets the current priority level (0 at start)
  61449. */
  61450. readonly currentPriorityLevel: number;
  61451. /**
  61452. * Gets the current frame rate checked by the SceneOptimizer
  61453. */
  61454. readonly currentFrameRate: number;
  61455. /**
  61456. * Gets or sets the current target frame rate (60 by default)
  61457. */
  61458. /**
  61459. * Gets or sets the current target frame rate (60 by default)
  61460. */
  61461. targetFrameRate: number;
  61462. /**
  61463. * Gets or sets the current interval between two checks (every 2000ms by default)
  61464. */
  61465. /**
  61466. * Gets or sets the current interval between two checks (every 2000ms by default)
  61467. */
  61468. trackerDuration: number;
  61469. /**
  61470. * Gets the list of active optimizations
  61471. */
  61472. readonly optimizations: SceneOptimization[];
  61473. /**
  61474. * Creates a new SceneOptimizer
  61475. * @param scene defines the scene to work on
  61476. * @param options defines the options to use with the SceneOptimizer
  61477. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  61478. * @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)
  61479. */
  61480. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  61481. /**
  61482. * Stops the current optimizer
  61483. */
  61484. stop(): void;
  61485. /**
  61486. * Reset the optimizer to initial step (current priority level = 0)
  61487. */
  61488. reset(): void;
  61489. /**
  61490. * Start the optimizer. By default it will try to reach a specific framerate
  61491. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  61492. */
  61493. start(): void;
  61494. private _checkCurrentState;
  61495. /**
  61496. * Release all resources
  61497. */
  61498. dispose(): void;
  61499. /**
  61500. * Helper function to create a SceneOptimizer with one single line of code
  61501. * @param scene defines the scene to work on
  61502. * @param options defines the options to use with the SceneOptimizer
  61503. * @param onSuccess defines a callback to call on success
  61504. * @param onFailure defines a callback to call on failure
  61505. * @returns the new SceneOptimizer object
  61506. */
  61507. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  61508. }
  61509. }
  61510. declare module "babylonjs/Misc/sceneSerializer" {
  61511. import { Scene } from "babylonjs/scene";
  61512. /**
  61513. * Class used to serialize a scene into a string
  61514. */
  61515. export class SceneSerializer {
  61516. /**
  61517. * Clear cache used by a previous serialization
  61518. */
  61519. static ClearCache(): void;
  61520. /**
  61521. * Serialize a scene into a JSON compatible object
  61522. * @param scene defines the scene to serialize
  61523. * @returns a JSON compatible object
  61524. */
  61525. static Serialize(scene: Scene): any;
  61526. /**
  61527. * Serialize a mesh into a JSON compatible object
  61528. * @param toSerialize defines the mesh to serialize
  61529. * @param withParents defines if parents must be serialized as well
  61530. * @param withChildren defines if children must be serialized as well
  61531. * @returns a JSON compatible object
  61532. */
  61533. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  61534. }
  61535. }
  61536. declare module "babylonjs/Misc/textureTools" {
  61537. import { Texture } from "babylonjs/Materials/Textures/texture";
  61538. /**
  61539. * Class used to host texture specific utilities
  61540. */
  61541. export class TextureTools {
  61542. /**
  61543. * Uses the GPU to create a copy texture rescaled at a given size
  61544. * @param texture Texture to copy from
  61545. * @param width defines the desired width
  61546. * @param height defines the desired height
  61547. * @param useBilinearMode defines if bilinear mode has to be used
  61548. * @return the generated texture
  61549. */
  61550. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  61551. }
  61552. }
  61553. declare module "babylonjs/Misc/videoRecorder" {
  61554. import { Nullable } from "babylonjs/types";
  61555. import { Engine } from "babylonjs/Engines/engine";
  61556. /**
  61557. * This represents the different options avilable for the video capture.
  61558. */
  61559. export interface VideoRecorderOptions {
  61560. /** Defines the mime type of the video */
  61561. mimeType: string;
  61562. /** Defines the video the video should be recorded at */
  61563. fps: number;
  61564. /** Defines the chunk size for the recording data */
  61565. recordChunckSize: number;
  61566. /** The audio tracks to attach to the record */
  61567. audioTracks?: MediaStreamTrack[];
  61568. }
  61569. /**
  61570. * This can helps recording videos from BabylonJS.
  61571. * This is based on the available WebRTC functionalities of the browser.
  61572. *
  61573. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  61574. */
  61575. export class VideoRecorder {
  61576. private static readonly _defaultOptions;
  61577. /**
  61578. * Returns wehther or not the VideoRecorder is available in your browser.
  61579. * @param engine Defines the Babylon Engine to check the support for
  61580. * @returns true if supported otherwise false
  61581. */
  61582. static IsSupported(engine: Engine): boolean;
  61583. private readonly _options;
  61584. private _canvas;
  61585. private _mediaRecorder;
  61586. private _recordedChunks;
  61587. private _fileName;
  61588. private _resolve;
  61589. private _reject;
  61590. /**
  61591. * True wether a recording is already in progress.
  61592. */
  61593. readonly isRecording: boolean;
  61594. /**
  61595. * Create a new VideoCapture object which can help converting what you see in Babylon to
  61596. * a video file.
  61597. * @param engine Defines the BabylonJS Engine you wish to record
  61598. * @param options Defines options that can be used to customized the capture
  61599. */
  61600. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  61601. /**
  61602. * Stops the current recording before the default capture timeout passed in the startRecording
  61603. * functions.
  61604. */
  61605. stopRecording(): void;
  61606. /**
  61607. * Starts recording the canvas for a max duration specified in parameters.
  61608. * @param fileName Defines the name of the file to be downloaded when the recording stop. If null no automatic download will start and you can rely on the promise to get the data back.
  61609. * @param maxDuration Defines the maximum recording time in seconds.
  61610. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  61611. * @return a promise callback at the end of the recording with the video data in Blob.
  61612. */
  61613. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  61614. /**
  61615. * Releases internal resources used during the recording.
  61616. */
  61617. dispose(): void;
  61618. private _handleDataAvailable;
  61619. private _handleError;
  61620. private _handleStop;
  61621. }
  61622. }
  61623. declare module "babylonjs/Misc/screenshotTools" {
  61624. import { Camera } from "babylonjs/Cameras/camera";
  61625. import { Engine } from "babylonjs/Engines/engine";
  61626. /**
  61627. * Class containing a set of static utilities functions for screenshots
  61628. */
  61629. export class ScreenshotTools {
  61630. /**
  61631. * Captures a screenshot of the current rendering
  61632. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61633. * @param engine defines the rendering engine
  61634. * @param camera defines the source camera
  61635. * @param size This parameter can be set to a single number or to an object with the
  61636. * following (optional) properties: precision, width, height. If a single number is passed,
  61637. * it will be used for both width and height. If an object is passed, the screenshot size
  61638. * will be derived from the parameters. The precision property is a multiplier allowing
  61639. * rendering at a higher or lower resolution
  61640. * @param successCallback defines the callback receives a single parameter which contains the
  61641. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61642. * src parameter of an <img> to display it
  61643. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  61644. * Check your browser for supported MIME types
  61645. */
  61646. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  61647. /**
  61648. * Generates an image screenshot from the specified camera.
  61649. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61650. * @param engine The engine to use for rendering
  61651. * @param camera The camera to use for rendering
  61652. * @param size This parameter can be set to a single number or to an object with the
  61653. * following (optional) properties: precision, width, height. If a single number is passed,
  61654. * it will be used for both width and height. If an object is passed, the screenshot size
  61655. * will be derived from the parameters. The precision property is a multiplier allowing
  61656. * rendering at a higher or lower resolution
  61657. * @param successCallback The callback receives a single parameter which contains the
  61658. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61659. * src parameter of an <img> to display it
  61660. * @param mimeType The MIME type of the screenshot image (default: image/png).
  61661. * Check your browser for supported MIME types
  61662. * @param samples Texture samples (default: 1)
  61663. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  61664. * @param fileName A name for for the downloaded file.
  61665. */
  61666. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  61667. }
  61668. }
  61669. declare module "babylonjs/Misc/index" {
  61670. export * from "babylonjs/Misc/andOrNotEvaluator";
  61671. export * from "babylonjs/Misc/assetsManager";
  61672. export * from "babylonjs/Misc/dds";
  61673. export * from "babylonjs/Misc/decorators";
  61674. export * from "babylonjs/Misc/deferred";
  61675. export * from "babylonjs/Misc/environmentTextureTools";
  61676. export * from "babylonjs/Misc/meshExploder";
  61677. export * from "babylonjs/Misc/filesInput";
  61678. export * from "babylonjs/Misc/HighDynamicRange/index";
  61679. export * from "babylonjs/Misc/khronosTextureContainer";
  61680. export * from "babylonjs/Misc/observable";
  61681. export * from "babylonjs/Misc/performanceMonitor";
  61682. export * from "babylonjs/Misc/promise";
  61683. export * from "babylonjs/Misc/sceneOptimizer";
  61684. export * from "babylonjs/Misc/sceneSerializer";
  61685. export * from "babylonjs/Misc/smartArray";
  61686. export * from "babylonjs/Misc/stringDictionary";
  61687. export * from "babylonjs/Misc/tags";
  61688. export * from "babylonjs/Misc/textureTools";
  61689. export * from "babylonjs/Misc/tga";
  61690. export * from "babylonjs/Misc/tools";
  61691. export * from "babylonjs/Misc/videoRecorder";
  61692. export * from "babylonjs/Misc/virtualJoystick";
  61693. export * from "babylonjs/Misc/workerPool";
  61694. export * from "babylonjs/Misc/logger";
  61695. export * from "babylonjs/Misc/typeStore";
  61696. export * from "babylonjs/Misc/filesInputStore";
  61697. export * from "babylonjs/Misc/deepCopier";
  61698. export * from "babylonjs/Misc/pivotTools";
  61699. export * from "babylonjs/Misc/precisionDate";
  61700. export * from "babylonjs/Misc/screenshotTools";
  61701. export * from "babylonjs/Misc/typeStore";
  61702. export * from "babylonjs/Misc/webRequest";
  61703. export * from "babylonjs/Misc/iInspectable";
  61704. export * from "babylonjs/Misc/brdfTextureTools";
  61705. }
  61706. declare module "babylonjs/index" {
  61707. export * from "babylonjs/abstractScene";
  61708. export * from "babylonjs/Actions/index";
  61709. export * from "babylonjs/Animations/index";
  61710. export * from "babylonjs/assetContainer";
  61711. export * from "babylonjs/Audio/index";
  61712. export * from "babylonjs/Behaviors/index";
  61713. export * from "babylonjs/Bones/index";
  61714. export * from "babylonjs/Cameras/index";
  61715. export * from "babylonjs/Collisions/index";
  61716. export * from "babylonjs/Culling/index";
  61717. export * from "babylonjs/Debug/index";
  61718. export * from "babylonjs/Engines/index";
  61719. export * from "babylonjs/Events/index";
  61720. export * from "babylonjs/Gamepads/index";
  61721. export * from "babylonjs/Gizmos/index";
  61722. export * from "babylonjs/Helpers/index";
  61723. export * from "babylonjs/Instrumentation/index";
  61724. export * from "babylonjs/Layers/index";
  61725. export * from "babylonjs/LensFlares/index";
  61726. export * from "babylonjs/Lights/index";
  61727. export * from "babylonjs/Loading/index";
  61728. export * from "babylonjs/Materials/index";
  61729. export * from "babylonjs/Maths/index";
  61730. export * from "babylonjs/Meshes/index";
  61731. export * from "babylonjs/Morph/index";
  61732. export * from "babylonjs/node";
  61733. export * from "babylonjs/Offline/index";
  61734. export * from "babylonjs/Particles/index";
  61735. export * from "babylonjs/Physics/index";
  61736. export * from "babylonjs/PostProcesses/index";
  61737. export * from "babylonjs/Probes/index";
  61738. export * from "babylonjs/Rendering/index";
  61739. export * from "babylonjs/scene";
  61740. export * from "babylonjs/sceneComponent";
  61741. export * from "babylonjs/Sprites/index";
  61742. export * from "babylonjs/States/index";
  61743. export * from "babylonjs/Misc/index";
  61744. export * from "babylonjs/types";
  61745. }
  61746. declare module "babylonjs/Animations/pathCursor" {
  61747. import { Path2, Vector3 } from "babylonjs/Maths/math";
  61748. /**
  61749. * A cursor which tracks a point on a path
  61750. */
  61751. export class PathCursor {
  61752. private path;
  61753. /**
  61754. * Stores path cursor callbacks for when an onchange event is triggered
  61755. */
  61756. private _onchange;
  61757. /**
  61758. * The value of the path cursor
  61759. */
  61760. value: number;
  61761. /**
  61762. * The animation array of the path cursor
  61763. */
  61764. animations: Animation[];
  61765. /**
  61766. * Initializes the path cursor
  61767. * @param path The path to track
  61768. */
  61769. constructor(path: Path2);
  61770. /**
  61771. * Gets the cursor point on the path
  61772. * @returns A point on the path cursor at the cursor location
  61773. */
  61774. getPoint(): Vector3;
  61775. /**
  61776. * Moves the cursor ahead by the step amount
  61777. * @param step The amount to move the cursor forward
  61778. * @returns This path cursor
  61779. */
  61780. moveAhead(step?: number): PathCursor;
  61781. /**
  61782. * Moves the cursor behind by the step amount
  61783. * @param step The amount to move the cursor back
  61784. * @returns This path cursor
  61785. */
  61786. moveBack(step?: number): PathCursor;
  61787. /**
  61788. * Moves the cursor by the step amount
  61789. * If the step amount is greater than one, an exception is thrown
  61790. * @param step The amount to move the cursor
  61791. * @returns This path cursor
  61792. */
  61793. move(step: number): PathCursor;
  61794. /**
  61795. * Ensures that the value is limited between zero and one
  61796. * @returns This path cursor
  61797. */
  61798. private ensureLimits;
  61799. /**
  61800. * Runs onchange callbacks on change (used by the animation engine)
  61801. * @returns This path cursor
  61802. */
  61803. private raiseOnChange;
  61804. /**
  61805. * Executes a function on change
  61806. * @param f A path cursor onchange callback
  61807. * @returns This path cursor
  61808. */
  61809. onchange(f: (cursor: PathCursor) => void): PathCursor;
  61810. }
  61811. }
  61812. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  61813. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  61814. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  61815. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  61816. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  61817. }
  61818. declare module "babylonjs/Engines/Processors/Expressions/index" {
  61819. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  61820. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  61821. }
  61822. declare module "babylonjs/Engines/Processors/index" {
  61823. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  61824. export * from "babylonjs/Engines/Processors/Expressions/index";
  61825. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  61826. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  61827. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  61828. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  61829. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  61830. export * from "babylonjs/Engines/Processors/shaderProcessor";
  61831. }
  61832. declare module "babylonjs/Legacy/legacy" {
  61833. import * as Babylon from "babylonjs/index";
  61834. export * from "babylonjs/index";
  61835. }
  61836. declare module "babylonjs/Shaders/blur.fragment" {
  61837. /** @hidden */
  61838. export var blurPixelShader: {
  61839. name: string;
  61840. shader: string;
  61841. };
  61842. }
  61843. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  61844. /** @hidden */
  61845. export var bones300Declaration: {
  61846. name: string;
  61847. shader: string;
  61848. };
  61849. }
  61850. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  61851. /** @hidden */
  61852. export var instances300Declaration: {
  61853. name: string;
  61854. shader: string;
  61855. };
  61856. }
  61857. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  61858. /** @hidden */
  61859. export var pointCloudVertexDeclaration: {
  61860. name: string;
  61861. shader: string;
  61862. };
  61863. }
  61864. // Mixins
  61865. interface Window {
  61866. mozIndexedDB: IDBFactory;
  61867. webkitIndexedDB: IDBFactory;
  61868. msIndexedDB: IDBFactory;
  61869. webkitURL: typeof URL;
  61870. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  61871. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  61872. WebGLRenderingContext: WebGLRenderingContext;
  61873. MSGesture: MSGesture;
  61874. CANNON: any;
  61875. AudioContext: AudioContext;
  61876. webkitAudioContext: AudioContext;
  61877. PointerEvent: any;
  61878. Math: Math;
  61879. Uint8Array: Uint8ArrayConstructor;
  61880. Float32Array: Float32ArrayConstructor;
  61881. mozURL: typeof URL;
  61882. msURL: typeof URL;
  61883. VRFrameData: any; // WebVR, from specs 1.1
  61884. DracoDecoderModule: any;
  61885. setImmediate(handler: (...args: any[]) => void): number;
  61886. }
  61887. interface HTMLCanvasElement {
  61888. requestPointerLock(): void;
  61889. msRequestPointerLock?(): void;
  61890. mozRequestPointerLock?(): void;
  61891. webkitRequestPointerLock?(): void;
  61892. /** Track wether a record is in progress */
  61893. isRecording: boolean;
  61894. /** Capture Stream method defined by some browsers */
  61895. captureStream(fps?: number): MediaStream;
  61896. }
  61897. interface CanvasRenderingContext2D {
  61898. msImageSmoothingEnabled: boolean;
  61899. }
  61900. interface MouseEvent {
  61901. mozMovementX: number;
  61902. mozMovementY: number;
  61903. webkitMovementX: number;
  61904. webkitMovementY: number;
  61905. msMovementX: number;
  61906. msMovementY: number;
  61907. }
  61908. interface Navigator {
  61909. mozGetVRDevices: (any: any) => any;
  61910. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61911. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61912. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61913. webkitGetGamepads(): Gamepad[];
  61914. msGetGamepads(): Gamepad[];
  61915. webkitGamepads(): Gamepad[];
  61916. }
  61917. interface HTMLVideoElement {
  61918. mozSrcObject: any;
  61919. }
  61920. interface Math {
  61921. fround(x: number): number;
  61922. imul(a: number, b: number): number;
  61923. }
  61924. interface WebGLRenderingContext {
  61925. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  61926. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  61927. vertexAttribDivisor(index: number, divisor: number): void;
  61928. createVertexArray(): any;
  61929. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  61930. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  61931. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  61932. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  61933. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  61934. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  61935. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  61936. // Queries
  61937. createQuery(): WebGLQuery;
  61938. deleteQuery(query: WebGLQuery): void;
  61939. beginQuery(target: number, query: WebGLQuery): void;
  61940. endQuery(target: number): void;
  61941. getQueryParameter(query: WebGLQuery, pname: number): any;
  61942. getQuery(target: number, pname: number): any;
  61943. MAX_SAMPLES: number;
  61944. RGBA8: number;
  61945. READ_FRAMEBUFFER: number;
  61946. DRAW_FRAMEBUFFER: number;
  61947. UNIFORM_BUFFER: number;
  61948. HALF_FLOAT_OES: number;
  61949. RGBA16F: number;
  61950. RGBA32F: number;
  61951. R32F: number;
  61952. RG32F: number;
  61953. RGB32F: number;
  61954. R16F: number;
  61955. RG16F: number;
  61956. RGB16F: number;
  61957. RED: number;
  61958. RG: number;
  61959. R8: number;
  61960. RG8: number;
  61961. UNSIGNED_INT_24_8: number;
  61962. DEPTH24_STENCIL8: number;
  61963. /* Multiple Render Targets */
  61964. drawBuffers(buffers: number[]): void;
  61965. readBuffer(src: number): void;
  61966. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  61967. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  61968. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  61969. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  61970. // Occlusion Query
  61971. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  61972. ANY_SAMPLES_PASSED: number;
  61973. QUERY_RESULT_AVAILABLE: number;
  61974. QUERY_RESULT: number;
  61975. }
  61976. interface WebGLProgram {
  61977. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  61978. }
  61979. interface EXT_disjoint_timer_query {
  61980. QUERY_COUNTER_BITS_EXT: number;
  61981. TIME_ELAPSED_EXT: number;
  61982. TIMESTAMP_EXT: number;
  61983. GPU_DISJOINT_EXT: number;
  61984. QUERY_RESULT_EXT: number;
  61985. QUERY_RESULT_AVAILABLE_EXT: number;
  61986. queryCounterEXT(query: WebGLQuery, target: number): void;
  61987. createQueryEXT(): WebGLQuery;
  61988. beginQueryEXT(target: number, query: WebGLQuery): void;
  61989. endQueryEXT(target: number): void;
  61990. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  61991. deleteQueryEXT(query: WebGLQuery): void;
  61992. }
  61993. interface WebGLUniformLocation {
  61994. _currentState: any;
  61995. }
  61996. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  61997. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  61998. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  61999. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62000. interface WebGLRenderingContext {
  62001. readonly RASTERIZER_DISCARD: number;
  62002. readonly DEPTH_COMPONENT24: number;
  62003. readonly TEXTURE_3D: number;
  62004. readonly TEXTURE_2D_ARRAY: number;
  62005. readonly TEXTURE_COMPARE_FUNC: number;
  62006. readonly TEXTURE_COMPARE_MODE: number;
  62007. readonly COMPARE_REF_TO_TEXTURE: number;
  62008. readonly TEXTURE_WRAP_R: number;
  62009. readonly HALF_FLOAT: number;
  62010. readonly RGB8: number;
  62011. readonly RED_INTEGER: number;
  62012. readonly RG_INTEGER: number;
  62013. readonly RGB_INTEGER: number;
  62014. readonly RGBA_INTEGER: number;
  62015. readonly R8_SNORM: number;
  62016. readonly RG8_SNORM: number;
  62017. readonly RGB8_SNORM: number;
  62018. readonly RGBA8_SNORM: number;
  62019. readonly R8I: number;
  62020. readonly RG8I: number;
  62021. readonly RGB8I: number;
  62022. readonly RGBA8I: number;
  62023. readonly R8UI: number;
  62024. readonly RG8UI: number;
  62025. readonly RGB8UI: number;
  62026. readonly RGBA8UI: number;
  62027. readonly R16I: number;
  62028. readonly RG16I: number;
  62029. readonly RGB16I: number;
  62030. readonly RGBA16I: number;
  62031. readonly R16UI: number;
  62032. readonly RG16UI: number;
  62033. readonly RGB16UI: number;
  62034. readonly RGBA16UI: number;
  62035. readonly R32I: number;
  62036. readonly RG32I: number;
  62037. readonly RGB32I: number;
  62038. readonly RGBA32I: number;
  62039. readonly R32UI: number;
  62040. readonly RG32UI: number;
  62041. readonly RGB32UI: number;
  62042. readonly RGBA32UI: number;
  62043. readonly RGB10_A2UI: number;
  62044. readonly R11F_G11F_B10F: number;
  62045. readonly RGB9_E5: number;
  62046. readonly RGB10_A2: number;
  62047. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  62048. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  62049. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  62050. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  62051. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  62052. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  62053. 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;
  62054. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  62055. readonly TRANSFORM_FEEDBACK: number;
  62056. readonly INTERLEAVED_ATTRIBS: number;
  62057. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  62058. createTransformFeedback(): WebGLTransformFeedback;
  62059. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  62060. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  62061. beginTransformFeedback(primitiveMode: number): void;
  62062. endTransformFeedback(): void;
  62063. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  62064. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62065. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62066. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62067. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  62068. }
  62069. interface ImageBitmap {
  62070. readonly width: number;
  62071. readonly height: number;
  62072. close(): void;
  62073. }
  62074. interface WebGLQuery extends WebGLObject {
  62075. }
  62076. declare var WebGLQuery: {
  62077. prototype: WebGLQuery;
  62078. new(): WebGLQuery;
  62079. };
  62080. interface WebGLSampler extends WebGLObject {
  62081. }
  62082. declare var WebGLSampler: {
  62083. prototype: WebGLSampler;
  62084. new(): WebGLSampler;
  62085. };
  62086. interface WebGLSync extends WebGLObject {
  62087. }
  62088. declare var WebGLSync: {
  62089. prototype: WebGLSync;
  62090. new(): WebGLSync;
  62091. };
  62092. interface WebGLTransformFeedback extends WebGLObject {
  62093. }
  62094. declare var WebGLTransformFeedback: {
  62095. prototype: WebGLTransformFeedback;
  62096. new(): WebGLTransformFeedback;
  62097. };
  62098. interface WebGLVertexArrayObject extends WebGLObject {
  62099. }
  62100. declare var WebGLVertexArrayObject: {
  62101. prototype: WebGLVertexArrayObject;
  62102. new(): WebGLVertexArrayObject;
  62103. };
  62104. // Type definitions for WebVR API
  62105. // Project: https://w3c.github.io/webvr/
  62106. // Definitions by: six a <https://github.com/lostfictions>
  62107. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62108. interface VRDisplay extends EventTarget {
  62109. /**
  62110. * Dictionary of capabilities describing the VRDisplay.
  62111. */
  62112. readonly capabilities: VRDisplayCapabilities;
  62113. /**
  62114. * z-depth defining the far plane of the eye view frustum
  62115. * enables mapping of values in the render target depth
  62116. * attachment to scene coordinates. Initially set to 10000.0.
  62117. */
  62118. depthFar: number;
  62119. /**
  62120. * z-depth defining the near plane of the eye view frustum
  62121. * enables mapping of values in the render target depth
  62122. * attachment to scene coordinates. Initially set to 0.01.
  62123. */
  62124. depthNear: number;
  62125. /**
  62126. * An identifier for this distinct VRDisplay. Used as an
  62127. * association point in the Gamepad API.
  62128. */
  62129. readonly displayId: number;
  62130. /**
  62131. * A display name, a user-readable name identifying it.
  62132. */
  62133. readonly displayName: string;
  62134. readonly isConnected: boolean;
  62135. readonly isPresenting: boolean;
  62136. /**
  62137. * If this VRDisplay supports room-scale experiences, the optional
  62138. * stage attribute contains details on the room-scale parameters.
  62139. */
  62140. readonly stageParameters: VRStageParameters | null;
  62141. /**
  62142. * Passing the value returned by `requestAnimationFrame` to
  62143. * `cancelAnimationFrame` will unregister the callback.
  62144. * @param handle Define the hanle of the request to cancel
  62145. */
  62146. cancelAnimationFrame(handle: number): void;
  62147. /**
  62148. * Stops presenting to the VRDisplay.
  62149. * @returns a promise to know when it stopped
  62150. */
  62151. exitPresent(): Promise<void>;
  62152. /**
  62153. * Return the current VREyeParameters for the given eye.
  62154. * @param whichEye Define the eye we want the parameter for
  62155. * @returns the eye parameters
  62156. */
  62157. getEyeParameters(whichEye: string): VREyeParameters;
  62158. /**
  62159. * Populates the passed VRFrameData with the information required to render
  62160. * the current frame.
  62161. * @param frameData Define the data structure to populate
  62162. * @returns true if ok otherwise false
  62163. */
  62164. getFrameData(frameData: VRFrameData): boolean;
  62165. /**
  62166. * Get the layers currently being presented.
  62167. * @returns the list of VR layers
  62168. */
  62169. getLayers(): VRLayer[];
  62170. /**
  62171. * Return a VRPose containing the future predicted pose of the VRDisplay
  62172. * when the current frame will be presented. The value returned will not
  62173. * change until JavaScript has returned control to the browser.
  62174. *
  62175. * The VRPose will contain the position, orientation, velocity,
  62176. * and acceleration of each of these properties.
  62177. * @returns the pose object
  62178. */
  62179. getPose(): VRPose;
  62180. /**
  62181. * Return the current instantaneous pose of the VRDisplay, with no
  62182. * prediction applied.
  62183. * @returns the current instantaneous pose
  62184. */
  62185. getImmediatePose(): VRPose;
  62186. /**
  62187. * The callback passed to `requestAnimationFrame` will be called
  62188. * any time a new frame should be rendered. When the VRDisplay is
  62189. * presenting the callback will be called at the native refresh
  62190. * rate of the HMD. When not presenting this function acts
  62191. * identically to how window.requestAnimationFrame acts. Content should
  62192. * make no assumptions of frame rate or vsync behavior as the HMD runs
  62193. * asynchronously from other displays and at differing refresh rates.
  62194. * @param callback Define the eaction to run next frame
  62195. * @returns the request handle it
  62196. */
  62197. requestAnimationFrame(callback: FrameRequestCallback): number;
  62198. /**
  62199. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  62200. * Repeat calls while already presenting will update the VRLayers being displayed.
  62201. * @param layers Define the list of layer to present
  62202. * @returns a promise to know when the request has been fulfilled
  62203. */
  62204. requestPresent(layers: VRLayer[]): Promise<void>;
  62205. /**
  62206. * Reset the pose for this display, treating its current position and
  62207. * orientation as the "origin/zero" values. VRPose.position,
  62208. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  62209. * updated when calling resetPose(). This should be called in only
  62210. * sitting-space experiences.
  62211. */
  62212. resetPose(): void;
  62213. /**
  62214. * The VRLayer provided to the VRDisplay will be captured and presented
  62215. * in the HMD. Calling this function has the same effect on the source
  62216. * canvas as any other operation that uses its source image, and canvases
  62217. * created without preserveDrawingBuffer set to true will be cleared.
  62218. * @param pose Define the pose to submit
  62219. */
  62220. submitFrame(pose?: VRPose): void;
  62221. }
  62222. declare var VRDisplay: {
  62223. prototype: VRDisplay;
  62224. new(): VRDisplay;
  62225. };
  62226. interface VRLayer {
  62227. leftBounds?: number[] | Float32Array | null;
  62228. rightBounds?: number[] | Float32Array | null;
  62229. source?: HTMLCanvasElement | null;
  62230. }
  62231. interface VRDisplayCapabilities {
  62232. readonly canPresent: boolean;
  62233. readonly hasExternalDisplay: boolean;
  62234. readonly hasOrientation: boolean;
  62235. readonly hasPosition: boolean;
  62236. readonly maxLayers: number;
  62237. }
  62238. interface VREyeParameters {
  62239. /** @deprecated */
  62240. readonly fieldOfView: VRFieldOfView;
  62241. readonly offset: Float32Array;
  62242. readonly renderHeight: number;
  62243. readonly renderWidth: number;
  62244. }
  62245. interface VRFieldOfView {
  62246. readonly downDegrees: number;
  62247. readonly leftDegrees: number;
  62248. readonly rightDegrees: number;
  62249. readonly upDegrees: number;
  62250. }
  62251. interface VRFrameData {
  62252. readonly leftProjectionMatrix: Float32Array;
  62253. readonly leftViewMatrix: Float32Array;
  62254. readonly pose: VRPose;
  62255. readonly rightProjectionMatrix: Float32Array;
  62256. readonly rightViewMatrix: Float32Array;
  62257. readonly timestamp: number;
  62258. }
  62259. interface VRPose {
  62260. readonly angularAcceleration: Float32Array | null;
  62261. readonly angularVelocity: Float32Array | null;
  62262. readonly linearAcceleration: Float32Array | null;
  62263. readonly linearVelocity: Float32Array | null;
  62264. readonly orientation: Float32Array | null;
  62265. readonly position: Float32Array | null;
  62266. readonly timestamp: number;
  62267. }
  62268. interface VRStageParameters {
  62269. sittingToStandingTransform?: Float32Array;
  62270. sizeX?: number;
  62271. sizeY?: number;
  62272. }
  62273. interface Navigator {
  62274. getVRDisplays(): Promise<VRDisplay[]>;
  62275. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  62276. }
  62277. interface Window {
  62278. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  62279. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  62280. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  62281. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62282. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62283. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  62284. }
  62285. interface Gamepad {
  62286. readonly displayId: number;
  62287. }
  62288. interface XRDevice {
  62289. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  62290. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  62291. }
  62292. interface XRSession {
  62293. getInputSources(): Array<any>;
  62294. baseLayer: XRWebGLLayer;
  62295. requestFrameOfReference(type: string): Promise<void>;
  62296. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  62297. end(): Promise<void>;
  62298. requestAnimationFrame: Function;
  62299. addEventListener: Function;
  62300. }
  62301. interface XRSessionCreationOptions {
  62302. outputContext?: WebGLRenderingContext | null;
  62303. immersive?: boolean;
  62304. environmentIntegration?: boolean;
  62305. }
  62306. interface XRLayer {
  62307. getViewport: Function;
  62308. framebufferWidth: number;
  62309. framebufferHeight: number;
  62310. }
  62311. interface XRView {
  62312. projectionMatrix: Float32Array;
  62313. }
  62314. interface XRFrame {
  62315. getDevicePose: Function;
  62316. getInputPose: Function;
  62317. views: Array<XRView>;
  62318. baseLayer: XRLayer;
  62319. }
  62320. interface XRFrameOfReference {
  62321. }
  62322. interface XRWebGLLayer extends XRLayer {
  62323. framebuffer: WebGLFramebuffer;
  62324. }
  62325. declare var XRWebGLLayer: {
  62326. prototype: XRWebGLLayer;
  62327. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  62328. };
  62329. declare module "babylonjs" {
  62330. export * from "babylonjs/Legacy/legacy";
  62331. }
  62332. declare module BABYLON {
  62333. /** Alias type for value that can be null */
  62334. export type Nullable<T> = T | null;
  62335. /**
  62336. * Alias type for number that are floats
  62337. * @ignorenaming
  62338. */
  62339. export type float = number;
  62340. /**
  62341. * Alias type for number that are doubles.
  62342. * @ignorenaming
  62343. */
  62344. export type double = number;
  62345. /**
  62346. * Alias type for number that are integer
  62347. * @ignorenaming
  62348. */
  62349. export type int = number;
  62350. /** Alias type for number array or Float32Array */
  62351. export type FloatArray = number[] | Float32Array;
  62352. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  62353. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  62354. /**
  62355. * Alias for types that can be used by a Buffer or VertexBuffer.
  62356. */
  62357. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  62358. /**
  62359. * Alias type for primitive types
  62360. * @ignorenaming
  62361. */
  62362. type Primitive = undefined | null | boolean | string | number | Function;
  62363. /**
  62364. * Type modifier to make all the properties of an object Readonly
  62365. */
  62366. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  62367. /**
  62368. * Type modifier to make all the properties of an object Readonly recursively
  62369. */
  62370. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  62371. /** @hidden */
  62372. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  62373. }
  62374. /** @hidden */
  62375. /** @hidden */
  62376. type DeepImmutableObject<T> = {
  62377. readonly [K in keyof T]: DeepImmutable<T[K]>;
  62378. };
  62379. }
  62380. declare module BABYLON {
  62381. /**
  62382. * Class containing a set of static utilities functions for arrays.
  62383. */
  62384. export class ArrayTools {
  62385. /**
  62386. * Returns an array of the given size filled with element built from the given constructor and the paramters
  62387. * @param size the number of element to construct and put in the array
  62388. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  62389. * @returns a new array filled with new objects
  62390. */
  62391. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  62392. }
  62393. }
  62394. declare module BABYLON {
  62395. /**
  62396. * Scalar computation library
  62397. */
  62398. export class Scalar {
  62399. /**
  62400. * Two pi constants convenient for computation.
  62401. */
  62402. static TwoPi: number;
  62403. /**
  62404. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  62405. * @param a number
  62406. * @param b number
  62407. * @param epsilon (default = 1.401298E-45)
  62408. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  62409. */
  62410. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  62411. /**
  62412. * Returns a string : the upper case translation of the number i to hexadecimal.
  62413. * @param i number
  62414. * @returns the upper case translation of the number i to hexadecimal.
  62415. */
  62416. static ToHex(i: number): string;
  62417. /**
  62418. * Returns -1 if value is negative and +1 is value is positive.
  62419. * @param value the value
  62420. * @returns the value itself if it's equal to zero.
  62421. */
  62422. static Sign(value: number): number;
  62423. /**
  62424. * Returns the value itself if it's between min and max.
  62425. * Returns min if the value is lower than min.
  62426. * Returns max if the value is greater than max.
  62427. * @param value the value to clmap
  62428. * @param min the min value to clamp to (default: 0)
  62429. * @param max the max value to clamp to (default: 1)
  62430. * @returns the clamped value
  62431. */
  62432. static Clamp(value: number, min?: number, max?: number): number;
  62433. /**
  62434. * the log2 of value.
  62435. * @param value the value to compute log2 of
  62436. * @returns the log2 of value.
  62437. */
  62438. static Log2(value: number): number;
  62439. /**
  62440. * Loops the value, so that it is never larger than length and never smaller than 0.
  62441. *
  62442. * This is similar to the modulo operator but it works with floating point numbers.
  62443. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  62444. * With t = 5 and length = 2.5, the result would be 0.0.
  62445. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  62446. * @param value the value
  62447. * @param length the length
  62448. * @returns the looped value
  62449. */
  62450. static Repeat(value: number, length: number): number;
  62451. /**
  62452. * Normalize the value between 0.0 and 1.0 using min and max values
  62453. * @param value value to normalize
  62454. * @param min max to normalize between
  62455. * @param max min to normalize between
  62456. * @returns the normalized value
  62457. */
  62458. static Normalize(value: number, min: number, max: number): number;
  62459. /**
  62460. * Denormalize the value from 0.0 and 1.0 using min and max values
  62461. * @param normalized value to denormalize
  62462. * @param min max to denormalize between
  62463. * @param max min to denormalize between
  62464. * @returns the denormalized value
  62465. */
  62466. static Denormalize(normalized: number, min: number, max: number): number;
  62467. /**
  62468. * Calculates the shortest difference between two given angles given in degrees.
  62469. * @param current current angle in degrees
  62470. * @param target target angle in degrees
  62471. * @returns the delta
  62472. */
  62473. static DeltaAngle(current: number, target: number): number;
  62474. /**
  62475. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  62476. * @param tx value
  62477. * @param length length
  62478. * @returns The returned value will move back and forth between 0 and length
  62479. */
  62480. static PingPong(tx: number, length: number): number;
  62481. /**
  62482. * Interpolates between min and max with smoothing at the limits.
  62483. *
  62484. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  62485. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  62486. * @param from from
  62487. * @param to to
  62488. * @param tx value
  62489. * @returns the smooth stepped value
  62490. */
  62491. static SmoothStep(from: number, to: number, tx: number): number;
  62492. /**
  62493. * Moves a value current towards target.
  62494. *
  62495. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  62496. * Negative values of maxDelta pushes the value away from target.
  62497. * @param current current value
  62498. * @param target target value
  62499. * @param maxDelta max distance to move
  62500. * @returns resulting value
  62501. */
  62502. static MoveTowards(current: number, target: number, maxDelta: number): number;
  62503. /**
  62504. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  62505. *
  62506. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  62507. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  62508. * @param current current value
  62509. * @param target target value
  62510. * @param maxDelta max distance to move
  62511. * @returns resulting angle
  62512. */
  62513. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  62514. /**
  62515. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  62516. * @param start start value
  62517. * @param end target value
  62518. * @param amount amount to lerp between
  62519. * @returns the lerped value
  62520. */
  62521. static Lerp(start: number, end: number, amount: number): number;
  62522. /**
  62523. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  62524. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  62525. * @param start start value
  62526. * @param end target value
  62527. * @param amount amount to lerp between
  62528. * @returns the lerped value
  62529. */
  62530. static LerpAngle(start: number, end: number, amount: number): number;
  62531. /**
  62532. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  62533. * @param a start value
  62534. * @param b target value
  62535. * @param value value between a and b
  62536. * @returns the inverseLerp value
  62537. */
  62538. static InverseLerp(a: number, b: number, value: number): number;
  62539. /**
  62540. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  62541. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  62542. * @param value1 spline value
  62543. * @param tangent1 spline value
  62544. * @param value2 spline value
  62545. * @param tangent2 spline value
  62546. * @param amount input value
  62547. * @returns hermite result
  62548. */
  62549. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  62550. /**
  62551. * Returns a random float number between and min and max values
  62552. * @param min min value of random
  62553. * @param max max value of random
  62554. * @returns random value
  62555. */
  62556. static RandomRange(min: number, max: number): number;
  62557. /**
  62558. * This function returns percentage of a number in a given range.
  62559. *
  62560. * RangeToPercent(40,20,60) will return 0.5 (50%)
  62561. * RangeToPercent(34,0,100) will return 0.34 (34%)
  62562. * @param number to convert to percentage
  62563. * @param min min range
  62564. * @param max max range
  62565. * @returns the percentage
  62566. */
  62567. static RangeToPercent(number: number, min: number, max: number): number;
  62568. /**
  62569. * This function returns number that corresponds to the percentage in a given range.
  62570. *
  62571. * PercentToRange(0.34,0,100) will return 34.
  62572. * @param percent to convert to number
  62573. * @param min min range
  62574. * @param max max range
  62575. * @returns the number
  62576. */
  62577. static PercentToRange(percent: number, min: number, max: number): number;
  62578. /**
  62579. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  62580. * @param angle The angle to normalize in radian.
  62581. * @return The converted angle.
  62582. */
  62583. static NormalizeRadians(angle: number): number;
  62584. }
  62585. }
  62586. declare module BABYLON {
  62587. /**
  62588. * Constant used to convert a value to gamma space
  62589. * @ignorenaming
  62590. */
  62591. export const ToGammaSpace: number;
  62592. /**
  62593. * Constant used to convert a value to linear space
  62594. * @ignorenaming
  62595. */
  62596. export const ToLinearSpace = 2.2;
  62597. /**
  62598. * Constant used to define the minimal number value in Babylon.js
  62599. * @ignorenaming
  62600. */
  62601. let Epsilon: number;
  62602. /**
  62603. * Class used to hold a RBG color
  62604. */
  62605. export class Color3 {
  62606. /**
  62607. * Defines the red component (between 0 and 1, default is 0)
  62608. */
  62609. r: number;
  62610. /**
  62611. * Defines the green component (between 0 and 1, default is 0)
  62612. */
  62613. g: number;
  62614. /**
  62615. * Defines the blue component (between 0 and 1, default is 0)
  62616. */
  62617. b: number;
  62618. /**
  62619. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  62620. * @param r defines the red component (between 0 and 1, default is 0)
  62621. * @param g defines the green component (between 0 and 1, default is 0)
  62622. * @param b defines the blue component (between 0 and 1, default is 0)
  62623. */
  62624. constructor(
  62625. /**
  62626. * Defines the red component (between 0 and 1, default is 0)
  62627. */
  62628. r?: number,
  62629. /**
  62630. * Defines the green component (between 0 and 1, default is 0)
  62631. */
  62632. g?: number,
  62633. /**
  62634. * Defines the blue component (between 0 and 1, default is 0)
  62635. */
  62636. b?: number);
  62637. /**
  62638. * Creates a string with the Color3 current values
  62639. * @returns the string representation of the Color3 object
  62640. */
  62641. toString(): string;
  62642. /**
  62643. * Returns the string "Color3"
  62644. * @returns "Color3"
  62645. */
  62646. getClassName(): string;
  62647. /**
  62648. * Compute the Color3 hash code
  62649. * @returns an unique number that can be used to hash Color3 objects
  62650. */
  62651. getHashCode(): number;
  62652. /**
  62653. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  62654. * @param array defines the array where to store the r,g,b components
  62655. * @param index defines an optional index in the target array to define where to start storing values
  62656. * @returns the current Color3 object
  62657. */
  62658. toArray(array: FloatArray, index?: number): Color3;
  62659. /**
  62660. * Returns a new Color4 object from the current Color3 and the given alpha
  62661. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  62662. * @returns a new Color4 object
  62663. */
  62664. toColor4(alpha?: number): Color4;
  62665. /**
  62666. * Returns a new array populated with 3 numeric elements : red, green and blue values
  62667. * @returns the new array
  62668. */
  62669. asArray(): number[];
  62670. /**
  62671. * Returns the luminance value
  62672. * @returns a float value
  62673. */
  62674. toLuminance(): number;
  62675. /**
  62676. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  62677. * @param otherColor defines the second operand
  62678. * @returns the new Color3 object
  62679. */
  62680. multiply(otherColor: DeepImmutable<Color3>): Color3;
  62681. /**
  62682. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  62683. * @param otherColor defines the second operand
  62684. * @param result defines the Color3 object where to store the result
  62685. * @returns the current Color3
  62686. */
  62687. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  62688. /**
  62689. * Determines equality between Color3 objects
  62690. * @param otherColor defines the second operand
  62691. * @returns true if the rgb values are equal to the given ones
  62692. */
  62693. equals(otherColor: DeepImmutable<Color3>): boolean;
  62694. /**
  62695. * Determines equality between the current Color3 object and a set of r,b,g values
  62696. * @param r defines the red component to check
  62697. * @param g defines the green component to check
  62698. * @param b defines the blue component to check
  62699. * @returns true if the rgb values are equal to the given ones
  62700. */
  62701. equalsFloats(r: number, g: number, b: number): boolean;
  62702. /**
  62703. * Multiplies in place each rgb value by scale
  62704. * @param scale defines the scaling factor
  62705. * @returns the updated Color3
  62706. */
  62707. scale(scale: number): Color3;
  62708. /**
  62709. * Multiplies the rgb values by scale and stores the result into "result"
  62710. * @param scale defines the scaling factor
  62711. * @param result defines the Color3 object where to store the result
  62712. * @returns the unmodified current Color3
  62713. */
  62714. scaleToRef(scale: number, result: Color3): Color3;
  62715. /**
  62716. * Scale the current Color3 values by a factor and add the result to a given Color3
  62717. * @param scale defines the scale factor
  62718. * @param result defines color to store the result into
  62719. * @returns the unmodified current Color3
  62720. */
  62721. scaleAndAddToRef(scale: number, result: Color3): Color3;
  62722. /**
  62723. * Clamps the rgb values by the min and max values and stores the result into "result"
  62724. * @param min defines minimum clamping value (default is 0)
  62725. * @param max defines maximum clamping value (default is 1)
  62726. * @param result defines color to store the result into
  62727. * @returns the original Color3
  62728. */
  62729. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  62730. /**
  62731. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  62732. * @param otherColor defines the second operand
  62733. * @returns the new Color3
  62734. */
  62735. add(otherColor: DeepImmutable<Color3>): Color3;
  62736. /**
  62737. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  62738. * @param otherColor defines the second operand
  62739. * @param result defines Color3 object to store the result into
  62740. * @returns the unmodified current Color3
  62741. */
  62742. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  62743. /**
  62744. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  62745. * @param otherColor defines the second operand
  62746. * @returns the new Color3
  62747. */
  62748. subtract(otherColor: DeepImmutable<Color3>): Color3;
  62749. /**
  62750. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  62751. * @param otherColor defines the second operand
  62752. * @param result defines Color3 object to store the result into
  62753. * @returns the unmodified current Color3
  62754. */
  62755. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  62756. /**
  62757. * Copy the current object
  62758. * @returns a new Color3 copied the current one
  62759. */
  62760. clone(): Color3;
  62761. /**
  62762. * Copies the rgb values from the source in the current Color3
  62763. * @param source defines the source Color3 object
  62764. * @returns the updated Color3 object
  62765. */
  62766. copyFrom(source: DeepImmutable<Color3>): Color3;
  62767. /**
  62768. * Updates the Color3 rgb values from the given floats
  62769. * @param r defines the red component to read from
  62770. * @param g defines the green component to read from
  62771. * @param b defines the blue component to read from
  62772. * @returns the current Color3 object
  62773. */
  62774. copyFromFloats(r: number, g: number, b: number): Color3;
  62775. /**
  62776. * Updates the Color3 rgb values from the given floats
  62777. * @param r defines the red component to read from
  62778. * @param g defines the green component to read from
  62779. * @param b defines the blue component to read from
  62780. * @returns the current Color3 object
  62781. */
  62782. set(r: number, g: number, b: number): Color3;
  62783. /**
  62784. * Compute the Color3 hexadecimal code as a string
  62785. * @returns a string containing the hexadecimal representation of the Color3 object
  62786. */
  62787. toHexString(): string;
  62788. /**
  62789. * Computes a new Color3 converted from the current one to linear space
  62790. * @returns a new Color3 object
  62791. */
  62792. toLinearSpace(): Color3;
  62793. /**
  62794. * Converts current color in rgb space to HSV values
  62795. * @returns a new color3 representing the HSV values
  62796. */
  62797. toHSV(): Color3;
  62798. /**
  62799. * Converts current color in rgb space to HSV values
  62800. * @param result defines the Color3 where to store the HSV values
  62801. */
  62802. toHSVToRef(result: Color3): void;
  62803. /**
  62804. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  62805. * @param convertedColor defines the Color3 object where to store the linear space version
  62806. * @returns the unmodified Color3
  62807. */
  62808. toLinearSpaceToRef(convertedColor: Color3): Color3;
  62809. /**
  62810. * Computes a new Color3 converted from the current one to gamma space
  62811. * @returns a new Color3 object
  62812. */
  62813. toGammaSpace(): Color3;
  62814. /**
  62815. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  62816. * @param convertedColor defines the Color3 object where to store the gamma space version
  62817. * @returns the unmodified Color3
  62818. */
  62819. toGammaSpaceToRef(convertedColor: Color3): Color3;
  62820. private static _BlackReadOnly;
  62821. /**
  62822. * Convert Hue, saturation and value to a Color3 (RGB)
  62823. * @param hue defines the hue
  62824. * @param saturation defines the saturation
  62825. * @param value defines the value
  62826. * @param result defines the Color3 where to store the RGB values
  62827. */
  62828. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  62829. /**
  62830. * Creates a new Color3 from the string containing valid hexadecimal values
  62831. * @param hex defines a string containing valid hexadecimal values
  62832. * @returns a new Color3 object
  62833. */
  62834. static FromHexString(hex: string): Color3;
  62835. /**
  62836. * Creates a new Color3 from the starting index of the given array
  62837. * @param array defines the source array
  62838. * @param offset defines an offset in the source array
  62839. * @returns a new Color3 object
  62840. */
  62841. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  62842. /**
  62843. * Creates a new Color3 from integer values (< 256)
  62844. * @param r defines the red component to read from (value between 0 and 255)
  62845. * @param g defines the green component to read from (value between 0 and 255)
  62846. * @param b defines the blue component to read from (value between 0 and 255)
  62847. * @returns a new Color3 object
  62848. */
  62849. static FromInts(r: number, g: number, b: number): Color3;
  62850. /**
  62851. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  62852. * @param start defines the start Color3 value
  62853. * @param end defines the end Color3 value
  62854. * @param amount defines the gradient value between start and end
  62855. * @returns a new Color3 object
  62856. */
  62857. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  62858. /**
  62859. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  62860. * @param left defines the start value
  62861. * @param right defines the end value
  62862. * @param amount defines the gradient factor
  62863. * @param result defines the Color3 object where to store the result
  62864. */
  62865. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  62866. /**
  62867. * Returns a Color3 value containing a red color
  62868. * @returns a new Color3 object
  62869. */
  62870. static Red(): Color3;
  62871. /**
  62872. * Returns a Color3 value containing a green color
  62873. * @returns a new Color3 object
  62874. */
  62875. static Green(): Color3;
  62876. /**
  62877. * Returns a Color3 value containing a blue color
  62878. * @returns a new Color3 object
  62879. */
  62880. static Blue(): Color3;
  62881. /**
  62882. * Returns a Color3 value containing a black color
  62883. * @returns a new Color3 object
  62884. */
  62885. static Black(): Color3;
  62886. /**
  62887. * Gets a Color3 value containing a black color that must not be updated
  62888. */
  62889. static readonly BlackReadOnly: DeepImmutable<Color3>;
  62890. /**
  62891. * Returns a Color3 value containing a white color
  62892. * @returns a new Color3 object
  62893. */
  62894. static White(): Color3;
  62895. /**
  62896. * Returns a Color3 value containing a purple color
  62897. * @returns a new Color3 object
  62898. */
  62899. static Purple(): Color3;
  62900. /**
  62901. * Returns a Color3 value containing a magenta color
  62902. * @returns a new Color3 object
  62903. */
  62904. static Magenta(): Color3;
  62905. /**
  62906. * Returns a Color3 value containing a yellow color
  62907. * @returns a new Color3 object
  62908. */
  62909. static Yellow(): Color3;
  62910. /**
  62911. * Returns a Color3 value containing a gray color
  62912. * @returns a new Color3 object
  62913. */
  62914. static Gray(): Color3;
  62915. /**
  62916. * Returns a Color3 value containing a teal color
  62917. * @returns a new Color3 object
  62918. */
  62919. static Teal(): Color3;
  62920. /**
  62921. * Returns a Color3 value containing a random color
  62922. * @returns a new Color3 object
  62923. */
  62924. static Random(): Color3;
  62925. }
  62926. /**
  62927. * Class used to hold a RBGA color
  62928. */
  62929. export class Color4 {
  62930. /**
  62931. * Defines the red component (between 0 and 1, default is 0)
  62932. */
  62933. r: number;
  62934. /**
  62935. * Defines the green component (between 0 and 1, default is 0)
  62936. */
  62937. g: number;
  62938. /**
  62939. * Defines the blue component (between 0 and 1, default is 0)
  62940. */
  62941. b: number;
  62942. /**
  62943. * Defines the alpha component (between 0 and 1, default is 1)
  62944. */
  62945. a: number;
  62946. /**
  62947. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  62948. * @param r defines the red component (between 0 and 1, default is 0)
  62949. * @param g defines the green component (between 0 and 1, default is 0)
  62950. * @param b defines the blue component (between 0 and 1, default is 0)
  62951. * @param a defines the alpha component (between 0 and 1, default is 1)
  62952. */
  62953. constructor(
  62954. /**
  62955. * Defines the red component (between 0 and 1, default is 0)
  62956. */
  62957. r?: number,
  62958. /**
  62959. * Defines the green component (between 0 and 1, default is 0)
  62960. */
  62961. g?: number,
  62962. /**
  62963. * Defines the blue component (between 0 and 1, default is 0)
  62964. */
  62965. b?: number,
  62966. /**
  62967. * Defines the alpha component (between 0 and 1, default is 1)
  62968. */
  62969. a?: number);
  62970. /**
  62971. * Adds in place the given Color4 values to the current Color4 object
  62972. * @param right defines the second operand
  62973. * @returns the current updated Color4 object
  62974. */
  62975. addInPlace(right: DeepImmutable<Color4>): Color4;
  62976. /**
  62977. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  62978. * @returns the new array
  62979. */
  62980. asArray(): number[];
  62981. /**
  62982. * Stores from the starting index in the given array the Color4 successive values
  62983. * @param array defines the array where to store the r,g,b components
  62984. * @param index defines an optional index in the target array to define where to start storing values
  62985. * @returns the current Color4 object
  62986. */
  62987. toArray(array: number[], index?: number): Color4;
  62988. /**
  62989. * Determines equality between Color4 objects
  62990. * @param otherColor defines the second operand
  62991. * @returns true if the rgba values are equal to the given ones
  62992. */
  62993. equals(otherColor: DeepImmutable<Color4>): boolean;
  62994. /**
  62995. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  62996. * @param right defines the second operand
  62997. * @returns a new Color4 object
  62998. */
  62999. add(right: DeepImmutable<Color4>): Color4;
  63000. /**
  63001. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  63002. * @param right defines the second operand
  63003. * @returns a new Color4 object
  63004. */
  63005. subtract(right: DeepImmutable<Color4>): Color4;
  63006. /**
  63007. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  63008. * @param right defines the second operand
  63009. * @param result defines the Color4 object where to store the result
  63010. * @returns the current Color4 object
  63011. */
  63012. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  63013. /**
  63014. * Creates a new Color4 with the current Color4 values multiplied by scale
  63015. * @param scale defines the scaling factor to apply
  63016. * @returns a new Color4 object
  63017. */
  63018. scale(scale: number): Color4;
  63019. /**
  63020. * Multiplies the current Color4 values by scale and stores the result in "result"
  63021. * @param scale defines the scaling factor to apply
  63022. * @param result defines the Color4 object where to store the result
  63023. * @returns the current unmodified Color4
  63024. */
  63025. scaleToRef(scale: number, result: Color4): Color4;
  63026. /**
  63027. * Scale the current Color4 values by a factor and add the result to a given Color4
  63028. * @param scale defines the scale factor
  63029. * @param result defines the Color4 object where to store the result
  63030. * @returns the unmodified current Color4
  63031. */
  63032. scaleAndAddToRef(scale: number, result: Color4): Color4;
  63033. /**
  63034. * Clamps the rgb values by the min and max values and stores the result into "result"
  63035. * @param min defines minimum clamping value (default is 0)
  63036. * @param max defines maximum clamping value (default is 1)
  63037. * @param result defines color to store the result into.
  63038. * @returns the cuurent Color4
  63039. */
  63040. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  63041. /**
  63042. * Multipy an Color4 value by another and return a new Color4 object
  63043. * @param color defines the Color4 value to multiply by
  63044. * @returns a new Color4 object
  63045. */
  63046. multiply(color: Color4): Color4;
  63047. /**
  63048. * Multipy a Color4 value by another and push the result in a reference value
  63049. * @param color defines the Color4 value to multiply by
  63050. * @param result defines the Color4 to fill the result in
  63051. * @returns the result Color4
  63052. */
  63053. multiplyToRef(color: Color4, result: Color4): Color4;
  63054. /**
  63055. * Creates a string with the Color4 current values
  63056. * @returns the string representation of the Color4 object
  63057. */
  63058. toString(): string;
  63059. /**
  63060. * Returns the string "Color4"
  63061. * @returns "Color4"
  63062. */
  63063. getClassName(): string;
  63064. /**
  63065. * Compute the Color4 hash code
  63066. * @returns an unique number that can be used to hash Color4 objects
  63067. */
  63068. getHashCode(): number;
  63069. /**
  63070. * Creates a new Color4 copied from the current one
  63071. * @returns a new Color4 object
  63072. */
  63073. clone(): Color4;
  63074. /**
  63075. * Copies the given Color4 values into the current one
  63076. * @param source defines the source Color4 object
  63077. * @returns the current updated Color4 object
  63078. */
  63079. copyFrom(source: Color4): Color4;
  63080. /**
  63081. * Copies the given float values into the current one
  63082. * @param r defines the red component to read from
  63083. * @param g defines the green component to read from
  63084. * @param b defines the blue component to read from
  63085. * @param a defines the alpha component to read from
  63086. * @returns the current updated Color4 object
  63087. */
  63088. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  63089. /**
  63090. * Copies the given float values into the current one
  63091. * @param r defines the red component to read from
  63092. * @param g defines the green component to read from
  63093. * @param b defines the blue component to read from
  63094. * @param a defines the alpha component to read from
  63095. * @returns the current updated Color4 object
  63096. */
  63097. set(r: number, g: number, b: number, a: number): Color4;
  63098. /**
  63099. * Compute the Color4 hexadecimal code as a string
  63100. * @returns a string containing the hexadecimal representation of the Color4 object
  63101. */
  63102. toHexString(): string;
  63103. /**
  63104. * Computes a new Color4 converted from the current one to linear space
  63105. * @returns a new Color4 object
  63106. */
  63107. toLinearSpace(): Color4;
  63108. /**
  63109. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  63110. * @param convertedColor defines the Color4 object where to store the linear space version
  63111. * @returns the unmodified Color4
  63112. */
  63113. toLinearSpaceToRef(convertedColor: Color4): Color4;
  63114. /**
  63115. * Computes a new Color4 converted from the current one to gamma space
  63116. * @returns a new Color4 object
  63117. */
  63118. toGammaSpace(): Color4;
  63119. /**
  63120. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  63121. * @param convertedColor defines the Color4 object where to store the gamma space version
  63122. * @returns the unmodified Color4
  63123. */
  63124. toGammaSpaceToRef(convertedColor: Color4): Color4;
  63125. /**
  63126. * Creates a new Color4 from the string containing valid hexadecimal values
  63127. * @param hex defines a string containing valid hexadecimal values
  63128. * @returns a new Color4 object
  63129. */
  63130. static FromHexString(hex: string): Color4;
  63131. /**
  63132. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  63133. * @param left defines the start value
  63134. * @param right defines the end value
  63135. * @param amount defines the gradient factor
  63136. * @returns a new Color4 object
  63137. */
  63138. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  63139. /**
  63140. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  63141. * @param left defines the start value
  63142. * @param right defines the end value
  63143. * @param amount defines the gradient factor
  63144. * @param result defines the Color4 object where to store data
  63145. */
  63146. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  63147. /**
  63148. * Creates a new Color4 from a Color3 and an alpha value
  63149. * @param color3 defines the source Color3 to read from
  63150. * @param alpha defines the alpha component (1.0 by default)
  63151. * @returns a new Color4 object
  63152. */
  63153. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  63154. /**
  63155. * Creates a new Color4 from the starting index element of the given array
  63156. * @param array defines the source array to read from
  63157. * @param offset defines the offset in the source array
  63158. * @returns a new Color4 object
  63159. */
  63160. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  63161. /**
  63162. * Creates a new Color3 from integer values (< 256)
  63163. * @param r defines the red component to read from (value between 0 and 255)
  63164. * @param g defines the green component to read from (value between 0 and 255)
  63165. * @param b defines the blue component to read from (value between 0 and 255)
  63166. * @param a defines the alpha component to read from (value between 0 and 255)
  63167. * @returns a new Color3 object
  63168. */
  63169. static FromInts(r: number, g: number, b: number, a: number): Color4;
  63170. /**
  63171. * Check the content of a given array and convert it to an array containing RGBA data
  63172. * If the original array was already containing count * 4 values then it is returned directly
  63173. * @param colors defines the array to check
  63174. * @param count defines the number of RGBA data to expect
  63175. * @returns an array containing count * 4 values (RGBA)
  63176. */
  63177. static CheckColors4(colors: number[], count: number): number[];
  63178. }
  63179. /**
  63180. * Class representing a vector containing 2 coordinates
  63181. */
  63182. export class Vector2 {
  63183. /** defines the first coordinate */
  63184. x: number;
  63185. /** defines the second coordinate */
  63186. y: number;
  63187. /**
  63188. * Creates a new Vector2 from the given x and y coordinates
  63189. * @param x defines the first coordinate
  63190. * @param y defines the second coordinate
  63191. */
  63192. constructor(
  63193. /** defines the first coordinate */
  63194. x?: number,
  63195. /** defines the second coordinate */
  63196. y?: number);
  63197. /**
  63198. * Gets a string with the Vector2 coordinates
  63199. * @returns a string with the Vector2 coordinates
  63200. */
  63201. toString(): string;
  63202. /**
  63203. * Gets class name
  63204. * @returns the string "Vector2"
  63205. */
  63206. getClassName(): string;
  63207. /**
  63208. * Gets current vector hash code
  63209. * @returns the Vector2 hash code as a number
  63210. */
  63211. getHashCode(): number;
  63212. /**
  63213. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  63214. * @param array defines the source array
  63215. * @param index defines the offset in source array
  63216. * @returns the current Vector2
  63217. */
  63218. toArray(array: FloatArray, index?: number): Vector2;
  63219. /**
  63220. * Copy the current vector to an array
  63221. * @returns a new array with 2 elements: the Vector2 coordinates.
  63222. */
  63223. asArray(): number[];
  63224. /**
  63225. * Sets the Vector2 coordinates with the given Vector2 coordinates
  63226. * @param source defines the source Vector2
  63227. * @returns the current updated Vector2
  63228. */
  63229. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  63230. /**
  63231. * Sets the Vector2 coordinates with the given floats
  63232. * @param x defines the first coordinate
  63233. * @param y defines the second coordinate
  63234. * @returns the current updated Vector2
  63235. */
  63236. copyFromFloats(x: number, y: number): Vector2;
  63237. /**
  63238. * Sets the Vector2 coordinates with the given floats
  63239. * @param x defines the first coordinate
  63240. * @param y defines the second coordinate
  63241. * @returns the current updated Vector2
  63242. */
  63243. set(x: number, y: number): Vector2;
  63244. /**
  63245. * Add another vector with the current one
  63246. * @param otherVector defines the other vector
  63247. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  63248. */
  63249. add(otherVector: DeepImmutable<Vector2>): Vector2;
  63250. /**
  63251. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  63252. * @param otherVector defines the other vector
  63253. * @param result defines the target vector
  63254. * @returns the unmodified current Vector2
  63255. */
  63256. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63257. /**
  63258. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  63259. * @param otherVector defines the other vector
  63260. * @returns the current updated Vector2
  63261. */
  63262. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63263. /**
  63264. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  63265. * @param otherVector defines the other vector
  63266. * @returns a new Vector2
  63267. */
  63268. addVector3(otherVector: Vector3): Vector2;
  63269. /**
  63270. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  63271. * @param otherVector defines the other vector
  63272. * @returns a new Vector2
  63273. */
  63274. subtract(otherVector: Vector2): Vector2;
  63275. /**
  63276. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  63277. * @param otherVector defines the other vector
  63278. * @param result defines the target vector
  63279. * @returns the unmodified current Vector2
  63280. */
  63281. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63282. /**
  63283. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  63284. * @param otherVector defines the other vector
  63285. * @returns the current updated Vector2
  63286. */
  63287. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63288. /**
  63289. * Multiplies in place the current Vector2 coordinates by the given ones
  63290. * @param otherVector defines the other vector
  63291. * @returns the current updated Vector2
  63292. */
  63293. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63294. /**
  63295. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  63296. * @param otherVector defines the other vector
  63297. * @returns a new Vector2
  63298. */
  63299. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  63300. /**
  63301. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  63302. * @param otherVector defines the other vector
  63303. * @param result defines the target vector
  63304. * @returns the unmodified current Vector2
  63305. */
  63306. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63307. /**
  63308. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  63309. * @param x defines the first coordinate
  63310. * @param y defines the second coordinate
  63311. * @returns a new Vector2
  63312. */
  63313. multiplyByFloats(x: number, y: number): Vector2;
  63314. /**
  63315. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  63316. * @param otherVector defines the other vector
  63317. * @returns a new Vector2
  63318. */
  63319. divide(otherVector: Vector2): Vector2;
  63320. /**
  63321. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  63322. * @param otherVector defines the other vector
  63323. * @param result defines the target vector
  63324. * @returns the unmodified current Vector2
  63325. */
  63326. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63327. /**
  63328. * Divides the current Vector2 coordinates by the given ones
  63329. * @param otherVector defines the other vector
  63330. * @returns the current updated Vector2
  63331. */
  63332. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63333. /**
  63334. * Gets a new Vector2 with current Vector2 negated coordinates
  63335. * @returns a new Vector2
  63336. */
  63337. negate(): Vector2;
  63338. /**
  63339. * Multiply the Vector2 coordinates by scale
  63340. * @param scale defines the scaling factor
  63341. * @returns the current updated Vector2
  63342. */
  63343. scaleInPlace(scale: number): Vector2;
  63344. /**
  63345. * Returns a new Vector2 scaled by "scale" from the current Vector2
  63346. * @param scale defines the scaling factor
  63347. * @returns a new Vector2
  63348. */
  63349. scale(scale: number): Vector2;
  63350. /**
  63351. * Scale the current Vector2 values by a factor to a given Vector2
  63352. * @param scale defines the scale factor
  63353. * @param result defines the Vector2 object where to store the result
  63354. * @returns the unmodified current Vector2
  63355. */
  63356. scaleToRef(scale: number, result: Vector2): Vector2;
  63357. /**
  63358. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  63359. * @param scale defines the scale factor
  63360. * @param result defines the Vector2 object where to store the result
  63361. * @returns the unmodified current Vector2
  63362. */
  63363. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  63364. /**
  63365. * Gets a boolean if two vectors are equals
  63366. * @param otherVector defines the other vector
  63367. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  63368. */
  63369. equals(otherVector: DeepImmutable<Vector2>): boolean;
  63370. /**
  63371. * Gets a boolean if two vectors are equals (using an epsilon value)
  63372. * @param otherVector defines the other vector
  63373. * @param epsilon defines the minimal distance to consider equality
  63374. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  63375. */
  63376. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  63377. /**
  63378. * Gets a new Vector2 from current Vector2 floored values
  63379. * @returns a new Vector2
  63380. */
  63381. floor(): Vector2;
  63382. /**
  63383. * Gets a new Vector2 from current Vector2 floored values
  63384. * @returns a new Vector2
  63385. */
  63386. fract(): Vector2;
  63387. /**
  63388. * Gets the length of the vector
  63389. * @returns the vector length (float)
  63390. */
  63391. length(): number;
  63392. /**
  63393. * Gets the vector squared length
  63394. * @returns the vector squared length (float)
  63395. */
  63396. lengthSquared(): number;
  63397. /**
  63398. * Normalize the vector
  63399. * @returns the current updated Vector2
  63400. */
  63401. normalize(): Vector2;
  63402. /**
  63403. * Gets a new Vector2 copied from the Vector2
  63404. * @returns a new Vector2
  63405. */
  63406. clone(): Vector2;
  63407. /**
  63408. * Gets a new Vector2(0, 0)
  63409. * @returns a new Vector2
  63410. */
  63411. static Zero(): Vector2;
  63412. /**
  63413. * Gets a new Vector2(1, 1)
  63414. * @returns a new Vector2
  63415. */
  63416. static One(): Vector2;
  63417. /**
  63418. * Gets a new Vector2 set from the given index element of the given array
  63419. * @param array defines the data source
  63420. * @param offset defines the offset in the data source
  63421. * @returns a new Vector2
  63422. */
  63423. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  63424. /**
  63425. * Sets "result" from the given index element of the given array
  63426. * @param array defines the data source
  63427. * @param offset defines the offset in the data source
  63428. * @param result defines the target vector
  63429. */
  63430. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  63431. /**
  63432. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  63433. * @param value1 defines 1st point of control
  63434. * @param value2 defines 2nd point of control
  63435. * @param value3 defines 3rd point of control
  63436. * @param value4 defines 4th point of control
  63437. * @param amount defines the interpolation factor
  63438. * @returns a new Vector2
  63439. */
  63440. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  63441. /**
  63442. * 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".
  63443. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  63444. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  63445. * @param value defines the value to clamp
  63446. * @param min defines the lower limit
  63447. * @param max defines the upper limit
  63448. * @returns a new Vector2
  63449. */
  63450. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  63451. /**
  63452. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  63453. * @param value1 defines the 1st control point
  63454. * @param tangent1 defines the outgoing tangent
  63455. * @param value2 defines the 2nd control point
  63456. * @param tangent2 defines the incoming tangent
  63457. * @param amount defines the interpolation factor
  63458. * @returns a new Vector2
  63459. */
  63460. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  63461. /**
  63462. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  63463. * @param start defines the start vector
  63464. * @param end defines the end vector
  63465. * @param amount defines the interpolation factor
  63466. * @returns a new Vector2
  63467. */
  63468. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  63469. /**
  63470. * Gets the dot product of the vector "left" and the vector "right"
  63471. * @param left defines first vector
  63472. * @param right defines second vector
  63473. * @returns the dot product (float)
  63474. */
  63475. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  63476. /**
  63477. * Returns a new Vector2 equal to the normalized given vector
  63478. * @param vector defines the vector to normalize
  63479. * @returns a new Vector2
  63480. */
  63481. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  63482. /**
  63483. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  63484. * @param left defines 1st vector
  63485. * @param right defines 2nd vector
  63486. * @returns a new Vector2
  63487. */
  63488. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  63489. /**
  63490. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  63491. * @param left defines 1st vector
  63492. * @param right defines 2nd vector
  63493. * @returns a new Vector2
  63494. */
  63495. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  63496. /**
  63497. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  63498. * @param vector defines the vector to transform
  63499. * @param transformation defines the matrix to apply
  63500. * @returns a new Vector2
  63501. */
  63502. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  63503. /**
  63504. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  63505. * @param vector defines the vector to transform
  63506. * @param transformation defines the matrix to apply
  63507. * @param result defines the target vector
  63508. */
  63509. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  63510. /**
  63511. * Determines if a given vector is included in a triangle
  63512. * @param p defines the vector to test
  63513. * @param p0 defines 1st triangle point
  63514. * @param p1 defines 2nd triangle point
  63515. * @param p2 defines 3rd triangle point
  63516. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  63517. */
  63518. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  63519. /**
  63520. * Gets the distance between the vectors "value1" and "value2"
  63521. * @param value1 defines first vector
  63522. * @param value2 defines second vector
  63523. * @returns the distance between vectors
  63524. */
  63525. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  63526. /**
  63527. * Returns the squared distance between the vectors "value1" and "value2"
  63528. * @param value1 defines first vector
  63529. * @param value2 defines second vector
  63530. * @returns the squared distance between vectors
  63531. */
  63532. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  63533. /**
  63534. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  63535. * @param value1 defines first vector
  63536. * @param value2 defines second vector
  63537. * @returns a new Vector2
  63538. */
  63539. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  63540. /**
  63541. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  63542. * @param p defines the middle point
  63543. * @param segA defines one point of the segment
  63544. * @param segB defines the other point of the segment
  63545. * @returns the shortest distance
  63546. */
  63547. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  63548. }
  63549. /**
  63550. * Classed used to store (x,y,z) vector representation
  63551. * A Vector3 is the main object used in 3D geometry
  63552. * It can represent etiher the coordinates of a point the space, either a direction
  63553. * Reminder: js uses a left handed forward facing system
  63554. */
  63555. export class Vector3 {
  63556. /**
  63557. * Defines the first coordinates (on X axis)
  63558. */
  63559. x: number;
  63560. /**
  63561. * Defines the second coordinates (on Y axis)
  63562. */
  63563. y: number;
  63564. /**
  63565. * Defines the third coordinates (on Z axis)
  63566. */
  63567. z: number;
  63568. private static _UpReadOnly;
  63569. private static _ZeroReadOnly;
  63570. /**
  63571. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  63572. * @param x defines the first coordinates (on X axis)
  63573. * @param y defines the second coordinates (on Y axis)
  63574. * @param z defines the third coordinates (on Z axis)
  63575. */
  63576. constructor(
  63577. /**
  63578. * Defines the first coordinates (on X axis)
  63579. */
  63580. x?: number,
  63581. /**
  63582. * Defines the second coordinates (on Y axis)
  63583. */
  63584. y?: number,
  63585. /**
  63586. * Defines the third coordinates (on Z axis)
  63587. */
  63588. z?: number);
  63589. /**
  63590. * Creates a string representation of the Vector3
  63591. * @returns a string with the Vector3 coordinates.
  63592. */
  63593. toString(): string;
  63594. /**
  63595. * Gets the class name
  63596. * @returns the string "Vector3"
  63597. */
  63598. getClassName(): string;
  63599. /**
  63600. * Creates the Vector3 hash code
  63601. * @returns a number which tends to be unique between Vector3 instances
  63602. */
  63603. getHashCode(): number;
  63604. /**
  63605. * Creates an array containing three elements : the coordinates of the Vector3
  63606. * @returns a new array of numbers
  63607. */
  63608. asArray(): number[];
  63609. /**
  63610. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  63611. * @param array defines the destination array
  63612. * @param index defines the offset in the destination array
  63613. * @returns the current Vector3
  63614. */
  63615. toArray(array: FloatArray, index?: number): Vector3;
  63616. /**
  63617. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  63618. * @returns a new Quaternion object, computed from the Vector3 coordinates
  63619. */
  63620. toQuaternion(): Quaternion;
  63621. /**
  63622. * Adds the given vector to the current Vector3
  63623. * @param otherVector defines the second operand
  63624. * @returns the current updated Vector3
  63625. */
  63626. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  63627. /**
  63628. * Adds the given coordinates to the current Vector3
  63629. * @param x defines the x coordinate of the operand
  63630. * @param y defines the y coordinate of the operand
  63631. * @param z defines the z coordinate of the operand
  63632. * @returns the current updated Vector3
  63633. */
  63634. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  63635. /**
  63636. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  63637. * @param otherVector defines the second operand
  63638. * @returns the resulting Vector3
  63639. */
  63640. add(otherVector: DeepImmutable<Vector3>): Vector3;
  63641. /**
  63642. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  63643. * @param otherVector defines the second operand
  63644. * @param result defines the Vector3 object where to store the result
  63645. * @returns the current Vector3
  63646. */
  63647. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  63648. /**
  63649. * Subtract the given vector from the current Vector3
  63650. * @param otherVector defines the second operand
  63651. * @returns the current updated Vector3
  63652. */
  63653. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  63654. /**
  63655. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  63656. * @param otherVector defines the second operand
  63657. * @returns the resulting Vector3
  63658. */
  63659. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  63660. /**
  63661. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  63662. * @param otherVector defines the second operand
  63663. * @param result defines the Vector3 object where to store the result
  63664. * @returns the current Vector3
  63665. */
  63666. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  63667. /**
  63668. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  63669. * @param x defines the x coordinate of the operand
  63670. * @param y defines the y coordinate of the operand
  63671. * @param z defines the z coordinate of the operand
  63672. * @returns the resulting Vector3
  63673. */
  63674. subtractFromFloats(x: number, y: number, z: number): Vector3;
  63675. /**
  63676. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  63677. * @param x defines the x coordinate of the operand
  63678. * @param y defines the y coordinate of the operand
  63679. * @param z defines the z coordinate of the operand
  63680. * @param result defines the Vector3 object where to store the result
  63681. * @returns the current Vector3
  63682. */
  63683. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  63684. /**
  63685. * Gets a new Vector3 set with the current Vector3 negated coordinates
  63686. * @returns a new Vector3
  63687. */
  63688. negate(): Vector3;
  63689. /**
  63690. * Multiplies the Vector3 coordinates by the float "scale"
  63691. * @param scale defines the multiplier factor
  63692. * @returns the current updated Vector3
  63693. */
  63694. scaleInPlace(scale: number): Vector3;
  63695. /**
  63696. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  63697. * @param scale defines the multiplier factor
  63698. * @returns a new Vector3
  63699. */
  63700. scale(scale: number): Vector3;
  63701. /**
  63702. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  63703. * @param scale defines the multiplier factor
  63704. * @param result defines the Vector3 object where to store the result
  63705. * @returns the current Vector3
  63706. */
  63707. scaleToRef(scale: number, result: Vector3): Vector3;
  63708. /**
  63709. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  63710. * @param scale defines the scale factor
  63711. * @param result defines the Vector3 object where to store the result
  63712. * @returns the unmodified current Vector3
  63713. */
  63714. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  63715. /**
  63716. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  63717. * @param otherVector defines the second operand
  63718. * @returns true if both vectors are equals
  63719. */
  63720. equals(otherVector: DeepImmutable<Vector3>): boolean;
  63721. /**
  63722. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  63723. * @param otherVector defines the second operand
  63724. * @param epsilon defines the minimal distance to define values as equals
  63725. * @returns true if both vectors are distant less than epsilon
  63726. */
  63727. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  63728. /**
  63729. * Returns true if the current Vector3 coordinates equals the given floats
  63730. * @param x defines the x coordinate of the operand
  63731. * @param y defines the y coordinate of the operand
  63732. * @param z defines the z coordinate of the operand
  63733. * @returns true if both vectors are equals
  63734. */
  63735. equalsToFloats(x: number, y: number, z: number): boolean;
  63736. /**
  63737. * Multiplies the current Vector3 coordinates by the given ones
  63738. * @param otherVector defines the second operand
  63739. * @returns the current updated Vector3
  63740. */
  63741. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  63742. /**
  63743. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  63744. * @param otherVector defines the second operand
  63745. * @returns the new Vector3
  63746. */
  63747. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  63748. /**
  63749. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  63750. * @param otherVector defines the second operand
  63751. * @param result defines the Vector3 object where to store the result
  63752. * @returns the current Vector3
  63753. */
  63754. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  63755. /**
  63756. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  63757. * @param x defines the x coordinate of the operand
  63758. * @param y defines the y coordinate of the operand
  63759. * @param z defines the z coordinate of the operand
  63760. * @returns the new Vector3
  63761. */
  63762. multiplyByFloats(x: number, y: number, z: number): Vector3;
  63763. /**
  63764. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  63765. * @param otherVector defines the second operand
  63766. * @returns the new Vector3
  63767. */
  63768. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  63769. /**
  63770. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  63771. * @param otherVector defines the second operand
  63772. * @param result defines the Vector3 object where to store the result
  63773. * @returns the current Vector3
  63774. */
  63775. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  63776. /**
  63777. * Divides the current Vector3 coordinates by the given ones.
  63778. * @param otherVector defines the second operand
  63779. * @returns the current updated Vector3
  63780. */
  63781. divideInPlace(otherVector: Vector3): Vector3;
  63782. /**
  63783. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  63784. * @param other defines the second operand
  63785. * @returns the current updated Vector3
  63786. */
  63787. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  63788. /**
  63789. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  63790. * @param other defines the second operand
  63791. * @returns the current updated Vector3
  63792. */
  63793. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  63794. /**
  63795. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  63796. * @param x defines the x coordinate of the operand
  63797. * @param y defines the y coordinate of the operand
  63798. * @param z defines the z coordinate of the operand
  63799. * @returns the current updated Vector3
  63800. */
  63801. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  63802. /**
  63803. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  63804. * @param x defines the x coordinate of the operand
  63805. * @param y defines the y coordinate of the operand
  63806. * @param z defines the z coordinate of the operand
  63807. * @returns the current updated Vector3
  63808. */
  63809. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  63810. /**
  63811. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  63812. * Check if is non uniform within a certain amount of decimal places to account for this
  63813. * @param epsilon the amount the values can differ
  63814. * @returns if the the vector is non uniform to a certain number of decimal places
  63815. */
  63816. isNonUniformWithinEpsilon(epsilon: number): boolean;
  63817. /**
  63818. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  63819. */
  63820. readonly isNonUniform: boolean;
  63821. /**
  63822. * Gets a new Vector3 from current Vector3 floored values
  63823. * @returns a new Vector3
  63824. */
  63825. floor(): Vector3;
  63826. /**
  63827. * Gets a new Vector3 from current Vector3 floored values
  63828. * @returns a new Vector3
  63829. */
  63830. fract(): Vector3;
  63831. /**
  63832. * Gets the length of the Vector3
  63833. * @returns the length of the Vecto3
  63834. */
  63835. length(): number;
  63836. /**
  63837. * Gets the squared length of the Vector3
  63838. * @returns squared length of the Vector3
  63839. */
  63840. lengthSquared(): number;
  63841. /**
  63842. * Normalize the current Vector3.
  63843. * Please note that this is an in place operation.
  63844. * @returns the current updated Vector3
  63845. */
  63846. normalize(): Vector3;
  63847. /**
  63848. * Reorders the x y z properties of the vector in place
  63849. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  63850. * @returns the current updated vector
  63851. */
  63852. reorderInPlace(order: string): this;
  63853. /**
  63854. * Rotates the vector around 0,0,0 by a quaternion
  63855. * @param quaternion the rotation quaternion
  63856. * @param result vector to store the result
  63857. * @returns the resulting vector
  63858. */
  63859. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  63860. /**
  63861. * Rotates a vector around a given point
  63862. * @param quaternion the rotation quaternion
  63863. * @param point the point to rotate around
  63864. * @param result vector to store the result
  63865. * @returns the resulting vector
  63866. */
  63867. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  63868. /**
  63869. * Normalize the current Vector3 with the given input length.
  63870. * Please note that this is an in place operation.
  63871. * @param len the length of the vector
  63872. * @returns the current updated Vector3
  63873. */
  63874. normalizeFromLength(len: number): Vector3;
  63875. /**
  63876. * Normalize the current Vector3 to a new vector
  63877. * @returns the new Vector3
  63878. */
  63879. normalizeToNew(): Vector3;
  63880. /**
  63881. * Normalize the current Vector3 to the reference
  63882. * @param reference define the Vector3 to update
  63883. * @returns the updated Vector3
  63884. */
  63885. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  63886. /**
  63887. * Creates a new Vector3 copied from the current Vector3
  63888. * @returns the new Vector3
  63889. */
  63890. clone(): Vector3;
  63891. /**
  63892. * Copies the given vector coordinates to the current Vector3 ones
  63893. * @param source defines the source Vector3
  63894. * @returns the current updated Vector3
  63895. */
  63896. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  63897. /**
  63898. * Copies the given floats to the current Vector3 coordinates
  63899. * @param x defines the x coordinate of the operand
  63900. * @param y defines the y coordinate of the operand
  63901. * @param z defines the z coordinate of the operand
  63902. * @returns the current updated Vector3
  63903. */
  63904. copyFromFloats(x: number, y: number, z: number): Vector3;
  63905. /**
  63906. * Copies the given floats to the current Vector3 coordinates
  63907. * @param x defines the x coordinate of the operand
  63908. * @param y defines the y coordinate of the operand
  63909. * @param z defines the z coordinate of the operand
  63910. * @returns the current updated Vector3
  63911. */
  63912. set(x: number, y: number, z: number): Vector3;
  63913. /**
  63914. * Copies the given float to the current Vector3 coordinates
  63915. * @param v defines the x, y and z coordinates of the operand
  63916. * @returns the current updated Vector3
  63917. */
  63918. setAll(v: number): Vector3;
  63919. /**
  63920. * Get the clip factor between two vectors
  63921. * @param vector0 defines the first operand
  63922. * @param vector1 defines the second operand
  63923. * @param axis defines the axis to use
  63924. * @param size defines the size along the axis
  63925. * @returns the clip factor
  63926. */
  63927. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  63928. /**
  63929. * Get angle between two vectors
  63930. * @param vector0 angle between vector0 and vector1
  63931. * @param vector1 angle between vector0 and vector1
  63932. * @param normal direction of the normal
  63933. * @return the angle between vector0 and vector1
  63934. */
  63935. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  63936. /**
  63937. * Returns a new Vector3 set from the index "offset" of the given array
  63938. * @param array defines the source array
  63939. * @param offset defines the offset in the source array
  63940. * @returns the new Vector3
  63941. */
  63942. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  63943. /**
  63944. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  63945. * This function is deprecated. Use FromArray instead
  63946. * @param array defines the source array
  63947. * @param offset defines the offset in the source array
  63948. * @returns the new Vector3
  63949. */
  63950. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  63951. /**
  63952. * Sets the given vector "result" with the element values from the index "offset" of the given array
  63953. * @param array defines the source array
  63954. * @param offset defines the offset in the source array
  63955. * @param result defines the Vector3 where to store the result
  63956. */
  63957. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  63958. /**
  63959. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  63960. * This function is deprecated. Use FromArrayToRef instead.
  63961. * @param array defines the source array
  63962. * @param offset defines the offset in the source array
  63963. * @param result defines the Vector3 where to store the result
  63964. */
  63965. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  63966. /**
  63967. * Sets the given vector "result" with the given floats.
  63968. * @param x defines the x coordinate of the source
  63969. * @param y defines the y coordinate of the source
  63970. * @param z defines the z coordinate of the source
  63971. * @param result defines the Vector3 where to store the result
  63972. */
  63973. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  63974. /**
  63975. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  63976. * @returns a new empty Vector3
  63977. */
  63978. static Zero(): Vector3;
  63979. /**
  63980. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  63981. * @returns a new unit Vector3
  63982. */
  63983. static One(): Vector3;
  63984. /**
  63985. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  63986. * @returns a new up Vector3
  63987. */
  63988. static Up(): Vector3;
  63989. /**
  63990. * Gets a up Vector3 that must not be updated
  63991. */
  63992. static readonly UpReadOnly: DeepImmutable<Vector3>;
  63993. /**
  63994. * Gets a zero Vector3 that must not be updated
  63995. */
  63996. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  63997. /**
  63998. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  63999. * @returns a new down Vector3
  64000. */
  64001. static Down(): Vector3;
  64002. /**
  64003. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  64004. * @returns a new forward Vector3
  64005. */
  64006. static Forward(): Vector3;
  64007. /**
  64008. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  64009. * @returns a new forward Vector3
  64010. */
  64011. static Backward(): Vector3;
  64012. /**
  64013. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  64014. * @returns a new right Vector3
  64015. */
  64016. static Right(): Vector3;
  64017. /**
  64018. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  64019. * @returns a new left Vector3
  64020. */
  64021. static Left(): Vector3;
  64022. /**
  64023. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  64024. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  64025. * @param vector defines the Vector3 to transform
  64026. * @param transformation defines the transformation matrix
  64027. * @returns the transformed Vector3
  64028. */
  64029. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  64030. /**
  64031. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  64032. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  64033. * @param vector defines the Vector3 to transform
  64034. * @param transformation defines the transformation matrix
  64035. * @param result defines the Vector3 where to store the result
  64036. */
  64037. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64038. /**
  64039. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  64040. * This method computes tranformed coordinates only, not transformed direction vectors
  64041. * @param x define the x coordinate of the source vector
  64042. * @param y define the y coordinate of the source vector
  64043. * @param z define the z coordinate of the source vector
  64044. * @param transformation defines the transformation matrix
  64045. * @param result defines the Vector3 where to store the result
  64046. */
  64047. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64048. /**
  64049. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  64050. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64051. * @param vector defines the Vector3 to transform
  64052. * @param transformation defines the transformation matrix
  64053. * @returns the new Vector3
  64054. */
  64055. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  64056. /**
  64057. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  64058. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64059. * @param vector defines the Vector3 to transform
  64060. * @param transformation defines the transformation matrix
  64061. * @param result defines the Vector3 where to store the result
  64062. */
  64063. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64064. /**
  64065. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  64066. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64067. * @param x define the x coordinate of the source vector
  64068. * @param y define the y coordinate of the source vector
  64069. * @param z define the z coordinate of the source vector
  64070. * @param transformation defines the transformation matrix
  64071. * @param result defines the Vector3 where to store the result
  64072. */
  64073. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64074. /**
  64075. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  64076. * @param value1 defines the first control point
  64077. * @param value2 defines the second control point
  64078. * @param value3 defines the third control point
  64079. * @param value4 defines the fourth control point
  64080. * @param amount defines the amount on the spline to use
  64081. * @returns the new Vector3
  64082. */
  64083. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  64084. /**
  64085. * 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"
  64086. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  64087. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  64088. * @param value defines the current value
  64089. * @param min defines the lower range value
  64090. * @param max defines the upper range value
  64091. * @returns the new Vector3
  64092. */
  64093. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  64094. /**
  64095. * 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"
  64096. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  64097. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  64098. * @param value defines the current value
  64099. * @param min defines the lower range value
  64100. * @param max defines the upper range value
  64101. * @param result defines the Vector3 where to store the result
  64102. */
  64103. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  64104. /**
  64105. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  64106. * @param value1 defines the first control point
  64107. * @param tangent1 defines the first tangent vector
  64108. * @param value2 defines the second control point
  64109. * @param tangent2 defines the second tangent vector
  64110. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  64111. * @returns the new Vector3
  64112. */
  64113. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  64114. /**
  64115. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  64116. * @param start defines the start value
  64117. * @param end defines the end value
  64118. * @param amount max defines amount between both (between 0 and 1)
  64119. * @returns the new Vector3
  64120. */
  64121. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  64122. /**
  64123. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  64124. * @param start defines the start value
  64125. * @param end defines the end value
  64126. * @param amount max defines amount between both (between 0 and 1)
  64127. * @param result defines the Vector3 where to store the result
  64128. */
  64129. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  64130. /**
  64131. * Returns the dot product (float) between the vectors "left" and "right"
  64132. * @param left defines the left operand
  64133. * @param right defines the right operand
  64134. * @returns the dot product
  64135. */
  64136. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  64137. /**
  64138. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  64139. * The cross product is then orthogonal to both "left" and "right"
  64140. * @param left defines the left operand
  64141. * @param right defines the right operand
  64142. * @returns the cross product
  64143. */
  64144. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64145. /**
  64146. * Sets the given vector "result" with the cross product of "left" and "right"
  64147. * The cross product is then orthogonal to both "left" and "right"
  64148. * @param left defines the left operand
  64149. * @param right defines the right operand
  64150. * @param result defines the Vector3 where to store the result
  64151. */
  64152. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  64153. /**
  64154. * Returns a new Vector3 as the normalization of the given vector
  64155. * @param vector defines the Vector3 to normalize
  64156. * @returns the new Vector3
  64157. */
  64158. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  64159. /**
  64160. * Sets the given vector "result" with the normalization of the given first vector
  64161. * @param vector defines the Vector3 to normalize
  64162. * @param result defines the Vector3 where to store the result
  64163. */
  64164. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  64165. /**
  64166. * Project a Vector3 onto screen space
  64167. * @param vector defines the Vector3 to project
  64168. * @param world defines the world matrix to use
  64169. * @param transform defines the transform (view x projection) matrix to use
  64170. * @param viewport defines the screen viewport to use
  64171. * @returns the new Vector3
  64172. */
  64173. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  64174. /** @hidden */
  64175. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  64176. /**
  64177. * Unproject from screen space to object space
  64178. * @param source defines the screen space Vector3 to use
  64179. * @param viewportWidth defines the current width of the viewport
  64180. * @param viewportHeight defines the current height of the viewport
  64181. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64182. * @param transform defines the transform (view x projection) matrix to use
  64183. * @returns the new Vector3
  64184. */
  64185. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  64186. /**
  64187. * Unproject from screen space to object space
  64188. * @param source defines the screen space Vector3 to use
  64189. * @param viewportWidth defines the current width of the viewport
  64190. * @param viewportHeight defines the current height of the viewport
  64191. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64192. * @param view defines the view matrix to use
  64193. * @param projection defines the projection matrix to use
  64194. * @returns the new Vector3
  64195. */
  64196. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  64197. /**
  64198. * Unproject from screen space to object space
  64199. * @param source defines the screen space Vector3 to use
  64200. * @param viewportWidth defines the current width of the viewport
  64201. * @param viewportHeight defines the current height of the viewport
  64202. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64203. * @param view defines the view matrix to use
  64204. * @param projection defines the projection matrix to use
  64205. * @param result defines the Vector3 where to store the result
  64206. */
  64207. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  64208. /**
  64209. * Unproject from screen space to object space
  64210. * @param sourceX defines the screen space x coordinate to use
  64211. * @param sourceY defines the screen space y coordinate to use
  64212. * @param sourceZ defines the screen space z coordinate to use
  64213. * @param viewportWidth defines the current width of the viewport
  64214. * @param viewportHeight defines the current height of the viewport
  64215. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64216. * @param view defines the view matrix to use
  64217. * @param projection defines the projection matrix to use
  64218. * @param result defines the Vector3 where to store the result
  64219. */
  64220. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  64221. /**
  64222. * Gets the minimal coordinate values between two Vector3
  64223. * @param left defines the first operand
  64224. * @param right defines the second operand
  64225. * @returns the new Vector3
  64226. */
  64227. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64228. /**
  64229. * Gets the maximal coordinate values between two Vector3
  64230. * @param left defines the first operand
  64231. * @param right defines the second operand
  64232. * @returns the new Vector3
  64233. */
  64234. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64235. /**
  64236. * Returns the distance between the vectors "value1" and "value2"
  64237. * @param value1 defines the first operand
  64238. * @param value2 defines the second operand
  64239. * @returns the distance
  64240. */
  64241. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  64242. /**
  64243. * Returns the squared distance between the vectors "value1" and "value2"
  64244. * @param value1 defines the first operand
  64245. * @param value2 defines the second operand
  64246. * @returns the squared distance
  64247. */
  64248. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  64249. /**
  64250. * Returns a new Vector3 located at the center between "value1" and "value2"
  64251. * @param value1 defines the first operand
  64252. * @param value2 defines the second operand
  64253. * @returns the new Vector3
  64254. */
  64255. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  64256. /**
  64257. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  64258. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  64259. * to something in order to rotate it from its local system to the given target system
  64260. * Note: axis1, axis2 and axis3 are normalized during this operation
  64261. * @param axis1 defines the first axis
  64262. * @param axis2 defines the second axis
  64263. * @param axis3 defines the third axis
  64264. * @returns a new Vector3
  64265. */
  64266. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  64267. /**
  64268. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  64269. * @param axis1 defines the first axis
  64270. * @param axis2 defines the second axis
  64271. * @param axis3 defines the third axis
  64272. * @param ref defines the Vector3 where to store the result
  64273. */
  64274. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  64275. }
  64276. /**
  64277. * Vector4 class created for EulerAngle class conversion to Quaternion
  64278. */
  64279. export class Vector4 {
  64280. /** x value of the vector */
  64281. x: number;
  64282. /** y value of the vector */
  64283. y: number;
  64284. /** z value of the vector */
  64285. z: number;
  64286. /** w value of the vector */
  64287. w: number;
  64288. /**
  64289. * Creates a Vector4 object from the given floats.
  64290. * @param x x value of the vector
  64291. * @param y y value of the vector
  64292. * @param z z value of the vector
  64293. * @param w w value of the vector
  64294. */
  64295. constructor(
  64296. /** x value of the vector */
  64297. x: number,
  64298. /** y value of the vector */
  64299. y: number,
  64300. /** z value of the vector */
  64301. z: number,
  64302. /** w value of the vector */
  64303. w: number);
  64304. /**
  64305. * Returns the string with the Vector4 coordinates.
  64306. * @returns a string containing all the vector values
  64307. */
  64308. toString(): string;
  64309. /**
  64310. * Returns the string "Vector4".
  64311. * @returns "Vector4"
  64312. */
  64313. getClassName(): string;
  64314. /**
  64315. * Returns the Vector4 hash code.
  64316. * @returns a unique hash code
  64317. */
  64318. getHashCode(): number;
  64319. /**
  64320. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  64321. * @returns the resulting array
  64322. */
  64323. asArray(): number[];
  64324. /**
  64325. * Populates the given array from the given index with the Vector4 coordinates.
  64326. * @param array array to populate
  64327. * @param index index of the array to start at (default: 0)
  64328. * @returns the Vector4.
  64329. */
  64330. toArray(array: FloatArray, index?: number): Vector4;
  64331. /**
  64332. * Adds the given vector to the current Vector4.
  64333. * @param otherVector the vector to add
  64334. * @returns the updated Vector4.
  64335. */
  64336. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64337. /**
  64338. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  64339. * @param otherVector the vector to add
  64340. * @returns the resulting vector
  64341. */
  64342. add(otherVector: DeepImmutable<Vector4>): Vector4;
  64343. /**
  64344. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  64345. * @param otherVector the vector to add
  64346. * @param result the vector to store the result
  64347. * @returns the current Vector4.
  64348. */
  64349. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64350. /**
  64351. * Subtract in place the given vector from the current Vector4.
  64352. * @param otherVector the vector to subtract
  64353. * @returns the updated Vector4.
  64354. */
  64355. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64356. /**
  64357. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  64358. * @param otherVector the vector to add
  64359. * @returns the new vector with the result
  64360. */
  64361. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  64362. /**
  64363. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  64364. * @param otherVector the vector to subtract
  64365. * @param result the vector to store the result
  64366. * @returns the current Vector4.
  64367. */
  64368. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64369. /**
  64370. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64371. */
  64372. /**
  64373. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64374. * @param x value to subtract
  64375. * @param y value to subtract
  64376. * @param z value to subtract
  64377. * @param w value to subtract
  64378. * @returns new vector containing the result
  64379. */
  64380. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  64381. /**
  64382. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64383. * @param x value to subtract
  64384. * @param y value to subtract
  64385. * @param z value to subtract
  64386. * @param w value to subtract
  64387. * @param result the vector to store the result in
  64388. * @returns the current Vector4.
  64389. */
  64390. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  64391. /**
  64392. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  64393. * @returns a new vector with the negated values
  64394. */
  64395. negate(): Vector4;
  64396. /**
  64397. * Multiplies the current Vector4 coordinates by scale (float).
  64398. * @param scale the number to scale with
  64399. * @returns the updated Vector4.
  64400. */
  64401. scaleInPlace(scale: number): Vector4;
  64402. /**
  64403. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  64404. * @param scale the number to scale with
  64405. * @returns a new vector with the result
  64406. */
  64407. scale(scale: number): Vector4;
  64408. /**
  64409. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  64410. * @param scale the number to scale with
  64411. * @param result a vector to store the result in
  64412. * @returns the current Vector4.
  64413. */
  64414. scaleToRef(scale: number, result: Vector4): Vector4;
  64415. /**
  64416. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  64417. * @param scale defines the scale factor
  64418. * @param result defines the Vector4 object where to store the result
  64419. * @returns the unmodified current Vector4
  64420. */
  64421. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  64422. /**
  64423. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  64424. * @param otherVector the vector to compare against
  64425. * @returns true if they are equal
  64426. */
  64427. equals(otherVector: DeepImmutable<Vector4>): boolean;
  64428. /**
  64429. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  64430. * @param otherVector vector to compare against
  64431. * @param epsilon (Default: very small number)
  64432. * @returns true if they are equal
  64433. */
  64434. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  64435. /**
  64436. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  64437. * @param x x value to compare against
  64438. * @param y y value to compare against
  64439. * @param z z value to compare against
  64440. * @param w w value to compare against
  64441. * @returns true if equal
  64442. */
  64443. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  64444. /**
  64445. * Multiplies in place the current Vector4 by the given one.
  64446. * @param otherVector vector to multiple with
  64447. * @returns the updated Vector4.
  64448. */
  64449. multiplyInPlace(otherVector: Vector4): Vector4;
  64450. /**
  64451. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  64452. * @param otherVector vector to multiple with
  64453. * @returns resulting new vector
  64454. */
  64455. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  64456. /**
  64457. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  64458. * @param otherVector vector to multiple with
  64459. * @param result vector to store the result
  64460. * @returns the current Vector4.
  64461. */
  64462. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64463. /**
  64464. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  64465. * @param x x value multiply with
  64466. * @param y y value multiply with
  64467. * @param z z value multiply with
  64468. * @param w w value multiply with
  64469. * @returns resulting new vector
  64470. */
  64471. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  64472. /**
  64473. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  64474. * @param otherVector vector to devide with
  64475. * @returns resulting new vector
  64476. */
  64477. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  64478. /**
  64479. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  64480. * @param otherVector vector to devide with
  64481. * @param result vector to store the result
  64482. * @returns the current Vector4.
  64483. */
  64484. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64485. /**
  64486. * Divides the current Vector3 coordinates by the given ones.
  64487. * @param otherVector vector to devide with
  64488. * @returns the updated Vector3.
  64489. */
  64490. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64491. /**
  64492. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  64493. * @param other defines the second operand
  64494. * @returns the current updated Vector4
  64495. */
  64496. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  64497. /**
  64498. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  64499. * @param other defines the second operand
  64500. * @returns the current updated Vector4
  64501. */
  64502. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  64503. /**
  64504. * Gets a new Vector4 from current Vector4 floored values
  64505. * @returns a new Vector4
  64506. */
  64507. floor(): Vector4;
  64508. /**
  64509. * Gets a new Vector4 from current Vector3 floored values
  64510. * @returns a new Vector4
  64511. */
  64512. fract(): Vector4;
  64513. /**
  64514. * Returns the Vector4 length (float).
  64515. * @returns the length
  64516. */
  64517. length(): number;
  64518. /**
  64519. * Returns the Vector4 squared length (float).
  64520. * @returns the length squared
  64521. */
  64522. lengthSquared(): number;
  64523. /**
  64524. * Normalizes in place the Vector4.
  64525. * @returns the updated Vector4.
  64526. */
  64527. normalize(): Vector4;
  64528. /**
  64529. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  64530. * @returns this converted to a new vector3
  64531. */
  64532. toVector3(): Vector3;
  64533. /**
  64534. * Returns a new Vector4 copied from the current one.
  64535. * @returns the new cloned vector
  64536. */
  64537. clone(): Vector4;
  64538. /**
  64539. * Updates the current Vector4 with the given one coordinates.
  64540. * @param source the source vector to copy from
  64541. * @returns the updated Vector4.
  64542. */
  64543. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  64544. /**
  64545. * Updates the current Vector4 coordinates with the given floats.
  64546. * @param x float to copy from
  64547. * @param y float to copy from
  64548. * @param z float to copy from
  64549. * @param w float to copy from
  64550. * @returns the updated Vector4.
  64551. */
  64552. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  64553. /**
  64554. * Updates the current Vector4 coordinates with the given floats.
  64555. * @param x float to set from
  64556. * @param y float to set from
  64557. * @param z float to set from
  64558. * @param w float to set from
  64559. * @returns the updated Vector4.
  64560. */
  64561. set(x: number, y: number, z: number, w: number): Vector4;
  64562. /**
  64563. * Copies the given float to the current Vector3 coordinates
  64564. * @param v defines the x, y, z and w coordinates of the operand
  64565. * @returns the current updated Vector3
  64566. */
  64567. setAll(v: number): Vector4;
  64568. /**
  64569. * Returns a new Vector4 set from the starting index of the given array.
  64570. * @param array the array to pull values from
  64571. * @param offset the offset into the array to start at
  64572. * @returns the new vector
  64573. */
  64574. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  64575. /**
  64576. * Updates the given vector "result" from the starting index of the given array.
  64577. * @param array the array to pull values from
  64578. * @param offset the offset into the array to start at
  64579. * @param result the vector to store the result in
  64580. */
  64581. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  64582. /**
  64583. * Updates the given vector "result" from the starting index of the given Float32Array.
  64584. * @param array the array to pull values from
  64585. * @param offset the offset into the array to start at
  64586. * @param result the vector to store the result in
  64587. */
  64588. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  64589. /**
  64590. * Updates the given vector "result" coordinates from the given floats.
  64591. * @param x float to set from
  64592. * @param y float to set from
  64593. * @param z float to set from
  64594. * @param w float to set from
  64595. * @param result the vector to the floats in
  64596. */
  64597. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  64598. /**
  64599. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  64600. * @returns the new vector
  64601. */
  64602. static Zero(): Vector4;
  64603. /**
  64604. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  64605. * @returns the new vector
  64606. */
  64607. static One(): Vector4;
  64608. /**
  64609. * Returns a new normalized Vector4 from the given one.
  64610. * @param vector the vector to normalize
  64611. * @returns the vector
  64612. */
  64613. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  64614. /**
  64615. * Updates the given vector "result" from the normalization of the given one.
  64616. * @param vector the vector to normalize
  64617. * @param result the vector to store the result in
  64618. */
  64619. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  64620. /**
  64621. * Returns a vector with the minimum values from the left and right vectors
  64622. * @param left left vector to minimize
  64623. * @param right right vector to minimize
  64624. * @returns a new vector with the minimum of the left and right vector values
  64625. */
  64626. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  64627. /**
  64628. * Returns a vector with the maximum values from the left and right vectors
  64629. * @param left left vector to maximize
  64630. * @param right right vector to maximize
  64631. * @returns a new vector with the maximum of the left and right vector values
  64632. */
  64633. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  64634. /**
  64635. * Returns the distance (float) between the vectors "value1" and "value2".
  64636. * @param value1 value to calulate the distance between
  64637. * @param value2 value to calulate the distance between
  64638. * @return the distance between the two vectors
  64639. */
  64640. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  64641. /**
  64642. * Returns the squared distance (float) between the vectors "value1" and "value2".
  64643. * @param value1 value to calulate the distance between
  64644. * @param value2 value to calulate the distance between
  64645. * @return the distance between the two vectors squared
  64646. */
  64647. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  64648. /**
  64649. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  64650. * @param value1 value to calulate the center between
  64651. * @param value2 value to calulate the center between
  64652. * @return the center between the two vectors
  64653. */
  64654. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  64655. /**
  64656. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  64657. * This methods computes transformed normalized direction vectors only.
  64658. * @param vector the vector to transform
  64659. * @param transformation the transformation matrix to apply
  64660. * @returns the new vector
  64661. */
  64662. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  64663. /**
  64664. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  64665. * This methods computes transformed normalized direction vectors only.
  64666. * @param vector the vector to transform
  64667. * @param transformation the transformation matrix to apply
  64668. * @param result the vector to store the result in
  64669. */
  64670. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  64671. /**
  64672. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  64673. * This methods computes transformed normalized direction vectors only.
  64674. * @param x value to transform
  64675. * @param y value to transform
  64676. * @param z value to transform
  64677. * @param w value to transform
  64678. * @param transformation the transformation matrix to apply
  64679. * @param result the vector to store the results in
  64680. */
  64681. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  64682. /**
  64683. * Creates a new Vector4 from a Vector3
  64684. * @param source defines the source data
  64685. * @param w defines the 4th component (default is 0)
  64686. * @returns a new Vector4
  64687. */
  64688. static FromVector3(source: Vector3, w?: number): Vector4;
  64689. }
  64690. /**
  64691. * Interface for the size containing width and height
  64692. */
  64693. export interface ISize {
  64694. /**
  64695. * Width
  64696. */
  64697. width: number;
  64698. /**
  64699. * Heighht
  64700. */
  64701. height: number;
  64702. }
  64703. /**
  64704. * Size containing widht and height
  64705. */
  64706. export class Size implements ISize {
  64707. /**
  64708. * Width
  64709. */
  64710. width: number;
  64711. /**
  64712. * Height
  64713. */
  64714. height: number;
  64715. /**
  64716. * Creates a Size object from the given width and height (floats).
  64717. * @param width width of the new size
  64718. * @param height height of the new size
  64719. */
  64720. constructor(width: number, height: number);
  64721. /**
  64722. * Returns a string with the Size width and height
  64723. * @returns a string with the Size width and height
  64724. */
  64725. toString(): string;
  64726. /**
  64727. * "Size"
  64728. * @returns the string "Size"
  64729. */
  64730. getClassName(): string;
  64731. /**
  64732. * Returns the Size hash code.
  64733. * @returns a hash code for a unique width and height
  64734. */
  64735. getHashCode(): number;
  64736. /**
  64737. * Updates the current size from the given one.
  64738. * @param src the given size
  64739. */
  64740. copyFrom(src: Size): void;
  64741. /**
  64742. * Updates in place the current Size from the given floats.
  64743. * @param width width of the new size
  64744. * @param height height of the new size
  64745. * @returns the updated Size.
  64746. */
  64747. copyFromFloats(width: number, height: number): Size;
  64748. /**
  64749. * Updates in place the current Size from the given floats.
  64750. * @param width width to set
  64751. * @param height height to set
  64752. * @returns the updated Size.
  64753. */
  64754. set(width: number, height: number): Size;
  64755. /**
  64756. * Multiplies the width and height by numbers
  64757. * @param w factor to multiple the width by
  64758. * @param h factor to multiple the height by
  64759. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  64760. */
  64761. multiplyByFloats(w: number, h: number): Size;
  64762. /**
  64763. * Clones the size
  64764. * @returns a new Size copied from the given one.
  64765. */
  64766. clone(): Size;
  64767. /**
  64768. * True if the current Size and the given one width and height are strictly equal.
  64769. * @param other the other size to compare against
  64770. * @returns True if the current Size and the given one width and height are strictly equal.
  64771. */
  64772. equals(other: Size): boolean;
  64773. /**
  64774. * The surface of the Size : width * height (float).
  64775. */
  64776. readonly surface: number;
  64777. /**
  64778. * Create a new size of zero
  64779. * @returns a new Size set to (0.0, 0.0)
  64780. */
  64781. static Zero(): Size;
  64782. /**
  64783. * Sums the width and height of two sizes
  64784. * @param otherSize size to add to this size
  64785. * @returns a new Size set as the addition result of the current Size and the given one.
  64786. */
  64787. add(otherSize: Size): Size;
  64788. /**
  64789. * Subtracts the width and height of two
  64790. * @param otherSize size to subtract to this size
  64791. * @returns a new Size set as the subtraction result of the given one from the current Size.
  64792. */
  64793. subtract(otherSize: Size): Size;
  64794. /**
  64795. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  64796. * @param start starting size to lerp between
  64797. * @param end end size to lerp between
  64798. * @param amount amount to lerp between the start and end values
  64799. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  64800. */
  64801. static Lerp(start: Size, end: Size, amount: number): Size;
  64802. }
  64803. /**
  64804. * Class used to store quaternion data
  64805. * @see https://en.wikipedia.org/wiki/Quaternion
  64806. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  64807. */
  64808. export class Quaternion {
  64809. /** defines the first component (0 by default) */
  64810. x: number;
  64811. /** defines the second component (0 by default) */
  64812. y: number;
  64813. /** defines the third component (0 by default) */
  64814. z: number;
  64815. /** defines the fourth component (1.0 by default) */
  64816. w: number;
  64817. /**
  64818. * Creates a new Quaternion from the given floats
  64819. * @param x defines the first component (0 by default)
  64820. * @param y defines the second component (0 by default)
  64821. * @param z defines the third component (0 by default)
  64822. * @param w defines the fourth component (1.0 by default)
  64823. */
  64824. constructor(
  64825. /** defines the first component (0 by default) */
  64826. x?: number,
  64827. /** defines the second component (0 by default) */
  64828. y?: number,
  64829. /** defines the third component (0 by default) */
  64830. z?: number,
  64831. /** defines the fourth component (1.0 by default) */
  64832. w?: number);
  64833. /**
  64834. * Gets a string representation for the current quaternion
  64835. * @returns a string with the Quaternion coordinates
  64836. */
  64837. toString(): string;
  64838. /**
  64839. * Gets the class name of the quaternion
  64840. * @returns the string "Quaternion"
  64841. */
  64842. getClassName(): string;
  64843. /**
  64844. * Gets a hash code for this quaternion
  64845. * @returns the quaternion hash code
  64846. */
  64847. getHashCode(): number;
  64848. /**
  64849. * Copy the quaternion to an array
  64850. * @returns a new array populated with 4 elements from the quaternion coordinates
  64851. */
  64852. asArray(): number[];
  64853. /**
  64854. * Check if two quaternions are equals
  64855. * @param otherQuaternion defines the second operand
  64856. * @return true if the current quaternion and the given one coordinates are strictly equals
  64857. */
  64858. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  64859. /**
  64860. * Clone the current quaternion
  64861. * @returns a new quaternion copied from the current one
  64862. */
  64863. clone(): Quaternion;
  64864. /**
  64865. * Copy a quaternion to the current one
  64866. * @param other defines the other quaternion
  64867. * @returns the updated current quaternion
  64868. */
  64869. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  64870. /**
  64871. * Updates the current quaternion with the given float coordinates
  64872. * @param x defines the x coordinate
  64873. * @param y defines the y coordinate
  64874. * @param z defines the z coordinate
  64875. * @param w defines the w coordinate
  64876. * @returns the updated current quaternion
  64877. */
  64878. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  64879. /**
  64880. * Updates the current quaternion from the given float coordinates
  64881. * @param x defines the x coordinate
  64882. * @param y defines the y coordinate
  64883. * @param z defines the z coordinate
  64884. * @param w defines the w coordinate
  64885. * @returns the updated current quaternion
  64886. */
  64887. set(x: number, y: number, z: number, w: number): Quaternion;
  64888. /**
  64889. * Adds two quaternions
  64890. * @param other defines the second operand
  64891. * @returns a new quaternion as the addition result of the given one and the current quaternion
  64892. */
  64893. add(other: DeepImmutable<Quaternion>): Quaternion;
  64894. /**
  64895. * Add a quaternion to the current one
  64896. * @param other defines the quaternion to add
  64897. * @returns the current quaternion
  64898. */
  64899. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  64900. /**
  64901. * Subtract two quaternions
  64902. * @param other defines the second operand
  64903. * @returns a new quaternion as the subtraction result of the given one from the current one
  64904. */
  64905. subtract(other: Quaternion): Quaternion;
  64906. /**
  64907. * Multiplies the current quaternion by a scale factor
  64908. * @param value defines the scale factor
  64909. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  64910. */
  64911. scale(value: number): Quaternion;
  64912. /**
  64913. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  64914. * @param scale defines the scale factor
  64915. * @param result defines the Quaternion object where to store the result
  64916. * @returns the unmodified current quaternion
  64917. */
  64918. scaleToRef(scale: number, result: Quaternion): Quaternion;
  64919. /**
  64920. * Multiplies in place the current quaternion by a scale factor
  64921. * @param value defines the scale factor
  64922. * @returns the current modified quaternion
  64923. */
  64924. scaleInPlace(value: number): Quaternion;
  64925. /**
  64926. * Scale the current quaternion values by a factor and add the result to a given quaternion
  64927. * @param scale defines the scale factor
  64928. * @param result defines the Quaternion object where to store the result
  64929. * @returns the unmodified current quaternion
  64930. */
  64931. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  64932. /**
  64933. * Multiplies two quaternions
  64934. * @param q1 defines the second operand
  64935. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  64936. */
  64937. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  64938. /**
  64939. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  64940. * @param q1 defines the second operand
  64941. * @param result defines the target quaternion
  64942. * @returns the current quaternion
  64943. */
  64944. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  64945. /**
  64946. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  64947. * @param q1 defines the second operand
  64948. * @returns the currentupdated quaternion
  64949. */
  64950. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  64951. /**
  64952. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  64953. * @param ref defines the target quaternion
  64954. * @returns the current quaternion
  64955. */
  64956. conjugateToRef(ref: Quaternion): Quaternion;
  64957. /**
  64958. * Conjugates in place (1-q) the current quaternion
  64959. * @returns the current updated quaternion
  64960. */
  64961. conjugateInPlace(): Quaternion;
  64962. /**
  64963. * Conjugates in place (1-q) the current quaternion
  64964. * @returns a new quaternion
  64965. */
  64966. conjugate(): Quaternion;
  64967. /**
  64968. * Gets length of current quaternion
  64969. * @returns the quaternion length (float)
  64970. */
  64971. length(): number;
  64972. /**
  64973. * Normalize in place the current quaternion
  64974. * @returns the current updated quaternion
  64975. */
  64976. normalize(): Quaternion;
  64977. /**
  64978. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  64979. * @param order is a reserved parameter and is ignore for now
  64980. * @returns a new Vector3 containing the Euler angles
  64981. */
  64982. toEulerAngles(order?: string): Vector3;
  64983. /**
  64984. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  64985. * @param result defines the vector which will be filled with the Euler angles
  64986. * @param order is a reserved parameter and is ignore for now
  64987. * @returns the current unchanged quaternion
  64988. */
  64989. toEulerAnglesToRef(result: Vector3): Quaternion;
  64990. /**
  64991. * Updates the given rotation matrix with the current quaternion values
  64992. * @param result defines the target matrix
  64993. * @returns the current unchanged quaternion
  64994. */
  64995. toRotationMatrix(result: Matrix): Quaternion;
  64996. /**
  64997. * Updates the current quaternion from the given rotation matrix values
  64998. * @param matrix defines the source matrix
  64999. * @returns the current updated quaternion
  65000. */
  65001. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  65002. /**
  65003. * Creates a new quaternion from a rotation matrix
  65004. * @param matrix defines the source matrix
  65005. * @returns a new quaternion created from the given rotation matrix values
  65006. */
  65007. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  65008. /**
  65009. * Updates the given quaternion with the given rotation matrix values
  65010. * @param matrix defines the source matrix
  65011. * @param result defines the target quaternion
  65012. */
  65013. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  65014. /**
  65015. * Returns the dot product (float) between the quaternions "left" and "right"
  65016. * @param left defines the left operand
  65017. * @param right defines the right operand
  65018. * @returns the dot product
  65019. */
  65020. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  65021. /**
  65022. * Checks if the two quaternions are close to each other
  65023. * @param quat0 defines the first quaternion to check
  65024. * @param quat1 defines the second quaternion to check
  65025. * @returns true if the two quaternions are close to each other
  65026. */
  65027. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  65028. /**
  65029. * Creates an empty quaternion
  65030. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  65031. */
  65032. static Zero(): Quaternion;
  65033. /**
  65034. * Inverse a given quaternion
  65035. * @param q defines the source quaternion
  65036. * @returns a new quaternion as the inverted current quaternion
  65037. */
  65038. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  65039. /**
  65040. * Inverse a given quaternion
  65041. * @param q defines the source quaternion
  65042. * @param result the quaternion the result will be stored in
  65043. * @returns the result quaternion
  65044. */
  65045. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  65046. /**
  65047. * Creates an identity quaternion
  65048. * @returns the identity quaternion
  65049. */
  65050. static Identity(): Quaternion;
  65051. /**
  65052. * Gets a boolean indicating if the given quaternion is identity
  65053. * @param quaternion defines the quaternion to check
  65054. * @returns true if the quaternion is identity
  65055. */
  65056. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  65057. /**
  65058. * Creates a quaternion from a rotation around an axis
  65059. * @param axis defines the axis to use
  65060. * @param angle defines the angle to use
  65061. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  65062. */
  65063. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  65064. /**
  65065. * Creates a rotation around an axis and stores it into the given quaternion
  65066. * @param axis defines the axis to use
  65067. * @param angle defines the angle to use
  65068. * @param result defines the target quaternion
  65069. * @returns the target quaternion
  65070. */
  65071. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  65072. /**
  65073. * Creates a new quaternion from data stored into an array
  65074. * @param array defines the data source
  65075. * @param offset defines the offset in the source array where the data starts
  65076. * @returns a new quaternion
  65077. */
  65078. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  65079. /**
  65080. * Create a quaternion from Euler rotation angles
  65081. * @param x Pitch
  65082. * @param y Yaw
  65083. * @param z Roll
  65084. * @returns the new Quaternion
  65085. */
  65086. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  65087. /**
  65088. * Updates a quaternion from Euler rotation angles
  65089. * @param x Pitch
  65090. * @param y Yaw
  65091. * @param z Roll
  65092. * @param result the quaternion to store the result
  65093. * @returns the updated quaternion
  65094. */
  65095. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  65096. /**
  65097. * Create a quaternion from Euler rotation vector
  65098. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  65099. * @returns the new Quaternion
  65100. */
  65101. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  65102. /**
  65103. * Updates a quaternion from Euler rotation vector
  65104. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  65105. * @param result the quaternion to store the result
  65106. * @returns the updated quaternion
  65107. */
  65108. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  65109. /**
  65110. * Creates a new quaternion from the given Euler float angles (y, x, z)
  65111. * @param yaw defines the rotation around Y axis
  65112. * @param pitch defines the rotation around X axis
  65113. * @param roll defines the rotation around Z axis
  65114. * @returns the new quaternion
  65115. */
  65116. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  65117. /**
  65118. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  65119. * @param yaw defines the rotation around Y axis
  65120. * @param pitch defines the rotation around X axis
  65121. * @param roll defines the rotation around Z axis
  65122. * @param result defines the target quaternion
  65123. */
  65124. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  65125. /**
  65126. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  65127. * @param alpha defines the rotation around first axis
  65128. * @param beta defines the rotation around second axis
  65129. * @param gamma defines the rotation around third axis
  65130. * @returns the new quaternion
  65131. */
  65132. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  65133. /**
  65134. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  65135. * @param alpha defines the rotation around first axis
  65136. * @param beta defines the rotation around second axis
  65137. * @param gamma defines the rotation around third axis
  65138. * @param result defines the target quaternion
  65139. */
  65140. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  65141. /**
  65142. * 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)
  65143. * @param axis1 defines the first axis
  65144. * @param axis2 defines the second axis
  65145. * @param axis3 defines the third axis
  65146. * @returns the new quaternion
  65147. */
  65148. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  65149. /**
  65150. * 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
  65151. * @param axis1 defines the first axis
  65152. * @param axis2 defines the second axis
  65153. * @param axis3 defines the third axis
  65154. * @param ref defines the target quaternion
  65155. */
  65156. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  65157. /**
  65158. * Interpolates between two quaternions
  65159. * @param left defines first quaternion
  65160. * @param right defines second quaternion
  65161. * @param amount defines the gradient to use
  65162. * @returns the new interpolated quaternion
  65163. */
  65164. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  65165. /**
  65166. * Interpolates between two quaternions and stores it into a target quaternion
  65167. * @param left defines first quaternion
  65168. * @param right defines second quaternion
  65169. * @param amount defines the gradient to use
  65170. * @param result defines the target quaternion
  65171. */
  65172. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  65173. /**
  65174. * Interpolate between two quaternions using Hermite interpolation
  65175. * @param value1 defines first quaternion
  65176. * @param tangent1 defines the incoming tangent
  65177. * @param value2 defines second quaternion
  65178. * @param tangent2 defines the outgoing tangent
  65179. * @param amount defines the target quaternion
  65180. * @returns the new interpolated quaternion
  65181. */
  65182. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  65183. }
  65184. /**
  65185. * Class used to store matrix data (4x4)
  65186. */
  65187. export class Matrix {
  65188. private static _updateFlagSeed;
  65189. private static _identityReadOnly;
  65190. private _isIdentity;
  65191. private _isIdentityDirty;
  65192. private _isIdentity3x2;
  65193. private _isIdentity3x2Dirty;
  65194. /**
  65195. * Gets the update flag of the matrix which is an unique number for the matrix.
  65196. * It will be incremented every time the matrix data change.
  65197. * You can use it to speed the comparison between two versions of the same matrix.
  65198. */
  65199. updateFlag: number;
  65200. private readonly _m;
  65201. /**
  65202. * Gets the internal data of the matrix
  65203. */
  65204. readonly m: DeepImmutable<Float32Array>;
  65205. /** @hidden */
  65206. _markAsUpdated(): void;
  65207. /** @hidden */
  65208. private _updateIdentityStatus;
  65209. /**
  65210. * Creates an empty matrix (filled with zeros)
  65211. */
  65212. constructor();
  65213. /**
  65214. * Check if the current matrix is identity
  65215. * @returns true is the matrix is the identity matrix
  65216. */
  65217. isIdentity(): boolean;
  65218. /**
  65219. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  65220. * @returns true is the matrix is the identity matrix
  65221. */
  65222. isIdentityAs3x2(): boolean;
  65223. /**
  65224. * Gets the determinant of the matrix
  65225. * @returns the matrix determinant
  65226. */
  65227. determinant(): number;
  65228. /**
  65229. * Returns the matrix as a Float32Array
  65230. * @returns the matrix underlying array
  65231. */
  65232. toArray(): DeepImmutable<Float32Array>;
  65233. /**
  65234. * Returns the matrix as a Float32Array
  65235. * @returns the matrix underlying array.
  65236. */
  65237. asArray(): DeepImmutable<Float32Array>;
  65238. /**
  65239. * Inverts the current matrix in place
  65240. * @returns the current inverted matrix
  65241. */
  65242. invert(): Matrix;
  65243. /**
  65244. * Sets all the matrix elements to zero
  65245. * @returns the current matrix
  65246. */
  65247. reset(): Matrix;
  65248. /**
  65249. * Adds the current matrix with a second one
  65250. * @param other defines the matrix to add
  65251. * @returns a new matrix as the addition of the current matrix and the given one
  65252. */
  65253. add(other: DeepImmutable<Matrix>): Matrix;
  65254. /**
  65255. * Sets the given matrix "result" to the addition of the current matrix and the given one
  65256. * @param other defines the matrix to add
  65257. * @param result defines the target matrix
  65258. * @returns the current matrix
  65259. */
  65260. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  65261. /**
  65262. * Adds in place the given matrix to the current matrix
  65263. * @param other defines the second operand
  65264. * @returns the current updated matrix
  65265. */
  65266. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  65267. /**
  65268. * Sets the given matrix to the current inverted Matrix
  65269. * @param other defines the target matrix
  65270. * @returns the unmodified current matrix
  65271. */
  65272. invertToRef(other: Matrix): Matrix;
  65273. /**
  65274. * add a value at the specified position in the current Matrix
  65275. * @param index the index of the value within the matrix. between 0 and 15.
  65276. * @param value the value to be added
  65277. * @returns the current updated matrix
  65278. */
  65279. addAtIndex(index: number, value: number): Matrix;
  65280. /**
  65281. * mutiply the specified position in the current Matrix by a value
  65282. * @param index the index of the value within the matrix. between 0 and 15.
  65283. * @param value the value to be added
  65284. * @returns the current updated matrix
  65285. */
  65286. multiplyAtIndex(index: number, value: number): Matrix;
  65287. /**
  65288. * Inserts the translation vector (using 3 floats) in the current matrix
  65289. * @param x defines the 1st component of the translation
  65290. * @param y defines the 2nd component of the translation
  65291. * @param z defines the 3rd component of the translation
  65292. * @returns the current updated matrix
  65293. */
  65294. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  65295. /**
  65296. * Adds the translation vector (using 3 floats) in the current matrix
  65297. * @param x defines the 1st component of the translation
  65298. * @param y defines the 2nd component of the translation
  65299. * @param z defines the 3rd component of the translation
  65300. * @returns the current updated matrix
  65301. */
  65302. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  65303. /**
  65304. * Inserts the translation vector in the current matrix
  65305. * @param vector3 defines the translation to insert
  65306. * @returns the current updated matrix
  65307. */
  65308. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  65309. /**
  65310. * Gets the translation value of the current matrix
  65311. * @returns a new Vector3 as the extracted translation from the matrix
  65312. */
  65313. getTranslation(): Vector3;
  65314. /**
  65315. * Fill a Vector3 with the extracted translation from the matrix
  65316. * @param result defines the Vector3 where to store the translation
  65317. * @returns the current matrix
  65318. */
  65319. getTranslationToRef(result: Vector3): Matrix;
  65320. /**
  65321. * Remove rotation and scaling part from the matrix
  65322. * @returns the updated matrix
  65323. */
  65324. removeRotationAndScaling(): Matrix;
  65325. /**
  65326. * Multiply two matrices
  65327. * @param other defines the second operand
  65328. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  65329. */
  65330. multiply(other: DeepImmutable<Matrix>): Matrix;
  65331. /**
  65332. * Copy the current matrix from the given one
  65333. * @param other defines the source matrix
  65334. * @returns the current updated matrix
  65335. */
  65336. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  65337. /**
  65338. * Populates the given array from the starting index with the current matrix values
  65339. * @param array defines the target array
  65340. * @param offset defines the offset in the target array where to start storing values
  65341. * @returns the current matrix
  65342. */
  65343. copyToArray(array: Float32Array, offset?: number): Matrix;
  65344. /**
  65345. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  65346. * @param other defines the second operand
  65347. * @param result defines the matrix where to store the multiplication
  65348. * @returns the current matrix
  65349. */
  65350. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  65351. /**
  65352. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  65353. * @param other defines the second operand
  65354. * @param result defines the array where to store the multiplication
  65355. * @param offset defines the offset in the target array where to start storing values
  65356. * @returns the current matrix
  65357. */
  65358. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  65359. /**
  65360. * Check equality between this matrix and a second one
  65361. * @param value defines the second matrix to compare
  65362. * @returns true is the current matrix and the given one values are strictly equal
  65363. */
  65364. equals(value: DeepImmutable<Matrix>): boolean;
  65365. /**
  65366. * Clone the current matrix
  65367. * @returns a new matrix from the current matrix
  65368. */
  65369. clone(): Matrix;
  65370. /**
  65371. * Returns the name of the current matrix class
  65372. * @returns the string "Matrix"
  65373. */
  65374. getClassName(): string;
  65375. /**
  65376. * Gets the hash code of the current matrix
  65377. * @returns the hash code
  65378. */
  65379. getHashCode(): number;
  65380. /**
  65381. * Decomposes the current Matrix into a translation, rotation and scaling components
  65382. * @param scale defines the scale vector3 given as a reference to update
  65383. * @param rotation defines the rotation quaternion given as a reference to update
  65384. * @param translation defines the translation vector3 given as a reference to update
  65385. * @returns true if operation was successful
  65386. */
  65387. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  65388. /**
  65389. * Gets specific row of the matrix
  65390. * @param index defines the number of the row to get
  65391. * @returns the index-th row of the current matrix as a new Vector4
  65392. */
  65393. getRow(index: number): Nullable<Vector4>;
  65394. /**
  65395. * Sets the index-th row of the current matrix to the vector4 values
  65396. * @param index defines the number of the row to set
  65397. * @param row defines the target vector4
  65398. * @returns the updated current matrix
  65399. */
  65400. setRow(index: number, row: Vector4): Matrix;
  65401. /**
  65402. * Compute the transpose of the matrix
  65403. * @returns the new transposed matrix
  65404. */
  65405. transpose(): Matrix;
  65406. /**
  65407. * Compute the transpose of the matrix and store it in a given matrix
  65408. * @param result defines the target matrix
  65409. * @returns the current matrix
  65410. */
  65411. transposeToRef(result: Matrix): Matrix;
  65412. /**
  65413. * Sets the index-th row of the current matrix with the given 4 x float values
  65414. * @param index defines the row index
  65415. * @param x defines the x component to set
  65416. * @param y defines the y component to set
  65417. * @param z defines the z component to set
  65418. * @param w defines the w component to set
  65419. * @returns the updated current matrix
  65420. */
  65421. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  65422. /**
  65423. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  65424. * @param scale defines the scale factor
  65425. * @returns a new matrix
  65426. */
  65427. scale(scale: number): Matrix;
  65428. /**
  65429. * Scale the current matrix values by a factor to a given result matrix
  65430. * @param scale defines the scale factor
  65431. * @param result defines the matrix to store the result
  65432. * @returns the current matrix
  65433. */
  65434. scaleToRef(scale: number, result: Matrix): Matrix;
  65435. /**
  65436. * Scale the current matrix values by a factor and add the result to a given matrix
  65437. * @param scale defines the scale factor
  65438. * @param result defines the Matrix to store the result
  65439. * @returns the current matrix
  65440. */
  65441. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  65442. /**
  65443. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  65444. * @param ref matrix to store the result
  65445. */
  65446. toNormalMatrix(ref: Matrix): void;
  65447. /**
  65448. * Gets only rotation part of the current matrix
  65449. * @returns a new matrix sets to the extracted rotation matrix from the current one
  65450. */
  65451. getRotationMatrix(): Matrix;
  65452. /**
  65453. * Extracts the rotation matrix from the current one and sets it as the given "result"
  65454. * @param result defines the target matrix to store data to
  65455. * @returns the current matrix
  65456. */
  65457. getRotationMatrixToRef(result: Matrix): Matrix;
  65458. /**
  65459. * Toggles model matrix from being right handed to left handed in place and vice versa
  65460. */
  65461. toggleModelMatrixHandInPlace(): void;
  65462. /**
  65463. * Toggles projection matrix from being right handed to left handed in place and vice versa
  65464. */
  65465. toggleProjectionMatrixHandInPlace(): void;
  65466. /**
  65467. * Creates a matrix from an array
  65468. * @param array defines the source array
  65469. * @param offset defines an offset in the source array
  65470. * @returns a new Matrix set from the starting index of the given array
  65471. */
  65472. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  65473. /**
  65474. * Copy the content of an array into a given matrix
  65475. * @param array defines the source array
  65476. * @param offset defines an offset in the source array
  65477. * @param result defines the target matrix
  65478. */
  65479. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  65480. /**
  65481. * Stores an array into a matrix after having multiplied each component by a given factor
  65482. * @param array defines the source array
  65483. * @param offset defines the offset in the source array
  65484. * @param scale defines the scaling factor
  65485. * @param result defines the target matrix
  65486. */
  65487. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  65488. /**
  65489. * Gets an identity matrix that must not be updated
  65490. */
  65491. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  65492. /**
  65493. * Stores a list of values (16) inside a given matrix
  65494. * @param initialM11 defines 1st value of 1st row
  65495. * @param initialM12 defines 2nd value of 1st row
  65496. * @param initialM13 defines 3rd value of 1st row
  65497. * @param initialM14 defines 4th value of 1st row
  65498. * @param initialM21 defines 1st value of 2nd row
  65499. * @param initialM22 defines 2nd value of 2nd row
  65500. * @param initialM23 defines 3rd value of 2nd row
  65501. * @param initialM24 defines 4th value of 2nd row
  65502. * @param initialM31 defines 1st value of 3rd row
  65503. * @param initialM32 defines 2nd value of 3rd row
  65504. * @param initialM33 defines 3rd value of 3rd row
  65505. * @param initialM34 defines 4th value of 3rd row
  65506. * @param initialM41 defines 1st value of 4th row
  65507. * @param initialM42 defines 2nd value of 4th row
  65508. * @param initialM43 defines 3rd value of 4th row
  65509. * @param initialM44 defines 4th value of 4th row
  65510. * @param result defines the target matrix
  65511. */
  65512. 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;
  65513. /**
  65514. * Creates new matrix from a list of values (16)
  65515. * @param initialM11 defines 1st value of 1st row
  65516. * @param initialM12 defines 2nd value of 1st row
  65517. * @param initialM13 defines 3rd value of 1st row
  65518. * @param initialM14 defines 4th value of 1st row
  65519. * @param initialM21 defines 1st value of 2nd row
  65520. * @param initialM22 defines 2nd value of 2nd row
  65521. * @param initialM23 defines 3rd value of 2nd row
  65522. * @param initialM24 defines 4th value of 2nd row
  65523. * @param initialM31 defines 1st value of 3rd row
  65524. * @param initialM32 defines 2nd value of 3rd row
  65525. * @param initialM33 defines 3rd value of 3rd row
  65526. * @param initialM34 defines 4th value of 3rd row
  65527. * @param initialM41 defines 1st value of 4th row
  65528. * @param initialM42 defines 2nd value of 4th row
  65529. * @param initialM43 defines 3rd value of 4th row
  65530. * @param initialM44 defines 4th value of 4th row
  65531. * @returns the new matrix
  65532. */
  65533. 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;
  65534. /**
  65535. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  65536. * @param scale defines the scale vector3
  65537. * @param rotation defines the rotation quaternion
  65538. * @param translation defines the translation vector3
  65539. * @returns a new matrix
  65540. */
  65541. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  65542. /**
  65543. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  65544. * @param scale defines the scale vector3
  65545. * @param rotation defines the rotation quaternion
  65546. * @param translation defines the translation vector3
  65547. * @param result defines the target matrix
  65548. */
  65549. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  65550. /**
  65551. * Creates a new identity matrix
  65552. * @returns a new identity matrix
  65553. */
  65554. static Identity(): Matrix;
  65555. /**
  65556. * Creates a new identity matrix and stores the result in a given matrix
  65557. * @param result defines the target matrix
  65558. */
  65559. static IdentityToRef(result: Matrix): void;
  65560. /**
  65561. * Creates a new zero matrix
  65562. * @returns a new zero matrix
  65563. */
  65564. static Zero(): Matrix;
  65565. /**
  65566. * Creates a new rotation matrix for "angle" radians around the X axis
  65567. * @param angle defines the angle (in radians) to use
  65568. * @return the new matrix
  65569. */
  65570. static RotationX(angle: number): Matrix;
  65571. /**
  65572. * Creates a new matrix as the invert of a given matrix
  65573. * @param source defines the source matrix
  65574. * @returns the new matrix
  65575. */
  65576. static Invert(source: DeepImmutable<Matrix>): Matrix;
  65577. /**
  65578. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  65579. * @param angle defines the angle (in radians) to use
  65580. * @param result defines the target matrix
  65581. */
  65582. static RotationXToRef(angle: number, result: Matrix): void;
  65583. /**
  65584. * Creates a new rotation matrix for "angle" radians around the Y axis
  65585. * @param angle defines the angle (in radians) to use
  65586. * @return the new matrix
  65587. */
  65588. static RotationY(angle: number): Matrix;
  65589. /**
  65590. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  65591. * @param angle defines the angle (in radians) to use
  65592. * @param result defines the target matrix
  65593. */
  65594. static RotationYToRef(angle: number, result: Matrix): void;
  65595. /**
  65596. * Creates a new rotation matrix for "angle" radians around the Z axis
  65597. * @param angle defines the angle (in radians) to use
  65598. * @return the new matrix
  65599. */
  65600. static RotationZ(angle: number): Matrix;
  65601. /**
  65602. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  65603. * @param angle defines the angle (in radians) to use
  65604. * @param result defines the target matrix
  65605. */
  65606. static RotationZToRef(angle: number, result: Matrix): void;
  65607. /**
  65608. * Creates a new rotation matrix for "angle" radians around the given axis
  65609. * @param axis defines the axis to use
  65610. * @param angle defines the angle (in radians) to use
  65611. * @return the new matrix
  65612. */
  65613. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  65614. /**
  65615. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  65616. * @param axis defines the axis to use
  65617. * @param angle defines the angle (in radians) to use
  65618. * @param result defines the target matrix
  65619. */
  65620. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  65621. /**
  65622. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  65623. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  65624. * @param from defines the vector to align
  65625. * @param to defines the vector to align to
  65626. * @param result defines the target matrix
  65627. */
  65628. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  65629. /**
  65630. * Creates a rotation matrix
  65631. * @param yaw defines the yaw angle in radians (Y axis)
  65632. * @param pitch defines the pitch angle in radians (X axis)
  65633. * @param roll defines the roll angle in radians (X axis)
  65634. * @returns the new rotation matrix
  65635. */
  65636. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  65637. /**
  65638. * Creates a rotation matrix and stores it in a given matrix
  65639. * @param yaw defines the yaw angle in radians (Y axis)
  65640. * @param pitch defines the pitch angle in radians (X axis)
  65641. * @param roll defines the roll angle in radians (X axis)
  65642. * @param result defines the target matrix
  65643. */
  65644. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  65645. /**
  65646. * Creates a scaling matrix
  65647. * @param x defines the scale factor on X axis
  65648. * @param y defines the scale factor on Y axis
  65649. * @param z defines the scale factor on Z axis
  65650. * @returns the new matrix
  65651. */
  65652. static Scaling(x: number, y: number, z: number): Matrix;
  65653. /**
  65654. * Creates a scaling matrix and stores it in a given matrix
  65655. * @param x defines the scale factor on X axis
  65656. * @param y defines the scale factor on Y axis
  65657. * @param z defines the scale factor on Z axis
  65658. * @param result defines the target matrix
  65659. */
  65660. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  65661. /**
  65662. * Creates a translation matrix
  65663. * @param x defines the translation on X axis
  65664. * @param y defines the translation on Y axis
  65665. * @param z defines the translationon Z axis
  65666. * @returns the new matrix
  65667. */
  65668. static Translation(x: number, y: number, z: number): Matrix;
  65669. /**
  65670. * Creates a translation matrix and stores it in a given matrix
  65671. * @param x defines the translation on X axis
  65672. * @param y defines the translation on Y axis
  65673. * @param z defines the translationon Z axis
  65674. * @param result defines the target matrix
  65675. */
  65676. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  65677. /**
  65678. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  65679. * @param startValue defines the start value
  65680. * @param endValue defines the end value
  65681. * @param gradient defines the gradient factor
  65682. * @returns the new matrix
  65683. */
  65684. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  65685. /**
  65686. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  65687. * @param startValue defines the start value
  65688. * @param endValue defines the end value
  65689. * @param gradient defines the gradient factor
  65690. * @param result defines the Matrix object where to store data
  65691. */
  65692. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  65693. /**
  65694. * Builds a new matrix whose values are computed by:
  65695. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  65696. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  65697. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  65698. * @param startValue defines the first matrix
  65699. * @param endValue defines the second matrix
  65700. * @param gradient defines the gradient between the two matrices
  65701. * @returns the new matrix
  65702. */
  65703. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  65704. /**
  65705. * Update a matrix to values which are computed by:
  65706. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  65707. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  65708. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  65709. * @param startValue defines the first matrix
  65710. * @param endValue defines the second matrix
  65711. * @param gradient defines the gradient between the two matrices
  65712. * @param result defines the target matrix
  65713. */
  65714. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  65715. /**
  65716. * 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"
  65717. * This function works in left handed mode
  65718. * @param eye defines the final position of the entity
  65719. * @param target defines where the entity should look at
  65720. * @param up defines the up vector for the entity
  65721. * @returns the new matrix
  65722. */
  65723. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  65724. /**
  65725. * 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".
  65726. * This function works in left handed mode
  65727. * @param eye defines the final position of the entity
  65728. * @param target defines where the entity should look at
  65729. * @param up defines the up vector for the entity
  65730. * @param result defines the target matrix
  65731. */
  65732. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  65733. /**
  65734. * 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"
  65735. * This function works in right handed mode
  65736. * @param eye defines the final position of the entity
  65737. * @param target defines where the entity should look at
  65738. * @param up defines the up vector for the entity
  65739. * @returns the new matrix
  65740. */
  65741. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  65742. /**
  65743. * 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".
  65744. * This function works in right handed mode
  65745. * @param eye defines the final position of the entity
  65746. * @param target defines where the entity should look at
  65747. * @param up defines the up vector for the entity
  65748. * @param result defines the target matrix
  65749. */
  65750. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  65751. /**
  65752. * Create a left-handed orthographic projection matrix
  65753. * @param width defines the viewport width
  65754. * @param height defines the viewport height
  65755. * @param znear defines the near clip plane
  65756. * @param zfar defines the far clip plane
  65757. * @returns a new matrix as a left-handed orthographic projection matrix
  65758. */
  65759. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  65760. /**
  65761. * Store a left-handed orthographic projection to a given matrix
  65762. * @param width defines the viewport width
  65763. * @param height defines the viewport height
  65764. * @param znear defines the near clip plane
  65765. * @param zfar defines the far clip plane
  65766. * @param result defines the target matrix
  65767. */
  65768. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  65769. /**
  65770. * Create a left-handed orthographic projection matrix
  65771. * @param left defines the viewport left coordinate
  65772. * @param right defines the viewport right coordinate
  65773. * @param bottom defines the viewport bottom coordinate
  65774. * @param top defines the viewport top coordinate
  65775. * @param znear defines the near clip plane
  65776. * @param zfar defines the far clip plane
  65777. * @returns a new matrix as a left-handed orthographic projection matrix
  65778. */
  65779. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  65780. /**
  65781. * Stores a left-handed orthographic projection into a given matrix
  65782. * @param left defines the viewport left coordinate
  65783. * @param right defines the viewport right coordinate
  65784. * @param bottom defines the viewport bottom coordinate
  65785. * @param top defines the viewport top coordinate
  65786. * @param znear defines the near clip plane
  65787. * @param zfar defines the far clip plane
  65788. * @param result defines the target matrix
  65789. */
  65790. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  65791. /**
  65792. * Creates a right-handed orthographic projection matrix
  65793. * @param left defines the viewport left coordinate
  65794. * @param right defines the viewport right coordinate
  65795. * @param bottom defines the viewport bottom coordinate
  65796. * @param top defines the viewport top coordinate
  65797. * @param znear defines the near clip plane
  65798. * @param zfar defines the far clip plane
  65799. * @returns a new matrix as a right-handed orthographic projection matrix
  65800. */
  65801. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  65802. /**
  65803. * Stores a right-handed orthographic projection into a given matrix
  65804. * @param left defines the viewport left coordinate
  65805. * @param right defines the viewport right coordinate
  65806. * @param bottom defines the viewport bottom coordinate
  65807. * @param top defines the viewport top coordinate
  65808. * @param znear defines the near clip plane
  65809. * @param zfar defines the far clip plane
  65810. * @param result defines the target matrix
  65811. */
  65812. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  65813. /**
  65814. * Creates a left-handed perspective projection matrix
  65815. * @param width defines the viewport width
  65816. * @param height defines the viewport height
  65817. * @param znear defines the near clip plane
  65818. * @param zfar defines the far clip plane
  65819. * @returns a new matrix as a left-handed perspective projection matrix
  65820. */
  65821. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  65822. /**
  65823. * Creates a left-handed perspective projection matrix
  65824. * @param fov defines the horizontal field of view
  65825. * @param aspect defines the aspect ratio
  65826. * @param znear defines the near clip plane
  65827. * @param zfar defines the far clip plane
  65828. * @returns a new matrix as a left-handed perspective projection matrix
  65829. */
  65830. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  65831. /**
  65832. * Stores a left-handed perspective projection into a given matrix
  65833. * @param fov defines the horizontal field of view
  65834. * @param aspect defines the aspect ratio
  65835. * @param znear defines the near clip plane
  65836. * @param zfar defines the far clip plane
  65837. * @param result defines the target matrix
  65838. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  65839. */
  65840. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  65841. /**
  65842. * Creates a right-handed perspective projection matrix
  65843. * @param fov defines the horizontal field of view
  65844. * @param aspect defines the aspect ratio
  65845. * @param znear defines the near clip plane
  65846. * @param zfar defines the far clip plane
  65847. * @returns a new matrix as a right-handed perspective projection matrix
  65848. */
  65849. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  65850. /**
  65851. * Stores a right-handed perspective projection into a given matrix
  65852. * @param fov defines the horizontal field of view
  65853. * @param aspect defines the aspect ratio
  65854. * @param znear defines the near clip plane
  65855. * @param zfar defines the far clip plane
  65856. * @param result defines the target matrix
  65857. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  65858. */
  65859. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  65860. /**
  65861. * Stores a perspective projection for WebVR info a given matrix
  65862. * @param fov defines the field of view
  65863. * @param znear defines the near clip plane
  65864. * @param zfar defines the far clip plane
  65865. * @param result defines the target matrix
  65866. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  65867. */
  65868. static PerspectiveFovWebVRToRef(fov: {
  65869. upDegrees: number;
  65870. downDegrees: number;
  65871. leftDegrees: number;
  65872. rightDegrees: number;
  65873. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  65874. /**
  65875. * Computes a complete transformation matrix
  65876. * @param viewport defines the viewport to use
  65877. * @param world defines the world matrix
  65878. * @param view defines the view matrix
  65879. * @param projection defines the projection matrix
  65880. * @param zmin defines the near clip plane
  65881. * @param zmax defines the far clip plane
  65882. * @returns the transformation matrix
  65883. */
  65884. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  65885. /**
  65886. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  65887. * @param matrix defines the matrix to use
  65888. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  65889. */
  65890. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  65891. /**
  65892. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  65893. * @param matrix defines the matrix to use
  65894. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  65895. */
  65896. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  65897. /**
  65898. * Compute the transpose of a given matrix
  65899. * @param matrix defines the matrix to transpose
  65900. * @returns the new matrix
  65901. */
  65902. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  65903. /**
  65904. * Compute the transpose of a matrix and store it in a target matrix
  65905. * @param matrix defines the matrix to transpose
  65906. * @param result defines the target matrix
  65907. */
  65908. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  65909. /**
  65910. * Computes a reflection matrix from a plane
  65911. * @param plane defines the reflection plane
  65912. * @returns a new matrix
  65913. */
  65914. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  65915. /**
  65916. * Computes a reflection matrix from a plane
  65917. * @param plane defines the reflection plane
  65918. * @param result defines the target matrix
  65919. */
  65920. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  65921. /**
  65922. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  65923. * @param xaxis defines the value of the 1st axis
  65924. * @param yaxis defines the value of the 2nd axis
  65925. * @param zaxis defines the value of the 3rd axis
  65926. * @param result defines the target matrix
  65927. */
  65928. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  65929. /**
  65930. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  65931. * @param quat defines the quaternion to use
  65932. * @param result defines the target matrix
  65933. */
  65934. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  65935. }
  65936. /**
  65937. * Represens a plane by the equation ax + by + cz + d = 0
  65938. */
  65939. export class Plane {
  65940. /**
  65941. * Normal of the plane (a,b,c)
  65942. */
  65943. normal: Vector3;
  65944. /**
  65945. * d component of the plane
  65946. */
  65947. d: number;
  65948. /**
  65949. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  65950. * @param a a component of the plane
  65951. * @param b b component of the plane
  65952. * @param c c component of the plane
  65953. * @param d d component of the plane
  65954. */
  65955. constructor(a: number, b: number, c: number, d: number);
  65956. /**
  65957. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  65958. */
  65959. asArray(): number[];
  65960. /**
  65961. * @returns a new plane copied from the current Plane.
  65962. */
  65963. clone(): Plane;
  65964. /**
  65965. * @returns the string "Plane".
  65966. */
  65967. getClassName(): string;
  65968. /**
  65969. * @returns the Plane hash code.
  65970. */
  65971. getHashCode(): number;
  65972. /**
  65973. * Normalize the current Plane in place.
  65974. * @returns the updated Plane.
  65975. */
  65976. normalize(): Plane;
  65977. /**
  65978. * Applies a transformation the plane and returns the result
  65979. * @param transformation the transformation matrix to be applied to the plane
  65980. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  65981. */
  65982. transform(transformation: DeepImmutable<Matrix>): Plane;
  65983. /**
  65984. * Calcualtte the dot product between the point and the plane normal
  65985. * @param point point to calculate the dot product with
  65986. * @returns the dot product (float) of the point coordinates and the plane normal.
  65987. */
  65988. dotCoordinate(point: DeepImmutable<Vector3>): number;
  65989. /**
  65990. * Updates the current Plane from the plane defined by the three given points.
  65991. * @param point1 one of the points used to contruct the plane
  65992. * @param point2 one of the points used to contruct the plane
  65993. * @param point3 one of the points used to contruct the plane
  65994. * @returns the updated Plane.
  65995. */
  65996. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  65997. /**
  65998. * Checks if the plane is facing a given direction
  65999. * @param direction the direction to check if the plane is facing
  66000. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  66001. * @returns True is the vector "direction" is the same side than the plane normal.
  66002. */
  66003. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  66004. /**
  66005. * Calculates the distance to a point
  66006. * @param point point to calculate distance to
  66007. * @returns the signed distance (float) from the given point to the Plane.
  66008. */
  66009. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  66010. /**
  66011. * Creates a plane from an array
  66012. * @param array the array to create a plane from
  66013. * @returns a new Plane from the given array.
  66014. */
  66015. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  66016. /**
  66017. * Creates a plane from three points
  66018. * @param point1 point used to create the plane
  66019. * @param point2 point used to create the plane
  66020. * @param point3 point used to create the plane
  66021. * @returns a new Plane defined by the three given points.
  66022. */
  66023. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  66024. /**
  66025. * Creates a plane from an origin point and a normal
  66026. * @param origin origin of the plane to be constructed
  66027. * @param normal normal of the plane to be constructed
  66028. * @returns a new Plane the normal vector to this plane at the given origin point.
  66029. * Note : the vector "normal" is updated because normalized.
  66030. */
  66031. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  66032. /**
  66033. * Calculates the distance from a plane and a point
  66034. * @param origin origin of the plane to be constructed
  66035. * @param normal normal of the plane to be constructed
  66036. * @param point point to calculate distance to
  66037. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  66038. */
  66039. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  66040. }
  66041. /**
  66042. * Class used to represent a viewport on screen
  66043. */
  66044. export class Viewport {
  66045. /** viewport left coordinate */
  66046. x: number;
  66047. /** viewport top coordinate */
  66048. y: number;
  66049. /**viewport width */
  66050. width: number;
  66051. /** viewport height */
  66052. height: number;
  66053. /**
  66054. * Creates a Viewport object located at (x, y) and sized (width, height)
  66055. * @param x defines viewport left coordinate
  66056. * @param y defines viewport top coordinate
  66057. * @param width defines the viewport width
  66058. * @param height defines the viewport height
  66059. */
  66060. constructor(
  66061. /** viewport left coordinate */
  66062. x: number,
  66063. /** viewport top coordinate */
  66064. y: number,
  66065. /**viewport width */
  66066. width: number,
  66067. /** viewport height */
  66068. height: number);
  66069. /**
  66070. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  66071. * @param renderWidth defines the rendering width
  66072. * @param renderHeight defines the rendering height
  66073. * @returns a new Viewport
  66074. */
  66075. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  66076. /**
  66077. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  66078. * @param renderWidth defines the rendering width
  66079. * @param renderHeight defines the rendering height
  66080. * @param ref defines the target viewport
  66081. * @returns the current viewport
  66082. */
  66083. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  66084. /**
  66085. * Returns a new Viewport copied from the current one
  66086. * @returns a new Viewport
  66087. */
  66088. clone(): Viewport;
  66089. }
  66090. /**
  66091. * Reprasents a camera frustum
  66092. */
  66093. export class Frustum {
  66094. /**
  66095. * Gets the planes representing the frustum
  66096. * @param transform matrix to be applied to the returned planes
  66097. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  66098. */
  66099. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  66100. /**
  66101. * Gets the near frustum plane transformed by the transform matrix
  66102. * @param transform transformation matrix to be applied to the resulting frustum plane
  66103. * @param frustumPlane the resuling frustum plane
  66104. */
  66105. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66106. /**
  66107. * Gets the far frustum plane transformed by the transform matrix
  66108. * @param transform transformation matrix to be applied to the resulting frustum plane
  66109. * @param frustumPlane the resuling frustum plane
  66110. */
  66111. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66112. /**
  66113. * Gets the left frustum plane transformed by the transform matrix
  66114. * @param transform transformation matrix to be applied to the resulting frustum plane
  66115. * @param frustumPlane the resuling frustum plane
  66116. */
  66117. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66118. /**
  66119. * Gets the right frustum plane transformed by the transform matrix
  66120. * @param transform transformation matrix to be applied to the resulting frustum plane
  66121. * @param frustumPlane the resuling frustum plane
  66122. */
  66123. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66124. /**
  66125. * Gets the top frustum plane transformed by the transform matrix
  66126. * @param transform transformation matrix to be applied to the resulting frustum plane
  66127. * @param frustumPlane the resuling frustum plane
  66128. */
  66129. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66130. /**
  66131. * Gets the bottom frustum plane transformed by the transform matrix
  66132. * @param transform transformation matrix to be applied to the resulting frustum plane
  66133. * @param frustumPlane the resuling frustum plane
  66134. */
  66135. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66136. /**
  66137. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  66138. * @param transform transformation matrix to be applied to the resulting frustum planes
  66139. * @param frustumPlanes the resuling frustum planes
  66140. */
  66141. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  66142. }
  66143. /** Defines supported spaces */
  66144. export enum Space {
  66145. /** Local (object) space */
  66146. LOCAL = 0,
  66147. /** World space */
  66148. WORLD = 1,
  66149. /** Bone space */
  66150. BONE = 2
  66151. }
  66152. /** Defines the 3 main axes */
  66153. export class Axis {
  66154. /** X axis */
  66155. static X: Vector3;
  66156. /** Y axis */
  66157. static Y: Vector3;
  66158. /** Z axis */
  66159. static Z: Vector3;
  66160. }
  66161. /** Class used to represent a Bezier curve */
  66162. export class BezierCurve {
  66163. /**
  66164. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  66165. * @param t defines the time
  66166. * @param x1 defines the left coordinate on X axis
  66167. * @param y1 defines the left coordinate on Y axis
  66168. * @param x2 defines the right coordinate on X axis
  66169. * @param y2 defines the right coordinate on Y axis
  66170. * @returns the interpolated value
  66171. */
  66172. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  66173. }
  66174. /**
  66175. * Defines potential orientation for back face culling
  66176. */
  66177. export enum Orientation {
  66178. /**
  66179. * Clockwise
  66180. */
  66181. CW = 0,
  66182. /** Counter clockwise */
  66183. CCW = 1
  66184. }
  66185. /**
  66186. * Defines angle representation
  66187. */
  66188. export class Angle {
  66189. private _radians;
  66190. /**
  66191. * Creates an Angle object of "radians" radians (float).
  66192. * @param radians the angle in radians
  66193. */
  66194. constructor(radians: number);
  66195. /**
  66196. * Get value in degrees
  66197. * @returns the Angle value in degrees (float)
  66198. */
  66199. degrees(): number;
  66200. /**
  66201. * Get value in radians
  66202. * @returns the Angle value in radians (float)
  66203. */
  66204. radians(): number;
  66205. /**
  66206. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  66207. * @param a defines first vector
  66208. * @param b defines second vector
  66209. * @returns a new Angle
  66210. */
  66211. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  66212. /**
  66213. * Gets a new Angle object from the given float in radians
  66214. * @param radians defines the angle value in radians
  66215. * @returns a new Angle
  66216. */
  66217. static FromRadians(radians: number): Angle;
  66218. /**
  66219. * Gets a new Angle object from the given float in degrees
  66220. * @param degrees defines the angle value in degrees
  66221. * @returns a new Angle
  66222. */
  66223. static FromDegrees(degrees: number): Angle;
  66224. }
  66225. /**
  66226. * This represents an arc in a 2d space.
  66227. */
  66228. export class Arc2 {
  66229. /** Defines the start point of the arc */
  66230. startPoint: Vector2;
  66231. /** Defines the mid point of the arc */
  66232. midPoint: Vector2;
  66233. /** Defines the end point of the arc */
  66234. endPoint: Vector2;
  66235. /**
  66236. * Defines the center point of the arc.
  66237. */
  66238. centerPoint: Vector2;
  66239. /**
  66240. * Defines the radius of the arc.
  66241. */
  66242. radius: number;
  66243. /**
  66244. * Defines the angle of the arc (from mid point to end point).
  66245. */
  66246. angle: Angle;
  66247. /**
  66248. * Defines the start angle of the arc (from start point to middle point).
  66249. */
  66250. startAngle: Angle;
  66251. /**
  66252. * Defines the orientation of the arc (clock wise/counter clock wise).
  66253. */
  66254. orientation: Orientation;
  66255. /**
  66256. * Creates an Arc object from the three given points : start, middle and end.
  66257. * @param startPoint Defines the start point of the arc
  66258. * @param midPoint Defines the midlle point of the arc
  66259. * @param endPoint Defines the end point of the arc
  66260. */
  66261. constructor(
  66262. /** Defines the start point of the arc */
  66263. startPoint: Vector2,
  66264. /** Defines the mid point of the arc */
  66265. midPoint: Vector2,
  66266. /** Defines the end point of the arc */
  66267. endPoint: Vector2);
  66268. }
  66269. /**
  66270. * Represents a 2D path made up of multiple 2D points
  66271. */
  66272. export class Path2 {
  66273. private _points;
  66274. private _length;
  66275. /**
  66276. * If the path start and end point are the same
  66277. */
  66278. closed: boolean;
  66279. /**
  66280. * Creates a Path2 object from the starting 2D coordinates x and y.
  66281. * @param x the starting points x value
  66282. * @param y the starting points y value
  66283. */
  66284. constructor(x: number, y: number);
  66285. /**
  66286. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  66287. * @param x the added points x value
  66288. * @param y the added points y value
  66289. * @returns the updated Path2.
  66290. */
  66291. addLineTo(x: number, y: number): Path2;
  66292. /**
  66293. * 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.
  66294. * @param midX middle point x value
  66295. * @param midY middle point y value
  66296. * @param endX end point x value
  66297. * @param endY end point y value
  66298. * @param numberOfSegments (default: 36)
  66299. * @returns the updated Path2.
  66300. */
  66301. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  66302. /**
  66303. * Closes the Path2.
  66304. * @returns the Path2.
  66305. */
  66306. close(): Path2;
  66307. /**
  66308. * Gets the sum of the distance between each sequential point in the path
  66309. * @returns the Path2 total length (float).
  66310. */
  66311. length(): number;
  66312. /**
  66313. * Gets the points which construct the path
  66314. * @returns the Path2 internal array of points.
  66315. */
  66316. getPoints(): Vector2[];
  66317. /**
  66318. * Retreives the point at the distance aways from the starting point
  66319. * @param normalizedLengthPosition the length along the path to retreive the point from
  66320. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  66321. */
  66322. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  66323. /**
  66324. * Creates a new path starting from an x and y position
  66325. * @param x starting x value
  66326. * @param y starting y value
  66327. * @returns a new Path2 starting at the coordinates (x, y).
  66328. */
  66329. static StartingAt(x: number, y: number): Path2;
  66330. }
  66331. /**
  66332. * Represents a 3D path made up of multiple 3D points
  66333. */
  66334. export class Path3D {
  66335. /**
  66336. * an array of Vector3, the curve axis of the Path3D
  66337. */
  66338. path: Vector3[];
  66339. private _curve;
  66340. private _distances;
  66341. private _tangents;
  66342. private _normals;
  66343. private _binormals;
  66344. private _raw;
  66345. /**
  66346. * new Path3D(path, normal, raw)
  66347. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  66348. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  66349. * @param path an array of Vector3, the curve axis of the Path3D
  66350. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  66351. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  66352. */
  66353. constructor(
  66354. /**
  66355. * an array of Vector3, the curve axis of the Path3D
  66356. */
  66357. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  66358. /**
  66359. * Returns the Path3D array of successive Vector3 designing its curve.
  66360. * @returns the Path3D array of successive Vector3 designing its curve.
  66361. */
  66362. getCurve(): Vector3[];
  66363. /**
  66364. * Returns an array populated with tangent vectors on each Path3D curve point.
  66365. * @returns an array populated with tangent vectors on each Path3D curve point.
  66366. */
  66367. getTangents(): Vector3[];
  66368. /**
  66369. * Returns an array populated with normal vectors on each Path3D curve point.
  66370. * @returns an array populated with normal vectors on each Path3D curve point.
  66371. */
  66372. getNormals(): Vector3[];
  66373. /**
  66374. * Returns an array populated with binormal vectors on each Path3D curve point.
  66375. * @returns an array populated with binormal vectors on each Path3D curve point.
  66376. */
  66377. getBinormals(): Vector3[];
  66378. /**
  66379. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  66380. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  66381. */
  66382. getDistances(): number[];
  66383. /**
  66384. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  66385. * @param path path which all values are copied into the curves points
  66386. * @param firstNormal which should be projected onto the curve
  66387. * @returns the same object updated.
  66388. */
  66389. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  66390. private _compute;
  66391. private _getFirstNonNullVector;
  66392. private _getLastNonNullVector;
  66393. private _normalVector;
  66394. }
  66395. /**
  66396. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  66397. * A Curve3 is designed from a series of successive Vector3.
  66398. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  66399. */
  66400. export class Curve3 {
  66401. private _points;
  66402. private _length;
  66403. /**
  66404. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  66405. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  66406. * @param v1 (Vector3) the control point
  66407. * @param v2 (Vector3) the end point of the Quadratic Bezier
  66408. * @param nbPoints (integer) the wanted number of points in the curve
  66409. * @returns the created Curve3
  66410. */
  66411. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66412. /**
  66413. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  66414. * @param v0 (Vector3) the origin point of the Cubic Bezier
  66415. * @param v1 (Vector3) the first control point
  66416. * @param v2 (Vector3) the second control point
  66417. * @param v3 (Vector3) the end point of the Cubic Bezier
  66418. * @param nbPoints (integer) the wanted number of points in the curve
  66419. * @returns the created Curve3
  66420. */
  66421. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66422. /**
  66423. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  66424. * @param p1 (Vector3) the origin point of the Hermite Spline
  66425. * @param t1 (Vector3) the tangent vector at the origin point
  66426. * @param p2 (Vector3) the end point of the Hermite Spline
  66427. * @param t2 (Vector3) the tangent vector at the end point
  66428. * @param nbPoints (integer) the wanted number of points in the curve
  66429. * @returns the created Curve3
  66430. */
  66431. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66432. /**
  66433. * Returns a Curve3 object along a CatmullRom Spline curve :
  66434. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  66435. * @param nbPoints (integer) the wanted number of points between each curve control points
  66436. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  66437. * @returns the created Curve3
  66438. */
  66439. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  66440. /**
  66441. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  66442. * A Curve3 is designed from a series of successive Vector3.
  66443. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  66444. * @param points points which make up the curve
  66445. */
  66446. constructor(points: Vector3[]);
  66447. /**
  66448. * @returns the Curve3 stored array of successive Vector3
  66449. */
  66450. getPoints(): Vector3[];
  66451. /**
  66452. * @returns the computed length (float) of the curve.
  66453. */
  66454. length(): number;
  66455. /**
  66456. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  66457. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  66458. * curveA and curveB keep unchanged.
  66459. * @param curve the curve to continue from this curve
  66460. * @returns the newly constructed curve
  66461. */
  66462. continue(curve: DeepImmutable<Curve3>): Curve3;
  66463. private _computeLength;
  66464. }
  66465. /**
  66466. * Contains position and normal vectors for a vertex
  66467. */
  66468. export class PositionNormalVertex {
  66469. /** the position of the vertex (defaut: 0,0,0) */
  66470. position: Vector3;
  66471. /** the normal of the vertex (defaut: 0,1,0) */
  66472. normal: Vector3;
  66473. /**
  66474. * Creates a PositionNormalVertex
  66475. * @param position the position of the vertex (defaut: 0,0,0)
  66476. * @param normal the normal of the vertex (defaut: 0,1,0)
  66477. */
  66478. constructor(
  66479. /** the position of the vertex (defaut: 0,0,0) */
  66480. position?: Vector3,
  66481. /** the normal of the vertex (defaut: 0,1,0) */
  66482. normal?: Vector3);
  66483. /**
  66484. * Clones the PositionNormalVertex
  66485. * @returns the cloned PositionNormalVertex
  66486. */
  66487. clone(): PositionNormalVertex;
  66488. }
  66489. /**
  66490. * Contains position, normal and uv vectors for a vertex
  66491. */
  66492. export class PositionNormalTextureVertex {
  66493. /** the position of the vertex (defaut: 0,0,0) */
  66494. position: Vector3;
  66495. /** the normal of the vertex (defaut: 0,1,0) */
  66496. normal: Vector3;
  66497. /** the uv of the vertex (default: 0,0) */
  66498. uv: Vector2;
  66499. /**
  66500. * Creates a PositionNormalTextureVertex
  66501. * @param position the position of the vertex (defaut: 0,0,0)
  66502. * @param normal the normal of the vertex (defaut: 0,1,0)
  66503. * @param uv the uv of the vertex (default: 0,0)
  66504. */
  66505. constructor(
  66506. /** the position of the vertex (defaut: 0,0,0) */
  66507. position?: Vector3,
  66508. /** the normal of the vertex (defaut: 0,1,0) */
  66509. normal?: Vector3,
  66510. /** the uv of the vertex (default: 0,0) */
  66511. uv?: Vector2);
  66512. /**
  66513. * Clones the PositionNormalTextureVertex
  66514. * @returns the cloned PositionNormalTextureVertex
  66515. */
  66516. clone(): PositionNormalTextureVertex;
  66517. }
  66518. /**
  66519. * @hidden
  66520. */
  66521. export class Tmp {
  66522. static Color3: Color3[];
  66523. static Color4: Color4[];
  66524. static Vector2: Vector2[];
  66525. static Vector3: Vector3[];
  66526. static Vector4: Vector4[];
  66527. static Quaternion: Quaternion[];
  66528. static Matrix: Matrix[];
  66529. }
  66530. }
  66531. declare module BABYLON {
  66532. /**
  66533. * Class used to enable access to offline support
  66534. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66535. */
  66536. export interface IOfflineProvider {
  66537. /**
  66538. * Gets a boolean indicating if scene must be saved in the database
  66539. */
  66540. enableSceneOffline: boolean;
  66541. /**
  66542. * Gets a boolean indicating if textures must be saved in the database
  66543. */
  66544. enableTexturesOffline: boolean;
  66545. /**
  66546. * Open the offline support and make it available
  66547. * @param successCallback defines the callback to call on success
  66548. * @param errorCallback defines the callback to call on error
  66549. */
  66550. open(successCallback: () => void, errorCallback: () => void): void;
  66551. /**
  66552. * Loads an image from the offline support
  66553. * @param url defines the url to load from
  66554. * @param image defines the target DOM image
  66555. */
  66556. loadImage(url: string, image: HTMLImageElement): void;
  66557. /**
  66558. * Loads a file from offline support
  66559. * @param url defines the URL to load from
  66560. * @param sceneLoaded defines a callback to call on success
  66561. * @param progressCallBack defines a callback to call when progress changed
  66562. * @param errorCallback defines a callback to call on error
  66563. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  66564. */
  66565. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66566. }
  66567. }
  66568. declare module BABYLON {
  66569. /**
  66570. * A class serves as a medium between the observable and its observers
  66571. */
  66572. export class EventState {
  66573. /**
  66574. * Create a new EventState
  66575. * @param mask defines the mask associated with this state
  66576. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66577. * @param target defines the original target of the state
  66578. * @param currentTarget defines the current target of the state
  66579. */
  66580. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  66581. /**
  66582. * Initialize the current event state
  66583. * @param mask defines the mask associated with this state
  66584. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66585. * @param target defines the original target of the state
  66586. * @param currentTarget defines the current target of the state
  66587. * @returns the current event state
  66588. */
  66589. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  66590. /**
  66591. * An Observer can set this property to true to prevent subsequent observers of being notified
  66592. */
  66593. skipNextObservers: boolean;
  66594. /**
  66595. * Get the mask value that were used to trigger the event corresponding to this EventState object
  66596. */
  66597. mask: number;
  66598. /**
  66599. * The object that originally notified the event
  66600. */
  66601. target?: any;
  66602. /**
  66603. * The current object in the bubbling phase
  66604. */
  66605. currentTarget?: any;
  66606. /**
  66607. * This will be populated with the return value of the last function that was executed.
  66608. * If it is the first function in the callback chain it will be the event data.
  66609. */
  66610. lastReturnValue?: any;
  66611. }
  66612. /**
  66613. * Represent an Observer registered to a given Observable object.
  66614. */
  66615. export class Observer<T> {
  66616. /**
  66617. * Defines the callback to call when the observer is notified
  66618. */
  66619. callback: (eventData: T, eventState: EventState) => void;
  66620. /**
  66621. * Defines the mask of the observer (used to filter notifications)
  66622. */
  66623. mask: number;
  66624. /**
  66625. * Defines the current scope used to restore the JS context
  66626. */
  66627. scope: any;
  66628. /** @hidden */
  66629. _willBeUnregistered: boolean;
  66630. /**
  66631. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  66632. */
  66633. unregisterOnNextCall: boolean;
  66634. /**
  66635. * Creates a new observer
  66636. * @param callback defines the callback to call when the observer is notified
  66637. * @param mask defines the mask of the observer (used to filter notifications)
  66638. * @param scope defines the current scope used to restore the JS context
  66639. */
  66640. constructor(
  66641. /**
  66642. * Defines the callback to call when the observer is notified
  66643. */
  66644. callback: (eventData: T, eventState: EventState) => void,
  66645. /**
  66646. * Defines the mask of the observer (used to filter notifications)
  66647. */
  66648. mask: number,
  66649. /**
  66650. * Defines the current scope used to restore the JS context
  66651. */
  66652. scope?: any);
  66653. }
  66654. /**
  66655. * Represent a list of observers registered to multiple Observables object.
  66656. */
  66657. export class MultiObserver<T> {
  66658. private _observers;
  66659. private _observables;
  66660. /**
  66661. * Release associated resources
  66662. */
  66663. dispose(): void;
  66664. /**
  66665. * Raise a callback when one of the observable will notify
  66666. * @param observables defines a list of observables to watch
  66667. * @param callback defines the callback to call on notification
  66668. * @param mask defines the mask used to filter notifications
  66669. * @param scope defines the current scope used to restore the JS context
  66670. * @returns the new MultiObserver
  66671. */
  66672. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  66673. }
  66674. /**
  66675. * The Observable class is a simple implementation of the Observable pattern.
  66676. *
  66677. * 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.
  66678. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  66679. * 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).
  66680. * 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.
  66681. */
  66682. export class Observable<T> {
  66683. private _observers;
  66684. private _eventState;
  66685. private _onObserverAdded;
  66686. /**
  66687. * Creates a new observable
  66688. * @param onObserverAdded defines a callback to call when a new observer is added
  66689. */
  66690. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  66691. /**
  66692. * Create a new Observer with the specified callback
  66693. * @param callback the callback that will be executed for that Observer
  66694. * @param mask the mask used to filter observers
  66695. * @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.
  66696. * @param scope optional scope for the callback to be called from
  66697. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  66698. * @returns the new observer created for the callback
  66699. */
  66700. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  66701. /**
  66702. * Create a new Observer with the specified callback and unregisters after the next notification
  66703. * @param callback the callback that will be executed for that Observer
  66704. * @returns the new observer created for the callback
  66705. */
  66706. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  66707. /**
  66708. * Remove an Observer from the Observable object
  66709. * @param observer the instance of the Observer to remove
  66710. * @returns false if it doesn't belong to this Observable
  66711. */
  66712. remove(observer: Nullable<Observer<T>>): boolean;
  66713. /**
  66714. * Remove a callback from the Observable object
  66715. * @param callback the callback to remove
  66716. * @param scope optional scope. If used only the callbacks with this scope will be removed
  66717. * @returns false if it doesn't belong to this Observable
  66718. */
  66719. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  66720. private _deferUnregister;
  66721. private _remove;
  66722. /**
  66723. * Moves the observable to the top of the observer list making it get called first when notified
  66724. * @param observer the observer to move
  66725. */
  66726. makeObserverTopPriority(observer: Observer<T>): void;
  66727. /**
  66728. * Moves the observable to the bottom of the observer list making it get called last when notified
  66729. * @param observer the observer to move
  66730. */
  66731. makeObserverBottomPriority(observer: Observer<T>): void;
  66732. /**
  66733. * Notify all Observers by calling their respective callback with the given data
  66734. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  66735. * @param eventData defines the data to send to all observers
  66736. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  66737. * @param target defines the original target of the state
  66738. * @param currentTarget defines the current target of the state
  66739. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  66740. */
  66741. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  66742. /**
  66743. * Calling this will execute each callback, expecting it to be a promise or return a value.
  66744. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  66745. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  66746. * and it is crucial that all callbacks will be executed.
  66747. * The order of the callbacks is kept, callbacks are not executed parallel.
  66748. *
  66749. * @param eventData The data to be sent to each callback
  66750. * @param mask is used to filter observers defaults to -1
  66751. * @param target defines the callback target (see EventState)
  66752. * @param currentTarget defines he current object in the bubbling phase
  66753. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  66754. */
  66755. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  66756. /**
  66757. * Notify a specific observer
  66758. * @param observer defines the observer to notify
  66759. * @param eventData defines the data to be sent to each callback
  66760. * @param mask is used to filter observers defaults to -1
  66761. */
  66762. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  66763. /**
  66764. * Gets a boolean indicating if the observable has at least one observer
  66765. * @returns true is the Observable has at least one Observer registered
  66766. */
  66767. hasObservers(): boolean;
  66768. /**
  66769. * Clear the list of observers
  66770. */
  66771. clear(): void;
  66772. /**
  66773. * Clone the current observable
  66774. * @returns a new observable
  66775. */
  66776. clone(): Observable<T>;
  66777. /**
  66778. * Does this observable handles observer registered with a given mask
  66779. * @param mask defines the mask to be tested
  66780. * @return whether or not one observer registered with the given mask is handeled
  66781. **/
  66782. hasSpecificMask(mask?: number): boolean;
  66783. }
  66784. }
  66785. declare module BABYLON {
  66786. /**
  66787. * Class used to help managing file picking and drag'n'drop
  66788. * File Storage
  66789. */
  66790. export class FilesInputStore {
  66791. /**
  66792. * List of files ready to be loaded
  66793. */
  66794. static FilesToLoad: {
  66795. [key: string]: File;
  66796. };
  66797. }
  66798. }
  66799. declare module BABYLON {
  66800. /** Defines the cross module used constants to avoid circular dependncies */
  66801. export class Constants {
  66802. /** Defines that alpha blending is disabled */
  66803. static readonly ALPHA_DISABLE: number;
  66804. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  66805. static readonly ALPHA_ADD: number;
  66806. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  66807. static readonly ALPHA_COMBINE: number;
  66808. /** Defines that alpha blending to DEST - SRC * DEST */
  66809. static readonly ALPHA_SUBTRACT: number;
  66810. /** Defines that alpha blending to SRC * DEST */
  66811. static readonly ALPHA_MULTIPLY: number;
  66812. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  66813. static readonly ALPHA_MAXIMIZED: number;
  66814. /** Defines that alpha blending to SRC + DEST */
  66815. static readonly ALPHA_ONEONE: number;
  66816. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  66817. static readonly ALPHA_PREMULTIPLIED: number;
  66818. /**
  66819. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  66820. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  66821. */
  66822. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  66823. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  66824. static readonly ALPHA_INTERPOLATE: number;
  66825. /**
  66826. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  66827. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  66828. */
  66829. static readonly ALPHA_SCREENMODE: number;
  66830. /** Defines that the ressource is not delayed*/
  66831. static readonly DELAYLOADSTATE_NONE: number;
  66832. /** Defines that the ressource was successfully delay loaded */
  66833. static readonly DELAYLOADSTATE_LOADED: number;
  66834. /** Defines that the ressource is currently delay loading */
  66835. static readonly DELAYLOADSTATE_LOADING: number;
  66836. /** Defines that the ressource is delayed and has not started loading */
  66837. static readonly DELAYLOADSTATE_NOTLOADED: number;
  66838. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  66839. static readonly NEVER: number;
  66840. /** 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 */
  66841. static readonly ALWAYS: number;
  66842. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  66843. static readonly LESS: number;
  66844. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  66845. static readonly EQUAL: number;
  66846. /** 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 */
  66847. static readonly LEQUAL: number;
  66848. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  66849. static readonly GREATER: number;
  66850. /** 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 */
  66851. static readonly GEQUAL: number;
  66852. /** 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 */
  66853. static readonly NOTEQUAL: number;
  66854. /** Passed to stencilOperation to specify that stencil value must be kept */
  66855. static readonly KEEP: number;
  66856. /** Passed to stencilOperation to specify that stencil value must be replaced */
  66857. static readonly REPLACE: number;
  66858. /** Passed to stencilOperation to specify that stencil value must be incremented */
  66859. static readonly INCR: number;
  66860. /** Passed to stencilOperation to specify that stencil value must be decremented */
  66861. static readonly DECR: number;
  66862. /** Passed to stencilOperation to specify that stencil value must be inverted */
  66863. static readonly INVERT: number;
  66864. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  66865. static readonly INCR_WRAP: number;
  66866. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  66867. static readonly DECR_WRAP: number;
  66868. /** Texture is not repeating outside of 0..1 UVs */
  66869. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  66870. /** Texture is repeating outside of 0..1 UVs */
  66871. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  66872. /** Texture is repeating and mirrored */
  66873. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  66874. /** ALPHA */
  66875. static readonly TEXTUREFORMAT_ALPHA: number;
  66876. /** LUMINANCE */
  66877. static readonly TEXTUREFORMAT_LUMINANCE: number;
  66878. /** LUMINANCE_ALPHA */
  66879. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  66880. /** RGB */
  66881. static readonly TEXTUREFORMAT_RGB: number;
  66882. /** RGBA */
  66883. static readonly TEXTUREFORMAT_RGBA: number;
  66884. /** RED */
  66885. static readonly TEXTUREFORMAT_RED: number;
  66886. /** RED (2nd reference) */
  66887. static readonly TEXTUREFORMAT_R: number;
  66888. /** RG */
  66889. static readonly TEXTUREFORMAT_RG: number;
  66890. /** RED_INTEGER */
  66891. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  66892. /** RED_INTEGER (2nd reference) */
  66893. static readonly TEXTUREFORMAT_R_INTEGER: number;
  66894. /** RG_INTEGER */
  66895. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  66896. /** RGB_INTEGER */
  66897. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  66898. /** RGBA_INTEGER */
  66899. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  66900. /** UNSIGNED_BYTE */
  66901. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  66902. /** UNSIGNED_BYTE (2nd reference) */
  66903. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  66904. /** FLOAT */
  66905. static readonly TEXTURETYPE_FLOAT: number;
  66906. /** HALF_FLOAT */
  66907. static readonly TEXTURETYPE_HALF_FLOAT: number;
  66908. /** BYTE */
  66909. static readonly TEXTURETYPE_BYTE: number;
  66910. /** SHORT */
  66911. static readonly TEXTURETYPE_SHORT: number;
  66912. /** UNSIGNED_SHORT */
  66913. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  66914. /** INT */
  66915. static readonly TEXTURETYPE_INT: number;
  66916. /** UNSIGNED_INT */
  66917. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  66918. /** UNSIGNED_SHORT_4_4_4_4 */
  66919. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  66920. /** UNSIGNED_SHORT_5_5_5_1 */
  66921. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  66922. /** UNSIGNED_SHORT_5_6_5 */
  66923. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  66924. /** UNSIGNED_INT_2_10_10_10_REV */
  66925. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  66926. /** UNSIGNED_INT_24_8 */
  66927. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  66928. /** UNSIGNED_INT_10F_11F_11F_REV */
  66929. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  66930. /** UNSIGNED_INT_5_9_9_9_REV */
  66931. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  66932. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  66933. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  66934. /** nearest is mag = nearest and min = nearest and mip = linear */
  66935. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  66936. /** Bilinear is mag = linear and min = linear and mip = nearest */
  66937. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  66938. /** Trilinear is mag = linear and min = linear and mip = linear */
  66939. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  66940. /** nearest is mag = nearest and min = nearest and mip = linear */
  66941. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  66942. /** Bilinear is mag = linear and min = linear and mip = nearest */
  66943. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  66944. /** Trilinear is mag = linear and min = linear and mip = linear */
  66945. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  66946. /** mag = nearest and min = nearest and mip = nearest */
  66947. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  66948. /** mag = nearest and min = linear and mip = nearest */
  66949. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  66950. /** mag = nearest and min = linear and mip = linear */
  66951. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  66952. /** mag = nearest and min = linear and mip = none */
  66953. static readonly TEXTURE_NEAREST_LINEAR: number;
  66954. /** mag = nearest and min = nearest and mip = none */
  66955. static readonly TEXTURE_NEAREST_NEAREST: number;
  66956. /** mag = linear and min = nearest and mip = nearest */
  66957. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  66958. /** mag = linear and min = nearest and mip = linear */
  66959. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  66960. /** mag = linear and min = linear and mip = none */
  66961. static readonly TEXTURE_LINEAR_LINEAR: number;
  66962. /** mag = linear and min = nearest and mip = none */
  66963. static readonly TEXTURE_LINEAR_NEAREST: number;
  66964. /** Explicit coordinates mode */
  66965. static readonly TEXTURE_EXPLICIT_MODE: number;
  66966. /** Spherical coordinates mode */
  66967. static readonly TEXTURE_SPHERICAL_MODE: number;
  66968. /** Planar coordinates mode */
  66969. static readonly TEXTURE_PLANAR_MODE: number;
  66970. /** Cubic coordinates mode */
  66971. static readonly TEXTURE_CUBIC_MODE: number;
  66972. /** Projection coordinates mode */
  66973. static readonly TEXTURE_PROJECTION_MODE: number;
  66974. /** Skybox coordinates mode */
  66975. static readonly TEXTURE_SKYBOX_MODE: number;
  66976. /** Inverse Cubic coordinates mode */
  66977. static readonly TEXTURE_INVCUBIC_MODE: number;
  66978. /** Equirectangular coordinates mode */
  66979. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  66980. /** Equirectangular Fixed coordinates mode */
  66981. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  66982. /** Equirectangular Fixed Mirrored coordinates mode */
  66983. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  66984. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  66985. static readonly SCALEMODE_FLOOR: number;
  66986. /** Defines that texture rescaling will look for the nearest power of 2 size */
  66987. static readonly SCALEMODE_NEAREST: number;
  66988. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  66989. static readonly SCALEMODE_CEILING: number;
  66990. /**
  66991. * The dirty texture flag value
  66992. */
  66993. static readonly MATERIAL_TextureDirtyFlag: number;
  66994. /**
  66995. * The dirty light flag value
  66996. */
  66997. static readonly MATERIAL_LightDirtyFlag: number;
  66998. /**
  66999. * The dirty fresnel flag value
  67000. */
  67001. static readonly MATERIAL_FresnelDirtyFlag: number;
  67002. /**
  67003. * The dirty attribute flag value
  67004. */
  67005. static readonly MATERIAL_AttributesDirtyFlag: number;
  67006. /**
  67007. * The dirty misc flag value
  67008. */
  67009. static readonly MATERIAL_MiscDirtyFlag: number;
  67010. /**
  67011. * The all dirty flag value
  67012. */
  67013. static readonly MATERIAL_AllDirtyFlag: number;
  67014. /**
  67015. * Returns the triangle fill mode
  67016. */
  67017. static readonly MATERIAL_TriangleFillMode: number;
  67018. /**
  67019. * Returns the wireframe mode
  67020. */
  67021. static readonly MATERIAL_WireFrameFillMode: number;
  67022. /**
  67023. * Returns the point fill mode
  67024. */
  67025. static readonly MATERIAL_PointFillMode: number;
  67026. /**
  67027. * Returns the point list draw mode
  67028. */
  67029. static readonly MATERIAL_PointListDrawMode: number;
  67030. /**
  67031. * Returns the line list draw mode
  67032. */
  67033. static readonly MATERIAL_LineListDrawMode: number;
  67034. /**
  67035. * Returns the line loop draw mode
  67036. */
  67037. static readonly MATERIAL_LineLoopDrawMode: number;
  67038. /**
  67039. * Returns the line strip draw mode
  67040. */
  67041. static readonly MATERIAL_LineStripDrawMode: number;
  67042. /**
  67043. * Returns the triangle strip draw mode
  67044. */
  67045. static readonly MATERIAL_TriangleStripDrawMode: number;
  67046. /**
  67047. * Returns the triangle fan draw mode
  67048. */
  67049. static readonly MATERIAL_TriangleFanDrawMode: number;
  67050. /**
  67051. * Stores the clock-wise side orientation
  67052. */
  67053. static readonly MATERIAL_ClockWiseSideOrientation: number;
  67054. /**
  67055. * Stores the counter clock-wise side orientation
  67056. */
  67057. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  67058. /**
  67059. * Nothing
  67060. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67061. */
  67062. static readonly ACTION_NothingTrigger: number;
  67063. /**
  67064. * On pick
  67065. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67066. */
  67067. static readonly ACTION_OnPickTrigger: number;
  67068. /**
  67069. * On left pick
  67070. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67071. */
  67072. static readonly ACTION_OnLeftPickTrigger: number;
  67073. /**
  67074. * On right pick
  67075. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67076. */
  67077. static readonly ACTION_OnRightPickTrigger: number;
  67078. /**
  67079. * On center pick
  67080. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67081. */
  67082. static readonly ACTION_OnCenterPickTrigger: number;
  67083. /**
  67084. * On pick down
  67085. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67086. */
  67087. static readonly ACTION_OnPickDownTrigger: number;
  67088. /**
  67089. * On double pick
  67090. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67091. */
  67092. static readonly ACTION_OnDoublePickTrigger: number;
  67093. /**
  67094. * On pick up
  67095. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67096. */
  67097. static readonly ACTION_OnPickUpTrigger: number;
  67098. /**
  67099. * On pick out.
  67100. * This trigger will only be raised if you also declared a OnPickDown
  67101. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67102. */
  67103. static readonly ACTION_OnPickOutTrigger: number;
  67104. /**
  67105. * On long press
  67106. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67107. */
  67108. static readonly ACTION_OnLongPressTrigger: number;
  67109. /**
  67110. * On pointer over
  67111. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67112. */
  67113. static readonly ACTION_OnPointerOverTrigger: number;
  67114. /**
  67115. * On pointer out
  67116. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67117. */
  67118. static readonly ACTION_OnPointerOutTrigger: number;
  67119. /**
  67120. * On every frame
  67121. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67122. */
  67123. static readonly ACTION_OnEveryFrameTrigger: number;
  67124. /**
  67125. * On intersection enter
  67126. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67127. */
  67128. static readonly ACTION_OnIntersectionEnterTrigger: number;
  67129. /**
  67130. * On intersection exit
  67131. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67132. */
  67133. static readonly ACTION_OnIntersectionExitTrigger: number;
  67134. /**
  67135. * On key down
  67136. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67137. */
  67138. static readonly ACTION_OnKeyDownTrigger: number;
  67139. /**
  67140. * On key up
  67141. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67142. */
  67143. static readonly ACTION_OnKeyUpTrigger: number;
  67144. /**
  67145. * Billboard mode will only apply to Y axis
  67146. */
  67147. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  67148. /**
  67149. * Billboard mode will apply to all axes
  67150. */
  67151. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  67152. /**
  67153. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  67154. */
  67155. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  67156. /**
  67157. * Gets or sets base Assets URL
  67158. */
  67159. static PARTICLES_BaseAssetsUrl: string;
  67160. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  67161. * Test order :
  67162. * Is the bounding sphere outside the frustum ?
  67163. * If not, are the bounding box vertices outside the frustum ?
  67164. * It not, then the cullable object is in the frustum.
  67165. */
  67166. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  67167. /** Culling strategy : Bounding Sphere Only.
  67168. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  67169. * It's also less accurate than the standard because some not visible objects can still be selected.
  67170. * Test : is the bounding sphere outside the frustum ?
  67171. * If not, then the cullable object is in the frustum.
  67172. */
  67173. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  67174. /** Culling strategy : Optimistic Inclusion.
  67175. * This in an inclusion test first, then the standard exclusion test.
  67176. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  67177. * 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.
  67178. * Anyway, it's as accurate as the standard strategy.
  67179. * Test :
  67180. * Is the cullable object bounding sphere center in the frustum ?
  67181. * If not, apply the default culling strategy.
  67182. */
  67183. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  67184. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  67185. * This in an inclusion test first, then the bounding sphere only exclusion test.
  67186. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  67187. * 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.
  67188. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  67189. * Test :
  67190. * Is the cullable object bounding sphere center in the frustum ?
  67191. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  67192. */
  67193. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  67194. /**
  67195. * No logging while loading
  67196. */
  67197. static readonly SCENELOADER_NO_LOGGING: number;
  67198. /**
  67199. * Minimal logging while loading
  67200. */
  67201. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  67202. /**
  67203. * Summary logging while loading
  67204. */
  67205. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  67206. /**
  67207. * Detailled logging while loading
  67208. */
  67209. static readonly SCENELOADER_DETAILED_LOGGING: number;
  67210. }
  67211. }
  67212. declare module BABYLON {
  67213. /**
  67214. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  67215. * Babylon.js
  67216. */
  67217. export class DomManagement {
  67218. /**
  67219. * Checks if the window object exists
  67220. * @returns true if the window object exists
  67221. */
  67222. static IsWindowObjectExist(): boolean;
  67223. /**
  67224. * Extracts text content from a DOM element hierarchy
  67225. * @param element defines the root element
  67226. * @returns a string
  67227. */
  67228. static GetDOMTextContent(element: HTMLElement): string;
  67229. }
  67230. }
  67231. declare module BABYLON {
  67232. /**
  67233. * Logger used througouht the application to allow configuration of
  67234. * the log level required for the messages.
  67235. */
  67236. export class Logger {
  67237. /**
  67238. * No log
  67239. */
  67240. static readonly NoneLogLevel: number;
  67241. /**
  67242. * Only message logs
  67243. */
  67244. static readonly MessageLogLevel: number;
  67245. /**
  67246. * Only warning logs
  67247. */
  67248. static readonly WarningLogLevel: number;
  67249. /**
  67250. * Only error logs
  67251. */
  67252. static readonly ErrorLogLevel: number;
  67253. /**
  67254. * All logs
  67255. */
  67256. static readonly AllLogLevel: number;
  67257. private static _LogCache;
  67258. /**
  67259. * Gets a value indicating the number of loading errors
  67260. * @ignorenaming
  67261. */
  67262. static errorsCount: number;
  67263. /**
  67264. * Callback called when a new log is added
  67265. */
  67266. static OnNewCacheEntry: (entry: string) => void;
  67267. private static _AddLogEntry;
  67268. private static _FormatMessage;
  67269. private static _LogDisabled;
  67270. private static _LogEnabled;
  67271. private static _WarnDisabled;
  67272. private static _WarnEnabled;
  67273. private static _ErrorDisabled;
  67274. private static _ErrorEnabled;
  67275. /**
  67276. * Log a message to the console
  67277. */
  67278. static Log: (message: string) => void;
  67279. /**
  67280. * Write a warning message to the console
  67281. */
  67282. static Warn: (message: string) => void;
  67283. /**
  67284. * Write an error message to the console
  67285. */
  67286. static Error: (message: string) => void;
  67287. /**
  67288. * Gets current log cache (list of logs)
  67289. */
  67290. static readonly LogCache: string;
  67291. /**
  67292. * Clears the log cache
  67293. */
  67294. static ClearLogCache(): void;
  67295. /**
  67296. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  67297. */
  67298. static LogLevels: number;
  67299. }
  67300. }
  67301. declare module BABYLON {
  67302. /** @hidden */
  67303. export class _TypeStore {
  67304. /** @hidden */
  67305. static RegisteredTypes: {
  67306. [key: string]: Object;
  67307. };
  67308. /** @hidden */
  67309. static GetClass(fqdn: string): any;
  67310. }
  67311. }
  67312. declare module BABYLON {
  67313. /**
  67314. * Class containing a set of static utilities functions for deep copy.
  67315. */
  67316. export class DeepCopier {
  67317. /**
  67318. * Tries to copy an object by duplicating every property
  67319. * @param source defines the source object
  67320. * @param destination defines the target object
  67321. * @param doNotCopyList defines a list of properties to avoid
  67322. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  67323. */
  67324. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  67325. }
  67326. }
  67327. declare module BABYLON {
  67328. /**
  67329. * Class containing a set of static utilities functions for precision date
  67330. */
  67331. export class PrecisionDate {
  67332. /**
  67333. * Gets either window.performance.now() if supported or Date.now() else
  67334. */
  67335. static readonly Now: number;
  67336. }
  67337. }
  67338. declare module BABYLON {
  67339. /** @hidden */
  67340. export class _DevTools {
  67341. static WarnImport(name: string): string;
  67342. }
  67343. }
  67344. declare module BABYLON {
  67345. /**
  67346. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  67347. */
  67348. export class WebRequest {
  67349. private _xhr;
  67350. /**
  67351. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  67352. * i.e. when loading files, where the server/service expects an Authorization header
  67353. */
  67354. static CustomRequestHeaders: {
  67355. [key: string]: string;
  67356. };
  67357. /**
  67358. * Add callback functions in this array to update all the requests before they get sent to the network
  67359. */
  67360. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  67361. private _injectCustomRequestHeaders;
  67362. /**
  67363. * Gets or sets a function to be called when loading progress changes
  67364. */
  67365. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  67366. /**
  67367. * Returns client's state
  67368. */
  67369. readonly readyState: number;
  67370. /**
  67371. * Returns client's status
  67372. */
  67373. readonly status: number;
  67374. /**
  67375. * Returns client's status as a text
  67376. */
  67377. readonly statusText: string;
  67378. /**
  67379. * Returns client's response
  67380. */
  67381. readonly response: any;
  67382. /**
  67383. * Returns client's response url
  67384. */
  67385. readonly responseURL: string;
  67386. /**
  67387. * Returns client's response as text
  67388. */
  67389. readonly responseText: string;
  67390. /**
  67391. * Gets or sets the expected response type
  67392. */
  67393. responseType: XMLHttpRequestResponseType;
  67394. /** @hidden */
  67395. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  67396. /** @hidden */
  67397. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  67398. /**
  67399. * Cancels any network activity
  67400. */
  67401. abort(): void;
  67402. /**
  67403. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  67404. * @param body defines an optional request body
  67405. */
  67406. send(body?: Document | BodyInit | null): void;
  67407. /**
  67408. * Sets the request method, request URL
  67409. * @param method defines the method to use (GET, POST, etc..)
  67410. * @param url defines the url to connect with
  67411. */
  67412. open(method: string, url: string): void;
  67413. }
  67414. }
  67415. declare module BABYLON {
  67416. /**
  67417. * Class used to evalaute queries containing `and` and `or` operators
  67418. */
  67419. export class AndOrNotEvaluator {
  67420. /**
  67421. * Evaluate a query
  67422. * @param query defines the query to evaluate
  67423. * @param evaluateCallback defines the callback used to filter result
  67424. * @returns true if the query matches
  67425. */
  67426. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  67427. private static _HandleParenthesisContent;
  67428. private static _SimplifyNegation;
  67429. }
  67430. }
  67431. declare module BABYLON {
  67432. /**
  67433. * Class used to store custom tags
  67434. */
  67435. export class Tags {
  67436. /**
  67437. * Adds support for tags on the given object
  67438. * @param obj defines the object to use
  67439. */
  67440. static EnableFor(obj: any): void;
  67441. /**
  67442. * Removes tags support
  67443. * @param obj defines the object to use
  67444. */
  67445. static DisableFor(obj: any): void;
  67446. /**
  67447. * Gets a boolean indicating if the given object has tags
  67448. * @param obj defines the object to use
  67449. * @returns a boolean
  67450. */
  67451. static HasTags(obj: any): boolean;
  67452. /**
  67453. * Gets the tags available on a given object
  67454. * @param obj defines the object to use
  67455. * @param asString defines if the tags must be returned as a string instead of an array of strings
  67456. * @returns the tags
  67457. */
  67458. static GetTags(obj: any, asString?: boolean): any;
  67459. /**
  67460. * Adds tags to an object
  67461. * @param obj defines the object to use
  67462. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  67463. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  67464. */
  67465. static AddTagsTo(obj: any, tagsString: string): void;
  67466. /**
  67467. * @hidden
  67468. */
  67469. static _AddTagTo(obj: any, tag: string): void;
  67470. /**
  67471. * Removes specific tags from a specific object
  67472. * @param obj defines the object to use
  67473. * @param tagsString defines the tags to remove
  67474. */
  67475. static RemoveTagsFrom(obj: any, tagsString: string): void;
  67476. /**
  67477. * @hidden
  67478. */
  67479. static _RemoveTagFrom(obj: any, tag: string): void;
  67480. /**
  67481. * Defines if tags hosted on an object match a given query
  67482. * @param obj defines the object to use
  67483. * @param tagsQuery defines the tag query
  67484. * @returns a boolean
  67485. */
  67486. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  67487. }
  67488. }
  67489. declare module BABYLON {
  67490. /**
  67491. * Manages the defines for the Material
  67492. */
  67493. export class MaterialDefines {
  67494. /** @hidden */
  67495. protected _keys: string[];
  67496. private _isDirty;
  67497. /** @hidden */
  67498. _renderId: number;
  67499. /** @hidden */
  67500. _areLightsDirty: boolean;
  67501. /** @hidden */
  67502. _areAttributesDirty: boolean;
  67503. /** @hidden */
  67504. _areTexturesDirty: boolean;
  67505. /** @hidden */
  67506. _areFresnelDirty: boolean;
  67507. /** @hidden */
  67508. _areMiscDirty: boolean;
  67509. /** @hidden */
  67510. _areImageProcessingDirty: boolean;
  67511. /** @hidden */
  67512. _normals: boolean;
  67513. /** @hidden */
  67514. _uvs: boolean;
  67515. /** @hidden */
  67516. _needNormals: boolean;
  67517. /** @hidden */
  67518. _needUVs: boolean;
  67519. [id: string]: any;
  67520. /**
  67521. * Specifies if the material needs to be re-calculated
  67522. */
  67523. readonly isDirty: boolean;
  67524. /**
  67525. * Marks the material to indicate that it has been re-calculated
  67526. */
  67527. markAsProcessed(): void;
  67528. /**
  67529. * Marks the material to indicate that it needs to be re-calculated
  67530. */
  67531. markAsUnprocessed(): void;
  67532. /**
  67533. * Marks the material to indicate all of its defines need to be re-calculated
  67534. */
  67535. markAllAsDirty(): void;
  67536. /**
  67537. * Marks the material to indicate that image processing needs to be re-calculated
  67538. */
  67539. markAsImageProcessingDirty(): void;
  67540. /**
  67541. * Marks the material to indicate the lights need to be re-calculated
  67542. */
  67543. markAsLightDirty(): void;
  67544. /**
  67545. * Marks the attribute state as changed
  67546. */
  67547. markAsAttributesDirty(): void;
  67548. /**
  67549. * Marks the texture state as changed
  67550. */
  67551. markAsTexturesDirty(): void;
  67552. /**
  67553. * Marks the fresnel state as changed
  67554. */
  67555. markAsFresnelDirty(): void;
  67556. /**
  67557. * Marks the misc state as changed
  67558. */
  67559. markAsMiscDirty(): void;
  67560. /**
  67561. * Rebuilds the material defines
  67562. */
  67563. rebuild(): void;
  67564. /**
  67565. * Specifies if two material defines are equal
  67566. * @param other - A material define instance to compare to
  67567. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  67568. */
  67569. isEqual(other: MaterialDefines): boolean;
  67570. /**
  67571. * Clones this instance's defines to another instance
  67572. * @param other - material defines to clone values to
  67573. */
  67574. cloneTo(other: MaterialDefines): void;
  67575. /**
  67576. * Resets the material define values
  67577. */
  67578. reset(): void;
  67579. /**
  67580. * Converts the material define values to a string
  67581. * @returns - String of material define information
  67582. */
  67583. toString(): string;
  67584. }
  67585. }
  67586. declare module BABYLON {
  67587. /**
  67588. * Class used to store and describe the pipeline context associated with an effect
  67589. */
  67590. export interface IPipelineContext {
  67591. /**
  67592. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  67593. */
  67594. isAsync: boolean;
  67595. /**
  67596. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  67597. */
  67598. isReady: boolean;
  67599. /** @hidden */
  67600. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  67601. }
  67602. }
  67603. declare module BABYLON {
  67604. /**
  67605. * Class used to store gfx data (like WebGLBuffer)
  67606. */
  67607. export class DataBuffer {
  67608. /**
  67609. * Gets or sets the number of objects referencing this buffer
  67610. */
  67611. references: number;
  67612. /** Gets or sets the size of the underlying buffer */
  67613. capacity: number;
  67614. /**
  67615. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  67616. */
  67617. is32Bits: boolean;
  67618. /**
  67619. * Gets the underlying buffer
  67620. */
  67621. readonly underlyingResource: any;
  67622. }
  67623. }
  67624. declare module BABYLON {
  67625. /** @hidden */
  67626. export interface IShaderProcessor {
  67627. attributeProcessor?: (attribute: string) => string;
  67628. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  67629. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  67630. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  67631. }
  67632. }
  67633. declare module BABYLON {
  67634. /** @hidden */
  67635. export interface ProcessingOptions {
  67636. defines: string[];
  67637. indexParameters: any;
  67638. isFragment: boolean;
  67639. shouldUseHighPrecisionShader: boolean;
  67640. supportsUniformBuffers: boolean;
  67641. shadersRepository: string;
  67642. includesShadersStore: {
  67643. [key: string]: string;
  67644. };
  67645. processor?: IShaderProcessor;
  67646. version: string;
  67647. }
  67648. }
  67649. declare module BABYLON {
  67650. /** @hidden */
  67651. export class ShaderCodeNode {
  67652. line: string;
  67653. children: ShaderCodeNode[];
  67654. additionalDefineKey?: string;
  67655. additionalDefineValue?: string;
  67656. isValid(preprocessors: {
  67657. [key: string]: string;
  67658. }): boolean;
  67659. process(preprocessors: {
  67660. [key: string]: string;
  67661. }, options: ProcessingOptions): string;
  67662. private _lineStartsWith;
  67663. }
  67664. }
  67665. declare module BABYLON {
  67666. /** @hidden */
  67667. export class ShaderCodeCursor {
  67668. private _lines;
  67669. lineIndex: number;
  67670. readonly currentLine: string;
  67671. readonly canRead: boolean;
  67672. lines: string[];
  67673. }
  67674. }
  67675. declare module BABYLON {
  67676. /** @hidden */
  67677. export class ShaderCodeConditionNode extends ShaderCodeNode {
  67678. process(preprocessors: {
  67679. [key: string]: string;
  67680. }, options: ProcessingOptions): string;
  67681. }
  67682. }
  67683. declare module BABYLON {
  67684. /** @hidden */
  67685. export class ShaderDefineExpression {
  67686. isTrue(preprocessors: {
  67687. [key: string]: string;
  67688. }): boolean;
  67689. }
  67690. }
  67691. declare module BABYLON {
  67692. /** @hidden */
  67693. export class ShaderCodeTestNode extends ShaderCodeNode {
  67694. testExpression: ShaderDefineExpression;
  67695. isValid(preprocessors: {
  67696. [key: string]: string;
  67697. }): boolean;
  67698. }
  67699. }
  67700. declare module BABYLON {
  67701. /** @hidden */
  67702. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  67703. define: string;
  67704. not: boolean;
  67705. constructor(define: string, not?: boolean);
  67706. isTrue(preprocessors: {
  67707. [key: string]: string;
  67708. }): boolean;
  67709. }
  67710. }
  67711. declare module BABYLON {
  67712. /** @hidden */
  67713. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  67714. leftOperand: ShaderDefineExpression;
  67715. rightOperand: ShaderDefineExpression;
  67716. isTrue(preprocessors: {
  67717. [key: string]: string;
  67718. }): boolean;
  67719. }
  67720. }
  67721. declare module BABYLON {
  67722. /** @hidden */
  67723. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  67724. leftOperand: ShaderDefineExpression;
  67725. rightOperand: ShaderDefineExpression;
  67726. isTrue(preprocessors: {
  67727. [key: string]: string;
  67728. }): boolean;
  67729. }
  67730. }
  67731. declare module BABYLON {
  67732. /** @hidden */
  67733. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  67734. define: string;
  67735. operand: string;
  67736. testValue: string;
  67737. constructor(define: string, operand: string, testValue: string);
  67738. isTrue(preprocessors: {
  67739. [key: string]: string;
  67740. }): boolean;
  67741. }
  67742. }
  67743. declare module BABYLON {
  67744. /** @hidden */
  67745. export class ShaderProcessor {
  67746. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  67747. private static _ProcessPrecision;
  67748. private static _ExtractOperation;
  67749. private static _BuildSubExpression;
  67750. private static _BuildExpression;
  67751. private static _MoveCursorWithinIf;
  67752. private static _MoveCursor;
  67753. private static _EvaluatePreProcessors;
  67754. private static _PreparePreProcessors;
  67755. private static _ProcessShaderConversion;
  67756. private static _ProcessIncludes;
  67757. }
  67758. }
  67759. declare module BABYLON {
  67760. /**
  67761. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  67762. */
  67763. export class PerformanceMonitor {
  67764. private _enabled;
  67765. private _rollingFrameTime;
  67766. private _lastFrameTimeMs;
  67767. /**
  67768. * constructor
  67769. * @param frameSampleSize The number of samples required to saturate the sliding window
  67770. */
  67771. constructor(frameSampleSize?: number);
  67772. /**
  67773. * Samples current frame
  67774. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  67775. */
  67776. sampleFrame(timeMs?: number): void;
  67777. /**
  67778. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  67779. */
  67780. readonly averageFrameTime: number;
  67781. /**
  67782. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  67783. */
  67784. readonly averageFrameTimeVariance: number;
  67785. /**
  67786. * Returns the frame time of the most recent frame
  67787. */
  67788. readonly instantaneousFrameTime: number;
  67789. /**
  67790. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  67791. */
  67792. readonly averageFPS: number;
  67793. /**
  67794. * Returns the average framerate in frames per second using the most recent frame time
  67795. */
  67796. readonly instantaneousFPS: number;
  67797. /**
  67798. * Returns true if enough samples have been taken to completely fill the sliding window
  67799. */
  67800. readonly isSaturated: boolean;
  67801. /**
  67802. * Enables contributions to the sliding window sample set
  67803. */
  67804. enable(): void;
  67805. /**
  67806. * Disables contributions to the sliding window sample set
  67807. * Samples will not be interpolated over the disabled period
  67808. */
  67809. disable(): void;
  67810. /**
  67811. * Returns true if sampling is enabled
  67812. */
  67813. readonly isEnabled: boolean;
  67814. /**
  67815. * Resets performance monitor
  67816. */
  67817. reset(): void;
  67818. }
  67819. /**
  67820. * RollingAverage
  67821. *
  67822. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  67823. */
  67824. export class RollingAverage {
  67825. /**
  67826. * Current average
  67827. */
  67828. average: number;
  67829. /**
  67830. * Current variance
  67831. */
  67832. variance: number;
  67833. protected _samples: Array<number>;
  67834. protected _sampleCount: number;
  67835. protected _pos: number;
  67836. protected _m2: number;
  67837. /**
  67838. * constructor
  67839. * @param length The number of samples required to saturate the sliding window
  67840. */
  67841. constructor(length: number);
  67842. /**
  67843. * Adds a sample to the sample set
  67844. * @param v The sample value
  67845. */
  67846. add(v: number): void;
  67847. /**
  67848. * Returns previously added values or null if outside of history or outside the sliding window domain
  67849. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  67850. * @return Value previously recorded with add() or null if outside of range
  67851. */
  67852. history(i: number): number;
  67853. /**
  67854. * Returns true if enough samples have been taken to completely fill the sliding window
  67855. * @return true if sample-set saturated
  67856. */
  67857. isSaturated(): boolean;
  67858. /**
  67859. * Resets the rolling average (equivalent to 0 samples taken so far)
  67860. */
  67861. reset(): void;
  67862. /**
  67863. * Wraps a value around the sample range boundaries
  67864. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  67865. * @return Wrapped position in sample range
  67866. */
  67867. protected _wrapPosition(i: number): number;
  67868. }
  67869. }
  67870. declare module BABYLON {
  67871. /**
  67872. * This class implement a typical dictionary using a string as key and the generic type T as value.
  67873. * The underlying implementation relies on an associative array to ensure the best performances.
  67874. * The value can be anything including 'null' but except 'undefined'
  67875. */
  67876. export class StringDictionary<T> {
  67877. /**
  67878. * This will clear this dictionary and copy the content from the 'source' one.
  67879. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  67880. * @param source the dictionary to take the content from and copy to this dictionary
  67881. */
  67882. copyFrom(source: StringDictionary<T>): void;
  67883. /**
  67884. * Get a value based from its key
  67885. * @param key the given key to get the matching value from
  67886. * @return the value if found, otherwise undefined is returned
  67887. */
  67888. get(key: string): T | undefined;
  67889. /**
  67890. * Get a value from its key or add it if it doesn't exist.
  67891. * This method will ensure you that a given key/data will be present in the dictionary.
  67892. * @param key the given key to get the matching value from
  67893. * @param factory the factory that will create the value if the key is not present in the dictionary.
  67894. * The factory will only be invoked if there's no data for the given key.
  67895. * @return the value corresponding to the key.
  67896. */
  67897. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  67898. /**
  67899. * Get a value from its key if present in the dictionary otherwise add it
  67900. * @param key the key to get the value from
  67901. * @param val if there's no such key/value pair in the dictionary add it with this value
  67902. * @return the value corresponding to the key
  67903. */
  67904. getOrAdd(key: string, val: T): T;
  67905. /**
  67906. * Check if there's a given key in the dictionary
  67907. * @param key the key to check for
  67908. * @return true if the key is present, false otherwise
  67909. */
  67910. contains(key: string): boolean;
  67911. /**
  67912. * Add a new key and its corresponding value
  67913. * @param key the key to add
  67914. * @param value the value corresponding to the key
  67915. * @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
  67916. */
  67917. add(key: string, value: T): boolean;
  67918. /**
  67919. * Update a specific value associated to a key
  67920. * @param key defines the key to use
  67921. * @param value defines the value to store
  67922. * @returns true if the value was updated (or false if the key was not found)
  67923. */
  67924. set(key: string, value: T): boolean;
  67925. /**
  67926. * Get the element of the given key and remove it from the dictionary
  67927. * @param key defines the key to search
  67928. * @returns the value associated with the key or null if not found
  67929. */
  67930. getAndRemove(key: string): Nullable<T>;
  67931. /**
  67932. * Remove a key/value from the dictionary.
  67933. * @param key the key to remove
  67934. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  67935. */
  67936. remove(key: string): boolean;
  67937. /**
  67938. * Clear the whole content of the dictionary
  67939. */
  67940. clear(): void;
  67941. /**
  67942. * Gets the current count
  67943. */
  67944. readonly count: number;
  67945. /**
  67946. * Execute a callback on each key/val of the dictionary.
  67947. * Note that you can remove any element in this dictionary in the callback implementation
  67948. * @param callback the callback to execute on a given key/value pair
  67949. */
  67950. forEach(callback: (key: string, val: T) => void): void;
  67951. /**
  67952. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  67953. * If the callback returns null or undefined the method will iterate to the next key/value pair
  67954. * Note that you can remove any element in this dictionary in the callback implementation
  67955. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  67956. * @returns the first item
  67957. */
  67958. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  67959. private _count;
  67960. private _data;
  67961. }
  67962. }
  67963. declare module BABYLON {
  67964. /**
  67965. * Helper class that provides a small promise polyfill
  67966. */
  67967. export class PromisePolyfill {
  67968. /**
  67969. * Static function used to check if the polyfill is required
  67970. * If this is the case then the function will inject the polyfill to window.Promise
  67971. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  67972. */
  67973. static Apply(force?: boolean): void;
  67974. }
  67975. }
  67976. declare module BABYLON {
  67977. /**
  67978. * Class used to store data that will be store in GPU memory
  67979. */
  67980. export class Buffer {
  67981. private _engine;
  67982. private _buffer;
  67983. /** @hidden */
  67984. _data: Nullable<DataArray>;
  67985. private _updatable;
  67986. private _instanced;
  67987. /**
  67988. * Gets the byte stride.
  67989. */
  67990. readonly byteStride: number;
  67991. /**
  67992. * Constructor
  67993. * @param engine the engine
  67994. * @param data the data to use for this buffer
  67995. * @param updatable whether the data is updatable
  67996. * @param stride the stride (optional)
  67997. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  67998. * @param instanced whether the buffer is instanced (optional)
  67999. * @param useBytes set to true if the stride in in bytes (optional)
  68000. */
  68001. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  68002. /**
  68003. * Create a new VertexBuffer based on the current buffer
  68004. * @param kind defines the vertex buffer kind (position, normal, etc.)
  68005. * @param offset defines offset in the buffer (0 by default)
  68006. * @param size defines the size in floats of attributes (position is 3 for instance)
  68007. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  68008. * @param instanced defines if the vertex buffer contains indexed data
  68009. * @param useBytes defines if the offset and stride are in bytes
  68010. * @returns the new vertex buffer
  68011. */
  68012. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  68013. /**
  68014. * Gets a boolean indicating if the Buffer is updatable?
  68015. * @returns true if the buffer is updatable
  68016. */
  68017. isUpdatable(): boolean;
  68018. /**
  68019. * Gets current buffer's data
  68020. * @returns a DataArray or null
  68021. */
  68022. getData(): Nullable<DataArray>;
  68023. /**
  68024. * Gets underlying native buffer
  68025. * @returns underlying native buffer
  68026. */
  68027. getBuffer(): Nullable<DataBuffer>;
  68028. /**
  68029. * Gets the stride in float32 units (i.e. byte stride / 4).
  68030. * May not be an integer if the byte stride is not divisible by 4.
  68031. * DEPRECATED. Use byteStride instead.
  68032. * @returns the stride in float32 units
  68033. */
  68034. getStrideSize(): number;
  68035. /**
  68036. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  68037. * @param data defines the data to store
  68038. */
  68039. create(data?: Nullable<DataArray>): void;
  68040. /** @hidden */
  68041. _rebuild(): void;
  68042. /**
  68043. * Update current buffer data
  68044. * @param data defines the data to store
  68045. */
  68046. update(data: DataArray): void;
  68047. /**
  68048. * Updates the data directly.
  68049. * @param data the new data
  68050. * @param offset the new offset
  68051. * @param vertexCount the vertex count (optional)
  68052. * @param useBytes set to true if the offset is in bytes
  68053. */
  68054. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  68055. /**
  68056. * Release all resources
  68057. */
  68058. dispose(): void;
  68059. }
  68060. /**
  68061. * Specialized buffer used to store vertex data
  68062. */
  68063. export class VertexBuffer {
  68064. /** @hidden */
  68065. _buffer: Buffer;
  68066. private _kind;
  68067. private _size;
  68068. private _ownsBuffer;
  68069. private _instanced;
  68070. private _instanceDivisor;
  68071. /**
  68072. * The byte type.
  68073. */
  68074. static readonly BYTE: number;
  68075. /**
  68076. * The unsigned byte type.
  68077. */
  68078. static readonly UNSIGNED_BYTE: number;
  68079. /**
  68080. * The short type.
  68081. */
  68082. static readonly SHORT: number;
  68083. /**
  68084. * The unsigned short type.
  68085. */
  68086. static readonly UNSIGNED_SHORT: number;
  68087. /**
  68088. * The integer type.
  68089. */
  68090. static readonly INT: number;
  68091. /**
  68092. * The unsigned integer type.
  68093. */
  68094. static readonly UNSIGNED_INT: number;
  68095. /**
  68096. * The float type.
  68097. */
  68098. static readonly FLOAT: number;
  68099. /**
  68100. * Gets or sets the instance divisor when in instanced mode
  68101. */
  68102. instanceDivisor: number;
  68103. /**
  68104. * Gets the byte stride.
  68105. */
  68106. readonly byteStride: number;
  68107. /**
  68108. * Gets the byte offset.
  68109. */
  68110. readonly byteOffset: number;
  68111. /**
  68112. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  68113. */
  68114. readonly normalized: boolean;
  68115. /**
  68116. * Gets the data type of each component in the array.
  68117. */
  68118. readonly type: number;
  68119. /**
  68120. * Constructor
  68121. * @param engine the engine
  68122. * @param data the data to use for this vertex buffer
  68123. * @param kind the vertex buffer kind
  68124. * @param updatable whether the data is updatable
  68125. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  68126. * @param stride the stride (optional)
  68127. * @param instanced whether the buffer is instanced (optional)
  68128. * @param offset the offset of the data (optional)
  68129. * @param size the number of components (optional)
  68130. * @param type the type of the component (optional)
  68131. * @param normalized whether the data contains normalized data (optional)
  68132. * @param useBytes set to true if stride and offset are in bytes (optional)
  68133. */
  68134. 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);
  68135. /** @hidden */
  68136. _rebuild(): void;
  68137. /**
  68138. * Returns the kind of the VertexBuffer (string)
  68139. * @returns a string
  68140. */
  68141. getKind(): string;
  68142. /**
  68143. * Gets a boolean indicating if the VertexBuffer is updatable?
  68144. * @returns true if the buffer is updatable
  68145. */
  68146. isUpdatable(): boolean;
  68147. /**
  68148. * Gets current buffer's data
  68149. * @returns a DataArray or null
  68150. */
  68151. getData(): Nullable<DataArray>;
  68152. /**
  68153. * Gets underlying native buffer
  68154. * @returns underlying native buffer
  68155. */
  68156. getBuffer(): Nullable<DataBuffer>;
  68157. /**
  68158. * Gets the stride in float32 units (i.e. byte stride / 4).
  68159. * May not be an integer if the byte stride is not divisible by 4.
  68160. * DEPRECATED. Use byteStride instead.
  68161. * @returns the stride in float32 units
  68162. */
  68163. getStrideSize(): number;
  68164. /**
  68165. * Returns the offset as a multiple of the type byte length.
  68166. * DEPRECATED. Use byteOffset instead.
  68167. * @returns the offset in bytes
  68168. */
  68169. getOffset(): number;
  68170. /**
  68171. * Returns the number of components per vertex attribute (integer)
  68172. * @returns the size in float
  68173. */
  68174. getSize(): number;
  68175. /**
  68176. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  68177. * @returns true if this buffer is instanced
  68178. */
  68179. getIsInstanced(): boolean;
  68180. /**
  68181. * Returns the instancing divisor, zero for non-instanced (integer).
  68182. * @returns a number
  68183. */
  68184. getInstanceDivisor(): number;
  68185. /**
  68186. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  68187. * @param data defines the data to store
  68188. */
  68189. create(data?: DataArray): void;
  68190. /**
  68191. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  68192. * This function will create a new buffer if the current one is not updatable
  68193. * @param data defines the data to store
  68194. */
  68195. update(data: DataArray): void;
  68196. /**
  68197. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  68198. * Returns the directly updated WebGLBuffer.
  68199. * @param data the new data
  68200. * @param offset the new offset
  68201. * @param useBytes set to true if the offset is in bytes
  68202. */
  68203. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  68204. /**
  68205. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  68206. */
  68207. dispose(): void;
  68208. /**
  68209. * Enumerates each value of this vertex buffer as numbers.
  68210. * @param count the number of values to enumerate
  68211. * @param callback the callback function called for each value
  68212. */
  68213. forEach(count: number, callback: (value: number, index: number) => void): void;
  68214. /**
  68215. * Positions
  68216. */
  68217. static readonly PositionKind: string;
  68218. /**
  68219. * Normals
  68220. */
  68221. static readonly NormalKind: string;
  68222. /**
  68223. * Tangents
  68224. */
  68225. static readonly TangentKind: string;
  68226. /**
  68227. * Texture coordinates
  68228. */
  68229. static readonly UVKind: string;
  68230. /**
  68231. * Texture coordinates 2
  68232. */
  68233. static readonly UV2Kind: string;
  68234. /**
  68235. * Texture coordinates 3
  68236. */
  68237. static readonly UV3Kind: string;
  68238. /**
  68239. * Texture coordinates 4
  68240. */
  68241. static readonly UV4Kind: string;
  68242. /**
  68243. * Texture coordinates 5
  68244. */
  68245. static readonly UV5Kind: string;
  68246. /**
  68247. * Texture coordinates 6
  68248. */
  68249. static readonly UV6Kind: string;
  68250. /**
  68251. * Colors
  68252. */
  68253. static readonly ColorKind: string;
  68254. /**
  68255. * Matrix indices (for bones)
  68256. */
  68257. static readonly MatricesIndicesKind: string;
  68258. /**
  68259. * Matrix weights (for bones)
  68260. */
  68261. static readonly MatricesWeightsKind: string;
  68262. /**
  68263. * Additional matrix indices (for bones)
  68264. */
  68265. static readonly MatricesIndicesExtraKind: string;
  68266. /**
  68267. * Additional matrix weights (for bones)
  68268. */
  68269. static readonly MatricesWeightsExtraKind: string;
  68270. /**
  68271. * Deduces the stride given a kind.
  68272. * @param kind The kind string to deduce
  68273. * @returns The deduced stride
  68274. */
  68275. static DeduceStride(kind: string): number;
  68276. /**
  68277. * Gets the byte length of the given type.
  68278. * @param type the type
  68279. * @returns the number of bytes
  68280. */
  68281. static GetTypeByteLength(type: number): number;
  68282. /**
  68283. * Enumerates each value of the given parameters as numbers.
  68284. * @param data the data to enumerate
  68285. * @param byteOffset the byte offset of the data
  68286. * @param byteStride the byte stride of the data
  68287. * @param componentCount the number of components per element
  68288. * @param componentType the type of the component
  68289. * @param count the total number of components
  68290. * @param normalized whether the data is normalized
  68291. * @param callback the callback function called for each value
  68292. */
  68293. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  68294. private static _GetFloatValue;
  68295. }
  68296. }
  68297. declare module BABYLON {
  68298. /**
  68299. * Class representing spherical harmonics coefficients to the 3rd degree
  68300. */
  68301. export class SphericalHarmonics {
  68302. /**
  68303. * Defines whether or not the harmonics have been prescaled for rendering.
  68304. */
  68305. preScaled: boolean;
  68306. /**
  68307. * The l0,0 coefficients of the spherical harmonics
  68308. */
  68309. l00: Vector3;
  68310. /**
  68311. * The l1,-1 coefficients of the spherical harmonics
  68312. */
  68313. l1_1: Vector3;
  68314. /**
  68315. * The l1,0 coefficients of the spherical harmonics
  68316. */
  68317. l10: Vector3;
  68318. /**
  68319. * The l1,1 coefficients of the spherical harmonics
  68320. */
  68321. l11: Vector3;
  68322. /**
  68323. * The l2,-2 coefficients of the spherical harmonics
  68324. */
  68325. l2_2: Vector3;
  68326. /**
  68327. * The l2,-1 coefficients of the spherical harmonics
  68328. */
  68329. l2_1: Vector3;
  68330. /**
  68331. * The l2,0 coefficients of the spherical harmonics
  68332. */
  68333. l20: Vector3;
  68334. /**
  68335. * The l2,1 coefficients of the spherical harmonics
  68336. */
  68337. l21: Vector3;
  68338. /**
  68339. * The l2,2 coefficients of the spherical harmonics
  68340. */
  68341. l22: Vector3;
  68342. /**
  68343. * Adds a light to the spherical harmonics
  68344. * @param direction the direction of the light
  68345. * @param color the color of the light
  68346. * @param deltaSolidAngle the delta solid angle of the light
  68347. */
  68348. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  68349. /**
  68350. * Scales the spherical harmonics by the given amount
  68351. * @param scale the amount to scale
  68352. */
  68353. scaleInPlace(scale: number): void;
  68354. /**
  68355. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  68356. *
  68357. * ```
  68358. * E_lm = A_l * L_lm
  68359. * ```
  68360. *
  68361. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  68362. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  68363. * the scaling factors are given in equation 9.
  68364. */
  68365. convertIncidentRadianceToIrradiance(): void;
  68366. /**
  68367. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  68368. *
  68369. * ```
  68370. * L = (1/pi) * E * rho
  68371. * ```
  68372. *
  68373. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  68374. */
  68375. convertIrradianceToLambertianRadiance(): void;
  68376. /**
  68377. * Integrates the reconstruction coefficients directly in to the SH preventing further
  68378. * required operations at run time.
  68379. *
  68380. * This is simply done by scaling back the SH with Ylm constants parameter.
  68381. * The trigonometric part being applied by the shader at run time.
  68382. */
  68383. preScaleForRendering(): void;
  68384. /**
  68385. * Constructs a spherical harmonics from an array.
  68386. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  68387. * @returns the spherical harmonics
  68388. */
  68389. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  68390. /**
  68391. * Gets the spherical harmonics from polynomial
  68392. * @param polynomial the spherical polynomial
  68393. * @returns the spherical harmonics
  68394. */
  68395. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  68396. }
  68397. /**
  68398. * Class representing spherical polynomial coefficients to the 3rd degree
  68399. */
  68400. export class SphericalPolynomial {
  68401. private _harmonics;
  68402. /**
  68403. * The spherical harmonics used to create the polynomials.
  68404. */
  68405. readonly preScaledHarmonics: SphericalHarmonics;
  68406. /**
  68407. * The x coefficients of the spherical polynomial
  68408. */
  68409. x: Vector3;
  68410. /**
  68411. * The y coefficients of the spherical polynomial
  68412. */
  68413. y: Vector3;
  68414. /**
  68415. * The z coefficients of the spherical polynomial
  68416. */
  68417. z: Vector3;
  68418. /**
  68419. * The xx coefficients of the spherical polynomial
  68420. */
  68421. xx: Vector3;
  68422. /**
  68423. * The yy coefficients of the spherical polynomial
  68424. */
  68425. yy: Vector3;
  68426. /**
  68427. * The zz coefficients of the spherical polynomial
  68428. */
  68429. zz: Vector3;
  68430. /**
  68431. * The xy coefficients of the spherical polynomial
  68432. */
  68433. xy: Vector3;
  68434. /**
  68435. * The yz coefficients of the spherical polynomial
  68436. */
  68437. yz: Vector3;
  68438. /**
  68439. * The zx coefficients of the spherical polynomial
  68440. */
  68441. zx: Vector3;
  68442. /**
  68443. * Adds an ambient color to the spherical polynomial
  68444. * @param color the color to add
  68445. */
  68446. addAmbient(color: Color3): void;
  68447. /**
  68448. * Scales the spherical polynomial by the given amount
  68449. * @param scale the amount to scale
  68450. */
  68451. scaleInPlace(scale: number): void;
  68452. /**
  68453. * Gets the spherical polynomial from harmonics
  68454. * @param harmonics the spherical harmonics
  68455. * @returns the spherical polynomial
  68456. */
  68457. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  68458. /**
  68459. * Constructs a spherical polynomial from an array.
  68460. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  68461. * @returns the spherical polynomial
  68462. */
  68463. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  68464. }
  68465. }
  68466. declare module BABYLON {
  68467. /**
  68468. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  68469. */
  68470. export interface CubeMapInfo {
  68471. /**
  68472. * The pixel array for the front face.
  68473. * This is stored in format, left to right, up to down format.
  68474. */
  68475. front: Nullable<ArrayBufferView>;
  68476. /**
  68477. * The pixel array for the back face.
  68478. * This is stored in format, left to right, up to down format.
  68479. */
  68480. back: Nullable<ArrayBufferView>;
  68481. /**
  68482. * The pixel array for the left face.
  68483. * This is stored in format, left to right, up to down format.
  68484. */
  68485. left: Nullable<ArrayBufferView>;
  68486. /**
  68487. * The pixel array for the right face.
  68488. * This is stored in format, left to right, up to down format.
  68489. */
  68490. right: Nullable<ArrayBufferView>;
  68491. /**
  68492. * The pixel array for the up face.
  68493. * This is stored in format, left to right, up to down format.
  68494. */
  68495. up: Nullable<ArrayBufferView>;
  68496. /**
  68497. * The pixel array for the down face.
  68498. * This is stored in format, left to right, up to down format.
  68499. */
  68500. down: Nullable<ArrayBufferView>;
  68501. /**
  68502. * The size of the cubemap stored.
  68503. *
  68504. * Each faces will be size * size pixels.
  68505. */
  68506. size: number;
  68507. /**
  68508. * The format of the texture.
  68509. *
  68510. * RGBA, RGB.
  68511. */
  68512. format: number;
  68513. /**
  68514. * The type of the texture data.
  68515. *
  68516. * UNSIGNED_INT, FLOAT.
  68517. */
  68518. type: number;
  68519. /**
  68520. * Specifies whether the texture is in gamma space.
  68521. */
  68522. gammaSpace: boolean;
  68523. }
  68524. /**
  68525. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  68526. */
  68527. export class PanoramaToCubeMapTools {
  68528. private static FACE_FRONT;
  68529. private static FACE_BACK;
  68530. private static FACE_RIGHT;
  68531. private static FACE_LEFT;
  68532. private static FACE_DOWN;
  68533. private static FACE_UP;
  68534. /**
  68535. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  68536. *
  68537. * @param float32Array The source data.
  68538. * @param inputWidth The width of the input panorama.
  68539. * @param inputHeight The height of the input panorama.
  68540. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  68541. * @return The cubemap data
  68542. */
  68543. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  68544. private static CreateCubemapTexture;
  68545. private static CalcProjectionSpherical;
  68546. }
  68547. }
  68548. declare module BABYLON {
  68549. /**
  68550. * Helper class dealing with the extraction of spherical polynomial dataArray
  68551. * from a cube map.
  68552. */
  68553. export class CubeMapToSphericalPolynomialTools {
  68554. private static FileFaces;
  68555. /**
  68556. * Converts a texture to the according Spherical Polynomial data.
  68557. * This extracts the first 3 orders only as they are the only one used in the lighting.
  68558. *
  68559. * @param texture The texture to extract the information from.
  68560. * @return The Spherical Polynomial data.
  68561. */
  68562. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  68563. /**
  68564. * Converts a cubemap to the according Spherical Polynomial data.
  68565. * This extracts the first 3 orders only as they are the only one used in the lighting.
  68566. *
  68567. * @param cubeInfo The Cube map to extract the information from.
  68568. * @return The Spherical Polynomial data.
  68569. */
  68570. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  68571. }
  68572. }
  68573. declare module BABYLON {
  68574. /**
  68575. * The engine store class is responsible to hold all the instances of Engine and Scene created
  68576. * during the life time of the application.
  68577. */
  68578. export class EngineStore {
  68579. /** Gets the list of created engines */
  68580. static Instances: Engine[];
  68581. /** @hidden */
  68582. static _LastCreatedScene: Nullable<Scene>;
  68583. /**
  68584. * Gets the latest created engine
  68585. */
  68586. static readonly LastCreatedEngine: Nullable<Engine>;
  68587. /**
  68588. * Gets the latest created scene
  68589. */
  68590. static readonly LastCreatedScene: Nullable<Scene>;
  68591. }
  68592. }
  68593. declare module BABYLON {
  68594. /**
  68595. * Define options used to create a render target texture
  68596. */
  68597. export class RenderTargetCreationOptions {
  68598. /**
  68599. * Specifies is mipmaps must be generated
  68600. */
  68601. generateMipMaps?: boolean;
  68602. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  68603. generateDepthBuffer?: boolean;
  68604. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  68605. generateStencilBuffer?: boolean;
  68606. /** Defines texture type (int by default) */
  68607. type?: number;
  68608. /** Defines sampling mode (trilinear by default) */
  68609. samplingMode?: number;
  68610. /** Defines format (RGBA by default) */
  68611. format?: number;
  68612. }
  68613. }
  68614. declare module BABYLON {
  68615. /**
  68616. * @hidden
  68617. **/
  68618. export class _AlphaState {
  68619. private _isAlphaBlendDirty;
  68620. private _isBlendFunctionParametersDirty;
  68621. private _isBlendEquationParametersDirty;
  68622. private _isBlendConstantsDirty;
  68623. private _alphaBlend;
  68624. private _blendFunctionParameters;
  68625. private _blendEquationParameters;
  68626. private _blendConstants;
  68627. /**
  68628. * Initializes the state.
  68629. */
  68630. constructor();
  68631. readonly isDirty: boolean;
  68632. alphaBlend: boolean;
  68633. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  68634. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  68635. setAlphaEquationParameters(rgb: number, alpha: number): void;
  68636. reset(): void;
  68637. apply(gl: WebGLRenderingContext): void;
  68638. }
  68639. }
  68640. declare module BABYLON {
  68641. /**
  68642. * @hidden
  68643. **/
  68644. export class _DepthCullingState {
  68645. private _isDepthTestDirty;
  68646. private _isDepthMaskDirty;
  68647. private _isDepthFuncDirty;
  68648. private _isCullFaceDirty;
  68649. private _isCullDirty;
  68650. private _isZOffsetDirty;
  68651. private _isFrontFaceDirty;
  68652. private _depthTest;
  68653. private _depthMask;
  68654. private _depthFunc;
  68655. private _cull;
  68656. private _cullFace;
  68657. private _zOffset;
  68658. private _frontFace;
  68659. /**
  68660. * Initializes the state.
  68661. */
  68662. constructor();
  68663. readonly isDirty: boolean;
  68664. zOffset: number;
  68665. cullFace: Nullable<number>;
  68666. cull: Nullable<boolean>;
  68667. depthFunc: Nullable<number>;
  68668. depthMask: boolean;
  68669. depthTest: boolean;
  68670. frontFace: Nullable<number>;
  68671. reset(): void;
  68672. apply(gl: WebGLRenderingContext): void;
  68673. }
  68674. }
  68675. declare module BABYLON {
  68676. /**
  68677. * @hidden
  68678. **/
  68679. export class _StencilState {
  68680. /** 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 */
  68681. static readonly ALWAYS: number;
  68682. /** Passed to stencilOperation to specify that stencil value must be kept */
  68683. static readonly KEEP: number;
  68684. /** Passed to stencilOperation to specify that stencil value must be replaced */
  68685. static readonly REPLACE: number;
  68686. private _isStencilTestDirty;
  68687. private _isStencilMaskDirty;
  68688. private _isStencilFuncDirty;
  68689. private _isStencilOpDirty;
  68690. private _stencilTest;
  68691. private _stencilMask;
  68692. private _stencilFunc;
  68693. private _stencilFuncRef;
  68694. private _stencilFuncMask;
  68695. private _stencilOpStencilFail;
  68696. private _stencilOpDepthFail;
  68697. private _stencilOpStencilDepthPass;
  68698. readonly isDirty: boolean;
  68699. stencilFunc: number;
  68700. stencilFuncRef: number;
  68701. stencilFuncMask: number;
  68702. stencilOpStencilFail: number;
  68703. stencilOpDepthFail: number;
  68704. stencilOpStencilDepthPass: number;
  68705. stencilMask: number;
  68706. stencilTest: boolean;
  68707. constructor();
  68708. reset(): void;
  68709. apply(gl: WebGLRenderingContext): void;
  68710. }
  68711. }
  68712. declare module BABYLON {
  68713. /**
  68714. * @hidden
  68715. **/
  68716. export class _TimeToken {
  68717. _startTimeQuery: Nullable<WebGLQuery>;
  68718. _endTimeQuery: Nullable<WebGLQuery>;
  68719. _timeElapsedQuery: Nullable<WebGLQuery>;
  68720. _timeElapsedQueryEnded: boolean;
  68721. }
  68722. }
  68723. declare module BABYLON {
  68724. /**
  68725. * Class used to store data associated with WebGL texture data for the engine
  68726. * This class should not be used directly
  68727. */
  68728. export class InternalTexture {
  68729. /** @hidden */
  68730. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  68731. /**
  68732. * The source of the texture data is unknown
  68733. */
  68734. static DATASOURCE_UNKNOWN: number;
  68735. /**
  68736. * Texture data comes from an URL
  68737. */
  68738. static DATASOURCE_URL: number;
  68739. /**
  68740. * Texture data is only used for temporary storage
  68741. */
  68742. static DATASOURCE_TEMP: number;
  68743. /**
  68744. * Texture data comes from raw data (ArrayBuffer)
  68745. */
  68746. static DATASOURCE_RAW: number;
  68747. /**
  68748. * Texture content is dynamic (video or dynamic texture)
  68749. */
  68750. static DATASOURCE_DYNAMIC: number;
  68751. /**
  68752. * Texture content is generated by rendering to it
  68753. */
  68754. static DATASOURCE_RENDERTARGET: number;
  68755. /**
  68756. * Texture content is part of a multi render target process
  68757. */
  68758. static DATASOURCE_MULTIRENDERTARGET: number;
  68759. /**
  68760. * Texture data comes from a cube data file
  68761. */
  68762. static DATASOURCE_CUBE: number;
  68763. /**
  68764. * Texture data comes from a raw cube data
  68765. */
  68766. static DATASOURCE_CUBERAW: number;
  68767. /**
  68768. * Texture data come from a prefiltered cube data file
  68769. */
  68770. static DATASOURCE_CUBEPREFILTERED: number;
  68771. /**
  68772. * Texture content is raw 3D data
  68773. */
  68774. static DATASOURCE_RAW3D: number;
  68775. /**
  68776. * Texture content is a depth texture
  68777. */
  68778. static DATASOURCE_DEPTHTEXTURE: number;
  68779. /**
  68780. * Texture data comes from a raw cube data encoded with RGBD
  68781. */
  68782. static DATASOURCE_CUBERAW_RGBD: number;
  68783. /**
  68784. * Defines if the texture is ready
  68785. */
  68786. isReady: boolean;
  68787. /**
  68788. * Defines if the texture is a cube texture
  68789. */
  68790. isCube: boolean;
  68791. /**
  68792. * Defines if the texture contains 3D data
  68793. */
  68794. is3D: boolean;
  68795. /**
  68796. * Defines if the texture contains multiview data
  68797. */
  68798. isMultiview: boolean;
  68799. /**
  68800. * Gets the URL used to load this texture
  68801. */
  68802. url: string;
  68803. /**
  68804. * Gets the sampling mode of the texture
  68805. */
  68806. samplingMode: number;
  68807. /**
  68808. * Gets a boolean indicating if the texture needs mipmaps generation
  68809. */
  68810. generateMipMaps: boolean;
  68811. /**
  68812. * Gets the number of samples used by the texture (WebGL2+ only)
  68813. */
  68814. samples: number;
  68815. /**
  68816. * Gets the type of the texture (int, float...)
  68817. */
  68818. type: number;
  68819. /**
  68820. * Gets the format of the texture (RGB, RGBA...)
  68821. */
  68822. format: number;
  68823. /**
  68824. * Observable called when the texture is loaded
  68825. */
  68826. onLoadedObservable: Observable<InternalTexture>;
  68827. /**
  68828. * Gets the width of the texture
  68829. */
  68830. width: number;
  68831. /**
  68832. * Gets the height of the texture
  68833. */
  68834. height: number;
  68835. /**
  68836. * Gets the depth of the texture
  68837. */
  68838. depth: number;
  68839. /**
  68840. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  68841. */
  68842. baseWidth: number;
  68843. /**
  68844. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  68845. */
  68846. baseHeight: number;
  68847. /**
  68848. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  68849. */
  68850. baseDepth: number;
  68851. /**
  68852. * Gets a boolean indicating if the texture is inverted on Y axis
  68853. */
  68854. invertY: boolean;
  68855. /** @hidden */
  68856. _invertVScale: boolean;
  68857. /** @hidden */
  68858. _associatedChannel: number;
  68859. /** @hidden */
  68860. _dataSource: number;
  68861. /** @hidden */
  68862. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  68863. /** @hidden */
  68864. _bufferView: Nullable<ArrayBufferView>;
  68865. /** @hidden */
  68866. _bufferViewArray: Nullable<ArrayBufferView[]>;
  68867. /** @hidden */
  68868. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  68869. /** @hidden */
  68870. _size: number;
  68871. /** @hidden */
  68872. _extension: string;
  68873. /** @hidden */
  68874. _files: Nullable<string[]>;
  68875. /** @hidden */
  68876. _workingCanvas: Nullable<HTMLCanvasElement>;
  68877. /** @hidden */
  68878. _workingContext: Nullable<CanvasRenderingContext2D>;
  68879. /** @hidden */
  68880. _framebuffer: Nullable<WebGLFramebuffer>;
  68881. /** @hidden */
  68882. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  68883. /** @hidden */
  68884. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  68885. /** @hidden */
  68886. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  68887. /** @hidden */
  68888. _attachments: Nullable<number[]>;
  68889. /** @hidden */
  68890. _cachedCoordinatesMode: Nullable<number>;
  68891. /** @hidden */
  68892. _cachedWrapU: Nullable<number>;
  68893. /** @hidden */
  68894. _cachedWrapV: Nullable<number>;
  68895. /** @hidden */
  68896. _cachedWrapR: Nullable<number>;
  68897. /** @hidden */
  68898. _cachedAnisotropicFilteringLevel: Nullable<number>;
  68899. /** @hidden */
  68900. _isDisabled: boolean;
  68901. /** @hidden */
  68902. _compression: Nullable<string>;
  68903. /** @hidden */
  68904. _generateStencilBuffer: boolean;
  68905. /** @hidden */
  68906. _generateDepthBuffer: boolean;
  68907. /** @hidden */
  68908. _comparisonFunction: number;
  68909. /** @hidden */
  68910. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  68911. /** @hidden */
  68912. _lodGenerationScale: number;
  68913. /** @hidden */
  68914. _lodGenerationOffset: number;
  68915. /** @hidden */
  68916. _colorTextureArray: Nullable<WebGLTexture>;
  68917. /** @hidden */
  68918. _depthStencilTextureArray: Nullable<WebGLTexture>;
  68919. /** @hidden */
  68920. _lodTextureHigh: Nullable<BaseTexture>;
  68921. /** @hidden */
  68922. _lodTextureMid: Nullable<BaseTexture>;
  68923. /** @hidden */
  68924. _lodTextureLow: Nullable<BaseTexture>;
  68925. /** @hidden */
  68926. _isRGBD: boolean;
  68927. /** @hidden */
  68928. _linearSpecularLOD: boolean;
  68929. /** @hidden */
  68930. _irradianceTexture: Nullable<BaseTexture>;
  68931. /** @hidden */
  68932. _webGLTexture: Nullable<WebGLTexture>;
  68933. /** @hidden */
  68934. _references: number;
  68935. private _engine;
  68936. /**
  68937. * Gets the Engine the texture belongs to.
  68938. * @returns The babylon engine
  68939. */
  68940. getEngine(): Engine;
  68941. /**
  68942. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  68943. */
  68944. readonly dataSource: number;
  68945. /**
  68946. * Creates a new InternalTexture
  68947. * @param engine defines the engine to use
  68948. * @param dataSource defines the type of data that will be used
  68949. * @param delayAllocation if the texture allocation should be delayed (default: false)
  68950. */
  68951. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  68952. /**
  68953. * Increments the number of references (ie. the number of Texture that point to it)
  68954. */
  68955. incrementReferences(): void;
  68956. /**
  68957. * Change the size of the texture (not the size of the content)
  68958. * @param width defines the new width
  68959. * @param height defines the new height
  68960. * @param depth defines the new depth (1 by default)
  68961. */
  68962. updateSize(width: int, height: int, depth?: int): void;
  68963. /** @hidden */
  68964. _rebuild(): void;
  68965. /** @hidden */
  68966. _swapAndDie(target: InternalTexture): void;
  68967. /**
  68968. * Dispose the current allocated resources
  68969. */
  68970. dispose(): void;
  68971. }
  68972. }
  68973. declare module BABYLON {
  68974. /**
  68975. * This represents the main contract an easing function should follow.
  68976. * Easing functions are used throughout the animation system.
  68977. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  68978. */
  68979. export interface IEasingFunction {
  68980. /**
  68981. * Given an input gradient between 0 and 1, this returns the corrseponding value
  68982. * of the easing function.
  68983. * The link below provides some of the most common examples of easing functions.
  68984. * @see https://easings.net/
  68985. * @param gradient Defines the value between 0 and 1 we want the easing value for
  68986. * @returns the corresponding value on the curve defined by the easing function
  68987. */
  68988. ease(gradient: number): number;
  68989. }
  68990. /**
  68991. * Base class used for every default easing function.
  68992. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  68993. */
  68994. export class EasingFunction implements IEasingFunction {
  68995. /**
  68996. * Interpolation follows the mathematical formula associated with the easing function.
  68997. */
  68998. static readonly EASINGMODE_EASEIN: number;
  68999. /**
  69000. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  69001. */
  69002. static readonly EASINGMODE_EASEOUT: number;
  69003. /**
  69004. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  69005. */
  69006. static readonly EASINGMODE_EASEINOUT: number;
  69007. private _easingMode;
  69008. /**
  69009. * Sets the easing mode of the current function.
  69010. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  69011. */
  69012. setEasingMode(easingMode: number): void;
  69013. /**
  69014. * Gets the current easing mode.
  69015. * @returns the easing mode
  69016. */
  69017. getEasingMode(): number;
  69018. /**
  69019. * @hidden
  69020. */
  69021. easeInCore(gradient: number): number;
  69022. /**
  69023. * Given an input gradient between 0 and 1, this returns the corrseponding value
  69024. * of the easing function.
  69025. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69026. * @returns the corresponding value on the curve defined by the easing function
  69027. */
  69028. ease(gradient: number): number;
  69029. }
  69030. /**
  69031. * Easing function with a circle shape (see link below).
  69032. * @see https://easings.net/#easeInCirc
  69033. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69034. */
  69035. export class CircleEase extends EasingFunction implements IEasingFunction {
  69036. /** @hidden */
  69037. easeInCore(gradient: number): number;
  69038. }
  69039. /**
  69040. * Easing function with a ease back shape (see link below).
  69041. * @see https://easings.net/#easeInBack
  69042. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69043. */
  69044. export class BackEase extends EasingFunction implements IEasingFunction {
  69045. /** Defines the amplitude of the function */
  69046. amplitude: number;
  69047. /**
  69048. * Instantiates a back ease easing
  69049. * @see https://easings.net/#easeInBack
  69050. * @param amplitude Defines the amplitude of the function
  69051. */
  69052. constructor(
  69053. /** Defines the amplitude of the function */
  69054. amplitude?: number);
  69055. /** @hidden */
  69056. easeInCore(gradient: number): number;
  69057. }
  69058. /**
  69059. * Easing function with a bouncing shape (see link below).
  69060. * @see https://easings.net/#easeInBounce
  69061. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69062. */
  69063. export class BounceEase extends EasingFunction implements IEasingFunction {
  69064. /** Defines the number of bounces */
  69065. bounces: number;
  69066. /** Defines the amplitude of the bounce */
  69067. bounciness: number;
  69068. /**
  69069. * Instantiates a bounce easing
  69070. * @see https://easings.net/#easeInBounce
  69071. * @param bounces Defines the number of bounces
  69072. * @param bounciness Defines the amplitude of the bounce
  69073. */
  69074. constructor(
  69075. /** Defines the number of bounces */
  69076. bounces?: number,
  69077. /** Defines the amplitude of the bounce */
  69078. bounciness?: number);
  69079. /** @hidden */
  69080. easeInCore(gradient: number): number;
  69081. }
  69082. /**
  69083. * Easing function with a power of 3 shape (see link below).
  69084. * @see https://easings.net/#easeInCubic
  69085. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69086. */
  69087. export class CubicEase extends EasingFunction implements IEasingFunction {
  69088. /** @hidden */
  69089. easeInCore(gradient: number): number;
  69090. }
  69091. /**
  69092. * Easing function with an elastic shape (see link below).
  69093. * @see https://easings.net/#easeInElastic
  69094. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69095. */
  69096. export class ElasticEase extends EasingFunction implements IEasingFunction {
  69097. /** Defines the number of oscillations*/
  69098. oscillations: number;
  69099. /** Defines the amplitude of the oscillations*/
  69100. springiness: number;
  69101. /**
  69102. * Instantiates an elastic easing function
  69103. * @see https://easings.net/#easeInElastic
  69104. * @param oscillations Defines the number of oscillations
  69105. * @param springiness Defines the amplitude of the oscillations
  69106. */
  69107. constructor(
  69108. /** Defines the number of oscillations*/
  69109. oscillations?: number,
  69110. /** Defines the amplitude of the oscillations*/
  69111. springiness?: number);
  69112. /** @hidden */
  69113. easeInCore(gradient: number): number;
  69114. }
  69115. /**
  69116. * Easing function with an exponential shape (see link below).
  69117. * @see https://easings.net/#easeInExpo
  69118. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69119. */
  69120. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  69121. /** Defines the exponent of the function */
  69122. exponent: number;
  69123. /**
  69124. * Instantiates an exponential easing function
  69125. * @see https://easings.net/#easeInExpo
  69126. * @param exponent Defines the exponent of the function
  69127. */
  69128. constructor(
  69129. /** Defines the exponent of the function */
  69130. exponent?: number);
  69131. /** @hidden */
  69132. easeInCore(gradient: number): number;
  69133. }
  69134. /**
  69135. * Easing function with a power shape (see link below).
  69136. * @see https://easings.net/#easeInQuad
  69137. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69138. */
  69139. export class PowerEase extends EasingFunction implements IEasingFunction {
  69140. /** Defines the power of the function */
  69141. power: number;
  69142. /**
  69143. * Instantiates an power base easing function
  69144. * @see https://easings.net/#easeInQuad
  69145. * @param power Defines the power of the function
  69146. */
  69147. constructor(
  69148. /** Defines the power of the function */
  69149. power?: number);
  69150. /** @hidden */
  69151. easeInCore(gradient: number): number;
  69152. }
  69153. /**
  69154. * Easing function with a power of 2 shape (see link below).
  69155. * @see https://easings.net/#easeInQuad
  69156. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69157. */
  69158. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  69159. /** @hidden */
  69160. easeInCore(gradient: number): number;
  69161. }
  69162. /**
  69163. * Easing function with a power of 4 shape (see link below).
  69164. * @see https://easings.net/#easeInQuart
  69165. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69166. */
  69167. export class QuarticEase extends EasingFunction implements IEasingFunction {
  69168. /** @hidden */
  69169. easeInCore(gradient: number): number;
  69170. }
  69171. /**
  69172. * Easing function with a power of 5 shape (see link below).
  69173. * @see https://easings.net/#easeInQuint
  69174. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69175. */
  69176. export class QuinticEase extends EasingFunction implements IEasingFunction {
  69177. /** @hidden */
  69178. easeInCore(gradient: number): number;
  69179. }
  69180. /**
  69181. * Easing function with a sin shape (see link below).
  69182. * @see https://easings.net/#easeInSine
  69183. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69184. */
  69185. export class SineEase extends EasingFunction implements IEasingFunction {
  69186. /** @hidden */
  69187. easeInCore(gradient: number): number;
  69188. }
  69189. /**
  69190. * Easing function with a bezier shape (see link below).
  69191. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  69192. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69193. */
  69194. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  69195. /** Defines the x component of the start tangent in the bezier curve */
  69196. x1: number;
  69197. /** Defines the y component of the start tangent in the bezier curve */
  69198. y1: number;
  69199. /** Defines the x component of the end tangent in the bezier curve */
  69200. x2: number;
  69201. /** Defines the y component of the end tangent in the bezier curve */
  69202. y2: number;
  69203. /**
  69204. * Instantiates a bezier function
  69205. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  69206. * @param x1 Defines the x component of the start tangent in the bezier curve
  69207. * @param y1 Defines the y component of the start tangent in the bezier curve
  69208. * @param x2 Defines the x component of the end tangent in the bezier curve
  69209. * @param y2 Defines the y component of the end tangent in the bezier curve
  69210. */
  69211. constructor(
  69212. /** Defines the x component of the start tangent in the bezier curve */
  69213. x1?: number,
  69214. /** Defines the y component of the start tangent in the bezier curve */
  69215. y1?: number,
  69216. /** Defines the x component of the end tangent in the bezier curve */
  69217. x2?: number,
  69218. /** Defines the y component of the end tangent in the bezier curve */
  69219. y2?: number);
  69220. /** @hidden */
  69221. easeInCore(gradient: number): number;
  69222. }
  69223. }
  69224. declare module BABYLON {
  69225. /**
  69226. * Defines an interface which represents an animation key frame
  69227. */
  69228. export interface IAnimationKey {
  69229. /**
  69230. * Frame of the key frame
  69231. */
  69232. frame: number;
  69233. /**
  69234. * Value at the specifies key frame
  69235. */
  69236. value: any;
  69237. /**
  69238. * The input tangent for the cubic hermite spline
  69239. */
  69240. inTangent?: any;
  69241. /**
  69242. * The output tangent for the cubic hermite spline
  69243. */
  69244. outTangent?: any;
  69245. /**
  69246. * The animation interpolation type
  69247. */
  69248. interpolation?: AnimationKeyInterpolation;
  69249. }
  69250. /**
  69251. * Enum for the animation key frame interpolation type
  69252. */
  69253. export enum AnimationKeyInterpolation {
  69254. /**
  69255. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  69256. */
  69257. STEP = 1
  69258. }
  69259. }
  69260. declare module BABYLON {
  69261. /**
  69262. * Represents the range of an animation
  69263. */
  69264. export class AnimationRange {
  69265. /**The name of the animation range**/
  69266. name: string;
  69267. /**The starting frame of the animation */
  69268. from: number;
  69269. /**The ending frame of the animation*/
  69270. to: number;
  69271. /**
  69272. * Initializes the range of an animation
  69273. * @param name The name of the animation range
  69274. * @param from The starting frame of the animation
  69275. * @param to The ending frame of the animation
  69276. */
  69277. constructor(
  69278. /**The name of the animation range**/
  69279. name: string,
  69280. /**The starting frame of the animation */
  69281. from: number,
  69282. /**The ending frame of the animation*/
  69283. to: number);
  69284. /**
  69285. * Makes a copy of the animation range
  69286. * @returns A copy of the animation range
  69287. */
  69288. clone(): AnimationRange;
  69289. }
  69290. }
  69291. declare module BABYLON {
  69292. /**
  69293. * Composed of a frame, and an action function
  69294. */
  69295. export class AnimationEvent {
  69296. /** The frame for which the event is triggered **/
  69297. frame: number;
  69298. /** The event to perform when triggered **/
  69299. action: (currentFrame: number) => void;
  69300. /** Specifies if the event should be triggered only once**/
  69301. onlyOnce?: boolean | undefined;
  69302. /**
  69303. * Specifies if the animation event is done
  69304. */
  69305. isDone: boolean;
  69306. /**
  69307. * Initializes the animation event
  69308. * @param frame The frame for which the event is triggered
  69309. * @param action The event to perform when triggered
  69310. * @param onlyOnce Specifies if the event should be triggered only once
  69311. */
  69312. constructor(
  69313. /** The frame for which the event is triggered **/
  69314. frame: number,
  69315. /** The event to perform when triggered **/
  69316. action: (currentFrame: number) => void,
  69317. /** Specifies if the event should be triggered only once**/
  69318. onlyOnce?: boolean | undefined);
  69319. /** @hidden */
  69320. _clone(): AnimationEvent;
  69321. }
  69322. }
  69323. declare module BABYLON {
  69324. /**
  69325. * Interface used to define a behavior
  69326. */
  69327. export interface Behavior<T> {
  69328. /** gets or sets behavior's name */
  69329. name: string;
  69330. /**
  69331. * Function called when the behavior needs to be initialized (after attaching it to a target)
  69332. */
  69333. init(): void;
  69334. /**
  69335. * Called when the behavior is attached to a target
  69336. * @param target defines the target where the behavior is attached to
  69337. */
  69338. attach(target: T): void;
  69339. /**
  69340. * Called when the behavior is detached from its target
  69341. */
  69342. detach(): void;
  69343. }
  69344. /**
  69345. * Interface implemented by classes supporting behaviors
  69346. */
  69347. export interface IBehaviorAware<T> {
  69348. /**
  69349. * Attach a behavior
  69350. * @param behavior defines the behavior to attach
  69351. * @returns the current host
  69352. */
  69353. addBehavior(behavior: Behavior<T>): T;
  69354. /**
  69355. * Remove a behavior from the current object
  69356. * @param behavior defines the behavior to detach
  69357. * @returns the current host
  69358. */
  69359. removeBehavior(behavior: Behavior<T>): T;
  69360. /**
  69361. * Gets a behavior using its name to search
  69362. * @param name defines the name to search
  69363. * @returns the behavior or null if not found
  69364. */
  69365. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  69366. }
  69367. }
  69368. declare module BABYLON {
  69369. /**
  69370. * @hidden
  69371. */
  69372. export class IntersectionInfo {
  69373. bu: Nullable<number>;
  69374. bv: Nullable<number>;
  69375. distance: number;
  69376. faceId: number;
  69377. subMeshId: number;
  69378. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  69379. }
  69380. }
  69381. declare module BABYLON {
  69382. /**
  69383. * Class used to store bounding sphere information
  69384. */
  69385. export class BoundingSphere {
  69386. /**
  69387. * Gets the center of the bounding sphere in local space
  69388. */
  69389. readonly center: Vector3;
  69390. /**
  69391. * Radius of the bounding sphere in local space
  69392. */
  69393. radius: number;
  69394. /**
  69395. * Gets the center of the bounding sphere in world space
  69396. */
  69397. readonly centerWorld: Vector3;
  69398. /**
  69399. * Radius of the bounding sphere in world space
  69400. */
  69401. radiusWorld: number;
  69402. /**
  69403. * Gets the minimum vector in local space
  69404. */
  69405. readonly minimum: Vector3;
  69406. /**
  69407. * Gets the maximum vector in local space
  69408. */
  69409. readonly maximum: Vector3;
  69410. private _worldMatrix;
  69411. private static readonly TmpVector3;
  69412. /**
  69413. * Creates a new bounding sphere
  69414. * @param min defines the minimum vector (in local space)
  69415. * @param max defines the maximum vector (in local space)
  69416. * @param worldMatrix defines the new world matrix
  69417. */
  69418. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  69419. /**
  69420. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  69421. * @param min defines the new minimum vector (in local space)
  69422. * @param max defines the new maximum vector (in local space)
  69423. * @param worldMatrix defines the new world matrix
  69424. */
  69425. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  69426. /**
  69427. * Scale the current bounding sphere by applying a scale factor
  69428. * @param factor defines the scale factor to apply
  69429. * @returns the current bounding box
  69430. */
  69431. scale(factor: number): BoundingSphere;
  69432. /**
  69433. * Gets the world matrix of the bounding box
  69434. * @returns a matrix
  69435. */
  69436. getWorldMatrix(): DeepImmutable<Matrix>;
  69437. /** @hidden */
  69438. _update(worldMatrix: DeepImmutable<Matrix>): void;
  69439. /**
  69440. * Tests if the bounding sphere is intersecting the frustum planes
  69441. * @param frustumPlanes defines the frustum planes to test
  69442. * @returns true if there is an intersection
  69443. */
  69444. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69445. /**
  69446. * Tests if the bounding sphere center is in between the frustum planes.
  69447. * Used for optimistic fast inclusion.
  69448. * @param frustumPlanes defines the frustum planes to test
  69449. * @returns true if the sphere center is in between the frustum planes
  69450. */
  69451. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69452. /**
  69453. * Tests if a point is inside the bounding sphere
  69454. * @param point defines the point to test
  69455. * @returns true if the point is inside the bounding sphere
  69456. */
  69457. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  69458. /**
  69459. * Checks if two sphere intersct
  69460. * @param sphere0 sphere 0
  69461. * @param sphere1 sphere 1
  69462. * @returns true if the speres intersect
  69463. */
  69464. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  69465. }
  69466. }
  69467. declare module BABYLON {
  69468. /**
  69469. * Class used to store bounding box information
  69470. */
  69471. export class BoundingBox implements ICullable {
  69472. /**
  69473. * Gets the 8 vectors representing the bounding box in local space
  69474. */
  69475. readonly vectors: Vector3[];
  69476. /**
  69477. * Gets the center of the bounding box in local space
  69478. */
  69479. readonly center: Vector3;
  69480. /**
  69481. * Gets the center of the bounding box in world space
  69482. */
  69483. readonly centerWorld: Vector3;
  69484. /**
  69485. * Gets the extend size in local space
  69486. */
  69487. readonly extendSize: Vector3;
  69488. /**
  69489. * Gets the extend size in world space
  69490. */
  69491. readonly extendSizeWorld: Vector3;
  69492. /**
  69493. * Gets the OBB (object bounding box) directions
  69494. */
  69495. readonly directions: Vector3[];
  69496. /**
  69497. * Gets the 8 vectors representing the bounding box in world space
  69498. */
  69499. readonly vectorsWorld: Vector3[];
  69500. /**
  69501. * Gets the minimum vector in world space
  69502. */
  69503. readonly minimumWorld: Vector3;
  69504. /**
  69505. * Gets the maximum vector in world space
  69506. */
  69507. readonly maximumWorld: Vector3;
  69508. /**
  69509. * Gets the minimum vector in local space
  69510. */
  69511. readonly minimum: Vector3;
  69512. /**
  69513. * Gets the maximum vector in local space
  69514. */
  69515. readonly maximum: Vector3;
  69516. private _worldMatrix;
  69517. private static readonly TmpVector3;
  69518. /**
  69519. * @hidden
  69520. */
  69521. _tag: number;
  69522. /**
  69523. * Creates a new bounding box
  69524. * @param min defines the minimum vector (in local space)
  69525. * @param max defines the maximum vector (in local space)
  69526. * @param worldMatrix defines the new world matrix
  69527. */
  69528. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  69529. /**
  69530. * Recreates the entire bounding box from scratch as if we call the constructor in place
  69531. * @param min defines the new minimum vector (in local space)
  69532. * @param max defines the new maximum vector (in local space)
  69533. * @param worldMatrix defines the new world matrix
  69534. */
  69535. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  69536. /**
  69537. * Scale the current bounding box by applying a scale factor
  69538. * @param factor defines the scale factor to apply
  69539. * @returns the current bounding box
  69540. */
  69541. scale(factor: number): BoundingBox;
  69542. /**
  69543. * Gets the world matrix of the bounding box
  69544. * @returns a matrix
  69545. */
  69546. getWorldMatrix(): DeepImmutable<Matrix>;
  69547. /** @hidden */
  69548. _update(world: DeepImmutable<Matrix>): void;
  69549. /**
  69550. * Tests if the bounding box is intersecting the frustum planes
  69551. * @param frustumPlanes defines the frustum planes to test
  69552. * @returns true if there is an intersection
  69553. */
  69554. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69555. /**
  69556. * Tests if the bounding box is entirely inside the frustum planes
  69557. * @param frustumPlanes defines the frustum planes to test
  69558. * @returns true if there is an inclusion
  69559. */
  69560. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69561. /**
  69562. * Tests if a point is inside the bounding box
  69563. * @param point defines the point to test
  69564. * @returns true if the point is inside the bounding box
  69565. */
  69566. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  69567. /**
  69568. * Tests if the bounding box intersects with a bounding sphere
  69569. * @param sphere defines the sphere to test
  69570. * @returns true if there is an intersection
  69571. */
  69572. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  69573. /**
  69574. * Tests if the bounding box intersects with a box defined by a min and max vectors
  69575. * @param min defines the min vector to use
  69576. * @param max defines the max vector to use
  69577. * @returns true if there is an intersection
  69578. */
  69579. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  69580. /**
  69581. * Tests if two bounding boxes are intersections
  69582. * @param box0 defines the first box to test
  69583. * @param box1 defines the second box to test
  69584. * @returns true if there is an intersection
  69585. */
  69586. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  69587. /**
  69588. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  69589. * @param minPoint defines the minimum vector of the bounding box
  69590. * @param maxPoint defines the maximum vector of the bounding box
  69591. * @param sphereCenter defines the sphere center
  69592. * @param sphereRadius defines the sphere radius
  69593. * @returns true if there is an intersection
  69594. */
  69595. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  69596. /**
  69597. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  69598. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  69599. * @param frustumPlanes defines the frustum planes to test
  69600. * @return true if there is an inclusion
  69601. */
  69602. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69603. /**
  69604. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  69605. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  69606. * @param frustumPlanes defines the frustum planes to test
  69607. * @return true if there is an intersection
  69608. */
  69609. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69610. }
  69611. }
  69612. declare module BABYLON {
  69613. /** @hidden */
  69614. export class Collider {
  69615. /** Define if a collision was found */
  69616. collisionFound: boolean;
  69617. /**
  69618. * Define last intersection point in local space
  69619. */
  69620. intersectionPoint: Vector3;
  69621. /**
  69622. * Define last collided mesh
  69623. */
  69624. collidedMesh: Nullable<AbstractMesh>;
  69625. private _collisionPoint;
  69626. private _planeIntersectionPoint;
  69627. private _tempVector;
  69628. private _tempVector2;
  69629. private _tempVector3;
  69630. private _tempVector4;
  69631. private _edge;
  69632. private _baseToVertex;
  69633. private _destinationPoint;
  69634. private _slidePlaneNormal;
  69635. private _displacementVector;
  69636. /** @hidden */
  69637. _radius: Vector3;
  69638. /** @hidden */
  69639. _retry: number;
  69640. private _velocity;
  69641. private _basePoint;
  69642. private _epsilon;
  69643. /** @hidden */
  69644. _velocityWorldLength: number;
  69645. /** @hidden */
  69646. _basePointWorld: Vector3;
  69647. private _velocityWorld;
  69648. private _normalizedVelocity;
  69649. /** @hidden */
  69650. _initialVelocity: Vector3;
  69651. /** @hidden */
  69652. _initialPosition: Vector3;
  69653. private _nearestDistance;
  69654. private _collisionMask;
  69655. collisionMask: number;
  69656. /**
  69657. * Gets the plane normal used to compute the sliding response (in local space)
  69658. */
  69659. readonly slidePlaneNormal: Vector3;
  69660. /** @hidden */
  69661. _initialize(source: Vector3, dir: Vector3, e: number): void;
  69662. /** @hidden */
  69663. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  69664. /** @hidden */
  69665. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  69666. /** @hidden */
  69667. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  69668. /** @hidden */
  69669. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  69670. /** @hidden */
  69671. _getResponse(pos: Vector3, vel: Vector3): void;
  69672. }
  69673. }
  69674. declare module BABYLON {
  69675. /**
  69676. * Interface for cullable objects
  69677. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  69678. */
  69679. export interface ICullable {
  69680. /**
  69681. * Checks if the object or part of the object is in the frustum
  69682. * @param frustumPlanes Camera near/planes
  69683. * @returns true if the object is in frustum otherwise false
  69684. */
  69685. isInFrustum(frustumPlanes: Plane[]): boolean;
  69686. /**
  69687. * Checks if a cullable object (mesh...) is in the camera frustum
  69688. * Unlike isInFrustum this cheks the full bounding box
  69689. * @param frustumPlanes Camera near/planes
  69690. * @returns true if the object is in frustum otherwise false
  69691. */
  69692. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  69693. }
  69694. /**
  69695. * Info for a bounding data of a mesh
  69696. */
  69697. export class BoundingInfo implements ICullable {
  69698. /**
  69699. * Bounding box for the mesh
  69700. */
  69701. readonly boundingBox: BoundingBox;
  69702. /**
  69703. * Bounding sphere for the mesh
  69704. */
  69705. readonly boundingSphere: BoundingSphere;
  69706. private _isLocked;
  69707. private static readonly TmpVector3;
  69708. /**
  69709. * Constructs bounding info
  69710. * @param minimum min vector of the bounding box/sphere
  69711. * @param maximum max vector of the bounding box/sphere
  69712. * @param worldMatrix defines the new world matrix
  69713. */
  69714. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  69715. /**
  69716. * Recreates the entire bounding info from scratch as if we call the constructor in place
  69717. * @param min defines the new minimum vector (in local space)
  69718. * @param max defines the new maximum vector (in local space)
  69719. * @param worldMatrix defines the new world matrix
  69720. */
  69721. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  69722. /**
  69723. * min vector of the bounding box/sphere
  69724. */
  69725. readonly minimum: Vector3;
  69726. /**
  69727. * max vector of the bounding box/sphere
  69728. */
  69729. readonly maximum: Vector3;
  69730. /**
  69731. * If the info is locked and won't be updated to avoid perf overhead
  69732. */
  69733. isLocked: boolean;
  69734. /**
  69735. * Updates the bounding sphere and box
  69736. * @param world world matrix to be used to update
  69737. */
  69738. update(world: DeepImmutable<Matrix>): void;
  69739. /**
  69740. * Recreate the bounding info to be centered around a specific point given a specific extend.
  69741. * @param center New center of the bounding info
  69742. * @param extend New extend of the bounding info
  69743. * @returns the current bounding info
  69744. */
  69745. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  69746. /**
  69747. * Scale the current bounding info by applying a scale factor
  69748. * @param factor defines the scale factor to apply
  69749. * @returns the current bounding info
  69750. */
  69751. scale(factor: number): BoundingInfo;
  69752. /**
  69753. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  69754. * @param frustumPlanes defines the frustum to test
  69755. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  69756. * @returns true if the bounding info is in the frustum planes
  69757. */
  69758. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  69759. /**
  69760. * Gets the world distance between the min and max points of the bounding box
  69761. */
  69762. readonly diagonalLength: number;
  69763. /**
  69764. * Checks if a cullable object (mesh...) is in the camera frustum
  69765. * Unlike isInFrustum this cheks the full bounding box
  69766. * @param frustumPlanes Camera near/planes
  69767. * @returns true if the object is in frustum otherwise false
  69768. */
  69769. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69770. /** @hidden */
  69771. _checkCollision(collider: Collider): boolean;
  69772. /**
  69773. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  69774. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  69775. * @param point the point to check intersection with
  69776. * @returns if the point intersects
  69777. */
  69778. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  69779. /**
  69780. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  69781. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  69782. * @param boundingInfo the bounding info to check intersection with
  69783. * @param precise if the intersection should be done using OBB
  69784. * @returns if the bounding info intersects
  69785. */
  69786. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  69787. }
  69788. }
  69789. declare module BABYLON {
  69790. /**
  69791. * Defines an array and its length.
  69792. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  69793. */
  69794. export interface ISmartArrayLike<T> {
  69795. /**
  69796. * The data of the array.
  69797. */
  69798. data: Array<T>;
  69799. /**
  69800. * The active length of the array.
  69801. */
  69802. length: number;
  69803. }
  69804. /**
  69805. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  69806. */
  69807. export class SmartArray<T> implements ISmartArrayLike<T> {
  69808. /**
  69809. * The full set of data from the array.
  69810. */
  69811. data: Array<T>;
  69812. /**
  69813. * The active length of the array.
  69814. */
  69815. length: number;
  69816. protected _id: number;
  69817. /**
  69818. * Instantiates a Smart Array.
  69819. * @param capacity defines the default capacity of the array.
  69820. */
  69821. constructor(capacity: number);
  69822. /**
  69823. * Pushes a value at the end of the active data.
  69824. * @param value defines the object to push in the array.
  69825. */
  69826. push(value: T): void;
  69827. /**
  69828. * Iterates over the active data and apply the lambda to them.
  69829. * @param func defines the action to apply on each value.
  69830. */
  69831. forEach(func: (content: T) => void): void;
  69832. /**
  69833. * Sorts the full sets of data.
  69834. * @param compareFn defines the comparison function to apply.
  69835. */
  69836. sort(compareFn: (a: T, b: T) => number): void;
  69837. /**
  69838. * Resets the active data to an empty array.
  69839. */
  69840. reset(): void;
  69841. /**
  69842. * Releases all the data from the array as well as the array.
  69843. */
  69844. dispose(): void;
  69845. /**
  69846. * Concats the active data with a given array.
  69847. * @param array defines the data to concatenate with.
  69848. */
  69849. concat(array: any): void;
  69850. /**
  69851. * Returns the position of a value in the active data.
  69852. * @param value defines the value to find the index for
  69853. * @returns the index if found in the active data otherwise -1
  69854. */
  69855. indexOf(value: T): number;
  69856. /**
  69857. * Returns whether an element is part of the active data.
  69858. * @param value defines the value to look for
  69859. * @returns true if found in the active data otherwise false
  69860. */
  69861. contains(value: T): boolean;
  69862. private static _GlobalId;
  69863. }
  69864. /**
  69865. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  69866. * The data in this array can only be present once
  69867. */
  69868. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  69869. private _duplicateId;
  69870. /**
  69871. * Pushes a value at the end of the active data.
  69872. * THIS DOES NOT PREVENT DUPPLICATE DATA
  69873. * @param value defines the object to push in the array.
  69874. */
  69875. push(value: T): void;
  69876. /**
  69877. * Pushes a value at the end of the active data.
  69878. * If the data is already present, it won t be added again
  69879. * @param value defines the object to push in the array.
  69880. * @returns true if added false if it was already present
  69881. */
  69882. pushNoDuplicate(value: T): boolean;
  69883. /**
  69884. * Resets the active data to an empty array.
  69885. */
  69886. reset(): void;
  69887. /**
  69888. * Concats the active data with a given array.
  69889. * This ensures no dupplicate will be present in the result.
  69890. * @param array defines the data to concatenate with.
  69891. */
  69892. concatWithNoDuplicate(array: any): void;
  69893. }
  69894. }
  69895. declare module BABYLON {
  69896. /**
  69897. * A multi-material is used to apply different materials to different parts of the same object without the need of
  69898. * separate meshes. This can be use to improve performances.
  69899. * @see http://doc.babylonjs.com/how_to/multi_materials
  69900. */
  69901. export class MultiMaterial extends Material {
  69902. private _subMaterials;
  69903. /**
  69904. * Gets or Sets the list of Materials used within the multi material.
  69905. * They need to be ordered according to the submeshes order in the associated mesh
  69906. */
  69907. subMaterials: Nullable<Material>[];
  69908. /**
  69909. * Function used to align with Node.getChildren()
  69910. * @returns the list of Materials used within the multi material
  69911. */
  69912. getChildren(): Nullable<Material>[];
  69913. /**
  69914. * Instantiates a new Multi Material
  69915. * A multi-material is used to apply different materials to different parts of the same object without the need of
  69916. * separate meshes. This can be use to improve performances.
  69917. * @see http://doc.babylonjs.com/how_to/multi_materials
  69918. * @param name Define the name in the scene
  69919. * @param scene Define the scene the material belongs to
  69920. */
  69921. constructor(name: string, scene: Scene);
  69922. private _hookArray;
  69923. /**
  69924. * Get one of the submaterial by its index in the submaterials array
  69925. * @param index The index to look the sub material at
  69926. * @returns The Material if the index has been defined
  69927. */
  69928. getSubMaterial(index: number): Nullable<Material>;
  69929. /**
  69930. * Get the list of active textures for the whole sub materials list.
  69931. * @returns All the textures that will be used during the rendering
  69932. */
  69933. getActiveTextures(): BaseTexture[];
  69934. /**
  69935. * Gets the current class name of the material e.g. "MultiMaterial"
  69936. * Mainly use in serialization.
  69937. * @returns the class name
  69938. */
  69939. getClassName(): string;
  69940. /**
  69941. * Checks if the material is ready to render the requested sub mesh
  69942. * @param mesh Define the mesh the submesh belongs to
  69943. * @param subMesh Define the sub mesh to look readyness for
  69944. * @param useInstances Define whether or not the material is used with instances
  69945. * @returns true if ready, otherwise false
  69946. */
  69947. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  69948. /**
  69949. * Clones the current material and its related sub materials
  69950. * @param name Define the name of the newly cloned material
  69951. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  69952. * @returns the cloned material
  69953. */
  69954. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  69955. /**
  69956. * Serializes the materials into a JSON representation.
  69957. * @returns the JSON representation
  69958. */
  69959. serialize(): any;
  69960. /**
  69961. * Dispose the material and release its associated resources
  69962. * @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)
  69963. * @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)
  69964. * @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)
  69965. */
  69966. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  69967. /**
  69968. * Creates a MultiMaterial from parsed MultiMaterial data.
  69969. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  69970. * @param scene defines the hosting scene
  69971. * @returns a new MultiMaterial
  69972. */
  69973. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  69974. }
  69975. }
  69976. declare module BABYLON {
  69977. /**
  69978. * Class used to represent data loading progression
  69979. */
  69980. export class SceneLoaderFlags {
  69981. private static _ForceFullSceneLoadingForIncremental;
  69982. private static _ShowLoadingScreen;
  69983. private static _CleanBoneMatrixWeights;
  69984. private static _loggingLevel;
  69985. /**
  69986. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  69987. */
  69988. static ForceFullSceneLoadingForIncremental: boolean;
  69989. /**
  69990. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  69991. */
  69992. static ShowLoadingScreen: boolean;
  69993. /**
  69994. * Defines the current logging level (while loading the scene)
  69995. * @ignorenaming
  69996. */
  69997. static loggingLevel: number;
  69998. /**
  69999. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  70000. */
  70001. static CleanBoneMatrixWeights: boolean;
  70002. }
  70003. }
  70004. declare module BABYLON {
  70005. /**
  70006. * 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.
  70007. * @see https://doc.babylonjs.com/how_to/transformnode
  70008. */
  70009. export class TransformNode extends Node {
  70010. /**
  70011. * Object will not rotate to face the camera
  70012. */
  70013. static BILLBOARDMODE_NONE: number;
  70014. /**
  70015. * Object will rotate to face the camera but only on the x axis
  70016. */
  70017. static BILLBOARDMODE_X: number;
  70018. /**
  70019. * Object will rotate to face the camera but only on the y axis
  70020. */
  70021. static BILLBOARDMODE_Y: number;
  70022. /**
  70023. * Object will rotate to face the camera but only on the z axis
  70024. */
  70025. static BILLBOARDMODE_Z: number;
  70026. /**
  70027. * Object will rotate to face the camera
  70028. */
  70029. static BILLBOARDMODE_ALL: number;
  70030. private _forward;
  70031. private _forwardInverted;
  70032. private _up;
  70033. private _right;
  70034. private _rightInverted;
  70035. private _position;
  70036. private _rotation;
  70037. private _rotationQuaternion;
  70038. protected _scaling: Vector3;
  70039. protected _isDirty: boolean;
  70040. private _transformToBoneReferal;
  70041. private _billboardMode;
  70042. /**
  70043. * Gets or sets the billboard mode. Default is 0.
  70044. *
  70045. * | Value | Type | Description |
  70046. * | --- | --- | --- |
  70047. * | 0 | BILLBOARDMODE_NONE | |
  70048. * | 1 | BILLBOARDMODE_X | |
  70049. * | 2 | BILLBOARDMODE_Y | |
  70050. * | 4 | BILLBOARDMODE_Z | |
  70051. * | 7 | BILLBOARDMODE_ALL | |
  70052. *
  70053. */
  70054. billboardMode: number;
  70055. private _preserveParentRotationForBillboard;
  70056. /**
  70057. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  70058. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  70059. */
  70060. preserveParentRotationForBillboard: boolean;
  70061. /**
  70062. * 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
  70063. */
  70064. scalingDeterminant: number;
  70065. private _infiniteDistance;
  70066. /**
  70067. * Gets or sets the distance of the object to max, often used by skybox
  70068. */
  70069. infiniteDistance: boolean;
  70070. /**
  70071. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  70072. * By default the system will update normals to compensate
  70073. */
  70074. ignoreNonUniformScaling: boolean;
  70075. /**
  70076. * 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
  70077. */
  70078. reIntegrateRotationIntoRotationQuaternion: boolean;
  70079. /** @hidden */
  70080. _poseMatrix: Nullable<Matrix>;
  70081. /** @hidden */
  70082. _localMatrix: Matrix;
  70083. private _usePivotMatrix;
  70084. private _absolutePosition;
  70085. private _pivotMatrix;
  70086. private _pivotMatrixInverse;
  70087. protected _postMultiplyPivotMatrix: boolean;
  70088. protected _isWorldMatrixFrozen: boolean;
  70089. /** @hidden */
  70090. _indexInSceneTransformNodesArray: number;
  70091. /**
  70092. * An event triggered after the world matrix is updated
  70093. */
  70094. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  70095. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  70096. /**
  70097. * Gets a string identifying the name of the class
  70098. * @returns "TransformNode" string
  70099. */
  70100. getClassName(): string;
  70101. /**
  70102. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  70103. */
  70104. position: Vector3;
  70105. /**
  70106. * 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)).
  70107. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  70108. */
  70109. rotation: Vector3;
  70110. /**
  70111. * 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)).
  70112. */
  70113. scaling: Vector3;
  70114. /**
  70115. * 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).
  70116. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  70117. */
  70118. rotationQuaternion: Nullable<Quaternion>;
  70119. /**
  70120. * The forward direction of that transform in world space.
  70121. */
  70122. readonly forward: Vector3;
  70123. /**
  70124. * The up direction of that transform in world space.
  70125. */
  70126. readonly up: Vector3;
  70127. /**
  70128. * The right direction of that transform in world space.
  70129. */
  70130. readonly right: Vector3;
  70131. /**
  70132. * Copies the parameter passed Matrix into the mesh Pose matrix.
  70133. * @param matrix the matrix to copy the pose from
  70134. * @returns this TransformNode.
  70135. */
  70136. updatePoseMatrix(matrix: Matrix): TransformNode;
  70137. /**
  70138. * Returns the mesh Pose matrix.
  70139. * @returns the pose matrix
  70140. */
  70141. getPoseMatrix(): Matrix;
  70142. /** @hidden */
  70143. _isSynchronized(): boolean;
  70144. /** @hidden */
  70145. _initCache(): void;
  70146. /**
  70147. * Flag the transform node as dirty (Forcing it to update everything)
  70148. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  70149. * @returns this transform node
  70150. */
  70151. markAsDirty(property: string): TransformNode;
  70152. /**
  70153. * Returns the current mesh absolute position.
  70154. * Returns a Vector3.
  70155. */
  70156. readonly absolutePosition: Vector3;
  70157. /**
  70158. * Sets a new matrix to apply before all other transformation
  70159. * @param matrix defines the transform matrix
  70160. * @returns the current TransformNode
  70161. */
  70162. setPreTransformMatrix(matrix: Matrix): TransformNode;
  70163. /**
  70164. * Sets a new pivot matrix to the current node
  70165. * @param matrix defines the new pivot matrix to use
  70166. * @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
  70167. * @returns the current TransformNode
  70168. */
  70169. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  70170. /**
  70171. * Returns the mesh pivot matrix.
  70172. * Default : Identity.
  70173. * @returns the matrix
  70174. */
  70175. getPivotMatrix(): Matrix;
  70176. /**
  70177. * Prevents the World matrix to be computed any longer.
  70178. * @returns the TransformNode.
  70179. */
  70180. freezeWorldMatrix(): TransformNode;
  70181. /**
  70182. * Allows back the World matrix computation.
  70183. * @returns the TransformNode.
  70184. */
  70185. unfreezeWorldMatrix(): this;
  70186. /**
  70187. * True if the World matrix has been frozen.
  70188. */
  70189. readonly isWorldMatrixFrozen: boolean;
  70190. /**
  70191. * Retuns the mesh absolute position in the World.
  70192. * @returns a Vector3.
  70193. */
  70194. getAbsolutePosition(): Vector3;
  70195. /**
  70196. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  70197. * @param absolutePosition the absolute position to set
  70198. * @returns the TransformNode.
  70199. */
  70200. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  70201. /**
  70202. * Sets the mesh position in its local space.
  70203. * @param vector3 the position to set in localspace
  70204. * @returns the TransformNode.
  70205. */
  70206. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  70207. /**
  70208. * Returns the mesh position in the local space from the current World matrix values.
  70209. * @returns a new Vector3.
  70210. */
  70211. getPositionExpressedInLocalSpace(): Vector3;
  70212. /**
  70213. * Translates the mesh along the passed Vector3 in its local space.
  70214. * @param vector3 the distance to translate in localspace
  70215. * @returns the TransformNode.
  70216. */
  70217. locallyTranslate(vector3: Vector3): TransformNode;
  70218. private static _lookAtVectorCache;
  70219. /**
  70220. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  70221. * @param targetPoint the position (must be in same space as current mesh) to look at
  70222. * @param yawCor optional yaw (y-axis) correction in radians
  70223. * @param pitchCor optional pitch (x-axis) correction in radians
  70224. * @param rollCor optional roll (z-axis) correction in radians
  70225. * @param space the choosen space of the target
  70226. * @returns the TransformNode.
  70227. */
  70228. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  70229. /**
  70230. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  70231. * This Vector3 is expressed in the World space.
  70232. * @param localAxis axis to rotate
  70233. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  70234. */
  70235. getDirection(localAxis: Vector3): Vector3;
  70236. /**
  70237. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  70238. * localAxis is expressed in the mesh local space.
  70239. * result is computed in the Wordl space from the mesh World matrix.
  70240. * @param localAxis axis to rotate
  70241. * @param result the resulting transformnode
  70242. * @returns this TransformNode.
  70243. */
  70244. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  70245. /**
  70246. * Sets this transform node rotation to the given local axis.
  70247. * @param localAxis the axis in local space
  70248. * @param yawCor optional yaw (y-axis) correction in radians
  70249. * @param pitchCor optional pitch (x-axis) correction in radians
  70250. * @param rollCor optional roll (z-axis) correction in radians
  70251. * @returns this TransformNode
  70252. */
  70253. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  70254. /**
  70255. * Sets a new pivot point to the current node
  70256. * @param point defines the new pivot point to use
  70257. * @param space defines if the point is in world or local space (local by default)
  70258. * @returns the current TransformNode
  70259. */
  70260. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  70261. /**
  70262. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  70263. * @returns the pivot point
  70264. */
  70265. getPivotPoint(): Vector3;
  70266. /**
  70267. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  70268. * @param result the vector3 to store the result
  70269. * @returns this TransformNode.
  70270. */
  70271. getPivotPointToRef(result: Vector3): TransformNode;
  70272. /**
  70273. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  70274. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  70275. */
  70276. getAbsolutePivotPoint(): Vector3;
  70277. /**
  70278. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  70279. * @param result vector3 to store the result
  70280. * @returns this TransformNode.
  70281. */
  70282. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  70283. /**
  70284. * Defines the passed node as the parent of the current node.
  70285. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  70286. * @see https://doc.babylonjs.com/how_to/parenting
  70287. * @param node the node ot set as the parent
  70288. * @returns this TransformNode.
  70289. */
  70290. setParent(node: Nullable<Node>): TransformNode;
  70291. private _nonUniformScaling;
  70292. /**
  70293. * True if the scaling property of this object is non uniform eg. (1,2,1)
  70294. */
  70295. readonly nonUniformScaling: boolean;
  70296. /** @hidden */
  70297. _updateNonUniformScalingState(value: boolean): boolean;
  70298. /**
  70299. * Attach the current TransformNode to another TransformNode associated with a bone
  70300. * @param bone Bone affecting the TransformNode
  70301. * @param affectedTransformNode TransformNode associated with the bone
  70302. * @returns this object
  70303. */
  70304. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  70305. /**
  70306. * Detach the transform node if its associated with a bone
  70307. * @returns this object
  70308. */
  70309. detachFromBone(): TransformNode;
  70310. private static _rotationAxisCache;
  70311. /**
  70312. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  70313. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  70314. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  70315. * The passed axis is also normalized.
  70316. * @param axis the axis to rotate around
  70317. * @param amount the amount to rotate in radians
  70318. * @param space Space to rotate in (Default: local)
  70319. * @returns the TransformNode.
  70320. */
  70321. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  70322. /**
  70323. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  70324. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  70325. * The passed axis is also normalized. .
  70326. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  70327. * @param point the point to rotate around
  70328. * @param axis the axis to rotate around
  70329. * @param amount the amount to rotate in radians
  70330. * @returns the TransformNode
  70331. */
  70332. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  70333. /**
  70334. * Translates the mesh along the axis vector for the passed distance in the given space.
  70335. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  70336. * @param axis the axis to translate in
  70337. * @param distance the distance to translate
  70338. * @param space Space to rotate in (Default: local)
  70339. * @returns the TransformNode.
  70340. */
  70341. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  70342. /**
  70343. * Adds a rotation step to the mesh current rotation.
  70344. * x, y, z are Euler angles expressed in radians.
  70345. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  70346. * This means this rotation is made in the mesh local space only.
  70347. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  70348. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  70349. * ```javascript
  70350. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  70351. * ```
  70352. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  70353. * 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.
  70354. * @param x Rotation to add
  70355. * @param y Rotation to add
  70356. * @param z Rotation to add
  70357. * @returns the TransformNode.
  70358. */
  70359. addRotation(x: number, y: number, z: number): TransformNode;
  70360. /**
  70361. * @hidden
  70362. */
  70363. protected _getEffectiveParent(): Nullable<Node>;
  70364. /**
  70365. * Computes the world matrix of the node
  70366. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  70367. * @returns the world matrix
  70368. */
  70369. computeWorldMatrix(force?: boolean): Matrix;
  70370. protected _afterComputeWorldMatrix(): void;
  70371. /**
  70372. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  70373. * @param func callback function to add
  70374. *
  70375. * @returns the TransformNode.
  70376. */
  70377. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  70378. /**
  70379. * Removes a registered callback function.
  70380. * @param func callback function to remove
  70381. * @returns the TransformNode.
  70382. */
  70383. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  70384. /**
  70385. * Gets the position of the current mesh in camera space
  70386. * @param camera defines the camera to use
  70387. * @returns a position
  70388. */
  70389. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  70390. /**
  70391. * Returns the distance from the mesh to the active camera
  70392. * @param camera defines the camera to use
  70393. * @returns the distance
  70394. */
  70395. getDistanceToCamera(camera?: Nullable<Camera>): number;
  70396. /**
  70397. * Clone the current transform node
  70398. * @param name Name of the new clone
  70399. * @param newParent New parent for the clone
  70400. * @param doNotCloneChildren Do not clone children hierarchy
  70401. * @returns the new transform node
  70402. */
  70403. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  70404. /**
  70405. * Serializes the objects information.
  70406. * @param currentSerializationObject defines the object to serialize in
  70407. * @returns the serialized object
  70408. */
  70409. serialize(currentSerializationObject?: any): any;
  70410. /**
  70411. * Returns a new TransformNode object parsed from the source provided.
  70412. * @param parsedTransformNode is the source.
  70413. * @param scene the scne the object belongs to
  70414. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  70415. * @returns a new TransformNode object parsed from the source provided.
  70416. */
  70417. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  70418. /**
  70419. * Get all child-transformNodes of this node
  70420. * @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
  70421. * @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
  70422. * @returns an array of TransformNode
  70423. */
  70424. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  70425. /**
  70426. * Releases resources associated with this transform node.
  70427. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  70428. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  70429. */
  70430. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  70431. }
  70432. }
  70433. declare module BABYLON {
  70434. /**
  70435. * Class used to override all child animations of a given target
  70436. */
  70437. export class AnimationPropertiesOverride {
  70438. /**
  70439. * Gets or sets a value indicating if animation blending must be used
  70440. */
  70441. enableBlending: boolean;
  70442. /**
  70443. * Gets or sets the blending speed to use when enableBlending is true
  70444. */
  70445. blendingSpeed: number;
  70446. /**
  70447. * Gets or sets the default loop mode to use
  70448. */
  70449. loopMode: number;
  70450. }
  70451. }
  70452. declare module BABYLON {
  70453. /**
  70454. * Class used to store bone information
  70455. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  70456. */
  70457. export class Bone extends Node {
  70458. /**
  70459. * defines the bone name
  70460. */
  70461. name: string;
  70462. private static _tmpVecs;
  70463. private static _tmpQuat;
  70464. private static _tmpMats;
  70465. /**
  70466. * Gets the list of child bones
  70467. */
  70468. children: Bone[];
  70469. /** Gets the animations associated with this bone */
  70470. animations: Animation[];
  70471. /**
  70472. * Gets or sets bone length
  70473. */
  70474. length: number;
  70475. /**
  70476. * @hidden Internal only
  70477. * Set this value to map this bone to a different index in the transform matrices
  70478. * Set this value to -1 to exclude the bone from the transform matrices
  70479. */
  70480. _index: Nullable<number>;
  70481. private _skeleton;
  70482. private _localMatrix;
  70483. private _restPose;
  70484. private _baseMatrix;
  70485. private _absoluteTransform;
  70486. private _invertedAbsoluteTransform;
  70487. private _parent;
  70488. private _scalingDeterminant;
  70489. private _worldTransform;
  70490. private _localScaling;
  70491. private _localRotation;
  70492. private _localPosition;
  70493. private _needToDecompose;
  70494. private _needToCompose;
  70495. /** @hidden */
  70496. _linkedTransformNode: Nullable<TransformNode>;
  70497. /** @hidden */
  70498. _waitingTransformNodeId: Nullable<string>;
  70499. /** @hidden */
  70500. /** @hidden */
  70501. _matrix: Matrix;
  70502. /**
  70503. * Create a new bone
  70504. * @param name defines the bone name
  70505. * @param skeleton defines the parent skeleton
  70506. * @param parentBone defines the parent (can be null if the bone is the root)
  70507. * @param localMatrix defines the local matrix
  70508. * @param restPose defines the rest pose matrix
  70509. * @param baseMatrix defines the base matrix
  70510. * @param index defines index of the bone in the hiearchy
  70511. */
  70512. constructor(
  70513. /**
  70514. * defines the bone name
  70515. */
  70516. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  70517. /**
  70518. * Gets the current object class name.
  70519. * @return the class name
  70520. */
  70521. getClassName(): string;
  70522. /**
  70523. * Gets the parent skeleton
  70524. * @returns a skeleton
  70525. */
  70526. getSkeleton(): Skeleton;
  70527. /**
  70528. * Gets parent bone
  70529. * @returns a bone or null if the bone is the root of the bone hierarchy
  70530. */
  70531. getParent(): Nullable<Bone>;
  70532. /**
  70533. * Returns an array containing the root bones
  70534. * @returns an array containing the root bones
  70535. */
  70536. getChildren(): Array<Bone>;
  70537. /**
  70538. * Sets the parent bone
  70539. * @param parent defines the parent (can be null if the bone is the root)
  70540. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  70541. */
  70542. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  70543. /**
  70544. * Gets the local matrix
  70545. * @returns a matrix
  70546. */
  70547. getLocalMatrix(): Matrix;
  70548. /**
  70549. * Gets the base matrix (initial matrix which remains unchanged)
  70550. * @returns a matrix
  70551. */
  70552. getBaseMatrix(): Matrix;
  70553. /**
  70554. * Gets the rest pose matrix
  70555. * @returns a matrix
  70556. */
  70557. getRestPose(): Matrix;
  70558. /**
  70559. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  70560. */
  70561. getWorldMatrix(): Matrix;
  70562. /**
  70563. * Sets the local matrix to rest pose matrix
  70564. */
  70565. returnToRest(): void;
  70566. /**
  70567. * Gets the inverse of the absolute transform matrix.
  70568. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  70569. * @returns a matrix
  70570. */
  70571. getInvertedAbsoluteTransform(): Matrix;
  70572. /**
  70573. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  70574. * @returns a matrix
  70575. */
  70576. getAbsoluteTransform(): Matrix;
  70577. /**
  70578. * Links with the given transform node.
  70579. * The local matrix of this bone is copied from the transform node every frame.
  70580. * @param transformNode defines the transform node to link to
  70581. */
  70582. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  70583. /** Gets or sets current position (in local space) */
  70584. position: Vector3;
  70585. /** Gets or sets current rotation (in local space) */
  70586. rotation: Vector3;
  70587. /** Gets or sets current rotation quaternion (in local space) */
  70588. rotationQuaternion: Quaternion;
  70589. /** Gets or sets current scaling (in local space) */
  70590. scaling: Vector3;
  70591. /**
  70592. * Gets the animation properties override
  70593. */
  70594. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  70595. private _decompose;
  70596. private _compose;
  70597. /**
  70598. * Update the base and local matrices
  70599. * @param matrix defines the new base or local matrix
  70600. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  70601. * @param updateLocalMatrix defines if the local matrix should be updated
  70602. */
  70603. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  70604. /** @hidden */
  70605. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  70606. /**
  70607. * Flag the bone as dirty (Forcing it to update everything)
  70608. */
  70609. markAsDirty(): void;
  70610. /** @hidden */
  70611. _markAsDirtyAndCompose(): void;
  70612. private _markAsDirtyAndDecompose;
  70613. /**
  70614. * Translate the bone in local or world space
  70615. * @param vec The amount to translate the bone
  70616. * @param space The space that the translation is in
  70617. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70618. */
  70619. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  70620. /**
  70621. * Set the postion of the bone in local or world space
  70622. * @param position The position to set the bone
  70623. * @param space The space that the position is in
  70624. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70625. */
  70626. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  70627. /**
  70628. * Set the absolute position of the bone (world space)
  70629. * @param position The position to set the bone
  70630. * @param mesh The mesh that this bone is attached to
  70631. */
  70632. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  70633. /**
  70634. * Scale the bone on the x, y and z axes (in local space)
  70635. * @param x The amount to scale the bone on the x axis
  70636. * @param y The amount to scale the bone on the y axis
  70637. * @param z The amount to scale the bone on the z axis
  70638. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  70639. */
  70640. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  70641. /**
  70642. * Set the bone scaling in local space
  70643. * @param scale defines the scaling vector
  70644. */
  70645. setScale(scale: Vector3): void;
  70646. /**
  70647. * Gets the current scaling in local space
  70648. * @returns the current scaling vector
  70649. */
  70650. getScale(): Vector3;
  70651. /**
  70652. * Gets the current scaling in local space and stores it in a target vector
  70653. * @param result defines the target vector
  70654. */
  70655. getScaleToRef(result: Vector3): void;
  70656. /**
  70657. * Set the yaw, pitch, and roll of the bone in local or world space
  70658. * @param yaw The rotation of the bone on the y axis
  70659. * @param pitch The rotation of the bone on the x axis
  70660. * @param roll The rotation of the bone on the z axis
  70661. * @param space The space that the axes of rotation are in
  70662. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70663. */
  70664. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  70665. /**
  70666. * Add a rotation to the bone on an axis in local or world space
  70667. * @param axis The axis to rotate the bone on
  70668. * @param amount The amount to rotate the bone
  70669. * @param space The space that the axis is in
  70670. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70671. */
  70672. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  70673. /**
  70674. * Set the rotation of the bone to a particular axis angle in local or world space
  70675. * @param axis The axis to rotate the bone on
  70676. * @param angle The angle that the bone should be rotated to
  70677. * @param space The space that the axis is in
  70678. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70679. */
  70680. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  70681. /**
  70682. * Set the euler rotation of the bone in local of world space
  70683. * @param rotation The euler rotation that the bone should be set to
  70684. * @param space The space that the rotation is in
  70685. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70686. */
  70687. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  70688. /**
  70689. * Set the quaternion rotation of the bone in local of world space
  70690. * @param quat The quaternion rotation that the bone should be set to
  70691. * @param space The space that the rotation is in
  70692. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70693. */
  70694. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  70695. /**
  70696. * Set the rotation matrix of the bone in local of world space
  70697. * @param rotMat The rotation matrix that the bone should be set to
  70698. * @param space The space that the rotation is in
  70699. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70700. */
  70701. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  70702. private _rotateWithMatrix;
  70703. private _getNegativeRotationToRef;
  70704. /**
  70705. * Get the position of the bone in local or world space
  70706. * @param space The space that the returned position is in
  70707. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70708. * @returns The position of the bone
  70709. */
  70710. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  70711. /**
  70712. * Copy the position of the bone to a vector3 in local or world space
  70713. * @param space The space that the returned position is in
  70714. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70715. * @param result The vector3 to copy the position to
  70716. */
  70717. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  70718. /**
  70719. * Get the absolute position of the bone (world space)
  70720. * @param mesh The mesh that this bone is attached to
  70721. * @returns The absolute position of the bone
  70722. */
  70723. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  70724. /**
  70725. * Copy the absolute position of the bone (world space) to the result param
  70726. * @param mesh The mesh that this bone is attached to
  70727. * @param result The vector3 to copy the absolute position to
  70728. */
  70729. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  70730. /**
  70731. * Compute the absolute transforms of this bone and its children
  70732. */
  70733. computeAbsoluteTransforms(): void;
  70734. /**
  70735. * Get the world direction from an axis that is in the local space of the bone
  70736. * @param localAxis The local direction that is used to compute the world direction
  70737. * @param mesh The mesh that this bone is attached to
  70738. * @returns The world direction
  70739. */
  70740. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  70741. /**
  70742. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  70743. * @param localAxis The local direction that is used to compute the world direction
  70744. * @param mesh The mesh that this bone is attached to
  70745. * @param result The vector3 that the world direction will be copied to
  70746. */
  70747. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  70748. /**
  70749. * Get the euler rotation of the bone in local or world space
  70750. * @param space The space that the rotation should be in
  70751. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70752. * @returns The euler rotation
  70753. */
  70754. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  70755. /**
  70756. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  70757. * @param space The space that the rotation should be in
  70758. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70759. * @param result The vector3 that the rotation should be copied to
  70760. */
  70761. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  70762. /**
  70763. * Get the quaternion rotation of the bone in either local or world space
  70764. * @param space The space that the rotation should be in
  70765. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70766. * @returns The quaternion rotation
  70767. */
  70768. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  70769. /**
  70770. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  70771. * @param space The space that the rotation should be in
  70772. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70773. * @param result The quaternion that the rotation should be copied to
  70774. */
  70775. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  70776. /**
  70777. * Get the rotation matrix of the bone in local or world space
  70778. * @param space The space that the rotation should be in
  70779. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70780. * @returns The rotation matrix
  70781. */
  70782. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  70783. /**
  70784. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  70785. * @param space The space that the rotation should be in
  70786. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70787. * @param result The quaternion that the rotation should be copied to
  70788. */
  70789. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  70790. /**
  70791. * Get the world position of a point that is in the local space of the bone
  70792. * @param position The local position
  70793. * @param mesh The mesh that this bone is attached to
  70794. * @returns The world position
  70795. */
  70796. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  70797. /**
  70798. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  70799. * @param position The local position
  70800. * @param mesh The mesh that this bone is attached to
  70801. * @param result The vector3 that the world position should be copied to
  70802. */
  70803. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  70804. /**
  70805. * Get the local position of a point that is in world space
  70806. * @param position The world position
  70807. * @param mesh The mesh that this bone is attached to
  70808. * @returns The local position
  70809. */
  70810. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  70811. /**
  70812. * Get the local position of a point that is in world space and copy it to the result param
  70813. * @param position The world position
  70814. * @param mesh The mesh that this bone is attached to
  70815. * @param result The vector3 that the local position should be copied to
  70816. */
  70817. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  70818. }
  70819. }
  70820. declare module BABYLON {
  70821. /**
  70822. * Enum that determines the text-wrapping mode to use.
  70823. */
  70824. export enum InspectableType {
  70825. /**
  70826. * Checkbox for booleans
  70827. */
  70828. Checkbox = 0,
  70829. /**
  70830. * Sliders for numbers
  70831. */
  70832. Slider = 1,
  70833. /**
  70834. * Vector3
  70835. */
  70836. Vector3 = 2,
  70837. /**
  70838. * Quaternions
  70839. */
  70840. Quaternion = 3,
  70841. /**
  70842. * Color3
  70843. */
  70844. Color3 = 4
  70845. }
  70846. /**
  70847. * Interface used to define custom inspectable properties.
  70848. * This interface is used by the inspector to display custom property grids
  70849. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70850. */
  70851. export interface IInspectable {
  70852. /**
  70853. * Gets the label to display
  70854. */
  70855. label: string;
  70856. /**
  70857. * Gets the name of the property to edit
  70858. */
  70859. propertyName: string;
  70860. /**
  70861. * Gets the type of the editor to use
  70862. */
  70863. type: InspectableType;
  70864. /**
  70865. * Gets the minimum value of the property when using in "slider" mode
  70866. */
  70867. min?: number;
  70868. /**
  70869. * Gets the maximum value of the property when using in "slider" mode
  70870. */
  70871. max?: number;
  70872. /**
  70873. * Gets the setp to use when using in "slider" mode
  70874. */
  70875. step?: number;
  70876. }
  70877. }
  70878. declare module BABYLON {
  70879. /**
  70880. * This represents the required contract to create a new type of texture loader.
  70881. */
  70882. export interface IInternalTextureLoader {
  70883. /**
  70884. * Defines wether the loader supports cascade loading the different faces.
  70885. */
  70886. supportCascades: boolean;
  70887. /**
  70888. * This returns if the loader support the current file information.
  70889. * @param extension defines the file extension of the file being loaded
  70890. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70891. * @param fallback defines the fallback internal texture if any
  70892. * @param isBase64 defines whether the texture is encoded as a base64
  70893. * @param isBuffer defines whether the texture data are stored as a buffer
  70894. * @returns true if the loader can load the specified file
  70895. */
  70896. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  70897. /**
  70898. * Transform the url before loading if required.
  70899. * @param rootUrl the url of the texture
  70900. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70901. * @returns the transformed texture
  70902. */
  70903. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  70904. /**
  70905. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  70906. * @param rootUrl the url of the texture
  70907. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70908. * @returns the fallback texture
  70909. */
  70910. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  70911. /**
  70912. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  70913. * @param data contains the texture data
  70914. * @param texture defines the BabylonJS internal texture
  70915. * @param createPolynomials will be true if polynomials have been requested
  70916. * @param onLoad defines the callback to trigger once the texture is ready
  70917. * @param onError defines the callback to trigger in case of error
  70918. */
  70919. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  70920. /**
  70921. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  70922. * @param data contains the texture data
  70923. * @param texture defines the BabylonJS internal texture
  70924. * @param callback defines the method to call once ready to upload
  70925. */
  70926. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  70927. }
  70928. }
  70929. declare module BABYLON {
  70930. interface Engine {
  70931. /**
  70932. * Creates a depth stencil cube texture.
  70933. * This is only available in WebGL 2.
  70934. * @param size The size of face edge in the cube texture.
  70935. * @param options The options defining the cube texture.
  70936. * @returns The cube texture
  70937. */
  70938. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  70939. /**
  70940. * Creates a cube texture
  70941. * @param rootUrl defines the url where the files to load is located
  70942. * @param scene defines the current scene
  70943. * @param files defines the list of files to load (1 per face)
  70944. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70945. * @param onLoad defines an optional callback raised when the texture is loaded
  70946. * @param onError defines an optional callback raised if there is an issue to load the texture
  70947. * @param format defines the format of the data
  70948. * @param forcedExtension defines the extension to use to pick the right loader
  70949. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  70950. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70951. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70952. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  70953. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  70954. * @returns the cube texture as an InternalTexture
  70955. */
  70956. 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;
  70957. /**
  70958. * Creates a cube texture
  70959. * @param rootUrl defines the url where the files to load is located
  70960. * @param scene defines the current scene
  70961. * @param files defines the list of files to load (1 per face)
  70962. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70963. * @param onLoad defines an optional callback raised when the texture is loaded
  70964. * @param onError defines an optional callback raised if there is an issue to load the texture
  70965. * @param format defines the format of the data
  70966. * @param forcedExtension defines the extension to use to pick the right loader
  70967. * @returns the cube texture as an InternalTexture
  70968. */
  70969. 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;
  70970. /**
  70971. * Creates a cube texture
  70972. * @param rootUrl defines the url where the files to load is located
  70973. * @param scene defines the current scene
  70974. * @param files defines the list of files to load (1 per face)
  70975. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70976. * @param onLoad defines an optional callback raised when the texture is loaded
  70977. * @param onError defines an optional callback raised if there is an issue to load the texture
  70978. * @param format defines the format of the data
  70979. * @param forcedExtension defines the extension to use to pick the right loader
  70980. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  70981. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70982. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70983. * @returns the cube texture as an InternalTexture
  70984. */
  70985. 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;
  70986. /** @hidden */
  70987. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  70988. /** @hidden */
  70989. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  70990. /** @hidden */
  70991. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  70992. /** @hidden */
  70993. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  70994. }
  70995. }
  70996. declare module BABYLON {
  70997. /**
  70998. * Class for creating a cube texture
  70999. */
  71000. export class CubeTexture extends BaseTexture {
  71001. private _delayedOnLoad;
  71002. /**
  71003. * The url of the texture
  71004. */
  71005. url: string;
  71006. /**
  71007. * Gets or sets the center of the bounding box associated with the cube texture.
  71008. * It must define where the camera used to render the texture was set
  71009. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  71010. */
  71011. boundingBoxPosition: Vector3;
  71012. private _boundingBoxSize;
  71013. /**
  71014. * Gets or sets the size of the bounding box associated with the cube texture
  71015. * When defined, the cubemap will switch to local mode
  71016. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  71017. * @example https://www.babylonjs-playground.com/#RNASML
  71018. */
  71019. /**
  71020. * Returns the bounding box size
  71021. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  71022. */
  71023. boundingBoxSize: Vector3;
  71024. protected _rotationY: number;
  71025. /**
  71026. * Sets texture matrix rotation angle around Y axis in radians.
  71027. */
  71028. /**
  71029. * Gets texture matrix rotation angle around Y axis radians.
  71030. */
  71031. rotationY: number;
  71032. /**
  71033. * Are mip maps generated for this texture or not.
  71034. */
  71035. readonly noMipmap: boolean;
  71036. private _noMipmap;
  71037. private _files;
  71038. private _extensions;
  71039. private _textureMatrix;
  71040. private _format;
  71041. private _createPolynomials;
  71042. /** @hidden */
  71043. _prefiltered: boolean;
  71044. /**
  71045. * Creates a cube texture from an array of image urls
  71046. * @param files defines an array of image urls
  71047. * @param scene defines the hosting scene
  71048. * @param noMipmap specifies if mip maps are not used
  71049. * @returns a cube texture
  71050. */
  71051. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  71052. /**
  71053. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  71054. * @param url defines the url of the prefiltered texture
  71055. * @param scene defines the scene the texture is attached to
  71056. * @param forcedExtension defines the extension of the file if different from the url
  71057. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  71058. * @return the prefiltered texture
  71059. */
  71060. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  71061. /**
  71062. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  71063. * as prefiltered data.
  71064. * @param rootUrl defines the url of the texture or the root name of the six images
  71065. * @param scene defines the scene the texture is attached to
  71066. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  71067. * @param noMipmap defines if mipmaps should be created or not
  71068. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  71069. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  71070. * @param onError defines a callback triggered in case of error during load
  71071. * @param format defines the internal format to use for the texture once loaded
  71072. * @param prefiltered defines whether or not the texture is created from prefiltered data
  71073. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  71074. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  71075. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  71076. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  71077. * @return the cube texture
  71078. */
  71079. 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);
  71080. /**
  71081. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  71082. */
  71083. readonly isPrefiltered: boolean;
  71084. /**
  71085. * Get the current class name of the texture useful for serialization or dynamic coding.
  71086. * @returns "CubeTexture"
  71087. */
  71088. getClassName(): string;
  71089. /**
  71090. * Update the url (and optional buffer) of this texture if url was null during construction.
  71091. * @param url the url of the texture
  71092. * @param forcedExtension defines the extension to use
  71093. * @param onLoad callback called when the texture is loaded (defaults to null)
  71094. */
  71095. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  71096. /**
  71097. * Delays loading of the cube texture
  71098. * @param forcedExtension defines the extension to use
  71099. */
  71100. delayLoad(forcedExtension?: string): void;
  71101. /**
  71102. * Returns the reflection texture matrix
  71103. * @returns the reflection texture matrix
  71104. */
  71105. getReflectionTextureMatrix(): Matrix;
  71106. /**
  71107. * Sets the reflection texture matrix
  71108. * @param value Reflection texture matrix
  71109. */
  71110. setReflectionTextureMatrix(value: Matrix): void;
  71111. /**
  71112. * Parses text to create a cube texture
  71113. * @param parsedTexture define the serialized text to read from
  71114. * @param scene defines the hosting scene
  71115. * @param rootUrl defines the root url of the cube texture
  71116. * @returns a cube texture
  71117. */
  71118. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  71119. /**
  71120. * Makes a clone, or deep copy, of the cube texture
  71121. * @returns a new cube texture
  71122. */
  71123. clone(): CubeTexture;
  71124. }
  71125. }
  71126. declare module BABYLON {
  71127. /** @hidden */
  71128. export var postprocessVertexShader: {
  71129. name: string;
  71130. shader: string;
  71131. };
  71132. }
  71133. declare module BABYLON {
  71134. /**
  71135. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  71136. * This is the base of the follow, arc rotate cameras and Free camera
  71137. * @see http://doc.babylonjs.com/features/cameras
  71138. */
  71139. export class TargetCamera extends Camera {
  71140. private static _RigCamTransformMatrix;
  71141. private static _TargetTransformMatrix;
  71142. private static _TargetFocalPoint;
  71143. /**
  71144. * Define the current direction the camera is moving to
  71145. */
  71146. cameraDirection: Vector3;
  71147. /**
  71148. * Define the current rotation the camera is rotating to
  71149. */
  71150. cameraRotation: Vector2;
  71151. /**
  71152. * When set, the up vector of the camera will be updated by the rotation of the camera
  71153. */
  71154. updateUpVectorFromRotation: boolean;
  71155. private _tmpQuaternion;
  71156. /**
  71157. * Define the current rotation of the camera
  71158. */
  71159. rotation: Vector3;
  71160. /**
  71161. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  71162. */
  71163. rotationQuaternion: Quaternion;
  71164. /**
  71165. * Define the current speed of the camera
  71166. */
  71167. speed: number;
  71168. /**
  71169. * Add cconstraint to the camera to prevent it to move freely in all directions and
  71170. * around all axis.
  71171. */
  71172. noRotationConstraint: boolean;
  71173. /**
  71174. * Define the current target of the camera as an object or a position.
  71175. */
  71176. lockedTarget: any;
  71177. /** @hidden */
  71178. _currentTarget: Vector3;
  71179. /** @hidden */
  71180. _initialFocalDistance: number;
  71181. /** @hidden */
  71182. _viewMatrix: Matrix;
  71183. /** @hidden */
  71184. _camMatrix: Matrix;
  71185. /** @hidden */
  71186. _cameraTransformMatrix: Matrix;
  71187. /** @hidden */
  71188. _cameraRotationMatrix: Matrix;
  71189. /** @hidden */
  71190. _referencePoint: Vector3;
  71191. /** @hidden */
  71192. _transformedReferencePoint: Vector3;
  71193. protected _globalCurrentTarget: Vector3;
  71194. protected _globalCurrentUpVector: Vector3;
  71195. /** @hidden */
  71196. _reset: () => void;
  71197. private _defaultUp;
  71198. /**
  71199. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  71200. * This is the base of the follow, arc rotate cameras and Free camera
  71201. * @see http://doc.babylonjs.com/features/cameras
  71202. * @param name Defines the name of the camera in the scene
  71203. * @param position Defines the start position of the camera in the scene
  71204. * @param scene Defines the scene the camera belongs to
  71205. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  71206. */
  71207. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  71208. /**
  71209. * Gets the position in front of the camera at a given distance.
  71210. * @param distance The distance from the camera we want the position to be
  71211. * @returns the position
  71212. */
  71213. getFrontPosition(distance: number): Vector3;
  71214. /** @hidden */
  71215. _getLockedTargetPosition(): Nullable<Vector3>;
  71216. private _storedPosition;
  71217. private _storedRotation;
  71218. private _storedRotationQuaternion;
  71219. /**
  71220. * Store current camera state of the camera (fov, position, rotation, etc..)
  71221. * @returns the camera
  71222. */
  71223. storeState(): Camera;
  71224. /**
  71225. * Restored camera state. You must call storeState() first
  71226. * @returns whether it was successful or not
  71227. * @hidden
  71228. */
  71229. _restoreStateValues(): boolean;
  71230. /** @hidden */
  71231. _initCache(): void;
  71232. /** @hidden */
  71233. _updateCache(ignoreParentClass?: boolean): void;
  71234. /** @hidden */
  71235. _isSynchronizedViewMatrix(): boolean;
  71236. /** @hidden */
  71237. _computeLocalCameraSpeed(): number;
  71238. /**
  71239. * Defines the target the camera should look at.
  71240. * This will automatically adapt alpha beta and radius to fit within the new target.
  71241. * @param target Defines the new target as a Vector or a mesh
  71242. */
  71243. setTarget(target: Vector3): void;
  71244. /**
  71245. * Return the current target position of the camera. This value is expressed in local space.
  71246. * @returns the target position
  71247. */
  71248. getTarget(): Vector3;
  71249. /** @hidden */
  71250. _decideIfNeedsToMove(): boolean;
  71251. /** @hidden */
  71252. _updatePosition(): void;
  71253. /** @hidden */
  71254. _checkInputs(): void;
  71255. protected _updateCameraRotationMatrix(): void;
  71256. /**
  71257. * 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)
  71258. * @returns the current camera
  71259. */
  71260. private _rotateUpVectorWithCameraRotationMatrix;
  71261. private _cachedRotationZ;
  71262. private _cachedQuaternionRotationZ;
  71263. /** @hidden */
  71264. _getViewMatrix(): Matrix;
  71265. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  71266. /**
  71267. * @hidden
  71268. */
  71269. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  71270. /**
  71271. * @hidden
  71272. */
  71273. _updateRigCameras(): void;
  71274. private _getRigCamPositionAndTarget;
  71275. /**
  71276. * Gets the current object class name.
  71277. * @return the class name
  71278. */
  71279. getClassName(): string;
  71280. }
  71281. }
  71282. declare module BABYLON {
  71283. /**
  71284. * @ignore
  71285. * This is a list of all the different input types that are available in the application.
  71286. * Fo instance: ArcRotateCameraGamepadInput...
  71287. */
  71288. export var CameraInputTypes: {};
  71289. /**
  71290. * This is the contract to implement in order to create a new input class.
  71291. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  71292. */
  71293. export interface ICameraInput<TCamera extends Camera> {
  71294. /**
  71295. * Defines the camera the input is attached to.
  71296. */
  71297. camera: Nullable<TCamera>;
  71298. /**
  71299. * Gets the class name of the current intput.
  71300. * @returns the class name
  71301. */
  71302. getClassName(): string;
  71303. /**
  71304. * Get the friendly name associated with the input class.
  71305. * @returns the input friendly name
  71306. */
  71307. getSimpleName(): string;
  71308. /**
  71309. * Attach the input controls to a specific dom element to get the input from.
  71310. * @param element Defines the element the controls should be listened from
  71311. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71312. */
  71313. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71314. /**
  71315. * Detach the current controls from the specified dom element.
  71316. * @param element Defines the element to stop listening the inputs from
  71317. */
  71318. detachControl(element: Nullable<HTMLElement>): void;
  71319. /**
  71320. * Update the current camera state depending on the inputs that have been used this frame.
  71321. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71322. */
  71323. checkInputs?: () => void;
  71324. }
  71325. /**
  71326. * Represents a map of input types to input instance or input index to input instance.
  71327. */
  71328. export interface CameraInputsMap<TCamera extends Camera> {
  71329. /**
  71330. * Accessor to the input by input type.
  71331. */
  71332. [name: string]: ICameraInput<TCamera>;
  71333. /**
  71334. * Accessor to the input by input index.
  71335. */
  71336. [idx: number]: ICameraInput<TCamera>;
  71337. }
  71338. /**
  71339. * This represents the input manager used within a camera.
  71340. * It helps dealing with all the different kind of input attached to a camera.
  71341. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71342. */
  71343. export class CameraInputsManager<TCamera extends Camera> {
  71344. /**
  71345. * Defines the list of inputs attahed to the camera.
  71346. */
  71347. attached: CameraInputsMap<TCamera>;
  71348. /**
  71349. * Defines the dom element the camera is collecting inputs from.
  71350. * This is null if the controls have not been attached.
  71351. */
  71352. attachedElement: Nullable<HTMLElement>;
  71353. /**
  71354. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71355. */
  71356. noPreventDefault: boolean;
  71357. /**
  71358. * Defined the camera the input manager belongs to.
  71359. */
  71360. camera: TCamera;
  71361. /**
  71362. * Update the current camera state depending on the inputs that have been used this frame.
  71363. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71364. */
  71365. checkInputs: () => void;
  71366. /**
  71367. * Instantiate a new Camera Input Manager.
  71368. * @param camera Defines the camera the input manager blongs to
  71369. */
  71370. constructor(camera: TCamera);
  71371. /**
  71372. * Add an input method to a camera
  71373. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71374. * @param input camera input method
  71375. */
  71376. add(input: ICameraInput<TCamera>): void;
  71377. /**
  71378. * Remove a specific input method from a camera
  71379. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  71380. * @param inputToRemove camera input method
  71381. */
  71382. remove(inputToRemove: ICameraInput<TCamera>): void;
  71383. /**
  71384. * Remove a specific input type from a camera
  71385. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  71386. * @param inputType the type of the input to remove
  71387. */
  71388. removeByType(inputType: string): void;
  71389. private _addCheckInputs;
  71390. /**
  71391. * Attach the input controls to the currently attached dom element to listen the events from.
  71392. * @param input Defines the input to attach
  71393. */
  71394. attachInput(input: ICameraInput<TCamera>): void;
  71395. /**
  71396. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  71397. * @param element Defines the dom element to collect the events from
  71398. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71399. */
  71400. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  71401. /**
  71402. * Detach the current manager inputs controls from a specific dom element.
  71403. * @param element Defines the dom element to collect the events from
  71404. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  71405. */
  71406. detachElement(element: HTMLElement, disconnect?: boolean): void;
  71407. /**
  71408. * Rebuild the dynamic inputCheck function from the current list of
  71409. * defined inputs in the manager.
  71410. */
  71411. rebuildInputCheck(): void;
  71412. /**
  71413. * Remove all attached input methods from a camera
  71414. */
  71415. clear(): void;
  71416. /**
  71417. * Serialize the current input manager attached to a camera.
  71418. * This ensures than once parsed,
  71419. * the input associated to the camera will be identical to the current ones
  71420. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  71421. */
  71422. serialize(serializedCamera: any): void;
  71423. /**
  71424. * Parses an input manager serialized JSON to restore the previous list of inputs
  71425. * and states associated to a camera.
  71426. * @param parsedCamera Defines the JSON to parse
  71427. */
  71428. parse(parsedCamera: any): void;
  71429. }
  71430. }
  71431. declare module BABYLON {
  71432. /**
  71433. * Gather the list of keyboard event types as constants.
  71434. */
  71435. export class KeyboardEventTypes {
  71436. /**
  71437. * The keydown event is fired when a key becomes active (pressed).
  71438. */
  71439. static readonly KEYDOWN: number;
  71440. /**
  71441. * The keyup event is fired when a key has been released.
  71442. */
  71443. static readonly KEYUP: number;
  71444. }
  71445. /**
  71446. * This class is used to store keyboard related info for the onKeyboardObservable event.
  71447. */
  71448. export class KeyboardInfo {
  71449. /**
  71450. * Defines the type of event (KeyboardEventTypes)
  71451. */
  71452. type: number;
  71453. /**
  71454. * Defines the related dom event
  71455. */
  71456. event: KeyboardEvent;
  71457. /**
  71458. * Instantiates a new keyboard info.
  71459. * This class is used to store keyboard related info for the onKeyboardObservable event.
  71460. * @param type Defines the type of event (KeyboardEventTypes)
  71461. * @param event Defines the related dom event
  71462. */
  71463. constructor(
  71464. /**
  71465. * Defines the type of event (KeyboardEventTypes)
  71466. */
  71467. type: number,
  71468. /**
  71469. * Defines the related dom event
  71470. */
  71471. event: KeyboardEvent);
  71472. }
  71473. /**
  71474. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  71475. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  71476. */
  71477. export class KeyboardInfoPre extends KeyboardInfo {
  71478. /**
  71479. * Defines the type of event (KeyboardEventTypes)
  71480. */
  71481. type: number;
  71482. /**
  71483. * Defines the related dom event
  71484. */
  71485. event: KeyboardEvent;
  71486. /**
  71487. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  71488. */
  71489. skipOnPointerObservable: boolean;
  71490. /**
  71491. * Instantiates a new keyboard pre info.
  71492. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  71493. * @param type Defines the type of event (KeyboardEventTypes)
  71494. * @param event Defines the related dom event
  71495. */
  71496. constructor(
  71497. /**
  71498. * Defines the type of event (KeyboardEventTypes)
  71499. */
  71500. type: number,
  71501. /**
  71502. * Defines the related dom event
  71503. */
  71504. event: KeyboardEvent);
  71505. }
  71506. }
  71507. declare module BABYLON {
  71508. /**
  71509. * Manage the keyboard inputs to control the movement of a free camera.
  71510. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71511. */
  71512. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  71513. /**
  71514. * Defines the camera the input is attached to.
  71515. */
  71516. camera: FreeCamera;
  71517. /**
  71518. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  71519. */
  71520. keysUp: number[];
  71521. /**
  71522. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  71523. */
  71524. keysDown: number[];
  71525. /**
  71526. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  71527. */
  71528. keysLeft: number[];
  71529. /**
  71530. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  71531. */
  71532. keysRight: number[];
  71533. private _keys;
  71534. private _onCanvasBlurObserver;
  71535. private _onKeyboardObserver;
  71536. private _engine;
  71537. private _scene;
  71538. /**
  71539. * Attach the input controls to a specific dom element to get the input from.
  71540. * @param element Defines the element the controls should be listened from
  71541. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71542. */
  71543. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71544. /**
  71545. * Detach the current controls from the specified dom element.
  71546. * @param element Defines the element to stop listening the inputs from
  71547. */
  71548. detachControl(element: Nullable<HTMLElement>): void;
  71549. /**
  71550. * Update the current camera state depending on the inputs that have been used this frame.
  71551. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71552. */
  71553. checkInputs(): void;
  71554. /**
  71555. * Gets the class name of the current intput.
  71556. * @returns the class name
  71557. */
  71558. getClassName(): string;
  71559. /** @hidden */
  71560. _onLostFocus(): void;
  71561. /**
  71562. * Get the friendly name associated with the input class.
  71563. * @returns the input friendly name
  71564. */
  71565. getSimpleName(): string;
  71566. }
  71567. }
  71568. declare module BABYLON {
  71569. /**
  71570. * Interface describing all the common properties and methods a shadow light needs to implement.
  71571. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  71572. * as well as binding the different shadow properties to the effects.
  71573. */
  71574. export interface IShadowLight extends Light {
  71575. /**
  71576. * The light id in the scene (used in scene.findLighById for instance)
  71577. */
  71578. id: string;
  71579. /**
  71580. * The position the shdow will be casted from.
  71581. */
  71582. position: Vector3;
  71583. /**
  71584. * In 2d mode (needCube being false), the direction used to cast the shadow.
  71585. */
  71586. direction: Vector3;
  71587. /**
  71588. * The transformed position. Position of the light in world space taking parenting in account.
  71589. */
  71590. transformedPosition: Vector3;
  71591. /**
  71592. * The transformed direction. Direction of the light in world space taking parenting in account.
  71593. */
  71594. transformedDirection: Vector3;
  71595. /**
  71596. * The friendly name of the light in the scene.
  71597. */
  71598. name: string;
  71599. /**
  71600. * Defines the shadow projection clipping minimum z value.
  71601. */
  71602. shadowMinZ: number;
  71603. /**
  71604. * Defines the shadow projection clipping maximum z value.
  71605. */
  71606. shadowMaxZ: number;
  71607. /**
  71608. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  71609. * @returns true if the information has been computed, false if it does not need to (no parenting)
  71610. */
  71611. computeTransformedInformation(): boolean;
  71612. /**
  71613. * Gets the scene the light belongs to.
  71614. * @returns The scene
  71615. */
  71616. getScene(): Scene;
  71617. /**
  71618. * Callback defining a custom Projection Matrix Builder.
  71619. * This can be used to override the default projection matrix computation.
  71620. */
  71621. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  71622. /**
  71623. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  71624. * @param matrix The materix to updated with the projection information
  71625. * @param viewMatrix The transform matrix of the light
  71626. * @param renderList The list of mesh to render in the map
  71627. * @returns The current light
  71628. */
  71629. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  71630. /**
  71631. * Gets the current depth scale used in ESM.
  71632. * @returns The scale
  71633. */
  71634. getDepthScale(): number;
  71635. /**
  71636. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  71637. * @returns true if a cube texture needs to be use
  71638. */
  71639. needCube(): boolean;
  71640. /**
  71641. * Detects if the projection matrix requires to be recomputed this frame.
  71642. * @returns true if it requires to be recomputed otherwise, false.
  71643. */
  71644. needProjectionMatrixCompute(): boolean;
  71645. /**
  71646. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  71647. */
  71648. forceProjectionMatrixCompute(): void;
  71649. /**
  71650. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  71651. * @param faceIndex The index of the face we are computed the direction to generate shadow
  71652. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  71653. */
  71654. getShadowDirection(faceIndex?: number): Vector3;
  71655. /**
  71656. * Gets the minZ used for shadow according to both the scene and the light.
  71657. * @param activeCamera The camera we are returning the min for
  71658. * @returns the depth min z
  71659. */
  71660. getDepthMinZ(activeCamera: Camera): number;
  71661. /**
  71662. * Gets the maxZ used for shadow according to both the scene and the light.
  71663. * @param activeCamera The camera we are returning the max for
  71664. * @returns the depth max z
  71665. */
  71666. getDepthMaxZ(activeCamera: Camera): number;
  71667. }
  71668. /**
  71669. * Base implementation IShadowLight
  71670. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  71671. */
  71672. export abstract class ShadowLight extends Light implements IShadowLight {
  71673. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  71674. protected _position: Vector3;
  71675. protected _setPosition(value: Vector3): void;
  71676. /**
  71677. * Sets the position the shadow will be casted from. Also use as the light position for both
  71678. * point and spot lights.
  71679. */
  71680. /**
  71681. * Sets the position the shadow will be casted from. Also use as the light position for both
  71682. * point and spot lights.
  71683. */
  71684. position: Vector3;
  71685. protected _direction: Vector3;
  71686. protected _setDirection(value: Vector3): void;
  71687. /**
  71688. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  71689. * Also use as the light direction on spot and directional lights.
  71690. */
  71691. /**
  71692. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  71693. * Also use as the light direction on spot and directional lights.
  71694. */
  71695. direction: Vector3;
  71696. private _shadowMinZ;
  71697. /**
  71698. * Gets the shadow projection clipping minimum z value.
  71699. */
  71700. /**
  71701. * Sets the shadow projection clipping minimum z value.
  71702. */
  71703. shadowMinZ: number;
  71704. private _shadowMaxZ;
  71705. /**
  71706. * Sets the shadow projection clipping maximum z value.
  71707. */
  71708. /**
  71709. * Gets the shadow projection clipping maximum z value.
  71710. */
  71711. shadowMaxZ: number;
  71712. /**
  71713. * Callback defining a custom Projection Matrix Builder.
  71714. * This can be used to override the default projection matrix computation.
  71715. */
  71716. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  71717. /**
  71718. * The transformed position. Position of the light in world space taking parenting in account.
  71719. */
  71720. transformedPosition: Vector3;
  71721. /**
  71722. * The transformed direction. Direction of the light in world space taking parenting in account.
  71723. */
  71724. transformedDirection: Vector3;
  71725. private _needProjectionMatrixCompute;
  71726. /**
  71727. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  71728. * @returns true if the information has been computed, false if it does not need to (no parenting)
  71729. */
  71730. computeTransformedInformation(): boolean;
  71731. /**
  71732. * Return the depth scale used for the shadow map.
  71733. * @returns the depth scale.
  71734. */
  71735. getDepthScale(): number;
  71736. /**
  71737. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  71738. * @param faceIndex The index of the face we are computed the direction to generate shadow
  71739. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  71740. */
  71741. getShadowDirection(faceIndex?: number): Vector3;
  71742. /**
  71743. * Returns the ShadowLight absolute position in the World.
  71744. * @returns the position vector in world space
  71745. */
  71746. getAbsolutePosition(): Vector3;
  71747. /**
  71748. * Sets the ShadowLight direction toward the passed target.
  71749. * @param target The point to target in local space
  71750. * @returns the updated ShadowLight direction
  71751. */
  71752. setDirectionToTarget(target: Vector3): Vector3;
  71753. /**
  71754. * Returns the light rotation in euler definition.
  71755. * @returns the x y z rotation in local space.
  71756. */
  71757. getRotation(): Vector3;
  71758. /**
  71759. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  71760. * @returns true if a cube texture needs to be use
  71761. */
  71762. needCube(): boolean;
  71763. /**
  71764. * Detects if the projection matrix requires to be recomputed this frame.
  71765. * @returns true if it requires to be recomputed otherwise, false.
  71766. */
  71767. needProjectionMatrixCompute(): boolean;
  71768. /**
  71769. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  71770. */
  71771. forceProjectionMatrixCompute(): void;
  71772. /** @hidden */
  71773. _initCache(): void;
  71774. /** @hidden */
  71775. _isSynchronized(): boolean;
  71776. /**
  71777. * Computes the world matrix of the node
  71778. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  71779. * @returns the world matrix
  71780. */
  71781. computeWorldMatrix(force?: boolean): Matrix;
  71782. /**
  71783. * Gets the minZ used for shadow according to both the scene and the light.
  71784. * @param activeCamera The camera we are returning the min for
  71785. * @returns the depth min z
  71786. */
  71787. getDepthMinZ(activeCamera: Camera): number;
  71788. /**
  71789. * Gets the maxZ used for shadow according to both the scene and the light.
  71790. * @param activeCamera The camera we are returning the max for
  71791. * @returns the depth max z
  71792. */
  71793. getDepthMaxZ(activeCamera: Camera): number;
  71794. /**
  71795. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  71796. * @param matrix The materix to updated with the projection information
  71797. * @param viewMatrix The transform matrix of the light
  71798. * @param renderList The list of mesh to render in the map
  71799. * @returns The current light
  71800. */
  71801. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  71802. }
  71803. }
  71804. declare module BABYLON {
  71805. /**
  71806. * "Static Class" containing the most commonly used helper while dealing with material for
  71807. * rendering purpose.
  71808. *
  71809. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  71810. *
  71811. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  71812. */
  71813. export class MaterialHelper {
  71814. /**
  71815. * Bind the current view position to an effect.
  71816. * @param effect The effect to be bound
  71817. * @param scene The scene the eyes position is used from
  71818. */
  71819. static BindEyePosition(effect: Effect, scene: Scene): void;
  71820. /**
  71821. * Helps preparing the defines values about the UVs in used in the effect.
  71822. * UVs are shared as much as we can accross channels in the shaders.
  71823. * @param texture The texture we are preparing the UVs for
  71824. * @param defines The defines to update
  71825. * @param key The channel key "diffuse", "specular"... used in the shader
  71826. */
  71827. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  71828. /**
  71829. * Binds a texture matrix value to its corrsponding uniform
  71830. * @param texture The texture to bind the matrix for
  71831. * @param uniformBuffer The uniform buffer receivin the data
  71832. * @param key The channel key "diffuse", "specular"... used in the shader
  71833. */
  71834. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  71835. /**
  71836. * Gets the current status of the fog (should it be enabled?)
  71837. * @param mesh defines the mesh to evaluate for fog support
  71838. * @param scene defines the hosting scene
  71839. * @returns true if fog must be enabled
  71840. */
  71841. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  71842. /**
  71843. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  71844. * @param mesh defines the current mesh
  71845. * @param scene defines the current scene
  71846. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  71847. * @param pointsCloud defines if point cloud rendering has to be turned on
  71848. * @param fogEnabled defines if fog has to be turned on
  71849. * @param alphaTest defines if alpha testing has to be turned on
  71850. * @param defines defines the current list of defines
  71851. */
  71852. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  71853. /**
  71854. * Helper used to prepare the list of defines associated with frame values for shader compilation
  71855. * @param scene defines the current scene
  71856. * @param engine defines the current engine
  71857. * @param defines specifies the list of active defines
  71858. * @param useInstances defines if instances have to be turned on
  71859. * @param useClipPlane defines if clip plane have to be turned on
  71860. */
  71861. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  71862. /**
  71863. * Prepares the defines for bones
  71864. * @param mesh The mesh containing the geometry data we will draw
  71865. * @param defines The defines to update
  71866. */
  71867. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  71868. /**
  71869. * Prepares the defines for morph targets
  71870. * @param mesh The mesh containing the geometry data we will draw
  71871. * @param defines The defines to update
  71872. */
  71873. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  71874. /**
  71875. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  71876. * @param mesh The mesh containing the geometry data we will draw
  71877. * @param defines The defines to update
  71878. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  71879. * @param useBones Precise whether bones should be used or not (override mesh info)
  71880. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  71881. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  71882. * @returns false if defines are considered not dirty and have not been checked
  71883. */
  71884. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  71885. /**
  71886. * Prepares the defines related to multiview
  71887. * @param scene The scene we are intending to draw
  71888. * @param defines The defines to update
  71889. */
  71890. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  71891. /**
  71892. * Prepares the defines related to the light information passed in parameter
  71893. * @param scene The scene we are intending to draw
  71894. * @param mesh The mesh the effect is compiling for
  71895. * @param defines The defines to update
  71896. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  71897. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  71898. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  71899. * @returns true if normals will be required for the rest of the effect
  71900. */
  71901. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  71902. /**
  71903. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  71904. * that won t be acctive due to defines being turned off.
  71905. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  71906. * @param samplersList The samplers list
  71907. * @param defines The defines helping in the list generation
  71908. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  71909. */
  71910. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  71911. /**
  71912. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  71913. * @param defines The defines to update while falling back
  71914. * @param fallbacks The authorized effect fallbacks
  71915. * @param maxSimultaneousLights The maximum number of lights allowed
  71916. * @param rank the current rank of the Effect
  71917. * @returns The newly affected rank
  71918. */
  71919. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  71920. /**
  71921. * Prepares the list of attributes required for morph targets according to the effect defines.
  71922. * @param attribs The current list of supported attribs
  71923. * @param mesh The mesh to prepare the morph targets attributes for
  71924. * @param defines The current Defines of the effect
  71925. */
  71926. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  71927. /**
  71928. * Prepares the list of attributes required for bones according to the effect defines.
  71929. * @param attribs The current list of supported attribs
  71930. * @param mesh The mesh to prepare the bones attributes for
  71931. * @param defines The current Defines of the effect
  71932. * @param fallbacks The current efffect fallback strategy
  71933. */
  71934. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  71935. /**
  71936. * Check and prepare the list of attributes required for instances according to the effect defines.
  71937. * @param attribs The current list of supported attribs
  71938. * @param defines The current MaterialDefines of the effect
  71939. */
  71940. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  71941. /**
  71942. * Add the list of attributes required for instances to the attribs array.
  71943. * @param attribs The current list of supported attribs
  71944. */
  71945. static PushAttributesForInstances(attribs: string[]): void;
  71946. /**
  71947. * Binds the light shadow information to the effect for the given mesh.
  71948. * @param light The light containing the generator
  71949. * @param scene The scene the lights belongs to
  71950. * @param mesh The mesh we are binding the information to render
  71951. * @param lightIndex The light index in the effect used to render the mesh
  71952. * @param effect The effect we are binding the data to
  71953. */
  71954. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  71955. /**
  71956. * Binds the light information to the effect.
  71957. * @param light The light containing the generator
  71958. * @param effect The effect we are binding the data to
  71959. * @param lightIndex The light index in the effect used to render
  71960. */
  71961. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  71962. /**
  71963. * Binds the lights information from the scene to the effect for the given mesh.
  71964. * @param scene The scene the lights belongs to
  71965. * @param mesh The mesh we are binding the information to render
  71966. * @param effect The effect we are binding the data to
  71967. * @param defines The generated defines for the effect
  71968. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  71969. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  71970. */
  71971. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  71972. private static _tempFogColor;
  71973. /**
  71974. * Binds the fog information from the scene to the effect for the given mesh.
  71975. * @param scene The scene the lights belongs to
  71976. * @param mesh The mesh we are binding the information to render
  71977. * @param effect The effect we are binding the data to
  71978. * @param linearSpace Defines if the fog effect is applied in linear space
  71979. */
  71980. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  71981. /**
  71982. * Binds the bones information from the mesh to the effect.
  71983. * @param mesh The mesh we are binding the information to render
  71984. * @param effect The effect we are binding the data to
  71985. */
  71986. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  71987. /**
  71988. * Binds the morph targets information from the mesh to the effect.
  71989. * @param abstractMesh The mesh we are binding the information to render
  71990. * @param effect The effect we are binding the data to
  71991. */
  71992. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  71993. /**
  71994. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  71995. * @param defines The generated defines used in the effect
  71996. * @param effect The effect we are binding the data to
  71997. * @param scene The scene we are willing to render with logarithmic scale for
  71998. */
  71999. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  72000. /**
  72001. * Binds the clip plane information from the scene to the effect.
  72002. * @param scene The scene the clip plane information are extracted from
  72003. * @param effect The effect we are binding the data to
  72004. */
  72005. static BindClipPlane(effect: Effect, scene: Scene): void;
  72006. }
  72007. }
  72008. declare module BABYLON {
  72009. /** @hidden */
  72010. export var kernelBlurVaryingDeclaration: {
  72011. name: string;
  72012. shader: string;
  72013. };
  72014. }
  72015. declare module BABYLON {
  72016. /** @hidden */
  72017. export var kernelBlurFragment: {
  72018. name: string;
  72019. shader: string;
  72020. };
  72021. }
  72022. declare module BABYLON {
  72023. /** @hidden */
  72024. export var kernelBlurFragment2: {
  72025. name: string;
  72026. shader: string;
  72027. };
  72028. }
  72029. declare module BABYLON {
  72030. /** @hidden */
  72031. export var kernelBlurPixelShader: {
  72032. name: string;
  72033. shader: string;
  72034. };
  72035. }
  72036. declare module BABYLON {
  72037. /** @hidden */
  72038. export var kernelBlurVertex: {
  72039. name: string;
  72040. shader: string;
  72041. };
  72042. }
  72043. declare module BABYLON {
  72044. /** @hidden */
  72045. export var kernelBlurVertexShader: {
  72046. name: string;
  72047. shader: string;
  72048. };
  72049. }
  72050. declare module BABYLON {
  72051. /**
  72052. * The Blur Post Process which blurs an image based on a kernel and direction.
  72053. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  72054. */
  72055. export class BlurPostProcess extends PostProcess {
  72056. /** The direction in which to blur the image. */
  72057. direction: Vector2;
  72058. private blockCompilation;
  72059. protected _kernel: number;
  72060. protected _idealKernel: number;
  72061. protected _packedFloat: boolean;
  72062. private _staticDefines;
  72063. /**
  72064. * Sets the length in pixels of the blur sample region
  72065. */
  72066. /**
  72067. * Gets the length in pixels of the blur sample region
  72068. */
  72069. kernel: number;
  72070. /**
  72071. * Sets wether or not the blur needs to unpack/repack floats
  72072. */
  72073. /**
  72074. * Gets wether or not the blur is unpacking/repacking floats
  72075. */
  72076. packedFloat: boolean;
  72077. /**
  72078. * Creates a new instance BlurPostProcess
  72079. * @param name The name of the effect.
  72080. * @param direction The direction in which to blur the image.
  72081. * @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.
  72082. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  72083. * @param camera The camera to apply the render pass to.
  72084. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72085. * @param engine The engine which the post process will be applied. (default: current engine)
  72086. * @param reusable If the post process can be reused on the same frame. (default: false)
  72087. * @param textureType Type of textures used when performing the post process. (default: 0)
  72088. * @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)
  72089. */
  72090. constructor(name: string,
  72091. /** The direction in which to blur the image. */
  72092. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  72093. /**
  72094. * Updates the effect with the current post process compile time values and recompiles the shader.
  72095. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  72096. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  72097. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  72098. * @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
  72099. * @param onCompiled Called when the shader has been compiled.
  72100. * @param onError Called if there is an error when compiling a shader.
  72101. */
  72102. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  72103. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  72104. /**
  72105. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  72106. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  72107. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  72108. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  72109. * The gaps between physical kernels are compensated for in the weighting of the samples
  72110. * @param idealKernel Ideal blur kernel.
  72111. * @return Nearest best kernel.
  72112. */
  72113. protected _nearestBestKernel(idealKernel: number): number;
  72114. /**
  72115. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  72116. * @param x The point on the Gaussian distribution to sample.
  72117. * @return the value of the Gaussian function at x.
  72118. */
  72119. protected _gaussianWeight(x: number): number;
  72120. /**
  72121. * Generates a string that can be used as a floating point number in GLSL.
  72122. * @param x Value to print.
  72123. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  72124. * @return GLSL float string.
  72125. */
  72126. protected _glslFloat(x: number, decimalFigures?: number): string;
  72127. }
  72128. }
  72129. declare module BABYLON {
  72130. /** @hidden */
  72131. export var shadowMapPixelShader: {
  72132. name: string;
  72133. shader: string;
  72134. };
  72135. }
  72136. declare module BABYLON {
  72137. /** @hidden */
  72138. export var bonesDeclaration: {
  72139. name: string;
  72140. shader: string;
  72141. };
  72142. }
  72143. declare module BABYLON {
  72144. /** @hidden */
  72145. export var morphTargetsVertexGlobalDeclaration: {
  72146. name: string;
  72147. shader: string;
  72148. };
  72149. }
  72150. declare module BABYLON {
  72151. /** @hidden */
  72152. export var morphTargetsVertexDeclaration: {
  72153. name: string;
  72154. shader: string;
  72155. };
  72156. }
  72157. declare module BABYLON {
  72158. /** @hidden */
  72159. export var instancesDeclaration: {
  72160. name: string;
  72161. shader: string;
  72162. };
  72163. }
  72164. declare module BABYLON {
  72165. /** @hidden */
  72166. export var helperFunctions: {
  72167. name: string;
  72168. shader: string;
  72169. };
  72170. }
  72171. declare module BABYLON {
  72172. /** @hidden */
  72173. export var morphTargetsVertex: {
  72174. name: string;
  72175. shader: string;
  72176. };
  72177. }
  72178. declare module BABYLON {
  72179. /** @hidden */
  72180. export var instancesVertex: {
  72181. name: string;
  72182. shader: string;
  72183. };
  72184. }
  72185. declare module BABYLON {
  72186. /** @hidden */
  72187. export var bonesVertex: {
  72188. name: string;
  72189. shader: string;
  72190. };
  72191. }
  72192. declare module BABYLON {
  72193. /** @hidden */
  72194. export var shadowMapVertexShader: {
  72195. name: string;
  72196. shader: string;
  72197. };
  72198. }
  72199. declare module BABYLON {
  72200. /** @hidden */
  72201. export var depthBoxBlurPixelShader: {
  72202. name: string;
  72203. shader: string;
  72204. };
  72205. }
  72206. declare module BABYLON {
  72207. /**
  72208. * Defines the options associated with the creation of a custom shader for a shadow generator.
  72209. */
  72210. export interface ICustomShaderOptions {
  72211. /**
  72212. * Gets or sets the custom shader name to use
  72213. */
  72214. shaderName: string;
  72215. /**
  72216. * The list of attribute names used in the shader
  72217. */
  72218. attributes?: string[];
  72219. /**
  72220. * The list of unifrom names used in the shader
  72221. */
  72222. uniforms?: string[];
  72223. /**
  72224. * The list of sampler names used in the shader
  72225. */
  72226. samplers?: string[];
  72227. /**
  72228. * The list of defines used in the shader
  72229. */
  72230. defines?: string[];
  72231. }
  72232. /**
  72233. * Interface to implement to create a shadow generator compatible with BJS.
  72234. */
  72235. export interface IShadowGenerator {
  72236. /**
  72237. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  72238. * @returns The render target texture if present otherwise, null
  72239. */
  72240. getShadowMap(): Nullable<RenderTargetTexture>;
  72241. /**
  72242. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  72243. * @returns The render target texture if the shadow map is present otherwise, null
  72244. */
  72245. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  72246. /**
  72247. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  72248. * @param subMesh The submesh we want to render in the shadow map
  72249. * @param useInstances Defines wether will draw in the map using instances
  72250. * @returns true if ready otherwise, false
  72251. */
  72252. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72253. /**
  72254. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  72255. * @param defines Defines of the material we want to update
  72256. * @param lightIndex Index of the light in the enabled light list of the material
  72257. */
  72258. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  72259. /**
  72260. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  72261. * defined in the generator but impacting the effect).
  72262. * It implies the unifroms available on the materials are the standard BJS ones.
  72263. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  72264. * @param effect The effect we are binfing the information for
  72265. */
  72266. bindShadowLight(lightIndex: string, effect: Effect): void;
  72267. /**
  72268. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  72269. * (eq to shadow prjection matrix * light transform matrix)
  72270. * @returns The transform matrix used to create the shadow map
  72271. */
  72272. getTransformMatrix(): Matrix;
  72273. /**
  72274. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  72275. * Cube and 2D textures for instance.
  72276. */
  72277. recreateShadowMap(): void;
  72278. /**
  72279. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  72280. * @param onCompiled Callback triggered at the and of the effects compilation
  72281. * @param options Sets of optional options forcing the compilation with different modes
  72282. */
  72283. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  72284. useInstances: boolean;
  72285. }>): void;
  72286. /**
  72287. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  72288. * @param options Sets of optional options forcing the compilation with different modes
  72289. * @returns A promise that resolves when the compilation completes
  72290. */
  72291. forceCompilationAsync(options?: Partial<{
  72292. useInstances: boolean;
  72293. }>): Promise<void>;
  72294. /**
  72295. * Serializes the shadow generator setup to a json object.
  72296. * @returns The serialized JSON object
  72297. */
  72298. serialize(): any;
  72299. /**
  72300. * Disposes the Shadow map and related Textures and effects.
  72301. */
  72302. dispose(): void;
  72303. }
  72304. /**
  72305. * Default implementation IShadowGenerator.
  72306. * This is the main object responsible of generating shadows in the framework.
  72307. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  72308. */
  72309. export class ShadowGenerator implements IShadowGenerator {
  72310. /**
  72311. * Shadow generator mode None: no filtering applied.
  72312. */
  72313. static readonly FILTER_NONE: number;
  72314. /**
  72315. * Shadow generator mode ESM: Exponential Shadow Mapping.
  72316. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  72317. */
  72318. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  72319. /**
  72320. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  72321. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  72322. */
  72323. static readonly FILTER_POISSONSAMPLING: number;
  72324. /**
  72325. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  72326. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  72327. */
  72328. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  72329. /**
  72330. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  72331. * edge artifacts on steep falloff.
  72332. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  72333. */
  72334. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  72335. /**
  72336. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  72337. * edge artifacts on steep falloff.
  72338. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  72339. */
  72340. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  72341. /**
  72342. * Shadow generator mode PCF: Percentage Closer Filtering
  72343. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  72344. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  72345. */
  72346. static readonly FILTER_PCF: number;
  72347. /**
  72348. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  72349. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  72350. * Contact Hardening
  72351. */
  72352. static readonly FILTER_PCSS: number;
  72353. /**
  72354. * Reserved for PCF and PCSS
  72355. * Highest Quality.
  72356. *
  72357. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  72358. *
  72359. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  72360. */
  72361. static readonly QUALITY_HIGH: number;
  72362. /**
  72363. * Reserved for PCF and PCSS
  72364. * Good tradeoff for quality/perf cross devices
  72365. *
  72366. * Execute PCF on a 3*3 kernel.
  72367. *
  72368. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  72369. */
  72370. static readonly QUALITY_MEDIUM: number;
  72371. /**
  72372. * Reserved for PCF and PCSS
  72373. * The lowest quality but the fastest.
  72374. *
  72375. * Execute PCF on a 1*1 kernel.
  72376. *
  72377. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  72378. */
  72379. static readonly QUALITY_LOW: number;
  72380. /** Gets or sets the custom shader name to use */
  72381. customShaderOptions: ICustomShaderOptions;
  72382. /**
  72383. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  72384. */
  72385. onBeforeShadowMapRenderObservable: Observable<Effect>;
  72386. /**
  72387. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  72388. */
  72389. onAfterShadowMapRenderObservable: Observable<Effect>;
  72390. /**
  72391. * Observable triggered before a mesh is rendered in the shadow map.
  72392. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  72393. */
  72394. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  72395. /**
  72396. * Observable triggered after a mesh is rendered in the shadow map.
  72397. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  72398. */
  72399. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  72400. private _bias;
  72401. /**
  72402. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  72403. */
  72404. /**
  72405. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  72406. */
  72407. bias: number;
  72408. private _normalBias;
  72409. /**
  72410. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  72411. */
  72412. /**
  72413. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  72414. */
  72415. normalBias: number;
  72416. private _blurBoxOffset;
  72417. /**
  72418. * Gets the blur box offset: offset applied during the blur pass.
  72419. * Only useful if useKernelBlur = false
  72420. */
  72421. /**
  72422. * Sets the blur box offset: offset applied during the blur pass.
  72423. * Only useful if useKernelBlur = false
  72424. */
  72425. blurBoxOffset: number;
  72426. private _blurScale;
  72427. /**
  72428. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  72429. * 2 means half of the size.
  72430. */
  72431. /**
  72432. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  72433. * 2 means half of the size.
  72434. */
  72435. blurScale: number;
  72436. private _blurKernel;
  72437. /**
  72438. * Gets the blur kernel: kernel size of the blur pass.
  72439. * Only useful if useKernelBlur = true
  72440. */
  72441. /**
  72442. * Sets the blur kernel: kernel size of the blur pass.
  72443. * Only useful if useKernelBlur = true
  72444. */
  72445. blurKernel: number;
  72446. private _useKernelBlur;
  72447. /**
  72448. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  72449. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  72450. */
  72451. /**
  72452. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  72453. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  72454. */
  72455. useKernelBlur: boolean;
  72456. private _depthScale;
  72457. /**
  72458. * Gets the depth scale used in ESM mode.
  72459. */
  72460. /**
  72461. * Sets the depth scale used in ESM mode.
  72462. * This can override the scale stored on the light.
  72463. */
  72464. depthScale: number;
  72465. private _filter;
  72466. /**
  72467. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  72468. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  72469. */
  72470. /**
  72471. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  72472. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  72473. */
  72474. filter: number;
  72475. /**
  72476. * Gets if the current filter is set to Poisson Sampling.
  72477. */
  72478. /**
  72479. * Sets the current filter to Poisson Sampling.
  72480. */
  72481. usePoissonSampling: boolean;
  72482. /**
  72483. * Gets if the current filter is set to ESM.
  72484. */
  72485. /**
  72486. * Sets the current filter is to ESM.
  72487. */
  72488. useExponentialShadowMap: boolean;
  72489. /**
  72490. * Gets if the current filter is set to filtered ESM.
  72491. */
  72492. /**
  72493. * Gets if the current filter is set to filtered ESM.
  72494. */
  72495. useBlurExponentialShadowMap: boolean;
  72496. /**
  72497. * Gets if the current filter is set to "close ESM" (using the inverse of the
  72498. * exponential to prevent steep falloff artifacts).
  72499. */
  72500. /**
  72501. * Sets the current filter to "close ESM" (using the inverse of the
  72502. * exponential to prevent steep falloff artifacts).
  72503. */
  72504. useCloseExponentialShadowMap: boolean;
  72505. /**
  72506. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  72507. * exponential to prevent steep falloff artifacts).
  72508. */
  72509. /**
  72510. * Sets the current filter to filtered "close ESM" (using the inverse of the
  72511. * exponential to prevent steep falloff artifacts).
  72512. */
  72513. useBlurCloseExponentialShadowMap: boolean;
  72514. /**
  72515. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  72516. */
  72517. /**
  72518. * Sets the current filter to "PCF" (percentage closer filtering).
  72519. */
  72520. usePercentageCloserFiltering: boolean;
  72521. private _filteringQuality;
  72522. /**
  72523. * Gets the PCF or PCSS Quality.
  72524. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  72525. */
  72526. /**
  72527. * Sets the PCF or PCSS Quality.
  72528. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  72529. */
  72530. filteringQuality: number;
  72531. /**
  72532. * Gets if the current filter is set to "PCSS" (contact hardening).
  72533. */
  72534. /**
  72535. * Sets the current filter to "PCSS" (contact hardening).
  72536. */
  72537. useContactHardeningShadow: boolean;
  72538. private _contactHardeningLightSizeUVRatio;
  72539. /**
  72540. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  72541. * Using a ratio helps keeping shape stability independently of the map size.
  72542. *
  72543. * It does not account for the light projection as it was having too much
  72544. * instability during the light setup or during light position changes.
  72545. *
  72546. * Only valid if useContactHardeningShadow is true.
  72547. */
  72548. /**
  72549. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  72550. * Using a ratio helps keeping shape stability independently of the map size.
  72551. *
  72552. * It does not account for the light projection as it was having too much
  72553. * instability during the light setup or during light position changes.
  72554. *
  72555. * Only valid if useContactHardeningShadow is true.
  72556. */
  72557. contactHardeningLightSizeUVRatio: number;
  72558. private _darkness;
  72559. /** Gets or sets the actual darkness of a shadow */
  72560. darkness: number;
  72561. /**
  72562. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  72563. * 0 means strongest and 1 would means no shadow.
  72564. * @returns the darkness.
  72565. */
  72566. getDarkness(): number;
  72567. /**
  72568. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  72569. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  72570. * @returns the shadow generator allowing fluent coding.
  72571. */
  72572. setDarkness(darkness: number): ShadowGenerator;
  72573. private _transparencyShadow;
  72574. /** Gets or sets the ability to have transparent shadow */
  72575. transparencyShadow: boolean;
  72576. /**
  72577. * Sets the ability to have transparent shadow (boolean).
  72578. * @param transparent True if transparent else False
  72579. * @returns the shadow generator allowing fluent coding
  72580. */
  72581. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  72582. private _shadowMap;
  72583. private _shadowMap2;
  72584. /**
  72585. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  72586. * @returns The render target texture if present otherwise, null
  72587. */
  72588. getShadowMap(): Nullable<RenderTargetTexture>;
  72589. /**
  72590. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  72591. * @returns The render target texture if the shadow map is present otherwise, null
  72592. */
  72593. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  72594. /**
  72595. * Gets the class name of that object
  72596. * @returns "ShadowGenerator"
  72597. */
  72598. getClassName(): string;
  72599. /**
  72600. * Helper function to add a mesh and its descendants to the list of shadow casters.
  72601. * @param mesh Mesh to add
  72602. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  72603. * @returns the Shadow Generator itself
  72604. */
  72605. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  72606. /**
  72607. * Helper function to remove a mesh and its descendants from the list of shadow casters
  72608. * @param mesh Mesh to remove
  72609. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  72610. * @returns the Shadow Generator itself
  72611. */
  72612. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  72613. /**
  72614. * Controls the extent to which the shadows fade out at the edge of the frustum
  72615. * Used only by directionals and spots
  72616. */
  72617. frustumEdgeFalloff: number;
  72618. private _light;
  72619. /**
  72620. * Returns the associated light object.
  72621. * @returns the light generating the shadow
  72622. */
  72623. getLight(): IShadowLight;
  72624. /**
  72625. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  72626. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  72627. * It might on the other hand introduce peter panning.
  72628. */
  72629. forceBackFacesOnly: boolean;
  72630. private _scene;
  72631. private _lightDirection;
  72632. private _effect;
  72633. private _viewMatrix;
  72634. private _projectionMatrix;
  72635. private _transformMatrix;
  72636. private _cachedPosition;
  72637. private _cachedDirection;
  72638. private _cachedDefines;
  72639. private _currentRenderID;
  72640. private _boxBlurPostprocess;
  72641. private _kernelBlurXPostprocess;
  72642. private _kernelBlurYPostprocess;
  72643. private _blurPostProcesses;
  72644. private _mapSize;
  72645. private _currentFaceIndex;
  72646. private _currentFaceIndexCache;
  72647. private _textureType;
  72648. private _defaultTextureMatrix;
  72649. /** @hidden */
  72650. static _SceneComponentInitialization: (scene: Scene) => void;
  72651. /**
  72652. * Creates a ShadowGenerator object.
  72653. * A ShadowGenerator is the required tool to use the shadows.
  72654. * Each light casting shadows needs to use its own ShadowGenerator.
  72655. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  72656. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  72657. * @param light The light object generating the shadows.
  72658. * @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.
  72659. */
  72660. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  72661. private _initializeGenerator;
  72662. private _initializeShadowMap;
  72663. private _initializeBlurRTTAndPostProcesses;
  72664. private _renderForShadowMap;
  72665. private _renderSubMeshForShadowMap;
  72666. private _applyFilterValues;
  72667. /**
  72668. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  72669. * @param onCompiled Callback triggered at the and of the effects compilation
  72670. * @param options Sets of optional options forcing the compilation with different modes
  72671. */
  72672. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  72673. useInstances: boolean;
  72674. }>): void;
  72675. /**
  72676. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  72677. * @param options Sets of optional options forcing the compilation with different modes
  72678. * @returns A promise that resolves when the compilation completes
  72679. */
  72680. forceCompilationAsync(options?: Partial<{
  72681. useInstances: boolean;
  72682. }>): Promise<void>;
  72683. /**
  72684. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  72685. * @param subMesh The submesh we want to render in the shadow map
  72686. * @param useInstances Defines wether will draw in the map using instances
  72687. * @returns true if ready otherwise, false
  72688. */
  72689. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72690. /**
  72691. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  72692. * @param defines Defines of the material we want to update
  72693. * @param lightIndex Index of the light in the enabled light list of the material
  72694. */
  72695. prepareDefines(defines: any, lightIndex: number): void;
  72696. /**
  72697. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  72698. * defined in the generator but impacting the effect).
  72699. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  72700. * @param effect The effect we are binfing the information for
  72701. */
  72702. bindShadowLight(lightIndex: string, effect: Effect): void;
  72703. /**
  72704. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  72705. * (eq to shadow prjection matrix * light transform matrix)
  72706. * @returns The transform matrix used to create the shadow map
  72707. */
  72708. getTransformMatrix(): Matrix;
  72709. /**
  72710. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  72711. * Cube and 2D textures for instance.
  72712. */
  72713. recreateShadowMap(): void;
  72714. private _disposeBlurPostProcesses;
  72715. private _disposeRTTandPostProcesses;
  72716. /**
  72717. * Disposes the ShadowGenerator.
  72718. * Returns nothing.
  72719. */
  72720. dispose(): void;
  72721. /**
  72722. * Serializes the shadow generator setup to a json object.
  72723. * @returns The serialized JSON object
  72724. */
  72725. serialize(): any;
  72726. /**
  72727. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  72728. * @param parsedShadowGenerator The JSON object to parse
  72729. * @param scene The scene to create the shadow map for
  72730. * @returns The parsed shadow generator
  72731. */
  72732. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  72733. }
  72734. }
  72735. declare module BABYLON {
  72736. /**
  72737. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  72738. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  72739. * 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.
  72740. */
  72741. export abstract class Light extends Node {
  72742. /**
  72743. * Falloff Default: light is falling off following the material specification:
  72744. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  72745. */
  72746. static readonly FALLOFF_DEFAULT: number;
  72747. /**
  72748. * Falloff Physical: light is falling off following the inverse squared distance law.
  72749. */
  72750. static readonly FALLOFF_PHYSICAL: number;
  72751. /**
  72752. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  72753. * to enhance interoperability with other engines.
  72754. */
  72755. static readonly FALLOFF_GLTF: number;
  72756. /**
  72757. * Falloff Standard: light is falling off like in the standard material
  72758. * to enhance interoperability with other materials.
  72759. */
  72760. static readonly FALLOFF_STANDARD: number;
  72761. /**
  72762. * If every light affecting the material is in this lightmapMode,
  72763. * material.lightmapTexture adds or multiplies
  72764. * (depends on material.useLightmapAsShadowmap)
  72765. * after every other light calculations.
  72766. */
  72767. static readonly LIGHTMAP_DEFAULT: number;
  72768. /**
  72769. * material.lightmapTexture as only diffuse lighting from this light
  72770. * adds only specular lighting from this light
  72771. * adds dynamic shadows
  72772. */
  72773. static readonly LIGHTMAP_SPECULAR: number;
  72774. /**
  72775. * material.lightmapTexture as only lighting
  72776. * no light calculation from this light
  72777. * only adds dynamic shadows from this light
  72778. */
  72779. static readonly LIGHTMAP_SHADOWSONLY: number;
  72780. /**
  72781. * Each light type uses the default quantity according to its type:
  72782. * point/spot lights use luminous intensity
  72783. * directional lights use illuminance
  72784. */
  72785. static readonly INTENSITYMODE_AUTOMATIC: number;
  72786. /**
  72787. * lumen (lm)
  72788. */
  72789. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  72790. /**
  72791. * candela (lm/sr)
  72792. */
  72793. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  72794. /**
  72795. * lux (lm/m^2)
  72796. */
  72797. static readonly INTENSITYMODE_ILLUMINANCE: number;
  72798. /**
  72799. * nit (cd/m^2)
  72800. */
  72801. static readonly INTENSITYMODE_LUMINANCE: number;
  72802. /**
  72803. * Light type const id of the point light.
  72804. */
  72805. static readonly LIGHTTYPEID_POINTLIGHT: number;
  72806. /**
  72807. * Light type const id of the directional light.
  72808. */
  72809. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  72810. /**
  72811. * Light type const id of the spot light.
  72812. */
  72813. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  72814. /**
  72815. * Light type const id of the hemispheric light.
  72816. */
  72817. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  72818. /**
  72819. * Diffuse gives the basic color to an object.
  72820. */
  72821. diffuse: Color3;
  72822. /**
  72823. * Specular produces a highlight color on an object.
  72824. * Note: This is note affecting PBR materials.
  72825. */
  72826. specular: Color3;
  72827. /**
  72828. * Defines the falloff type for this light. This lets overrriding how punctual light are
  72829. * falling off base on range or angle.
  72830. * This can be set to any values in Light.FALLOFF_x.
  72831. *
  72832. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  72833. * other types of materials.
  72834. */
  72835. falloffType: number;
  72836. /**
  72837. * Strength of the light.
  72838. * Note: By default it is define in the framework own unit.
  72839. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  72840. */
  72841. intensity: number;
  72842. private _range;
  72843. protected _inverseSquaredRange: number;
  72844. /**
  72845. * Defines how far from the source the light is impacting in scene units.
  72846. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  72847. */
  72848. /**
  72849. * Defines how far from the source the light is impacting in scene units.
  72850. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  72851. */
  72852. range: number;
  72853. /**
  72854. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  72855. * of light.
  72856. */
  72857. private _photometricScale;
  72858. private _intensityMode;
  72859. /**
  72860. * Gets the photometric scale used to interpret the intensity.
  72861. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  72862. */
  72863. /**
  72864. * Sets the photometric scale used to interpret the intensity.
  72865. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  72866. */
  72867. intensityMode: number;
  72868. private _radius;
  72869. /**
  72870. * Gets the light radius used by PBR Materials to simulate soft area lights.
  72871. */
  72872. /**
  72873. * sets the light radius used by PBR Materials to simulate soft area lights.
  72874. */
  72875. radius: number;
  72876. private _renderPriority;
  72877. /**
  72878. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  72879. * exceeding the number allowed of the materials.
  72880. */
  72881. renderPriority: number;
  72882. private _shadowEnabled;
  72883. /**
  72884. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  72885. * the current shadow generator.
  72886. */
  72887. /**
  72888. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  72889. * the current shadow generator.
  72890. */
  72891. shadowEnabled: boolean;
  72892. private _includedOnlyMeshes;
  72893. /**
  72894. * Gets the only meshes impacted by this light.
  72895. */
  72896. /**
  72897. * Sets the only meshes impacted by this light.
  72898. */
  72899. includedOnlyMeshes: AbstractMesh[];
  72900. private _excludedMeshes;
  72901. /**
  72902. * Gets the meshes not impacted by this light.
  72903. */
  72904. /**
  72905. * Sets the meshes not impacted by this light.
  72906. */
  72907. excludedMeshes: AbstractMesh[];
  72908. private _excludeWithLayerMask;
  72909. /**
  72910. * Gets the layer id use to find what meshes are not impacted by the light.
  72911. * Inactive if 0
  72912. */
  72913. /**
  72914. * Sets the layer id use to find what meshes are not impacted by the light.
  72915. * Inactive if 0
  72916. */
  72917. excludeWithLayerMask: number;
  72918. private _includeOnlyWithLayerMask;
  72919. /**
  72920. * Gets the layer id use to find what meshes are impacted by the light.
  72921. * Inactive if 0
  72922. */
  72923. /**
  72924. * Sets the layer id use to find what meshes are impacted by the light.
  72925. * Inactive if 0
  72926. */
  72927. includeOnlyWithLayerMask: number;
  72928. private _lightmapMode;
  72929. /**
  72930. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  72931. */
  72932. /**
  72933. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  72934. */
  72935. lightmapMode: number;
  72936. /**
  72937. * Shadow generator associted to the light.
  72938. * @hidden Internal use only.
  72939. */
  72940. _shadowGenerator: Nullable<IShadowGenerator>;
  72941. /**
  72942. * @hidden Internal use only.
  72943. */
  72944. _excludedMeshesIds: string[];
  72945. /**
  72946. * @hidden Internal use only.
  72947. */
  72948. _includedOnlyMeshesIds: string[];
  72949. /**
  72950. * The current light unifom buffer.
  72951. * @hidden Internal use only.
  72952. */
  72953. _uniformBuffer: UniformBuffer;
  72954. /**
  72955. * Creates a Light object in the scene.
  72956. * Documentation : https://doc.babylonjs.com/babylon101/lights
  72957. * @param name The firendly name of the light
  72958. * @param scene The scene the light belongs too
  72959. */
  72960. constructor(name: string, scene: Scene);
  72961. protected abstract _buildUniformLayout(): void;
  72962. /**
  72963. * Sets the passed Effect "effect" with the Light information.
  72964. * @param effect The effect to update
  72965. * @param lightIndex The index of the light in the effect to update
  72966. * @returns The light
  72967. */
  72968. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  72969. /**
  72970. * Returns the string "Light".
  72971. * @returns the class name
  72972. */
  72973. getClassName(): string;
  72974. /** @hidden */
  72975. readonly _isLight: boolean;
  72976. /**
  72977. * Converts the light information to a readable string for debug purpose.
  72978. * @param fullDetails Supports for multiple levels of logging within scene loading
  72979. * @returns the human readable light info
  72980. */
  72981. toString(fullDetails?: boolean): string;
  72982. /** @hidden */
  72983. protected _syncParentEnabledState(): void;
  72984. /**
  72985. * Set the enabled state of this node.
  72986. * @param value - the new enabled state
  72987. */
  72988. setEnabled(value: boolean): void;
  72989. /**
  72990. * Returns the Light associated shadow generator if any.
  72991. * @return the associated shadow generator.
  72992. */
  72993. getShadowGenerator(): Nullable<IShadowGenerator>;
  72994. /**
  72995. * Returns a Vector3, the absolute light position in the World.
  72996. * @returns the world space position of the light
  72997. */
  72998. getAbsolutePosition(): Vector3;
  72999. /**
  73000. * Specifies if the light will affect the passed mesh.
  73001. * @param mesh The mesh to test against the light
  73002. * @return true the mesh is affected otherwise, false.
  73003. */
  73004. canAffectMesh(mesh: AbstractMesh): boolean;
  73005. /**
  73006. * Sort function to order lights for rendering.
  73007. * @param a First Light object to compare to second.
  73008. * @param b Second Light object to compare first.
  73009. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  73010. */
  73011. static CompareLightsPriority(a: Light, b: Light): number;
  73012. /**
  73013. * Releases resources associated with this node.
  73014. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  73015. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  73016. */
  73017. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  73018. /**
  73019. * Returns the light type ID (integer).
  73020. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  73021. */
  73022. getTypeID(): number;
  73023. /**
  73024. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  73025. * @returns the scaled intensity in intensity mode unit
  73026. */
  73027. getScaledIntensity(): number;
  73028. /**
  73029. * Returns a new Light object, named "name", from the current one.
  73030. * @param name The name of the cloned light
  73031. * @returns the new created light
  73032. */
  73033. clone(name: string): Nullable<Light>;
  73034. /**
  73035. * Serializes the current light into a Serialization object.
  73036. * @returns the serialized object.
  73037. */
  73038. serialize(): any;
  73039. /**
  73040. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  73041. * This new light is named "name" and added to the passed scene.
  73042. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  73043. * @param name The friendly name of the light
  73044. * @param scene The scene the new light will belong to
  73045. * @returns the constructor function
  73046. */
  73047. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  73048. /**
  73049. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  73050. * @param parsedLight The JSON representation of the light
  73051. * @param scene The scene to create the parsed light in
  73052. * @returns the created light after parsing
  73053. */
  73054. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  73055. private _hookArrayForExcluded;
  73056. private _hookArrayForIncludedOnly;
  73057. private _resyncMeshes;
  73058. /**
  73059. * Forces the meshes to update their light related information in their rendering used effects
  73060. * @hidden Internal Use Only
  73061. */
  73062. _markMeshesAsLightDirty(): void;
  73063. /**
  73064. * Recomputes the cached photometric scale if needed.
  73065. */
  73066. private _computePhotometricScale;
  73067. /**
  73068. * Returns the Photometric Scale according to the light type and intensity mode.
  73069. */
  73070. private _getPhotometricScale;
  73071. /**
  73072. * Reorder the light in the scene according to their defined priority.
  73073. * @hidden Internal Use Only
  73074. */
  73075. _reorderLightsInScene(): void;
  73076. /**
  73077. * Prepares the list of defines specific to the light type.
  73078. * @param defines the list of defines
  73079. * @param lightIndex defines the index of the light for the effect
  73080. */
  73081. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  73082. }
  73083. }
  73084. declare module BABYLON {
  73085. /**
  73086. * Interface used to define Action
  73087. */
  73088. export interface IAction {
  73089. /**
  73090. * Trigger for the action
  73091. */
  73092. trigger: number;
  73093. /** Options of the trigger */
  73094. triggerOptions: any;
  73095. /**
  73096. * Gets the trigger parameters
  73097. * @returns the trigger parameters
  73098. */
  73099. getTriggerParameter(): any;
  73100. /**
  73101. * Internal only - executes current action event
  73102. * @hidden
  73103. */
  73104. _executeCurrent(evt?: ActionEvent): void;
  73105. /**
  73106. * Serialize placeholder for child classes
  73107. * @param parent of child
  73108. * @returns the serialized object
  73109. */
  73110. serialize(parent: any): any;
  73111. /**
  73112. * Internal only
  73113. * @hidden
  73114. */
  73115. _prepare(): void;
  73116. /**
  73117. * Internal only - manager for action
  73118. * @hidden
  73119. */
  73120. _actionManager: AbstractActionManager;
  73121. /**
  73122. * Adds action to chain of actions, may be a DoNothingAction
  73123. * @param action defines the next action to execute
  73124. * @returns The action passed in
  73125. * @see https://www.babylonjs-playground.com/#1T30HR#0
  73126. */
  73127. then(action: IAction): IAction;
  73128. }
  73129. /**
  73130. * The action to be carried out following a trigger
  73131. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  73132. */
  73133. export class Action implements IAction {
  73134. /** the trigger, with or without parameters, for the action */
  73135. triggerOptions: any;
  73136. /**
  73137. * Trigger for the action
  73138. */
  73139. trigger: number;
  73140. /**
  73141. * Internal only - manager for action
  73142. * @hidden
  73143. */
  73144. _actionManager: ActionManager;
  73145. private _nextActiveAction;
  73146. private _child;
  73147. private _condition?;
  73148. private _triggerParameter;
  73149. /**
  73150. * An event triggered prior to action being executed.
  73151. */
  73152. onBeforeExecuteObservable: Observable<Action>;
  73153. /**
  73154. * Creates a new Action
  73155. * @param triggerOptions the trigger, with or without parameters, for the action
  73156. * @param condition an optional determinant of action
  73157. */
  73158. constructor(
  73159. /** the trigger, with or without parameters, for the action */
  73160. triggerOptions: any, condition?: Condition);
  73161. /**
  73162. * Internal only
  73163. * @hidden
  73164. */
  73165. _prepare(): void;
  73166. /**
  73167. * Gets the trigger parameters
  73168. * @returns the trigger parameters
  73169. */
  73170. getTriggerParameter(): any;
  73171. /**
  73172. * Internal only - executes current action event
  73173. * @hidden
  73174. */
  73175. _executeCurrent(evt?: ActionEvent): void;
  73176. /**
  73177. * Execute placeholder for child classes
  73178. * @param evt optional action event
  73179. */
  73180. execute(evt?: ActionEvent): void;
  73181. /**
  73182. * Skips to next active action
  73183. */
  73184. skipToNextActiveAction(): void;
  73185. /**
  73186. * Adds action to chain of actions, may be a DoNothingAction
  73187. * @param action defines the next action to execute
  73188. * @returns The action passed in
  73189. * @see https://www.babylonjs-playground.com/#1T30HR#0
  73190. */
  73191. then(action: Action): Action;
  73192. /**
  73193. * Internal only
  73194. * @hidden
  73195. */
  73196. _getProperty(propertyPath: string): string;
  73197. /**
  73198. * Internal only
  73199. * @hidden
  73200. */
  73201. _getEffectiveTarget(target: any, propertyPath: string): any;
  73202. /**
  73203. * Serialize placeholder for child classes
  73204. * @param parent of child
  73205. * @returns the serialized object
  73206. */
  73207. serialize(parent: any): any;
  73208. /**
  73209. * Internal only called by serialize
  73210. * @hidden
  73211. */
  73212. protected _serialize(serializedAction: any, parent?: any): any;
  73213. /**
  73214. * Internal only
  73215. * @hidden
  73216. */
  73217. static _SerializeValueAsString: (value: any) => string;
  73218. /**
  73219. * Internal only
  73220. * @hidden
  73221. */
  73222. static _GetTargetProperty: (target: Scene | Node) => {
  73223. name: string;
  73224. targetType: string;
  73225. value: string;
  73226. };
  73227. }
  73228. }
  73229. declare module BABYLON {
  73230. /**
  73231. * A Condition applied to an Action
  73232. */
  73233. export class Condition {
  73234. /**
  73235. * Internal only - manager for action
  73236. * @hidden
  73237. */
  73238. _actionManager: ActionManager;
  73239. /**
  73240. * Internal only
  73241. * @hidden
  73242. */
  73243. _evaluationId: number;
  73244. /**
  73245. * Internal only
  73246. * @hidden
  73247. */
  73248. _currentResult: boolean;
  73249. /**
  73250. * Creates a new Condition
  73251. * @param actionManager the manager of the action the condition is applied to
  73252. */
  73253. constructor(actionManager: ActionManager);
  73254. /**
  73255. * Check if the current condition is valid
  73256. * @returns a boolean
  73257. */
  73258. isValid(): boolean;
  73259. /**
  73260. * Internal only
  73261. * @hidden
  73262. */
  73263. _getProperty(propertyPath: string): string;
  73264. /**
  73265. * Internal only
  73266. * @hidden
  73267. */
  73268. _getEffectiveTarget(target: any, propertyPath: string): any;
  73269. /**
  73270. * Serialize placeholder for child classes
  73271. * @returns the serialized object
  73272. */
  73273. serialize(): any;
  73274. /**
  73275. * Internal only
  73276. * @hidden
  73277. */
  73278. protected _serialize(serializedCondition: any): any;
  73279. }
  73280. /**
  73281. * Defines specific conditional operators as extensions of Condition
  73282. */
  73283. export class ValueCondition extends Condition {
  73284. /** path to specify the property of the target the conditional operator uses */
  73285. propertyPath: string;
  73286. /** the value compared by the conditional operator against the current value of the property */
  73287. value: any;
  73288. /** the conditional operator, default ValueCondition.IsEqual */
  73289. operator: number;
  73290. /**
  73291. * Internal only
  73292. * @hidden
  73293. */
  73294. private static _IsEqual;
  73295. /**
  73296. * Internal only
  73297. * @hidden
  73298. */
  73299. private static _IsDifferent;
  73300. /**
  73301. * Internal only
  73302. * @hidden
  73303. */
  73304. private static _IsGreater;
  73305. /**
  73306. * Internal only
  73307. * @hidden
  73308. */
  73309. private static _IsLesser;
  73310. /**
  73311. * returns the number for IsEqual
  73312. */
  73313. static readonly IsEqual: number;
  73314. /**
  73315. * Returns the number for IsDifferent
  73316. */
  73317. static readonly IsDifferent: number;
  73318. /**
  73319. * Returns the number for IsGreater
  73320. */
  73321. static readonly IsGreater: number;
  73322. /**
  73323. * Returns the number for IsLesser
  73324. */
  73325. static readonly IsLesser: number;
  73326. /**
  73327. * Internal only The action manager for the condition
  73328. * @hidden
  73329. */
  73330. _actionManager: ActionManager;
  73331. /**
  73332. * Internal only
  73333. * @hidden
  73334. */
  73335. private _target;
  73336. /**
  73337. * Internal only
  73338. * @hidden
  73339. */
  73340. private _effectiveTarget;
  73341. /**
  73342. * Internal only
  73343. * @hidden
  73344. */
  73345. private _property;
  73346. /**
  73347. * Creates a new ValueCondition
  73348. * @param actionManager manager for the action the condition applies to
  73349. * @param target for the action
  73350. * @param propertyPath path to specify the property of the target the conditional operator uses
  73351. * @param value the value compared by the conditional operator against the current value of the property
  73352. * @param operator the conditional operator, default ValueCondition.IsEqual
  73353. */
  73354. constructor(actionManager: ActionManager, target: any,
  73355. /** path to specify the property of the target the conditional operator uses */
  73356. propertyPath: string,
  73357. /** the value compared by the conditional operator against the current value of the property */
  73358. value: any,
  73359. /** the conditional operator, default ValueCondition.IsEqual */
  73360. operator?: number);
  73361. /**
  73362. * Compares the given value with the property value for the specified conditional operator
  73363. * @returns the result of the comparison
  73364. */
  73365. isValid(): boolean;
  73366. /**
  73367. * Serialize the ValueCondition into a JSON compatible object
  73368. * @returns serialization object
  73369. */
  73370. serialize(): any;
  73371. /**
  73372. * Gets the name of the conditional operator for the ValueCondition
  73373. * @param operator the conditional operator
  73374. * @returns the name
  73375. */
  73376. static GetOperatorName(operator: number): string;
  73377. }
  73378. /**
  73379. * Defines a predicate condition as an extension of Condition
  73380. */
  73381. export class PredicateCondition extends Condition {
  73382. /** defines the predicate function used to validate the condition */
  73383. predicate: () => boolean;
  73384. /**
  73385. * Internal only - manager for action
  73386. * @hidden
  73387. */
  73388. _actionManager: ActionManager;
  73389. /**
  73390. * Creates a new PredicateCondition
  73391. * @param actionManager manager for the action the condition applies to
  73392. * @param predicate defines the predicate function used to validate the condition
  73393. */
  73394. constructor(actionManager: ActionManager,
  73395. /** defines the predicate function used to validate the condition */
  73396. predicate: () => boolean);
  73397. /**
  73398. * @returns the validity of the predicate condition
  73399. */
  73400. isValid(): boolean;
  73401. }
  73402. /**
  73403. * Defines a state condition as an extension of Condition
  73404. */
  73405. export class StateCondition extends Condition {
  73406. /** Value to compare with target state */
  73407. value: string;
  73408. /**
  73409. * Internal only - manager for action
  73410. * @hidden
  73411. */
  73412. _actionManager: ActionManager;
  73413. /**
  73414. * Internal only
  73415. * @hidden
  73416. */
  73417. private _target;
  73418. /**
  73419. * Creates a new StateCondition
  73420. * @param actionManager manager for the action the condition applies to
  73421. * @param target of the condition
  73422. * @param value to compare with target state
  73423. */
  73424. constructor(actionManager: ActionManager, target: any,
  73425. /** Value to compare with target state */
  73426. value: string);
  73427. /**
  73428. * Gets a boolean indicating if the current condition is met
  73429. * @returns the validity of the state
  73430. */
  73431. isValid(): boolean;
  73432. /**
  73433. * Serialize the StateCondition into a JSON compatible object
  73434. * @returns serialization object
  73435. */
  73436. serialize(): any;
  73437. }
  73438. }
  73439. declare module BABYLON {
  73440. /**
  73441. * This defines an action responsible to toggle a boolean once triggered.
  73442. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73443. */
  73444. export class SwitchBooleanAction extends Action {
  73445. /**
  73446. * The path to the boolean property in the target object
  73447. */
  73448. propertyPath: string;
  73449. private _target;
  73450. private _effectiveTarget;
  73451. private _property;
  73452. /**
  73453. * Instantiate the action
  73454. * @param triggerOptions defines the trigger options
  73455. * @param target defines the object containing the boolean
  73456. * @param propertyPath defines the path to the boolean property in the target object
  73457. * @param condition defines the trigger related conditions
  73458. */
  73459. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  73460. /** @hidden */
  73461. _prepare(): void;
  73462. /**
  73463. * Execute the action toggle the boolean value.
  73464. */
  73465. execute(): void;
  73466. /**
  73467. * Serializes the actions and its related information.
  73468. * @param parent defines the object to serialize in
  73469. * @returns the serialized object
  73470. */
  73471. serialize(parent: any): any;
  73472. }
  73473. /**
  73474. * This defines an action responsible to set a the state field of the target
  73475. * to a desired value once triggered.
  73476. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73477. */
  73478. export class SetStateAction extends Action {
  73479. /**
  73480. * The value to store in the state field.
  73481. */
  73482. value: string;
  73483. private _target;
  73484. /**
  73485. * Instantiate the action
  73486. * @param triggerOptions defines the trigger options
  73487. * @param target defines the object containing the state property
  73488. * @param value defines the value to store in the state field
  73489. * @param condition defines the trigger related conditions
  73490. */
  73491. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  73492. /**
  73493. * Execute the action and store the value on the target state property.
  73494. */
  73495. execute(): void;
  73496. /**
  73497. * Serializes the actions and its related information.
  73498. * @param parent defines the object to serialize in
  73499. * @returns the serialized object
  73500. */
  73501. serialize(parent: any): any;
  73502. }
  73503. /**
  73504. * This defines an action responsible to set a property of the target
  73505. * to a desired value once triggered.
  73506. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73507. */
  73508. export class SetValueAction extends Action {
  73509. /**
  73510. * The path of the property to set in the target.
  73511. */
  73512. propertyPath: string;
  73513. /**
  73514. * The value to set in the property
  73515. */
  73516. value: any;
  73517. private _target;
  73518. private _effectiveTarget;
  73519. private _property;
  73520. /**
  73521. * Instantiate the action
  73522. * @param triggerOptions defines the trigger options
  73523. * @param target defines the object containing the property
  73524. * @param propertyPath defines the path of the property to set in the target
  73525. * @param value defines the value to set in the property
  73526. * @param condition defines the trigger related conditions
  73527. */
  73528. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  73529. /** @hidden */
  73530. _prepare(): void;
  73531. /**
  73532. * Execute the action and set the targetted property to the desired value.
  73533. */
  73534. execute(): void;
  73535. /**
  73536. * Serializes the actions and its related information.
  73537. * @param parent defines the object to serialize in
  73538. * @returns the serialized object
  73539. */
  73540. serialize(parent: any): any;
  73541. }
  73542. /**
  73543. * This defines an action responsible to increment the target value
  73544. * to a desired value once triggered.
  73545. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73546. */
  73547. export class IncrementValueAction extends Action {
  73548. /**
  73549. * The path of the property to increment in the target.
  73550. */
  73551. propertyPath: string;
  73552. /**
  73553. * The value we should increment the property by.
  73554. */
  73555. value: any;
  73556. private _target;
  73557. private _effectiveTarget;
  73558. private _property;
  73559. /**
  73560. * Instantiate the action
  73561. * @param triggerOptions defines the trigger options
  73562. * @param target defines the object containing the property
  73563. * @param propertyPath defines the path of the property to increment in the target
  73564. * @param value defines the value value we should increment the property by
  73565. * @param condition defines the trigger related conditions
  73566. */
  73567. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  73568. /** @hidden */
  73569. _prepare(): void;
  73570. /**
  73571. * Execute the action and increment the target of the value amount.
  73572. */
  73573. execute(): void;
  73574. /**
  73575. * Serializes the actions and its related information.
  73576. * @param parent defines the object to serialize in
  73577. * @returns the serialized object
  73578. */
  73579. serialize(parent: any): any;
  73580. }
  73581. /**
  73582. * This defines an action responsible to start an animation once triggered.
  73583. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73584. */
  73585. export class PlayAnimationAction extends Action {
  73586. /**
  73587. * Where the animation should start (animation frame)
  73588. */
  73589. from: number;
  73590. /**
  73591. * Where the animation should stop (animation frame)
  73592. */
  73593. to: number;
  73594. /**
  73595. * Define if the animation should loop or stop after the first play.
  73596. */
  73597. loop?: boolean;
  73598. private _target;
  73599. /**
  73600. * Instantiate the action
  73601. * @param triggerOptions defines the trigger options
  73602. * @param target defines the target animation or animation name
  73603. * @param from defines from where the animation should start (animation frame)
  73604. * @param end defines where the animation should stop (animation frame)
  73605. * @param loop defines if the animation should loop or stop after the first play
  73606. * @param condition defines the trigger related conditions
  73607. */
  73608. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  73609. /** @hidden */
  73610. _prepare(): void;
  73611. /**
  73612. * Execute the action and play the animation.
  73613. */
  73614. execute(): void;
  73615. /**
  73616. * Serializes the actions and its related information.
  73617. * @param parent defines the object to serialize in
  73618. * @returns the serialized object
  73619. */
  73620. serialize(parent: any): any;
  73621. }
  73622. /**
  73623. * This defines an action responsible to stop an animation once triggered.
  73624. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73625. */
  73626. export class StopAnimationAction extends Action {
  73627. private _target;
  73628. /**
  73629. * Instantiate the action
  73630. * @param triggerOptions defines the trigger options
  73631. * @param target defines the target animation or animation name
  73632. * @param condition defines the trigger related conditions
  73633. */
  73634. constructor(triggerOptions: any, target: any, condition?: Condition);
  73635. /** @hidden */
  73636. _prepare(): void;
  73637. /**
  73638. * Execute the action and stop the animation.
  73639. */
  73640. execute(): void;
  73641. /**
  73642. * Serializes the actions and its related information.
  73643. * @param parent defines the object to serialize in
  73644. * @returns the serialized object
  73645. */
  73646. serialize(parent: any): any;
  73647. }
  73648. /**
  73649. * This defines an action responsible that does nothing once triggered.
  73650. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73651. */
  73652. export class DoNothingAction extends Action {
  73653. /**
  73654. * Instantiate the action
  73655. * @param triggerOptions defines the trigger options
  73656. * @param condition defines the trigger related conditions
  73657. */
  73658. constructor(triggerOptions?: any, condition?: Condition);
  73659. /**
  73660. * Execute the action and do nothing.
  73661. */
  73662. execute(): void;
  73663. /**
  73664. * Serializes the actions and its related information.
  73665. * @param parent defines the object to serialize in
  73666. * @returns the serialized object
  73667. */
  73668. serialize(parent: any): any;
  73669. }
  73670. /**
  73671. * This defines an action responsible to trigger several actions once triggered.
  73672. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73673. */
  73674. export class CombineAction extends Action {
  73675. /**
  73676. * The list of aggregated animations to run.
  73677. */
  73678. children: Action[];
  73679. /**
  73680. * Instantiate the action
  73681. * @param triggerOptions defines the trigger options
  73682. * @param children defines the list of aggregated animations to run
  73683. * @param condition defines the trigger related conditions
  73684. */
  73685. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  73686. /** @hidden */
  73687. _prepare(): void;
  73688. /**
  73689. * Execute the action and executes all the aggregated actions.
  73690. */
  73691. execute(evt: ActionEvent): void;
  73692. /**
  73693. * Serializes the actions and its related information.
  73694. * @param parent defines the object to serialize in
  73695. * @returns the serialized object
  73696. */
  73697. serialize(parent: any): any;
  73698. }
  73699. /**
  73700. * This defines an action responsible to run code (external event) once triggered.
  73701. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73702. */
  73703. export class ExecuteCodeAction extends Action {
  73704. /**
  73705. * The callback function to run.
  73706. */
  73707. func: (evt: ActionEvent) => void;
  73708. /**
  73709. * Instantiate the action
  73710. * @param triggerOptions defines the trigger options
  73711. * @param func defines the callback function to run
  73712. * @param condition defines the trigger related conditions
  73713. */
  73714. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  73715. /**
  73716. * Execute the action and run the attached code.
  73717. */
  73718. execute(evt: ActionEvent): void;
  73719. }
  73720. /**
  73721. * This defines an action responsible to set the parent property of the target once triggered.
  73722. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73723. */
  73724. export class SetParentAction extends Action {
  73725. private _parent;
  73726. private _target;
  73727. /**
  73728. * Instantiate the action
  73729. * @param triggerOptions defines the trigger options
  73730. * @param target defines the target containing the parent property
  73731. * @param parent defines from where the animation should start (animation frame)
  73732. * @param condition defines the trigger related conditions
  73733. */
  73734. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  73735. /** @hidden */
  73736. _prepare(): void;
  73737. /**
  73738. * Execute the action and set the parent property.
  73739. */
  73740. execute(): void;
  73741. /**
  73742. * Serializes the actions and its related information.
  73743. * @param parent defines the object to serialize in
  73744. * @returns the serialized object
  73745. */
  73746. serialize(parent: any): any;
  73747. }
  73748. }
  73749. declare module BABYLON {
  73750. /**
  73751. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  73752. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  73753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73754. */
  73755. export class ActionManager extends AbstractActionManager {
  73756. /**
  73757. * Nothing
  73758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73759. */
  73760. static readonly NothingTrigger: number;
  73761. /**
  73762. * On pick
  73763. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73764. */
  73765. static readonly OnPickTrigger: number;
  73766. /**
  73767. * On left pick
  73768. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73769. */
  73770. static readonly OnLeftPickTrigger: number;
  73771. /**
  73772. * On right pick
  73773. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73774. */
  73775. static readonly OnRightPickTrigger: number;
  73776. /**
  73777. * On center pick
  73778. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73779. */
  73780. static readonly OnCenterPickTrigger: number;
  73781. /**
  73782. * On pick down
  73783. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73784. */
  73785. static readonly OnPickDownTrigger: number;
  73786. /**
  73787. * On double pick
  73788. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73789. */
  73790. static readonly OnDoublePickTrigger: number;
  73791. /**
  73792. * On pick up
  73793. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73794. */
  73795. static readonly OnPickUpTrigger: number;
  73796. /**
  73797. * On pick out.
  73798. * This trigger will only be raised if you also declared a OnPickDown
  73799. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73800. */
  73801. static readonly OnPickOutTrigger: number;
  73802. /**
  73803. * On long press
  73804. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73805. */
  73806. static readonly OnLongPressTrigger: number;
  73807. /**
  73808. * On pointer over
  73809. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73810. */
  73811. static readonly OnPointerOverTrigger: number;
  73812. /**
  73813. * On pointer out
  73814. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73815. */
  73816. static readonly OnPointerOutTrigger: number;
  73817. /**
  73818. * On every frame
  73819. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73820. */
  73821. static readonly OnEveryFrameTrigger: number;
  73822. /**
  73823. * On intersection enter
  73824. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73825. */
  73826. static readonly OnIntersectionEnterTrigger: number;
  73827. /**
  73828. * On intersection exit
  73829. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73830. */
  73831. static readonly OnIntersectionExitTrigger: number;
  73832. /**
  73833. * On key down
  73834. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73835. */
  73836. static readonly OnKeyDownTrigger: number;
  73837. /**
  73838. * On key up
  73839. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73840. */
  73841. static readonly OnKeyUpTrigger: number;
  73842. private _scene;
  73843. /**
  73844. * Creates a new action manager
  73845. * @param scene defines the hosting scene
  73846. */
  73847. constructor(scene: Scene);
  73848. /**
  73849. * Releases all associated resources
  73850. */
  73851. dispose(): void;
  73852. /**
  73853. * Gets hosting scene
  73854. * @returns the hosting scene
  73855. */
  73856. getScene(): Scene;
  73857. /**
  73858. * Does this action manager handles actions of any of the given triggers
  73859. * @param triggers defines the triggers to be tested
  73860. * @return a boolean indicating whether one (or more) of the triggers is handled
  73861. */
  73862. hasSpecificTriggers(triggers: number[]): boolean;
  73863. /**
  73864. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  73865. * speed.
  73866. * @param triggerA defines the trigger to be tested
  73867. * @param triggerB defines the trigger to be tested
  73868. * @return a boolean indicating whether one (or more) of the triggers is handled
  73869. */
  73870. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  73871. /**
  73872. * Does this action manager handles actions of a given trigger
  73873. * @param trigger defines the trigger to be tested
  73874. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  73875. * @return whether the trigger is handled
  73876. */
  73877. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  73878. /**
  73879. * Does this action manager has pointer triggers
  73880. */
  73881. readonly hasPointerTriggers: boolean;
  73882. /**
  73883. * Does this action manager has pick triggers
  73884. */
  73885. readonly hasPickTriggers: boolean;
  73886. /**
  73887. * Registers an action to this action manager
  73888. * @param action defines the action to be registered
  73889. * @return the action amended (prepared) after registration
  73890. */
  73891. registerAction(action: IAction): Nullable<IAction>;
  73892. /**
  73893. * Unregisters an action to this action manager
  73894. * @param action defines the action to be unregistered
  73895. * @return a boolean indicating whether the action has been unregistered
  73896. */
  73897. unregisterAction(action: IAction): Boolean;
  73898. /**
  73899. * Process a specific trigger
  73900. * @param trigger defines the trigger to process
  73901. * @param evt defines the event details to be processed
  73902. */
  73903. processTrigger(trigger: number, evt?: IActionEvent): void;
  73904. /** @hidden */
  73905. _getEffectiveTarget(target: any, propertyPath: string): any;
  73906. /** @hidden */
  73907. _getProperty(propertyPath: string): string;
  73908. /**
  73909. * Serialize this manager to a JSON object
  73910. * @param name defines the property name to store this manager
  73911. * @returns a JSON representation of this manager
  73912. */
  73913. serialize(name: string): any;
  73914. /**
  73915. * Creates a new ActionManager from a JSON data
  73916. * @param parsedActions defines the JSON data to read from
  73917. * @param object defines the hosting mesh
  73918. * @param scene defines the hosting scene
  73919. */
  73920. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  73921. /**
  73922. * Get a trigger name by index
  73923. * @param trigger defines the trigger index
  73924. * @returns a trigger name
  73925. */
  73926. static GetTriggerName(trigger: number): string;
  73927. }
  73928. }
  73929. declare module BABYLON {
  73930. /**
  73931. * Class representing a ray with position and direction
  73932. */
  73933. export class Ray {
  73934. /** origin point */
  73935. origin: Vector3;
  73936. /** direction */
  73937. direction: Vector3;
  73938. /** length of the ray */
  73939. length: number;
  73940. private static readonly TmpVector3;
  73941. private _tmpRay;
  73942. /**
  73943. * Creates a new ray
  73944. * @param origin origin point
  73945. * @param direction direction
  73946. * @param length length of the ray
  73947. */
  73948. constructor(
  73949. /** origin point */
  73950. origin: Vector3,
  73951. /** direction */
  73952. direction: Vector3,
  73953. /** length of the ray */
  73954. length?: number);
  73955. /**
  73956. * Checks if the ray intersects a box
  73957. * @param minimum bound of the box
  73958. * @param maximum bound of the box
  73959. * @param intersectionTreshold extra extend to be added to the box in all direction
  73960. * @returns if the box was hit
  73961. */
  73962. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  73963. /**
  73964. * Checks if the ray intersects a box
  73965. * @param box the bounding box to check
  73966. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  73967. * @returns if the box was hit
  73968. */
  73969. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  73970. /**
  73971. * If the ray hits a sphere
  73972. * @param sphere the bounding sphere to check
  73973. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  73974. * @returns true if it hits the sphere
  73975. */
  73976. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  73977. /**
  73978. * If the ray hits a triange
  73979. * @param vertex0 triangle vertex
  73980. * @param vertex1 triangle vertex
  73981. * @param vertex2 triangle vertex
  73982. * @returns intersection information if hit
  73983. */
  73984. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  73985. /**
  73986. * Checks if ray intersects a plane
  73987. * @param plane the plane to check
  73988. * @returns the distance away it was hit
  73989. */
  73990. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  73991. /**
  73992. * Checks if ray intersects a mesh
  73993. * @param mesh the mesh to check
  73994. * @param fastCheck if only the bounding box should checked
  73995. * @returns picking info of the intersecton
  73996. */
  73997. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  73998. /**
  73999. * Checks if ray intersects a mesh
  74000. * @param meshes the meshes to check
  74001. * @param fastCheck if only the bounding box should checked
  74002. * @param results array to store result in
  74003. * @returns Array of picking infos
  74004. */
  74005. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  74006. private _comparePickingInfo;
  74007. private static smallnum;
  74008. private static rayl;
  74009. /**
  74010. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  74011. * @param sega the first point of the segment to test the intersection against
  74012. * @param segb the second point of the segment to test the intersection against
  74013. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  74014. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  74015. */
  74016. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  74017. /**
  74018. * Update the ray from viewport position
  74019. * @param x position
  74020. * @param y y position
  74021. * @param viewportWidth viewport width
  74022. * @param viewportHeight viewport height
  74023. * @param world world matrix
  74024. * @param view view matrix
  74025. * @param projection projection matrix
  74026. * @returns this ray updated
  74027. */
  74028. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  74029. /**
  74030. * Creates a ray with origin and direction of 0,0,0
  74031. * @returns the new ray
  74032. */
  74033. static Zero(): Ray;
  74034. /**
  74035. * Creates a new ray from screen space and viewport
  74036. * @param x position
  74037. * @param y y position
  74038. * @param viewportWidth viewport width
  74039. * @param viewportHeight viewport height
  74040. * @param world world matrix
  74041. * @param view view matrix
  74042. * @param projection projection matrix
  74043. * @returns new ray
  74044. */
  74045. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  74046. /**
  74047. * 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
  74048. * transformed to the given world matrix.
  74049. * @param origin The origin point
  74050. * @param end The end point
  74051. * @param world a matrix to transform the ray to. Default is the identity matrix.
  74052. * @returns the new ray
  74053. */
  74054. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  74055. /**
  74056. * Transforms a ray by a matrix
  74057. * @param ray ray to transform
  74058. * @param matrix matrix to apply
  74059. * @returns the resulting new ray
  74060. */
  74061. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  74062. /**
  74063. * Transforms a ray by a matrix
  74064. * @param ray ray to transform
  74065. * @param matrix matrix to apply
  74066. * @param result ray to store result in
  74067. */
  74068. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  74069. /**
  74070. * Unproject a ray from screen space to object space
  74071. * @param sourceX defines the screen space x coordinate to use
  74072. * @param sourceY defines the screen space y coordinate to use
  74073. * @param viewportWidth defines the current width of the viewport
  74074. * @param viewportHeight defines the current height of the viewport
  74075. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  74076. * @param view defines the view matrix to use
  74077. * @param projection defines the projection matrix to use
  74078. */
  74079. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  74080. }
  74081. /**
  74082. * Type used to define predicate used to select faces when a mesh intersection is detected
  74083. */
  74084. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  74085. interface Scene {
  74086. /** @hidden */
  74087. _tempPickingRay: Nullable<Ray>;
  74088. /** @hidden */
  74089. _cachedRayForTransform: Ray;
  74090. /** @hidden */
  74091. _pickWithRayInverseMatrix: Matrix;
  74092. /** @hidden */
  74093. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  74094. /** @hidden */
  74095. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  74096. }
  74097. }
  74098. declare module BABYLON {
  74099. /**
  74100. * Groups all the scene component constants in one place to ease maintenance.
  74101. * @hidden
  74102. */
  74103. export class SceneComponentConstants {
  74104. static readonly NAME_EFFECTLAYER: string;
  74105. static readonly NAME_LAYER: string;
  74106. static readonly NAME_LENSFLARESYSTEM: string;
  74107. static readonly NAME_BOUNDINGBOXRENDERER: string;
  74108. static readonly NAME_PARTICLESYSTEM: string;
  74109. static readonly NAME_GAMEPAD: string;
  74110. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  74111. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  74112. static readonly NAME_DEPTHRENDERER: string;
  74113. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  74114. static readonly NAME_SPRITE: string;
  74115. static readonly NAME_OUTLINERENDERER: string;
  74116. static readonly NAME_PROCEDURALTEXTURE: string;
  74117. static readonly NAME_SHADOWGENERATOR: string;
  74118. static readonly NAME_OCTREE: string;
  74119. static readonly NAME_PHYSICSENGINE: string;
  74120. static readonly NAME_AUDIO: string;
  74121. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  74122. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  74123. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  74124. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  74125. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  74126. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  74127. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  74128. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  74129. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  74130. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  74131. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  74132. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  74133. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  74134. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  74135. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  74136. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  74137. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  74138. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  74139. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  74140. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  74141. static readonly STEP_AFTERRENDER_AUDIO: number;
  74142. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  74143. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  74144. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  74145. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  74146. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  74147. static readonly STEP_POINTERMOVE_SPRITE: number;
  74148. static readonly STEP_POINTERDOWN_SPRITE: number;
  74149. static readonly STEP_POINTERUP_SPRITE: number;
  74150. }
  74151. /**
  74152. * This represents a scene component.
  74153. *
  74154. * This is used to decouple the dependency the scene is having on the different workloads like
  74155. * layers, post processes...
  74156. */
  74157. export interface ISceneComponent {
  74158. /**
  74159. * The name of the component. Each component must have a unique name.
  74160. */
  74161. name: string;
  74162. /**
  74163. * The scene the component belongs to.
  74164. */
  74165. scene: Scene;
  74166. /**
  74167. * Register the component to one instance of a scene.
  74168. */
  74169. register(): void;
  74170. /**
  74171. * Rebuilds the elements related to this component in case of
  74172. * context lost for instance.
  74173. */
  74174. rebuild(): void;
  74175. /**
  74176. * Disposes the component and the associated ressources.
  74177. */
  74178. dispose(): void;
  74179. }
  74180. /**
  74181. * This represents a SERIALIZABLE scene component.
  74182. *
  74183. * This extends Scene Component to add Serialization methods on top.
  74184. */
  74185. export interface ISceneSerializableComponent extends ISceneComponent {
  74186. /**
  74187. * Adds all the elements from the container to the scene
  74188. * @param container the container holding the elements
  74189. */
  74190. addFromContainer(container: AbstractScene): void;
  74191. /**
  74192. * Removes all the elements in the container from the scene
  74193. * @param container contains the elements to remove
  74194. * @param dispose if the removed element should be disposed (default: false)
  74195. */
  74196. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  74197. /**
  74198. * Serializes the component data to the specified json object
  74199. * @param serializationObject The object to serialize to
  74200. */
  74201. serialize(serializationObject: any): void;
  74202. }
  74203. /**
  74204. * Strong typing of a Mesh related stage step action
  74205. */
  74206. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  74207. /**
  74208. * Strong typing of a Evaluate Sub Mesh related stage step action
  74209. */
  74210. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  74211. /**
  74212. * Strong typing of a Active Mesh related stage step action
  74213. */
  74214. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  74215. /**
  74216. * Strong typing of a Camera related stage step action
  74217. */
  74218. export type CameraStageAction = (camera: Camera) => void;
  74219. /**
  74220. * Strong typing of a Camera Frame buffer related stage step action
  74221. */
  74222. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  74223. /**
  74224. * Strong typing of a Render Target related stage step action
  74225. */
  74226. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  74227. /**
  74228. * Strong typing of a RenderingGroup related stage step action
  74229. */
  74230. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  74231. /**
  74232. * Strong typing of a Mesh Render related stage step action
  74233. */
  74234. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  74235. /**
  74236. * Strong typing of a simple stage step action
  74237. */
  74238. export type SimpleStageAction = () => void;
  74239. /**
  74240. * Strong typing of a render target action.
  74241. */
  74242. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  74243. /**
  74244. * Strong typing of a pointer move action.
  74245. */
  74246. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  74247. /**
  74248. * Strong typing of a pointer up/down action.
  74249. */
  74250. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  74251. /**
  74252. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  74253. * @hidden
  74254. */
  74255. export class Stage<T extends Function> extends Array<{
  74256. index: number;
  74257. component: ISceneComponent;
  74258. action: T;
  74259. }> {
  74260. /**
  74261. * Hide ctor from the rest of the world.
  74262. * @param items The items to add.
  74263. */
  74264. private constructor();
  74265. /**
  74266. * Creates a new Stage.
  74267. * @returns A new instance of a Stage
  74268. */
  74269. static Create<T extends Function>(): Stage<T>;
  74270. /**
  74271. * Registers a step in an ordered way in the targeted stage.
  74272. * @param index Defines the position to register the step in
  74273. * @param component Defines the component attached to the step
  74274. * @param action Defines the action to launch during the step
  74275. */
  74276. registerStep(index: number, component: ISceneComponent, action: T): void;
  74277. /**
  74278. * Clears all the steps from the stage.
  74279. */
  74280. clear(): void;
  74281. }
  74282. }
  74283. declare module BABYLON {
  74284. interface Scene {
  74285. /** @hidden */
  74286. _pointerOverSprite: Nullable<Sprite>;
  74287. /** @hidden */
  74288. _pickedDownSprite: Nullable<Sprite>;
  74289. /** @hidden */
  74290. _tempSpritePickingRay: Nullable<Ray>;
  74291. /**
  74292. * All of the sprite managers added to this scene
  74293. * @see http://doc.babylonjs.com/babylon101/sprites
  74294. */
  74295. spriteManagers: Array<ISpriteManager>;
  74296. /**
  74297. * An event triggered when sprites rendering is about to start
  74298. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  74299. */
  74300. onBeforeSpritesRenderingObservable: Observable<Scene>;
  74301. /**
  74302. * An event triggered when sprites rendering is done
  74303. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  74304. */
  74305. onAfterSpritesRenderingObservable: Observable<Scene>;
  74306. /** @hidden */
  74307. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  74308. /** Launch a ray to try to pick a sprite in the scene
  74309. * @param x position on screen
  74310. * @param y position on screen
  74311. * @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
  74312. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  74313. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  74314. * @returns a PickingInfo
  74315. */
  74316. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  74317. /** Use the given ray to pick a sprite in the scene
  74318. * @param ray The ray (in world space) to use to pick meshes
  74319. * @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
  74320. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  74321. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  74322. * @returns a PickingInfo
  74323. */
  74324. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  74325. /**
  74326. * Force the sprite under the pointer
  74327. * @param sprite defines the sprite to use
  74328. */
  74329. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  74330. /**
  74331. * Gets the sprite under the pointer
  74332. * @returns a Sprite or null if no sprite is under the pointer
  74333. */
  74334. getPointerOverSprite(): Nullable<Sprite>;
  74335. }
  74336. /**
  74337. * Defines the sprite scene component responsible to manage sprites
  74338. * in a given scene.
  74339. */
  74340. export class SpriteSceneComponent implements ISceneComponent {
  74341. /**
  74342. * The component name helpfull to identify the component in the list of scene components.
  74343. */
  74344. readonly name: string;
  74345. /**
  74346. * The scene the component belongs to.
  74347. */
  74348. scene: Scene;
  74349. /** @hidden */
  74350. private _spritePredicate;
  74351. /**
  74352. * Creates a new instance of the component for the given scene
  74353. * @param scene Defines the scene to register the component in
  74354. */
  74355. constructor(scene: Scene);
  74356. /**
  74357. * Registers the component in a given scene
  74358. */
  74359. register(): void;
  74360. /**
  74361. * Rebuilds the elements related to this component in case of
  74362. * context lost for instance.
  74363. */
  74364. rebuild(): void;
  74365. /**
  74366. * Disposes the component and the associated ressources.
  74367. */
  74368. dispose(): void;
  74369. private _pickSpriteButKeepRay;
  74370. private _pointerMove;
  74371. private _pointerDown;
  74372. private _pointerUp;
  74373. }
  74374. }
  74375. declare module BABYLON {
  74376. /** @hidden */
  74377. export var fogFragmentDeclaration: {
  74378. name: string;
  74379. shader: string;
  74380. };
  74381. }
  74382. declare module BABYLON {
  74383. /** @hidden */
  74384. export var fogFragment: {
  74385. name: string;
  74386. shader: string;
  74387. };
  74388. }
  74389. declare module BABYLON {
  74390. /** @hidden */
  74391. export var spritesPixelShader: {
  74392. name: string;
  74393. shader: string;
  74394. };
  74395. }
  74396. declare module BABYLON {
  74397. /** @hidden */
  74398. export var fogVertexDeclaration: {
  74399. name: string;
  74400. shader: string;
  74401. };
  74402. }
  74403. declare module BABYLON {
  74404. /** @hidden */
  74405. export var spritesVertexShader: {
  74406. name: string;
  74407. shader: string;
  74408. };
  74409. }
  74410. declare module BABYLON {
  74411. /**
  74412. * Defines the minimum interface to fullfil in order to be a sprite manager.
  74413. */
  74414. export interface ISpriteManager extends IDisposable {
  74415. /**
  74416. * Restricts the camera to viewing objects with the same layerMask.
  74417. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  74418. */
  74419. layerMask: number;
  74420. /**
  74421. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  74422. */
  74423. isPickable: boolean;
  74424. /**
  74425. * Specifies the rendering group id for this mesh (0 by default)
  74426. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  74427. */
  74428. renderingGroupId: number;
  74429. /**
  74430. * Defines the list of sprites managed by the manager.
  74431. */
  74432. sprites: Array<Sprite>;
  74433. /**
  74434. * Tests the intersection of a sprite with a specific ray.
  74435. * @param ray The ray we are sending to test the collision
  74436. * @param camera The camera space we are sending rays in
  74437. * @param predicate A predicate allowing excluding sprites from the list of object to test
  74438. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  74439. * @returns picking info or null.
  74440. */
  74441. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  74442. /**
  74443. * Renders the list of sprites on screen.
  74444. */
  74445. render(): void;
  74446. }
  74447. /**
  74448. * Class used to manage multiple sprites on the same spritesheet
  74449. * @see http://doc.babylonjs.com/babylon101/sprites
  74450. */
  74451. export class SpriteManager implements ISpriteManager {
  74452. /** defines the manager's name */
  74453. name: string;
  74454. /** Gets the list of sprites */
  74455. sprites: Sprite[];
  74456. /** Gets or sets the rendering group id (0 by default) */
  74457. renderingGroupId: number;
  74458. /** Gets or sets camera layer mask */
  74459. layerMask: number;
  74460. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  74461. fogEnabled: boolean;
  74462. /** Gets or sets a boolean indicating if the sprites are pickable */
  74463. isPickable: boolean;
  74464. /** Defines the default width of a cell in the spritesheet */
  74465. cellWidth: number;
  74466. /** Defines the default height of a cell in the spritesheet */
  74467. cellHeight: number;
  74468. /**
  74469. * An event triggered when the manager is disposed.
  74470. */
  74471. onDisposeObservable: Observable<SpriteManager>;
  74472. private _onDisposeObserver;
  74473. /**
  74474. * Callback called when the manager is disposed
  74475. */
  74476. onDispose: () => void;
  74477. private _capacity;
  74478. private _spriteTexture;
  74479. private _epsilon;
  74480. private _scene;
  74481. private _vertexData;
  74482. private _buffer;
  74483. private _vertexBuffers;
  74484. private _indexBuffer;
  74485. private _effectBase;
  74486. private _effectFog;
  74487. /**
  74488. * Gets or sets the spritesheet texture
  74489. */
  74490. texture: Texture;
  74491. /**
  74492. * Creates a new sprite manager
  74493. * @param name defines the manager's name
  74494. * @param imgUrl defines the sprite sheet url
  74495. * @param capacity defines the maximum allowed number of sprites
  74496. * @param cellSize defines the size of a sprite cell
  74497. * @param scene defines the hosting scene
  74498. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  74499. * @param samplingMode defines the smapling mode to use with spritesheet
  74500. */
  74501. constructor(
  74502. /** defines the manager's name */
  74503. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  74504. private _appendSpriteVertex;
  74505. /**
  74506. * Intersects the sprites with a ray
  74507. * @param ray defines the ray to intersect with
  74508. * @param camera defines the current active camera
  74509. * @param predicate defines a predicate used to select candidate sprites
  74510. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  74511. * @returns null if no hit or a PickingInfo
  74512. */
  74513. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  74514. /**
  74515. * Render all child sprites
  74516. */
  74517. render(): void;
  74518. /**
  74519. * Release associated resources
  74520. */
  74521. dispose(): void;
  74522. }
  74523. }
  74524. declare module BABYLON {
  74525. /**
  74526. * Class used to represent a sprite
  74527. * @see http://doc.babylonjs.com/babylon101/sprites
  74528. */
  74529. export class Sprite {
  74530. /** defines the name */
  74531. name: string;
  74532. /** Gets or sets the current world position */
  74533. position: Vector3;
  74534. /** Gets or sets the main color */
  74535. color: Color4;
  74536. /** Gets or sets the width */
  74537. width: number;
  74538. /** Gets or sets the height */
  74539. height: number;
  74540. /** Gets or sets rotation angle */
  74541. angle: number;
  74542. /** Gets or sets the cell index in the sprite sheet */
  74543. cellIndex: number;
  74544. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  74545. invertU: number;
  74546. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  74547. invertV: number;
  74548. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  74549. disposeWhenFinishedAnimating: boolean;
  74550. /** Gets the list of attached animations */
  74551. animations: Animation[];
  74552. /** Gets or sets a boolean indicating if the sprite can be picked */
  74553. isPickable: boolean;
  74554. /**
  74555. * Gets or sets the associated action manager
  74556. */
  74557. actionManager: Nullable<ActionManager>;
  74558. private _animationStarted;
  74559. private _loopAnimation;
  74560. private _fromIndex;
  74561. private _toIndex;
  74562. private _delay;
  74563. private _direction;
  74564. private _manager;
  74565. private _time;
  74566. private _onAnimationEnd;
  74567. /**
  74568. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  74569. */
  74570. isVisible: boolean;
  74571. /**
  74572. * Gets or sets the sprite size
  74573. */
  74574. size: number;
  74575. /**
  74576. * Creates a new Sprite
  74577. * @param name defines the name
  74578. * @param manager defines the manager
  74579. */
  74580. constructor(
  74581. /** defines the name */
  74582. name: string, manager: ISpriteManager);
  74583. /**
  74584. * Starts an animation
  74585. * @param from defines the initial key
  74586. * @param to defines the end key
  74587. * @param loop defines if the animation must loop
  74588. * @param delay defines the start delay (in ms)
  74589. * @param onAnimationEnd defines a callback to call when animation ends
  74590. */
  74591. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  74592. /** Stops current animation (if any) */
  74593. stopAnimation(): void;
  74594. /** @hidden */
  74595. _animate(deltaTime: number): void;
  74596. /** Release associated resources */
  74597. dispose(): void;
  74598. }
  74599. }
  74600. declare module BABYLON {
  74601. /**
  74602. * Information about the result of picking within a scene
  74603. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  74604. */
  74605. export class PickingInfo {
  74606. /** @hidden */
  74607. _pickingUnavailable: boolean;
  74608. /**
  74609. * If the pick collided with an object
  74610. */
  74611. hit: boolean;
  74612. /**
  74613. * Distance away where the pick collided
  74614. */
  74615. distance: number;
  74616. /**
  74617. * The location of pick collision
  74618. */
  74619. pickedPoint: Nullable<Vector3>;
  74620. /**
  74621. * The mesh corresponding the the pick collision
  74622. */
  74623. pickedMesh: Nullable<AbstractMesh>;
  74624. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  74625. bu: number;
  74626. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  74627. bv: number;
  74628. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  74629. faceId: number;
  74630. /** Id of the the submesh that was picked */
  74631. subMeshId: number;
  74632. /** If a sprite was picked, this will be the sprite the pick collided with */
  74633. pickedSprite: Nullable<Sprite>;
  74634. /**
  74635. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  74636. */
  74637. originMesh: Nullable<AbstractMesh>;
  74638. /**
  74639. * The ray that was used to perform the picking.
  74640. */
  74641. ray: Nullable<Ray>;
  74642. /**
  74643. * Gets the normal correspodning to the face the pick collided with
  74644. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  74645. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  74646. * @returns The normal correspodning to the face the pick collided with
  74647. */
  74648. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  74649. /**
  74650. * Gets the texture coordinates of where the pick occured
  74651. * @returns the vector containing the coordnates of the texture
  74652. */
  74653. getTextureCoordinates(): Nullable<Vector2>;
  74654. }
  74655. }
  74656. declare module BABYLON {
  74657. /**
  74658. * Gather the list of pointer event types as constants.
  74659. */
  74660. export class PointerEventTypes {
  74661. /**
  74662. * 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.
  74663. */
  74664. static readonly POINTERDOWN: number;
  74665. /**
  74666. * The pointerup event is fired when a pointer is no longer active.
  74667. */
  74668. static readonly POINTERUP: number;
  74669. /**
  74670. * The pointermove event is fired when a pointer changes coordinates.
  74671. */
  74672. static readonly POINTERMOVE: number;
  74673. /**
  74674. * The pointerwheel event is fired when a mouse wheel has been rotated.
  74675. */
  74676. static readonly POINTERWHEEL: number;
  74677. /**
  74678. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  74679. */
  74680. static readonly POINTERPICK: number;
  74681. /**
  74682. * The pointertap event is fired when a the object has been touched and released without drag.
  74683. */
  74684. static readonly POINTERTAP: number;
  74685. /**
  74686. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  74687. */
  74688. static readonly POINTERDOUBLETAP: number;
  74689. }
  74690. /**
  74691. * Base class of pointer info types.
  74692. */
  74693. export class PointerInfoBase {
  74694. /**
  74695. * Defines the type of event (PointerEventTypes)
  74696. */
  74697. type: number;
  74698. /**
  74699. * Defines the related dom event
  74700. */
  74701. event: PointerEvent | MouseWheelEvent;
  74702. /**
  74703. * Instantiates the base class of pointers info.
  74704. * @param type Defines the type of event (PointerEventTypes)
  74705. * @param event Defines the related dom event
  74706. */
  74707. constructor(
  74708. /**
  74709. * Defines the type of event (PointerEventTypes)
  74710. */
  74711. type: number,
  74712. /**
  74713. * Defines the related dom event
  74714. */
  74715. event: PointerEvent | MouseWheelEvent);
  74716. }
  74717. /**
  74718. * This class is used to store pointer related info for the onPrePointerObservable event.
  74719. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  74720. */
  74721. export class PointerInfoPre extends PointerInfoBase {
  74722. /**
  74723. * Ray from a pointer if availible (eg. 6dof controller)
  74724. */
  74725. ray: Nullable<Ray>;
  74726. /**
  74727. * Defines the local position of the pointer on the canvas.
  74728. */
  74729. localPosition: Vector2;
  74730. /**
  74731. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  74732. */
  74733. skipOnPointerObservable: boolean;
  74734. /**
  74735. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  74736. * @param type Defines the type of event (PointerEventTypes)
  74737. * @param event Defines the related dom event
  74738. * @param localX Defines the local x coordinates of the pointer when the event occured
  74739. * @param localY Defines the local y coordinates of the pointer when the event occured
  74740. */
  74741. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  74742. }
  74743. /**
  74744. * This type contains all the data related to a pointer event in Babylon.js.
  74745. * 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.
  74746. */
  74747. export class PointerInfo extends PointerInfoBase {
  74748. /**
  74749. * Defines the picking info associated to the info (if any)\
  74750. */
  74751. pickInfo: Nullable<PickingInfo>;
  74752. /**
  74753. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  74754. * @param type Defines the type of event (PointerEventTypes)
  74755. * @param event Defines the related dom event
  74756. * @param pickInfo Defines the picking info associated to the info (if any)\
  74757. */
  74758. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  74759. /**
  74760. * Defines the picking info associated to the info (if any)\
  74761. */
  74762. pickInfo: Nullable<PickingInfo>);
  74763. }
  74764. /**
  74765. * Data relating to a touch event on the screen.
  74766. */
  74767. export interface PointerTouch {
  74768. /**
  74769. * X coordinate of touch.
  74770. */
  74771. x: number;
  74772. /**
  74773. * Y coordinate of touch.
  74774. */
  74775. y: number;
  74776. /**
  74777. * Id of touch. Unique for each finger.
  74778. */
  74779. pointerId: number;
  74780. /**
  74781. * Event type passed from DOM.
  74782. */
  74783. type: any;
  74784. }
  74785. }
  74786. declare module BABYLON {
  74787. /**
  74788. * Manage the mouse inputs to control the movement of a free camera.
  74789. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74790. */
  74791. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  74792. /**
  74793. * Define if touch is enabled in the mouse input
  74794. */
  74795. touchEnabled: boolean;
  74796. /**
  74797. * Defines the camera the input is attached to.
  74798. */
  74799. camera: FreeCamera;
  74800. /**
  74801. * Defines the buttons associated with the input to handle camera move.
  74802. */
  74803. buttons: number[];
  74804. /**
  74805. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  74806. */
  74807. angularSensibility: number;
  74808. private _pointerInput;
  74809. private _onMouseMove;
  74810. private _observer;
  74811. private previousPosition;
  74812. /**
  74813. * Observable for when a pointer move event occurs containing the move offset
  74814. */
  74815. onPointerMovedObservable: Observable<{
  74816. offsetX: number;
  74817. offsetY: number;
  74818. }>;
  74819. /**
  74820. * @hidden
  74821. * If the camera should be rotated automatically based on pointer movement
  74822. */
  74823. _allowCameraRotation: boolean;
  74824. /**
  74825. * Manage the mouse inputs to control the movement of a free camera.
  74826. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74827. * @param touchEnabled Defines if touch is enabled or not
  74828. */
  74829. constructor(
  74830. /**
  74831. * Define if touch is enabled in the mouse input
  74832. */
  74833. touchEnabled?: boolean);
  74834. /**
  74835. * Attach the input controls to a specific dom element to get the input from.
  74836. * @param element Defines the element the controls should be listened from
  74837. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74838. */
  74839. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  74840. /**
  74841. * Called on JS contextmenu event.
  74842. * Override this method to provide functionality.
  74843. */
  74844. protected onContextMenu(evt: PointerEvent): void;
  74845. /**
  74846. * Detach the current controls from the specified dom element.
  74847. * @param element Defines the element to stop listening the inputs from
  74848. */
  74849. detachControl(element: Nullable<HTMLElement>): void;
  74850. /**
  74851. * Gets the class name of the current intput.
  74852. * @returns the class name
  74853. */
  74854. getClassName(): string;
  74855. /**
  74856. * Get the friendly name associated with the input class.
  74857. * @returns the input friendly name
  74858. */
  74859. getSimpleName(): string;
  74860. }
  74861. }
  74862. declare module BABYLON {
  74863. /**
  74864. * Manage the touch inputs to control the movement of a free camera.
  74865. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74866. */
  74867. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  74868. /**
  74869. * Defines the camera the input is attached to.
  74870. */
  74871. camera: FreeCamera;
  74872. /**
  74873. * Defines the touch sensibility for rotation.
  74874. * The higher the faster.
  74875. */
  74876. touchAngularSensibility: number;
  74877. /**
  74878. * Defines the touch sensibility for move.
  74879. * The higher the faster.
  74880. */
  74881. touchMoveSensibility: number;
  74882. private _offsetX;
  74883. private _offsetY;
  74884. private _pointerPressed;
  74885. private _pointerInput;
  74886. private _observer;
  74887. private _onLostFocus;
  74888. /**
  74889. * Attach the input controls to a specific dom element to get the input from.
  74890. * @param element Defines the element the controls should be listened from
  74891. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74892. */
  74893. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  74894. /**
  74895. * Detach the current controls from the specified dom element.
  74896. * @param element Defines the element to stop listening the inputs from
  74897. */
  74898. detachControl(element: Nullable<HTMLElement>): void;
  74899. /**
  74900. * Update the current camera state depending on the inputs that have been used this frame.
  74901. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74902. */
  74903. checkInputs(): void;
  74904. /**
  74905. * Gets the class name of the current intput.
  74906. * @returns the class name
  74907. */
  74908. getClassName(): string;
  74909. /**
  74910. * Get the friendly name associated with the input class.
  74911. * @returns the input friendly name
  74912. */
  74913. getSimpleName(): string;
  74914. }
  74915. }
  74916. declare module BABYLON {
  74917. /**
  74918. * Default Inputs manager for the FreeCamera.
  74919. * It groups all the default supported inputs for ease of use.
  74920. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74921. */
  74922. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  74923. /**
  74924. * @hidden
  74925. */
  74926. _mouseInput: Nullable<FreeCameraMouseInput>;
  74927. /**
  74928. * Instantiates a new FreeCameraInputsManager.
  74929. * @param camera Defines the camera the inputs belong to
  74930. */
  74931. constructor(camera: FreeCamera);
  74932. /**
  74933. * Add keyboard input support to the input manager.
  74934. * @returns the current input manager
  74935. */
  74936. addKeyboard(): FreeCameraInputsManager;
  74937. /**
  74938. * Add mouse input support to the input manager.
  74939. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  74940. * @returns the current input manager
  74941. */
  74942. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  74943. /**
  74944. * Removes the mouse input support from the manager
  74945. * @returns the current input manager
  74946. */
  74947. removeMouse(): FreeCameraInputsManager;
  74948. /**
  74949. * Add touch input support to the input manager.
  74950. * @returns the current input manager
  74951. */
  74952. addTouch(): FreeCameraInputsManager;
  74953. /**
  74954. * Remove all attached input methods from a camera
  74955. */
  74956. clear(): void;
  74957. }
  74958. }
  74959. declare module BABYLON {
  74960. /**
  74961. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  74962. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  74963. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  74964. */
  74965. export class FreeCamera extends TargetCamera {
  74966. /**
  74967. * Define the collision ellipsoid of the camera.
  74968. * This is helpful to simulate a camera body like the player body around the camera
  74969. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  74970. */
  74971. ellipsoid: Vector3;
  74972. /**
  74973. * Define an offset for the position of the ellipsoid around the camera.
  74974. * This can be helpful to determine the center of the body near the gravity center of the body
  74975. * instead of its head.
  74976. */
  74977. ellipsoidOffset: Vector3;
  74978. /**
  74979. * Enable or disable collisions of the camera with the rest of the scene objects.
  74980. */
  74981. checkCollisions: boolean;
  74982. /**
  74983. * Enable or disable gravity on the camera.
  74984. */
  74985. applyGravity: boolean;
  74986. /**
  74987. * Define the input manager associated to the camera.
  74988. */
  74989. inputs: FreeCameraInputsManager;
  74990. /**
  74991. * Gets the input sensibility for a mouse input. (default is 2000.0)
  74992. * Higher values reduce sensitivity.
  74993. */
  74994. /**
  74995. * Sets the input sensibility for a mouse input. (default is 2000.0)
  74996. * Higher values reduce sensitivity.
  74997. */
  74998. angularSensibility: number;
  74999. /**
  75000. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  75001. */
  75002. keysUp: number[];
  75003. /**
  75004. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  75005. */
  75006. keysDown: number[];
  75007. /**
  75008. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  75009. */
  75010. keysLeft: number[];
  75011. /**
  75012. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  75013. */
  75014. keysRight: number[];
  75015. /**
  75016. * Event raised when the camera collide with a mesh in the scene.
  75017. */
  75018. onCollide: (collidedMesh: AbstractMesh) => void;
  75019. private _collider;
  75020. private _needMoveForGravity;
  75021. private _oldPosition;
  75022. private _diffPosition;
  75023. private _newPosition;
  75024. /** @hidden */
  75025. _localDirection: Vector3;
  75026. /** @hidden */
  75027. _transformedDirection: Vector3;
  75028. /**
  75029. * Instantiates a Free Camera.
  75030. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  75031. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  75032. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  75033. * @param name Define the name of the camera in the scene
  75034. * @param position Define the start position of the camera in the scene
  75035. * @param scene Define the scene the camera belongs to
  75036. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  75037. */
  75038. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  75039. /**
  75040. * Attached controls to the current camera.
  75041. * @param element Defines the element the controls should be listened from
  75042. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75043. */
  75044. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75045. /**
  75046. * Detach the current controls from the camera.
  75047. * The camera will stop reacting to inputs.
  75048. * @param element Defines the element to stop listening the inputs from
  75049. */
  75050. detachControl(element: HTMLElement): void;
  75051. private _collisionMask;
  75052. /**
  75053. * Define a collision mask to limit the list of object the camera can collide with
  75054. */
  75055. collisionMask: number;
  75056. /** @hidden */
  75057. _collideWithWorld(displacement: Vector3): void;
  75058. private _onCollisionPositionChange;
  75059. /** @hidden */
  75060. _checkInputs(): void;
  75061. /** @hidden */
  75062. _decideIfNeedsToMove(): boolean;
  75063. /** @hidden */
  75064. _updatePosition(): void;
  75065. /**
  75066. * Destroy the camera and release the current resources hold by it.
  75067. */
  75068. dispose(): void;
  75069. /**
  75070. * Gets the current object class name.
  75071. * @return the class name
  75072. */
  75073. getClassName(): string;
  75074. }
  75075. }
  75076. declare module BABYLON {
  75077. /**
  75078. * Represents a gamepad control stick position
  75079. */
  75080. export class StickValues {
  75081. /**
  75082. * The x component of the control stick
  75083. */
  75084. x: number;
  75085. /**
  75086. * The y component of the control stick
  75087. */
  75088. y: number;
  75089. /**
  75090. * Initializes the gamepad x and y control stick values
  75091. * @param x The x component of the gamepad control stick value
  75092. * @param y The y component of the gamepad control stick value
  75093. */
  75094. constructor(
  75095. /**
  75096. * The x component of the control stick
  75097. */
  75098. x: number,
  75099. /**
  75100. * The y component of the control stick
  75101. */
  75102. y: number);
  75103. }
  75104. /**
  75105. * An interface which manages callbacks for gamepad button changes
  75106. */
  75107. export interface GamepadButtonChanges {
  75108. /**
  75109. * Called when a gamepad has been changed
  75110. */
  75111. changed: boolean;
  75112. /**
  75113. * Called when a gamepad press event has been triggered
  75114. */
  75115. pressChanged: boolean;
  75116. /**
  75117. * Called when a touch event has been triggered
  75118. */
  75119. touchChanged: boolean;
  75120. /**
  75121. * Called when a value has changed
  75122. */
  75123. valueChanged: boolean;
  75124. }
  75125. /**
  75126. * Represents a gamepad
  75127. */
  75128. export class Gamepad {
  75129. /**
  75130. * The id of the gamepad
  75131. */
  75132. id: string;
  75133. /**
  75134. * The index of the gamepad
  75135. */
  75136. index: number;
  75137. /**
  75138. * The browser gamepad
  75139. */
  75140. browserGamepad: any;
  75141. /**
  75142. * Specifies what type of gamepad this represents
  75143. */
  75144. type: number;
  75145. private _leftStick;
  75146. private _rightStick;
  75147. /** @hidden */
  75148. _isConnected: boolean;
  75149. private _leftStickAxisX;
  75150. private _leftStickAxisY;
  75151. private _rightStickAxisX;
  75152. private _rightStickAxisY;
  75153. /**
  75154. * Triggered when the left control stick has been changed
  75155. */
  75156. private _onleftstickchanged;
  75157. /**
  75158. * Triggered when the right control stick has been changed
  75159. */
  75160. private _onrightstickchanged;
  75161. /**
  75162. * Represents a gamepad controller
  75163. */
  75164. static GAMEPAD: number;
  75165. /**
  75166. * Represents a generic controller
  75167. */
  75168. static GENERIC: number;
  75169. /**
  75170. * Represents an XBox controller
  75171. */
  75172. static XBOX: number;
  75173. /**
  75174. * Represents a pose-enabled controller
  75175. */
  75176. static POSE_ENABLED: number;
  75177. /**
  75178. * Specifies whether the left control stick should be Y-inverted
  75179. */
  75180. protected _invertLeftStickY: boolean;
  75181. /**
  75182. * Specifies if the gamepad has been connected
  75183. */
  75184. readonly isConnected: boolean;
  75185. /**
  75186. * Initializes the gamepad
  75187. * @param id The id of the gamepad
  75188. * @param index The index of the gamepad
  75189. * @param browserGamepad The browser gamepad
  75190. * @param leftStickX The x component of the left joystick
  75191. * @param leftStickY The y component of the left joystick
  75192. * @param rightStickX The x component of the right joystick
  75193. * @param rightStickY The y component of the right joystick
  75194. */
  75195. constructor(
  75196. /**
  75197. * The id of the gamepad
  75198. */
  75199. id: string,
  75200. /**
  75201. * The index of the gamepad
  75202. */
  75203. index: number,
  75204. /**
  75205. * The browser gamepad
  75206. */
  75207. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  75208. /**
  75209. * Callback triggered when the left joystick has changed
  75210. * @param callback
  75211. */
  75212. onleftstickchanged(callback: (values: StickValues) => void): void;
  75213. /**
  75214. * Callback triggered when the right joystick has changed
  75215. * @param callback
  75216. */
  75217. onrightstickchanged(callback: (values: StickValues) => void): void;
  75218. /**
  75219. * Gets the left joystick
  75220. */
  75221. /**
  75222. * Sets the left joystick values
  75223. */
  75224. leftStick: StickValues;
  75225. /**
  75226. * Gets the right joystick
  75227. */
  75228. /**
  75229. * Sets the right joystick value
  75230. */
  75231. rightStick: StickValues;
  75232. /**
  75233. * Updates the gamepad joystick positions
  75234. */
  75235. update(): void;
  75236. /**
  75237. * Disposes the gamepad
  75238. */
  75239. dispose(): void;
  75240. }
  75241. /**
  75242. * Represents a generic gamepad
  75243. */
  75244. export class GenericPad extends Gamepad {
  75245. private _buttons;
  75246. private _onbuttondown;
  75247. private _onbuttonup;
  75248. /**
  75249. * Observable triggered when a button has been pressed
  75250. */
  75251. onButtonDownObservable: Observable<number>;
  75252. /**
  75253. * Observable triggered when a button has been released
  75254. */
  75255. onButtonUpObservable: Observable<number>;
  75256. /**
  75257. * Callback triggered when a button has been pressed
  75258. * @param callback Called when a button has been pressed
  75259. */
  75260. onbuttondown(callback: (buttonPressed: number) => void): void;
  75261. /**
  75262. * Callback triggered when a button has been released
  75263. * @param callback Called when a button has been released
  75264. */
  75265. onbuttonup(callback: (buttonReleased: number) => void): void;
  75266. /**
  75267. * Initializes the generic gamepad
  75268. * @param id The id of the generic gamepad
  75269. * @param index The index of the generic gamepad
  75270. * @param browserGamepad The browser gamepad
  75271. */
  75272. constructor(id: string, index: number, browserGamepad: any);
  75273. private _setButtonValue;
  75274. /**
  75275. * Updates the generic gamepad
  75276. */
  75277. update(): void;
  75278. /**
  75279. * Disposes the generic gamepad
  75280. */
  75281. dispose(): void;
  75282. }
  75283. }
  75284. declare module BABYLON {
  75285. /**
  75286. * Defines the types of pose enabled controllers that are supported
  75287. */
  75288. export enum PoseEnabledControllerType {
  75289. /**
  75290. * HTC Vive
  75291. */
  75292. VIVE = 0,
  75293. /**
  75294. * Oculus Rift
  75295. */
  75296. OCULUS = 1,
  75297. /**
  75298. * Windows mixed reality
  75299. */
  75300. WINDOWS = 2,
  75301. /**
  75302. * Samsung gear VR
  75303. */
  75304. GEAR_VR = 3,
  75305. /**
  75306. * Google Daydream
  75307. */
  75308. DAYDREAM = 4,
  75309. /**
  75310. * Generic
  75311. */
  75312. GENERIC = 5
  75313. }
  75314. /**
  75315. * Defines the MutableGamepadButton interface for the state of a gamepad button
  75316. */
  75317. export interface MutableGamepadButton {
  75318. /**
  75319. * Value of the button/trigger
  75320. */
  75321. value: number;
  75322. /**
  75323. * If the button/trigger is currently touched
  75324. */
  75325. touched: boolean;
  75326. /**
  75327. * If the button/trigger is currently pressed
  75328. */
  75329. pressed: boolean;
  75330. }
  75331. /**
  75332. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  75333. * @hidden
  75334. */
  75335. export interface ExtendedGamepadButton extends GamepadButton {
  75336. /**
  75337. * If the button/trigger is currently pressed
  75338. */
  75339. readonly pressed: boolean;
  75340. /**
  75341. * If the button/trigger is currently touched
  75342. */
  75343. readonly touched: boolean;
  75344. /**
  75345. * Value of the button/trigger
  75346. */
  75347. readonly value: number;
  75348. }
  75349. /** @hidden */
  75350. export interface _GamePadFactory {
  75351. /**
  75352. * Returns wether or not the current gamepad can be created for this type of controller.
  75353. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  75354. * @returns true if it can be created, otherwise false
  75355. */
  75356. canCreate(gamepadInfo: any): boolean;
  75357. /**
  75358. * Creates a new instance of the Gamepad.
  75359. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  75360. * @returns the new gamepad instance
  75361. */
  75362. create(gamepadInfo: any): Gamepad;
  75363. }
  75364. /**
  75365. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  75366. */
  75367. export class PoseEnabledControllerHelper {
  75368. /** @hidden */
  75369. static _ControllerFactories: _GamePadFactory[];
  75370. /** @hidden */
  75371. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  75372. /**
  75373. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  75374. * @param vrGamepad the gamepad to initialized
  75375. * @returns a vr controller of the type the gamepad identified as
  75376. */
  75377. static InitiateController(vrGamepad: any): Gamepad;
  75378. }
  75379. /**
  75380. * Defines the PoseEnabledController object that contains state of a vr capable controller
  75381. */
  75382. export class PoseEnabledController extends Gamepad implements PoseControlled {
  75383. private _deviceRoomPosition;
  75384. private _deviceRoomRotationQuaternion;
  75385. /**
  75386. * The device position in babylon space
  75387. */
  75388. devicePosition: Vector3;
  75389. /**
  75390. * The device rotation in babylon space
  75391. */
  75392. deviceRotationQuaternion: Quaternion;
  75393. /**
  75394. * The scale factor of the device in babylon space
  75395. */
  75396. deviceScaleFactor: number;
  75397. /**
  75398. * (Likely devicePosition should be used instead) The device position in its room space
  75399. */
  75400. position: Vector3;
  75401. /**
  75402. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  75403. */
  75404. rotationQuaternion: Quaternion;
  75405. /**
  75406. * The type of controller (Eg. Windows mixed reality)
  75407. */
  75408. controllerType: PoseEnabledControllerType;
  75409. protected _calculatedPosition: Vector3;
  75410. private _calculatedRotation;
  75411. /**
  75412. * The raw pose from the device
  75413. */
  75414. rawPose: DevicePose;
  75415. private _trackPosition;
  75416. private _maxRotationDistFromHeadset;
  75417. private _draggedRoomRotation;
  75418. /**
  75419. * @hidden
  75420. */
  75421. _disableTrackPosition(fixedPosition: Vector3): void;
  75422. /**
  75423. * Internal, the mesh attached to the controller
  75424. * @hidden
  75425. */
  75426. _mesh: Nullable<AbstractMesh>;
  75427. private _poseControlledCamera;
  75428. private _leftHandSystemQuaternion;
  75429. /**
  75430. * Internal, matrix used to convert room space to babylon space
  75431. * @hidden
  75432. */
  75433. _deviceToWorld: Matrix;
  75434. /**
  75435. * Node to be used when casting a ray from the controller
  75436. * @hidden
  75437. */
  75438. _pointingPoseNode: Nullable<TransformNode>;
  75439. /**
  75440. * Name of the child mesh that can be used to cast a ray from the controller
  75441. */
  75442. static readonly POINTING_POSE: string;
  75443. /**
  75444. * Creates a new PoseEnabledController from a gamepad
  75445. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  75446. */
  75447. constructor(browserGamepad: any);
  75448. private _workingMatrix;
  75449. /**
  75450. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  75451. */
  75452. update(): void;
  75453. /**
  75454. * Updates only the pose device and mesh without doing any button event checking
  75455. */
  75456. protected _updatePoseAndMesh(): void;
  75457. /**
  75458. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  75459. * @param poseData raw pose fromthe device
  75460. */
  75461. updateFromDevice(poseData: DevicePose): void;
  75462. /**
  75463. * @hidden
  75464. */
  75465. _meshAttachedObservable: Observable<AbstractMesh>;
  75466. /**
  75467. * Attaches a mesh to the controller
  75468. * @param mesh the mesh to be attached
  75469. */
  75470. attachToMesh(mesh: AbstractMesh): void;
  75471. /**
  75472. * Attaches the controllers mesh to a camera
  75473. * @param camera the camera the mesh should be attached to
  75474. */
  75475. attachToPoseControlledCamera(camera: TargetCamera): void;
  75476. /**
  75477. * Disposes of the controller
  75478. */
  75479. dispose(): void;
  75480. /**
  75481. * The mesh that is attached to the controller
  75482. */
  75483. readonly mesh: Nullable<AbstractMesh>;
  75484. /**
  75485. * Gets the ray of the controller in the direction the controller is pointing
  75486. * @param length the length the resulting ray should be
  75487. * @returns a ray in the direction the controller is pointing
  75488. */
  75489. getForwardRay(length?: number): Ray;
  75490. }
  75491. }
  75492. declare module BABYLON {
  75493. /**
  75494. * Defines the WebVRController object that represents controllers tracked in 3D space
  75495. */
  75496. export abstract class WebVRController extends PoseEnabledController {
  75497. /**
  75498. * Internal, the default controller model for the controller
  75499. */
  75500. protected _defaultModel: AbstractMesh;
  75501. /**
  75502. * Fired when the trigger state has changed
  75503. */
  75504. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  75505. /**
  75506. * Fired when the main button state has changed
  75507. */
  75508. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  75509. /**
  75510. * Fired when the secondary button state has changed
  75511. */
  75512. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  75513. /**
  75514. * Fired when the pad state has changed
  75515. */
  75516. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  75517. /**
  75518. * Fired when controllers stick values have changed
  75519. */
  75520. onPadValuesChangedObservable: Observable<StickValues>;
  75521. /**
  75522. * Array of button availible on the controller
  75523. */
  75524. protected _buttons: Array<MutableGamepadButton>;
  75525. private _onButtonStateChange;
  75526. /**
  75527. * Fired when a controller button's state has changed
  75528. * @param callback the callback containing the button that was modified
  75529. */
  75530. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  75531. /**
  75532. * X and Y axis corrisponding to the controllers joystick
  75533. */
  75534. pad: StickValues;
  75535. /**
  75536. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  75537. */
  75538. hand: string;
  75539. /**
  75540. * The default controller model for the controller
  75541. */
  75542. readonly defaultModel: AbstractMesh;
  75543. /**
  75544. * Creates a new WebVRController from a gamepad
  75545. * @param vrGamepad the gamepad that the WebVRController should be created from
  75546. */
  75547. constructor(vrGamepad: any);
  75548. /**
  75549. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  75550. */
  75551. update(): void;
  75552. /**
  75553. * Function to be called when a button is modified
  75554. */
  75555. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  75556. /**
  75557. * Loads a mesh and attaches it to the controller
  75558. * @param scene the scene the mesh should be added to
  75559. * @param meshLoaded callback for when the mesh has been loaded
  75560. */
  75561. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  75562. private _setButtonValue;
  75563. private _changes;
  75564. private _checkChanges;
  75565. /**
  75566. * Disposes of th webVRCOntroller
  75567. */
  75568. dispose(): void;
  75569. }
  75570. }
  75571. declare module BABYLON {
  75572. /**
  75573. * The HemisphericLight simulates the ambient environment light,
  75574. * so the passed direction is the light reflection direction, not the incoming direction.
  75575. */
  75576. export class HemisphericLight extends Light {
  75577. /**
  75578. * The groundColor is the light in the opposite direction to the one specified during creation.
  75579. * 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.
  75580. */
  75581. groundColor: Color3;
  75582. /**
  75583. * The light reflection direction, not the incoming direction.
  75584. */
  75585. direction: Vector3;
  75586. /**
  75587. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  75588. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  75589. * The HemisphericLight can't cast shadows.
  75590. * Documentation : https://doc.babylonjs.com/babylon101/lights
  75591. * @param name The friendly name of the light
  75592. * @param direction The direction of the light reflection
  75593. * @param scene The scene the light belongs to
  75594. */
  75595. constructor(name: string, direction: Vector3, scene: Scene);
  75596. protected _buildUniformLayout(): void;
  75597. /**
  75598. * Returns the string "HemisphericLight".
  75599. * @return The class name
  75600. */
  75601. getClassName(): string;
  75602. /**
  75603. * Sets the HemisphericLight direction towards the passed target (Vector3).
  75604. * Returns the updated direction.
  75605. * @param target The target the direction should point to
  75606. * @return The computed direction
  75607. */
  75608. setDirectionToTarget(target: Vector3): Vector3;
  75609. /**
  75610. * Returns the shadow generator associated to the light.
  75611. * @returns Always null for hemispheric lights because it does not support shadows.
  75612. */
  75613. getShadowGenerator(): Nullable<IShadowGenerator>;
  75614. /**
  75615. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  75616. * @param effect The effect to update
  75617. * @param lightIndex The index of the light in the effect to update
  75618. * @returns The hemispheric light
  75619. */
  75620. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  75621. /**
  75622. * Computes the world matrix of the node
  75623. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  75624. * @param useWasUpdatedFlag defines a reserved property
  75625. * @returns the world matrix
  75626. */
  75627. computeWorldMatrix(): Matrix;
  75628. /**
  75629. * Returns the integer 3.
  75630. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  75631. */
  75632. getTypeID(): number;
  75633. /**
  75634. * Prepares the list of defines specific to the light type.
  75635. * @param defines the list of defines
  75636. * @param lightIndex defines the index of the light for the effect
  75637. */
  75638. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  75639. }
  75640. }
  75641. declare module BABYLON {
  75642. /** @hidden */
  75643. export var vrMultiviewToSingleviewPixelShader: {
  75644. name: string;
  75645. shader: string;
  75646. };
  75647. }
  75648. declare module BABYLON {
  75649. /**
  75650. * Renders to multiple views with a single draw call
  75651. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  75652. */
  75653. export class MultiviewRenderTarget extends RenderTargetTexture {
  75654. /**
  75655. * Creates a multiview render target
  75656. * @param scene scene used with the render target
  75657. * @param size the size of the render target (used for each view)
  75658. */
  75659. constructor(scene: Scene, size?: number | {
  75660. width: number;
  75661. height: number;
  75662. } | {
  75663. ratio: number;
  75664. });
  75665. /**
  75666. * @hidden
  75667. * @param faceIndex the face index, if its a cube texture
  75668. */
  75669. _bindFrameBuffer(faceIndex?: number): void;
  75670. /**
  75671. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  75672. * @returns the view count
  75673. */
  75674. getViewCount(): number;
  75675. }
  75676. }
  75677. declare module BABYLON {
  75678. interface Engine {
  75679. /**
  75680. * Creates a new multiview render target
  75681. * @param width defines the width of the texture
  75682. * @param height defines the height of the texture
  75683. * @returns the created multiview texture
  75684. */
  75685. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  75686. /**
  75687. * Binds a multiview framebuffer to be drawn to
  75688. * @param multiviewTexture texture to bind
  75689. */
  75690. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  75691. }
  75692. interface Camera {
  75693. /**
  75694. * @hidden
  75695. * 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)
  75696. */
  75697. _useMultiviewToSingleView: boolean;
  75698. /**
  75699. * @hidden
  75700. * 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)
  75701. */
  75702. _multiviewTexture: Nullable<RenderTargetTexture>;
  75703. /**
  75704. * @hidden
  75705. * ensures the multiview texture of the camera exists and has the specified width/height
  75706. * @param width height to set on the multiview texture
  75707. * @param height width to set on the multiview texture
  75708. */
  75709. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  75710. }
  75711. interface Scene {
  75712. /** @hidden */
  75713. _transformMatrixR: Matrix;
  75714. /** @hidden */
  75715. _multiviewSceneUbo: Nullable<UniformBuffer>;
  75716. /** @hidden */
  75717. _createMultiviewUbo(): void;
  75718. /** @hidden */
  75719. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  75720. /** @hidden */
  75721. _renderMultiviewToSingleView(camera: Camera): void;
  75722. }
  75723. }
  75724. declare module BABYLON {
  75725. /**
  75726. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  75727. * This will not be used for webXR as it supports displaying texture arrays directly
  75728. */
  75729. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  75730. /**
  75731. * Initializes a VRMultiviewToSingleview
  75732. * @param name name of the post process
  75733. * @param camera camera to be applied to
  75734. * @param scaleFactor scaling factor to the size of the output texture
  75735. */
  75736. constructor(name: string, camera: Camera, scaleFactor: number);
  75737. }
  75738. }
  75739. declare module BABYLON {
  75740. interface Engine {
  75741. /** @hidden */
  75742. _vrDisplay: any;
  75743. /** @hidden */
  75744. _vrSupported: boolean;
  75745. /** @hidden */
  75746. _oldSize: Size;
  75747. /** @hidden */
  75748. _oldHardwareScaleFactor: number;
  75749. /** @hidden */
  75750. _vrExclusivePointerMode: boolean;
  75751. /** @hidden */
  75752. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  75753. /** @hidden */
  75754. _onVRDisplayPointerRestricted: () => void;
  75755. /** @hidden */
  75756. _onVRDisplayPointerUnrestricted: () => void;
  75757. /** @hidden */
  75758. _onVrDisplayConnect: Nullable<(display: any) => void>;
  75759. /** @hidden */
  75760. _onVrDisplayDisconnect: Nullable<() => void>;
  75761. /** @hidden */
  75762. _onVrDisplayPresentChange: Nullable<() => void>;
  75763. /**
  75764. * Observable signaled when VR display mode changes
  75765. */
  75766. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  75767. /**
  75768. * Observable signaled when VR request present is complete
  75769. */
  75770. onVRRequestPresentComplete: Observable<boolean>;
  75771. /**
  75772. * Observable signaled when VR request present starts
  75773. */
  75774. onVRRequestPresentStart: Observable<Engine>;
  75775. /**
  75776. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  75777. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  75778. */
  75779. isInVRExclusivePointerMode: boolean;
  75780. /**
  75781. * Gets a boolean indicating if a webVR device was detected
  75782. * @returns true if a webVR device was detected
  75783. */
  75784. isVRDevicePresent(): boolean;
  75785. /**
  75786. * Gets the current webVR device
  75787. * @returns the current webVR device (or null)
  75788. */
  75789. getVRDevice(): any;
  75790. /**
  75791. * Initializes a webVR display and starts listening to display change events
  75792. * The onVRDisplayChangedObservable will be notified upon these changes
  75793. * @returns A promise containing a VRDisplay and if vr is supported
  75794. */
  75795. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  75796. /** @hidden */
  75797. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  75798. /**
  75799. * Call this function to switch to webVR mode
  75800. * Will do nothing if webVR is not supported or if there is no webVR device
  75801. * @see http://doc.babylonjs.com/how_to/webvr_camera
  75802. */
  75803. enableVR(): void;
  75804. /** @hidden */
  75805. _onVRFullScreenTriggered(): void;
  75806. }
  75807. }
  75808. declare module BABYLON {
  75809. /**
  75810. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  75811. * IMPORTANT!! The data is right-hand data.
  75812. * @export
  75813. * @interface DevicePose
  75814. */
  75815. export interface DevicePose {
  75816. /**
  75817. * The position of the device, values in array are [x,y,z].
  75818. */
  75819. readonly position: Nullable<Float32Array>;
  75820. /**
  75821. * The linearVelocity of the device, values in array are [x,y,z].
  75822. */
  75823. readonly linearVelocity: Nullable<Float32Array>;
  75824. /**
  75825. * The linearAcceleration of the device, values in array are [x,y,z].
  75826. */
  75827. readonly linearAcceleration: Nullable<Float32Array>;
  75828. /**
  75829. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  75830. */
  75831. readonly orientation: Nullable<Float32Array>;
  75832. /**
  75833. * The angularVelocity of the device, values in array are [x,y,z].
  75834. */
  75835. readonly angularVelocity: Nullable<Float32Array>;
  75836. /**
  75837. * The angularAcceleration of the device, values in array are [x,y,z].
  75838. */
  75839. readonly angularAcceleration: Nullable<Float32Array>;
  75840. }
  75841. /**
  75842. * Interface representing a pose controlled object in Babylon.
  75843. * A pose controlled object has both regular pose values as well as pose values
  75844. * from an external device such as a VR head mounted display
  75845. */
  75846. export interface PoseControlled {
  75847. /**
  75848. * The position of the object in babylon space.
  75849. */
  75850. position: Vector3;
  75851. /**
  75852. * The rotation quaternion of the object in babylon space.
  75853. */
  75854. rotationQuaternion: Quaternion;
  75855. /**
  75856. * The position of the device in babylon space.
  75857. */
  75858. devicePosition?: Vector3;
  75859. /**
  75860. * The rotation quaternion of the device in babylon space.
  75861. */
  75862. deviceRotationQuaternion: Quaternion;
  75863. /**
  75864. * The raw pose coming from the device.
  75865. */
  75866. rawPose: Nullable<DevicePose>;
  75867. /**
  75868. * The scale of the device to be used when translating from device space to babylon space.
  75869. */
  75870. deviceScaleFactor: number;
  75871. /**
  75872. * Updates the poseControlled values based on the input device pose.
  75873. * @param poseData the pose data to update the object with
  75874. */
  75875. updateFromDevice(poseData: DevicePose): void;
  75876. }
  75877. /**
  75878. * Set of options to customize the webVRCamera
  75879. */
  75880. export interface WebVROptions {
  75881. /**
  75882. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  75883. */
  75884. trackPosition?: boolean;
  75885. /**
  75886. * Sets the scale of the vrDevice in babylon space. (default: 1)
  75887. */
  75888. positionScale?: number;
  75889. /**
  75890. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  75891. */
  75892. displayName?: string;
  75893. /**
  75894. * Should the native controller meshes be initialized. (default: true)
  75895. */
  75896. controllerMeshes?: boolean;
  75897. /**
  75898. * Creating a default HemiLight only on controllers. (default: true)
  75899. */
  75900. defaultLightingOnControllers?: boolean;
  75901. /**
  75902. * If you don't want to use the default VR button of the helper. (default: false)
  75903. */
  75904. useCustomVRButton?: boolean;
  75905. /**
  75906. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  75907. */
  75908. customVRButton?: HTMLButtonElement;
  75909. /**
  75910. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  75911. */
  75912. rayLength?: number;
  75913. /**
  75914. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  75915. */
  75916. defaultHeight?: number;
  75917. /**
  75918. * If multiview should be used if availible (default: false)
  75919. */
  75920. useMultiview?: boolean;
  75921. }
  75922. /**
  75923. * This represents a WebVR camera.
  75924. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  75925. * @example http://doc.babylonjs.com/how_to/webvr_camera
  75926. */
  75927. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  75928. private webVROptions;
  75929. /**
  75930. * @hidden
  75931. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  75932. */
  75933. _vrDevice: any;
  75934. /**
  75935. * The rawPose of the vrDevice.
  75936. */
  75937. rawPose: Nullable<DevicePose>;
  75938. private _onVREnabled;
  75939. private _specsVersion;
  75940. private _attached;
  75941. private _frameData;
  75942. protected _descendants: Array<Node>;
  75943. private _deviceRoomPosition;
  75944. /** @hidden */
  75945. _deviceRoomRotationQuaternion: Quaternion;
  75946. private _standingMatrix;
  75947. /**
  75948. * Represents device position in babylon space.
  75949. */
  75950. devicePosition: Vector3;
  75951. /**
  75952. * Represents device rotation in babylon space.
  75953. */
  75954. deviceRotationQuaternion: Quaternion;
  75955. /**
  75956. * The scale of the device to be used when translating from device space to babylon space.
  75957. */
  75958. deviceScaleFactor: number;
  75959. private _deviceToWorld;
  75960. private _worldToDevice;
  75961. /**
  75962. * References to the webVR controllers for the vrDevice.
  75963. */
  75964. controllers: Array<WebVRController>;
  75965. /**
  75966. * Emits an event when a controller is attached.
  75967. */
  75968. onControllersAttachedObservable: Observable<WebVRController[]>;
  75969. /**
  75970. * Emits an event when a controller's mesh has been loaded;
  75971. */
  75972. onControllerMeshLoadedObservable: Observable<WebVRController>;
  75973. /**
  75974. * Emits an event when the HMD's pose has been updated.
  75975. */
  75976. onPoseUpdatedFromDeviceObservable: Observable<any>;
  75977. private _poseSet;
  75978. /**
  75979. * If the rig cameras be used as parent instead of this camera.
  75980. */
  75981. rigParenting: boolean;
  75982. private _lightOnControllers;
  75983. private _defaultHeight?;
  75984. /**
  75985. * Instantiates a WebVRFreeCamera.
  75986. * @param name The name of the WebVRFreeCamera
  75987. * @param position The starting anchor position for the camera
  75988. * @param scene The scene the camera belongs to
  75989. * @param webVROptions a set of customizable options for the webVRCamera
  75990. */
  75991. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  75992. /**
  75993. * Gets the device distance from the ground in meters.
  75994. * @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.
  75995. */
  75996. deviceDistanceToRoomGround(): number;
  75997. /**
  75998. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  75999. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  76000. */
  76001. useStandingMatrix(callback?: (bool: boolean) => void): void;
  76002. /**
  76003. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  76004. * @returns A promise with a boolean set to if the standing matrix is supported.
  76005. */
  76006. useStandingMatrixAsync(): Promise<boolean>;
  76007. /**
  76008. * Disposes the camera
  76009. */
  76010. dispose(): void;
  76011. /**
  76012. * Gets a vrController by name.
  76013. * @param name The name of the controller to retreive
  76014. * @returns the controller matching the name specified or null if not found
  76015. */
  76016. getControllerByName(name: string): Nullable<WebVRController>;
  76017. private _leftController;
  76018. /**
  76019. * The controller corrisponding to the users left hand.
  76020. */
  76021. readonly leftController: Nullable<WebVRController>;
  76022. private _rightController;
  76023. /**
  76024. * The controller corrisponding to the users right hand.
  76025. */
  76026. readonly rightController: Nullable<WebVRController>;
  76027. /**
  76028. * Casts a ray forward from the vrCamera's gaze.
  76029. * @param length Length of the ray (default: 100)
  76030. * @returns the ray corrisponding to the gaze
  76031. */
  76032. getForwardRay(length?: number): Ray;
  76033. /**
  76034. * @hidden
  76035. * Updates the camera based on device's frame data
  76036. */
  76037. _checkInputs(): void;
  76038. /**
  76039. * Updates the poseControlled values based on the input device pose.
  76040. * @param poseData Pose coming from the device
  76041. */
  76042. updateFromDevice(poseData: DevicePose): void;
  76043. private _htmlElementAttached;
  76044. private _detachIfAttached;
  76045. /**
  76046. * WebVR's attach control will start broadcasting frames to the device.
  76047. * Note that in certain browsers (chrome for example) this function must be called
  76048. * within a user-interaction callback. Example:
  76049. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  76050. *
  76051. * @param element html element to attach the vrDevice to
  76052. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  76053. */
  76054. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76055. /**
  76056. * Detaches the camera from the html element and disables VR
  76057. *
  76058. * @param element html element to detach from
  76059. */
  76060. detachControl(element: HTMLElement): void;
  76061. /**
  76062. * @returns the name of this class
  76063. */
  76064. getClassName(): string;
  76065. /**
  76066. * Calls resetPose on the vrDisplay
  76067. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  76068. */
  76069. resetToCurrentRotation(): void;
  76070. /**
  76071. * @hidden
  76072. * Updates the rig cameras (left and right eye)
  76073. */
  76074. _updateRigCameras(): void;
  76075. private _workingVector;
  76076. private _oneVector;
  76077. private _workingMatrix;
  76078. private updateCacheCalled;
  76079. private _correctPositionIfNotTrackPosition;
  76080. /**
  76081. * @hidden
  76082. * Updates the cached values of the camera
  76083. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  76084. */
  76085. _updateCache(ignoreParentClass?: boolean): void;
  76086. /**
  76087. * @hidden
  76088. * Get current device position in babylon world
  76089. */
  76090. _computeDevicePosition(): void;
  76091. /**
  76092. * Updates the current device position and rotation in the babylon world
  76093. */
  76094. update(): void;
  76095. /**
  76096. * @hidden
  76097. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  76098. * @returns an identity matrix
  76099. */
  76100. _getViewMatrix(): Matrix;
  76101. private _tmpMatrix;
  76102. /**
  76103. * This function is called by the two RIG cameras.
  76104. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  76105. * @hidden
  76106. */
  76107. _getWebVRViewMatrix(): Matrix;
  76108. /** @hidden */
  76109. _getWebVRProjectionMatrix(): Matrix;
  76110. private _onGamepadConnectedObserver;
  76111. private _onGamepadDisconnectedObserver;
  76112. private _updateCacheWhenTrackingDisabledObserver;
  76113. /**
  76114. * Initializes the controllers and their meshes
  76115. */
  76116. initControllers(): void;
  76117. }
  76118. }
  76119. declare module BABYLON {
  76120. /**
  76121. * Size options for a post process
  76122. */
  76123. export type PostProcessOptions = {
  76124. width: number;
  76125. height: number;
  76126. };
  76127. /**
  76128. * PostProcess can be used to apply a shader to a texture after it has been rendered
  76129. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  76130. */
  76131. export class PostProcess {
  76132. /** Name of the PostProcess. */
  76133. name: string;
  76134. /**
  76135. * Gets or sets the unique id of the post process
  76136. */
  76137. uniqueId: number;
  76138. /**
  76139. * Width of the texture to apply the post process on
  76140. */
  76141. width: number;
  76142. /**
  76143. * Height of the texture to apply the post process on
  76144. */
  76145. height: number;
  76146. /**
  76147. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  76148. * @hidden
  76149. */
  76150. _outputTexture: Nullable<InternalTexture>;
  76151. /**
  76152. * Sampling mode used by the shader
  76153. * See https://doc.babylonjs.com/classes/3.1/texture
  76154. */
  76155. renderTargetSamplingMode: number;
  76156. /**
  76157. * Clear color to use when screen clearing
  76158. */
  76159. clearColor: Color4;
  76160. /**
  76161. * If the buffer needs to be cleared before applying the post process. (default: true)
  76162. * Should be set to false if shader will overwrite all previous pixels.
  76163. */
  76164. autoClear: boolean;
  76165. /**
  76166. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  76167. */
  76168. alphaMode: number;
  76169. /**
  76170. * Sets the setAlphaBlendConstants of the babylon engine
  76171. */
  76172. alphaConstants: Color4;
  76173. /**
  76174. * Animations to be used for the post processing
  76175. */
  76176. animations: Animation[];
  76177. /**
  76178. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  76179. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  76180. */
  76181. enablePixelPerfectMode: boolean;
  76182. /**
  76183. * Force the postprocess to be applied without taking in account viewport
  76184. */
  76185. forceFullscreenViewport: boolean;
  76186. /**
  76187. * List of inspectable custom properties (used by the Inspector)
  76188. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  76189. */
  76190. inspectableCustomProperties: IInspectable[];
  76191. /**
  76192. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  76193. *
  76194. * | Value | Type | Description |
  76195. * | ----- | ----------------------------------- | ----------- |
  76196. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  76197. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  76198. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  76199. *
  76200. */
  76201. scaleMode: number;
  76202. /**
  76203. * Force textures to be a power of two (default: false)
  76204. */
  76205. alwaysForcePOT: boolean;
  76206. private _samples;
  76207. /**
  76208. * Number of sample textures (default: 1)
  76209. */
  76210. samples: number;
  76211. /**
  76212. * Modify the scale of the post process to be the same as the viewport (default: false)
  76213. */
  76214. adaptScaleToCurrentViewport: boolean;
  76215. private _camera;
  76216. private _scene;
  76217. private _engine;
  76218. private _options;
  76219. private _reusable;
  76220. private _textureType;
  76221. /**
  76222. * Smart array of input and output textures for the post process.
  76223. * @hidden
  76224. */
  76225. _textures: SmartArray<InternalTexture>;
  76226. /**
  76227. * The index in _textures that corresponds to the output texture.
  76228. * @hidden
  76229. */
  76230. _currentRenderTextureInd: number;
  76231. private _effect;
  76232. private _samplers;
  76233. private _fragmentUrl;
  76234. private _vertexUrl;
  76235. private _parameters;
  76236. private _scaleRatio;
  76237. protected _indexParameters: any;
  76238. private _shareOutputWithPostProcess;
  76239. private _texelSize;
  76240. private _forcedOutputTexture;
  76241. /**
  76242. * Returns the fragment url or shader name used in the post process.
  76243. * @returns the fragment url or name in the shader store.
  76244. */
  76245. getEffectName(): string;
  76246. /**
  76247. * An event triggered when the postprocess is activated.
  76248. */
  76249. onActivateObservable: Observable<Camera>;
  76250. private _onActivateObserver;
  76251. /**
  76252. * A function that is added to the onActivateObservable
  76253. */
  76254. onActivate: Nullable<(camera: Camera) => void>;
  76255. /**
  76256. * An event triggered when the postprocess changes its size.
  76257. */
  76258. onSizeChangedObservable: Observable<PostProcess>;
  76259. private _onSizeChangedObserver;
  76260. /**
  76261. * A function that is added to the onSizeChangedObservable
  76262. */
  76263. onSizeChanged: (postProcess: PostProcess) => void;
  76264. /**
  76265. * An event triggered when the postprocess applies its effect.
  76266. */
  76267. onApplyObservable: Observable<Effect>;
  76268. private _onApplyObserver;
  76269. /**
  76270. * A function that is added to the onApplyObservable
  76271. */
  76272. onApply: (effect: Effect) => void;
  76273. /**
  76274. * An event triggered before rendering the postprocess
  76275. */
  76276. onBeforeRenderObservable: Observable<Effect>;
  76277. private _onBeforeRenderObserver;
  76278. /**
  76279. * A function that is added to the onBeforeRenderObservable
  76280. */
  76281. onBeforeRender: (effect: Effect) => void;
  76282. /**
  76283. * An event triggered after rendering the postprocess
  76284. */
  76285. onAfterRenderObservable: Observable<Effect>;
  76286. private _onAfterRenderObserver;
  76287. /**
  76288. * A function that is added to the onAfterRenderObservable
  76289. */
  76290. onAfterRender: (efect: Effect) => void;
  76291. /**
  76292. * 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
  76293. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  76294. */
  76295. inputTexture: InternalTexture;
  76296. /**
  76297. * Gets the camera which post process is applied to.
  76298. * @returns The camera the post process is applied to.
  76299. */
  76300. getCamera(): Camera;
  76301. /**
  76302. * Gets the texel size of the postprocess.
  76303. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  76304. */
  76305. readonly texelSize: Vector2;
  76306. /**
  76307. * Creates a new instance PostProcess
  76308. * @param name The name of the PostProcess.
  76309. * @param fragmentUrl The url of the fragment shader to be used.
  76310. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  76311. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  76312. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  76313. * @param camera The camera to apply the render pass to.
  76314. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76315. * @param engine The engine which the post process will be applied. (default: current engine)
  76316. * @param reusable If the post process can be reused on the same frame. (default: false)
  76317. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  76318. * @param textureType Type of textures used when performing the post process. (default: 0)
  76319. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  76320. * @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
  76321. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  76322. */
  76323. constructor(
  76324. /** Name of the PostProcess. */
  76325. 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);
  76326. /**
  76327. * Gets a string idenfifying the name of the class
  76328. * @returns "PostProcess" string
  76329. */
  76330. getClassName(): string;
  76331. /**
  76332. * Gets the engine which this post process belongs to.
  76333. * @returns The engine the post process was enabled with.
  76334. */
  76335. getEngine(): Engine;
  76336. /**
  76337. * The effect that is created when initializing the post process.
  76338. * @returns The created effect corrisponding the the postprocess.
  76339. */
  76340. getEffect(): Effect;
  76341. /**
  76342. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  76343. * @param postProcess The post process to share the output with.
  76344. * @returns This post process.
  76345. */
  76346. shareOutputWith(postProcess: PostProcess): PostProcess;
  76347. /**
  76348. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  76349. * This should be called if the post process that shares output with this post process is disabled/disposed.
  76350. */
  76351. useOwnOutput(): void;
  76352. /**
  76353. * Updates the effect with the current post process compile time values and recompiles the shader.
  76354. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  76355. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  76356. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  76357. * @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
  76358. * @param onCompiled Called when the shader has been compiled.
  76359. * @param onError Called if there is an error when compiling a shader.
  76360. */
  76361. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  76362. /**
  76363. * The post process is reusable if it can be used multiple times within one frame.
  76364. * @returns If the post process is reusable
  76365. */
  76366. isReusable(): boolean;
  76367. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  76368. markTextureDirty(): void;
  76369. /**
  76370. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  76371. * 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.
  76372. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  76373. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  76374. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  76375. * @returns The target texture that was bound to be written to.
  76376. */
  76377. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  76378. /**
  76379. * If the post process is supported.
  76380. */
  76381. readonly isSupported: boolean;
  76382. /**
  76383. * The aspect ratio of the output texture.
  76384. */
  76385. readonly aspectRatio: number;
  76386. /**
  76387. * Get a value indicating if the post-process is ready to be used
  76388. * @returns true if the post-process is ready (shader is compiled)
  76389. */
  76390. isReady(): boolean;
  76391. /**
  76392. * Binds all textures and uniforms to the shader, this will be run on every pass.
  76393. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  76394. */
  76395. apply(): Nullable<Effect>;
  76396. private _disposeTextures;
  76397. /**
  76398. * Disposes the post process.
  76399. * @param camera The camera to dispose the post process on.
  76400. */
  76401. dispose(camera?: Camera): void;
  76402. }
  76403. }
  76404. declare module BABYLON {
  76405. /**
  76406. * PostProcessManager is used to manage one or more post processes or post process pipelines
  76407. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  76408. */
  76409. export class PostProcessManager {
  76410. private _scene;
  76411. private _indexBuffer;
  76412. private _vertexBuffers;
  76413. /**
  76414. * Creates a new instance PostProcess
  76415. * @param scene The scene that the post process is associated with.
  76416. */
  76417. constructor(scene: Scene);
  76418. private _prepareBuffers;
  76419. private _buildIndexBuffer;
  76420. /**
  76421. * Rebuilds the vertex buffers of the manager.
  76422. * @hidden
  76423. */
  76424. _rebuild(): void;
  76425. /**
  76426. * Prepares a frame to be run through a post process.
  76427. * @param sourceTexture The input texture to the post procesess. (default: null)
  76428. * @param postProcesses An array of post processes to be run. (default: null)
  76429. * @returns True if the post processes were able to be run.
  76430. * @hidden
  76431. */
  76432. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  76433. /**
  76434. * Manually render a set of post processes to a texture.
  76435. * @param postProcesses An array of post processes to be run.
  76436. * @param targetTexture The target texture to render to.
  76437. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  76438. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  76439. * @param lodLevel defines which lod of the texture to render to
  76440. */
  76441. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  76442. /**
  76443. * Finalize the result of the output of the postprocesses.
  76444. * @param doNotPresent If true the result will not be displayed to the screen.
  76445. * @param targetTexture The target texture to render to.
  76446. * @param faceIndex The index of the face to bind the target texture to.
  76447. * @param postProcesses The array of post processes to render.
  76448. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  76449. * @hidden
  76450. */
  76451. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  76452. /**
  76453. * Disposes of the post process manager.
  76454. */
  76455. dispose(): void;
  76456. }
  76457. }
  76458. declare module BABYLON {
  76459. interface AbstractScene {
  76460. /**
  76461. * The list of procedural textures added to the scene
  76462. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  76463. */
  76464. proceduralTextures: Array<ProceduralTexture>;
  76465. }
  76466. /**
  76467. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  76468. * in a given scene.
  76469. */
  76470. export class ProceduralTextureSceneComponent implements ISceneComponent {
  76471. /**
  76472. * The component name helpfull to identify the component in the list of scene components.
  76473. */
  76474. readonly name: string;
  76475. /**
  76476. * The scene the component belongs to.
  76477. */
  76478. scene: Scene;
  76479. /**
  76480. * Creates a new instance of the component for the given scene
  76481. * @param scene Defines the scene to register the component in
  76482. */
  76483. constructor(scene: Scene);
  76484. /**
  76485. * Registers the component in a given scene
  76486. */
  76487. register(): void;
  76488. /**
  76489. * Rebuilds the elements related to this component in case of
  76490. * context lost for instance.
  76491. */
  76492. rebuild(): void;
  76493. /**
  76494. * Disposes the component and the associated ressources.
  76495. */
  76496. dispose(): void;
  76497. private _beforeClear;
  76498. }
  76499. }
  76500. declare module BABYLON {
  76501. interface Engine {
  76502. /**
  76503. * Creates a new render target cube texture
  76504. * @param size defines the size of the texture
  76505. * @param options defines the options used to create the texture
  76506. * @returns a new render target cube texture stored in an InternalTexture
  76507. */
  76508. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  76509. }
  76510. }
  76511. declare module BABYLON {
  76512. /** @hidden */
  76513. export var proceduralVertexShader: {
  76514. name: string;
  76515. shader: string;
  76516. };
  76517. }
  76518. declare module BABYLON {
  76519. /**
  76520. * 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.
  76521. * This is the base class of any Procedural texture and contains most of the shareable code.
  76522. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  76523. */
  76524. export class ProceduralTexture extends Texture {
  76525. isCube: boolean;
  76526. /**
  76527. * Define if the texture is enabled or not (disabled texture will not render)
  76528. */
  76529. isEnabled: boolean;
  76530. /**
  76531. * Define if the texture must be cleared before rendering (default is true)
  76532. */
  76533. autoClear: boolean;
  76534. /**
  76535. * Callback called when the texture is generated
  76536. */
  76537. onGenerated: () => void;
  76538. /**
  76539. * Event raised when the texture is generated
  76540. */
  76541. onGeneratedObservable: Observable<ProceduralTexture>;
  76542. /** @hidden */
  76543. _generateMipMaps: boolean;
  76544. /** @hidden **/
  76545. _effect: Effect;
  76546. /** @hidden */
  76547. _textures: {
  76548. [key: string]: Texture;
  76549. };
  76550. private _size;
  76551. private _currentRefreshId;
  76552. private _refreshRate;
  76553. private _vertexBuffers;
  76554. private _indexBuffer;
  76555. private _uniforms;
  76556. private _samplers;
  76557. private _fragment;
  76558. private _floats;
  76559. private _ints;
  76560. private _floatsArrays;
  76561. private _colors3;
  76562. private _colors4;
  76563. private _vectors2;
  76564. private _vectors3;
  76565. private _matrices;
  76566. private _fallbackTexture;
  76567. private _fallbackTextureUsed;
  76568. private _engine;
  76569. private _cachedDefines;
  76570. private _contentUpdateId;
  76571. private _contentData;
  76572. /**
  76573. * Instantiates a new procedural texture.
  76574. * 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.
  76575. * This is the base class of any Procedural texture and contains most of the shareable code.
  76576. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  76577. * @param name Define the name of the texture
  76578. * @param size Define the size of the texture to create
  76579. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  76580. * @param scene Define the scene the texture belongs to
  76581. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  76582. * @param generateMipMaps Define if the texture should creates mip maps or not
  76583. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  76584. */
  76585. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  76586. /**
  76587. * The effect that is created when initializing the post process.
  76588. * @returns The created effect corrisponding the the postprocess.
  76589. */
  76590. getEffect(): Effect;
  76591. /**
  76592. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  76593. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  76594. */
  76595. getContent(): Nullable<ArrayBufferView>;
  76596. private _createIndexBuffer;
  76597. /** @hidden */
  76598. _rebuild(): void;
  76599. /**
  76600. * Resets the texture in order to recreate its associated resources.
  76601. * This can be called in case of context loss
  76602. */
  76603. reset(): void;
  76604. protected _getDefines(): string;
  76605. /**
  76606. * Is the texture ready to be used ? (rendered at least once)
  76607. * @returns true if ready, otherwise, false.
  76608. */
  76609. isReady(): boolean;
  76610. /**
  76611. * Resets the refresh counter of the texture and start bak from scratch.
  76612. * Could be useful to regenerate the texture if it is setup to render only once.
  76613. */
  76614. resetRefreshCounter(): void;
  76615. /**
  76616. * Set the fragment shader to use in order to render the texture.
  76617. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  76618. */
  76619. setFragment(fragment: any): void;
  76620. /**
  76621. * Define the refresh rate of the texture or the rendering frequency.
  76622. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  76623. */
  76624. refreshRate: number;
  76625. /** @hidden */
  76626. _shouldRender(): boolean;
  76627. /**
  76628. * Get the size the texture is rendering at.
  76629. * @returns the size (texture is always squared)
  76630. */
  76631. getRenderSize(): number;
  76632. /**
  76633. * Resize the texture to new value.
  76634. * @param size Define the new size the texture should have
  76635. * @param generateMipMaps Define whether the new texture should create mip maps
  76636. */
  76637. resize(size: number, generateMipMaps: boolean): void;
  76638. private _checkUniform;
  76639. /**
  76640. * Set a texture in the shader program used to render.
  76641. * @param name Define the name of the uniform samplers as defined in the shader
  76642. * @param texture Define the texture to bind to this sampler
  76643. * @return the texture itself allowing "fluent" like uniform updates
  76644. */
  76645. setTexture(name: string, texture: Texture): ProceduralTexture;
  76646. /**
  76647. * Set a float in the shader.
  76648. * @param name Define the name of the uniform as defined in the shader
  76649. * @param value Define the value to give to the uniform
  76650. * @return the texture itself allowing "fluent" like uniform updates
  76651. */
  76652. setFloat(name: string, value: number): ProceduralTexture;
  76653. /**
  76654. * Set a int in the shader.
  76655. * @param name Define the name of the uniform as defined in the shader
  76656. * @param value Define the value to give to the uniform
  76657. * @return the texture itself allowing "fluent" like uniform updates
  76658. */
  76659. setInt(name: string, value: number): ProceduralTexture;
  76660. /**
  76661. * Set an array of floats in the shader.
  76662. * @param name Define the name of the uniform as defined in the shader
  76663. * @param value Define the value to give to the uniform
  76664. * @return the texture itself allowing "fluent" like uniform updates
  76665. */
  76666. setFloats(name: string, value: number[]): ProceduralTexture;
  76667. /**
  76668. * Set a vec3 in the shader from a Color3.
  76669. * @param name Define the name of the uniform as defined in the shader
  76670. * @param value Define the value to give to the uniform
  76671. * @return the texture itself allowing "fluent" like uniform updates
  76672. */
  76673. setColor3(name: string, value: Color3): ProceduralTexture;
  76674. /**
  76675. * Set a vec4 in the shader from a Color4.
  76676. * @param name Define the name of the uniform as defined in the shader
  76677. * @param value Define the value to give to the uniform
  76678. * @return the texture itself allowing "fluent" like uniform updates
  76679. */
  76680. setColor4(name: string, value: Color4): ProceduralTexture;
  76681. /**
  76682. * Set a vec2 in the shader from a Vector2.
  76683. * @param name Define the name of the uniform as defined in the shader
  76684. * @param value Define the value to give to the uniform
  76685. * @return the texture itself allowing "fluent" like uniform updates
  76686. */
  76687. setVector2(name: string, value: Vector2): ProceduralTexture;
  76688. /**
  76689. * Set a vec3 in the shader from a Vector3.
  76690. * @param name Define the name of the uniform as defined in the shader
  76691. * @param value Define the value to give to the uniform
  76692. * @return the texture itself allowing "fluent" like uniform updates
  76693. */
  76694. setVector3(name: string, value: Vector3): ProceduralTexture;
  76695. /**
  76696. * Set a mat4 in the shader from a MAtrix.
  76697. * @param name Define the name of the uniform as defined in the shader
  76698. * @param value Define the value to give to the uniform
  76699. * @return the texture itself allowing "fluent" like uniform updates
  76700. */
  76701. setMatrix(name: string, value: Matrix): ProceduralTexture;
  76702. /**
  76703. * Render the texture to its associated render target.
  76704. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  76705. */
  76706. render(useCameraPostProcess?: boolean): void;
  76707. /**
  76708. * Clone the texture.
  76709. * @returns the cloned texture
  76710. */
  76711. clone(): ProceduralTexture;
  76712. /**
  76713. * Dispose the texture and release its asoociated resources.
  76714. */
  76715. dispose(): void;
  76716. }
  76717. }
  76718. declare module BABYLON {
  76719. /**
  76720. * This represents the base class for particle system in Babylon.
  76721. * 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.
  76722. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  76723. * @example https://doc.babylonjs.com/babylon101/particles
  76724. */
  76725. export class BaseParticleSystem {
  76726. /**
  76727. * Source color is added to the destination color without alpha affecting the result
  76728. */
  76729. static BLENDMODE_ONEONE: number;
  76730. /**
  76731. * Blend current color and particle color using particle’s alpha
  76732. */
  76733. static BLENDMODE_STANDARD: number;
  76734. /**
  76735. * Add current color and particle color multiplied by particle’s alpha
  76736. */
  76737. static BLENDMODE_ADD: number;
  76738. /**
  76739. * Multiply current color with particle color
  76740. */
  76741. static BLENDMODE_MULTIPLY: number;
  76742. /**
  76743. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  76744. */
  76745. static BLENDMODE_MULTIPLYADD: number;
  76746. /**
  76747. * List of animations used by the particle system.
  76748. */
  76749. animations: Animation[];
  76750. /**
  76751. * The id of the Particle system.
  76752. */
  76753. id: string;
  76754. /**
  76755. * The friendly name of the Particle system.
  76756. */
  76757. name: string;
  76758. /**
  76759. * The rendering group used by the Particle system to chose when to render.
  76760. */
  76761. renderingGroupId: number;
  76762. /**
  76763. * The emitter represents the Mesh or position we are attaching the particle system to.
  76764. */
  76765. emitter: Nullable<AbstractMesh | Vector3>;
  76766. /**
  76767. * The maximum number of particles to emit per frame
  76768. */
  76769. emitRate: number;
  76770. /**
  76771. * If you want to launch only a few particles at once, that can be done, as well.
  76772. */
  76773. manualEmitCount: number;
  76774. /**
  76775. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  76776. */
  76777. updateSpeed: number;
  76778. /**
  76779. * The amount of time the particle system is running (depends of the overall update speed).
  76780. */
  76781. targetStopDuration: number;
  76782. /**
  76783. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  76784. */
  76785. disposeOnStop: boolean;
  76786. /**
  76787. * Minimum power of emitting particles.
  76788. */
  76789. minEmitPower: number;
  76790. /**
  76791. * Maximum power of emitting particles.
  76792. */
  76793. maxEmitPower: number;
  76794. /**
  76795. * Minimum life time of emitting particles.
  76796. */
  76797. minLifeTime: number;
  76798. /**
  76799. * Maximum life time of emitting particles.
  76800. */
  76801. maxLifeTime: number;
  76802. /**
  76803. * Minimum Size of emitting particles.
  76804. */
  76805. minSize: number;
  76806. /**
  76807. * Maximum Size of emitting particles.
  76808. */
  76809. maxSize: number;
  76810. /**
  76811. * Minimum scale of emitting particles on X axis.
  76812. */
  76813. minScaleX: number;
  76814. /**
  76815. * Maximum scale of emitting particles on X axis.
  76816. */
  76817. maxScaleX: number;
  76818. /**
  76819. * Minimum scale of emitting particles on Y axis.
  76820. */
  76821. minScaleY: number;
  76822. /**
  76823. * Maximum scale of emitting particles on Y axis.
  76824. */
  76825. maxScaleY: number;
  76826. /**
  76827. * Gets or sets the minimal initial rotation in radians.
  76828. */
  76829. minInitialRotation: number;
  76830. /**
  76831. * Gets or sets the maximal initial rotation in radians.
  76832. */
  76833. maxInitialRotation: number;
  76834. /**
  76835. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  76836. */
  76837. minAngularSpeed: number;
  76838. /**
  76839. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  76840. */
  76841. maxAngularSpeed: number;
  76842. /**
  76843. * The texture used to render each particle. (this can be a spritesheet)
  76844. */
  76845. particleTexture: Nullable<Texture>;
  76846. /**
  76847. * The layer mask we are rendering the particles through.
  76848. */
  76849. layerMask: number;
  76850. /**
  76851. * This can help using your own shader to render the particle system.
  76852. * The according effect will be created
  76853. */
  76854. customShader: any;
  76855. /**
  76856. * By default particle system starts as soon as they are created. This prevents the
  76857. * automatic start to happen and let you decide when to start emitting particles.
  76858. */
  76859. preventAutoStart: boolean;
  76860. private _noiseTexture;
  76861. /**
  76862. * Gets or sets a texture used to add random noise to particle positions
  76863. */
  76864. noiseTexture: Nullable<ProceduralTexture>;
  76865. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  76866. noiseStrength: Vector3;
  76867. /**
  76868. * Callback triggered when the particle animation is ending.
  76869. */
  76870. onAnimationEnd: Nullable<() => void>;
  76871. /**
  76872. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  76873. */
  76874. blendMode: number;
  76875. /**
  76876. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  76877. * to override the particles.
  76878. */
  76879. forceDepthWrite: boolean;
  76880. /** 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 */
  76881. preWarmCycles: number;
  76882. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  76883. preWarmStepOffset: number;
  76884. /**
  76885. * 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)
  76886. */
  76887. spriteCellChangeSpeed: number;
  76888. /**
  76889. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  76890. */
  76891. startSpriteCellID: number;
  76892. /**
  76893. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  76894. */
  76895. endSpriteCellID: number;
  76896. /**
  76897. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  76898. */
  76899. spriteCellWidth: number;
  76900. /**
  76901. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  76902. */
  76903. spriteCellHeight: number;
  76904. /**
  76905. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  76906. */
  76907. spriteRandomStartCell: boolean;
  76908. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  76909. translationPivot: Vector2;
  76910. /** @hidden */
  76911. protected _isAnimationSheetEnabled: boolean;
  76912. /**
  76913. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  76914. */
  76915. beginAnimationOnStart: boolean;
  76916. /**
  76917. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  76918. */
  76919. beginAnimationFrom: number;
  76920. /**
  76921. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  76922. */
  76923. beginAnimationTo: number;
  76924. /**
  76925. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  76926. */
  76927. beginAnimationLoop: boolean;
  76928. /**
  76929. * Gets or sets a world offset applied to all particles
  76930. */
  76931. worldOffset: Vector3;
  76932. /**
  76933. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  76934. */
  76935. isAnimationSheetEnabled: boolean;
  76936. /**
  76937. * Get hosting scene
  76938. * @returns the scene
  76939. */
  76940. getScene(): Scene;
  76941. /**
  76942. * You can use gravity if you want to give an orientation to your particles.
  76943. */
  76944. gravity: Vector3;
  76945. protected _colorGradients: Nullable<Array<ColorGradient>>;
  76946. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  76947. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  76948. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  76949. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  76950. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  76951. protected _dragGradients: Nullable<Array<FactorGradient>>;
  76952. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  76953. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  76954. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  76955. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  76956. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  76957. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  76958. /**
  76959. * Defines the delay in milliseconds before starting the system (0 by default)
  76960. */
  76961. startDelay: number;
  76962. /**
  76963. * Gets the current list of drag gradients.
  76964. * You must use addDragGradient and removeDragGradient to udpate this list
  76965. * @returns the list of drag gradients
  76966. */
  76967. getDragGradients(): Nullable<Array<FactorGradient>>;
  76968. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  76969. limitVelocityDamping: number;
  76970. /**
  76971. * Gets the current list of limit velocity gradients.
  76972. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  76973. * @returns the list of limit velocity gradients
  76974. */
  76975. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  76976. /**
  76977. * Gets the current list of color gradients.
  76978. * You must use addColorGradient and removeColorGradient to udpate this list
  76979. * @returns the list of color gradients
  76980. */
  76981. getColorGradients(): Nullable<Array<ColorGradient>>;
  76982. /**
  76983. * Gets the current list of size gradients.
  76984. * You must use addSizeGradient and removeSizeGradient to udpate this list
  76985. * @returns the list of size gradients
  76986. */
  76987. getSizeGradients(): Nullable<Array<FactorGradient>>;
  76988. /**
  76989. * Gets the current list of color remap gradients.
  76990. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  76991. * @returns the list of color remap gradients
  76992. */
  76993. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  76994. /**
  76995. * Gets the current list of alpha remap gradients.
  76996. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  76997. * @returns the list of alpha remap gradients
  76998. */
  76999. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  77000. /**
  77001. * Gets the current list of life time gradients.
  77002. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  77003. * @returns the list of life time gradients
  77004. */
  77005. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  77006. /**
  77007. * Gets the current list of angular speed gradients.
  77008. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  77009. * @returns the list of angular speed gradients
  77010. */
  77011. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  77012. /**
  77013. * Gets the current list of velocity gradients.
  77014. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  77015. * @returns the list of velocity gradients
  77016. */
  77017. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  77018. /**
  77019. * Gets the current list of start size gradients.
  77020. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  77021. * @returns the list of start size gradients
  77022. */
  77023. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  77024. /**
  77025. * Gets the current list of emit rate gradients.
  77026. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  77027. * @returns the list of emit rate gradients
  77028. */
  77029. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  77030. /**
  77031. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  77032. * This only works when particleEmitterTyps is a BoxParticleEmitter
  77033. */
  77034. direction1: Vector3;
  77035. /**
  77036. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  77037. * This only works when particleEmitterTyps is a BoxParticleEmitter
  77038. */
  77039. direction2: Vector3;
  77040. /**
  77041. * 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.
  77042. * This only works when particleEmitterTyps is a BoxParticleEmitter
  77043. */
  77044. minEmitBox: Vector3;
  77045. /**
  77046. * 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.
  77047. * This only works when particleEmitterTyps is a BoxParticleEmitter
  77048. */
  77049. maxEmitBox: Vector3;
  77050. /**
  77051. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  77052. */
  77053. color1: Color4;
  77054. /**
  77055. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  77056. */
  77057. color2: Color4;
  77058. /**
  77059. * Color the particle will have at the end of its lifetime
  77060. */
  77061. colorDead: Color4;
  77062. /**
  77063. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  77064. */
  77065. textureMask: Color4;
  77066. /**
  77067. * The particle emitter type defines the emitter used by the particle system.
  77068. * It can be for example box, sphere, or cone...
  77069. */
  77070. particleEmitterType: IParticleEmitterType;
  77071. /** @hidden */
  77072. _isSubEmitter: boolean;
  77073. /**
  77074. * Gets or sets the billboard mode to use when isBillboardBased = true.
  77075. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  77076. */
  77077. billboardMode: number;
  77078. protected _isBillboardBased: boolean;
  77079. /**
  77080. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  77081. */
  77082. isBillboardBased: boolean;
  77083. /**
  77084. * The scene the particle system belongs to.
  77085. */
  77086. protected _scene: Scene;
  77087. /**
  77088. * Local cache of defines for image processing.
  77089. */
  77090. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  77091. /**
  77092. * Default configuration related to image processing available in the standard Material.
  77093. */
  77094. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  77095. /**
  77096. * Gets the image processing configuration used either in this material.
  77097. */
  77098. /**
  77099. * Sets the Default image processing configuration used either in the this material.
  77100. *
  77101. * If sets to null, the scene one is in use.
  77102. */
  77103. imageProcessingConfiguration: ImageProcessingConfiguration;
  77104. /**
  77105. * Attaches a new image processing configuration to the Standard Material.
  77106. * @param configuration
  77107. */
  77108. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  77109. /** @hidden */
  77110. protected _reset(): void;
  77111. /** @hidden */
  77112. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  77113. /**
  77114. * Instantiates a particle system.
  77115. * 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.
  77116. * @param name The name of the particle system
  77117. */
  77118. constructor(name: string);
  77119. /**
  77120. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  77121. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  77122. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  77123. * @returns the emitter
  77124. */
  77125. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  77126. /**
  77127. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  77128. * @param radius The radius of the hemisphere to emit from
  77129. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  77130. * @returns the emitter
  77131. */
  77132. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  77133. /**
  77134. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  77135. * @param radius The radius of the sphere to emit from
  77136. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  77137. * @returns the emitter
  77138. */
  77139. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  77140. /**
  77141. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  77142. * @param radius The radius of the sphere to emit from
  77143. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  77144. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  77145. * @returns the emitter
  77146. */
  77147. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  77148. /**
  77149. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  77150. * @param radius The radius of the emission cylinder
  77151. * @param height The height of the emission cylinder
  77152. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  77153. * @param directionRandomizer How much to randomize the particle direction [0-1]
  77154. * @returns the emitter
  77155. */
  77156. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  77157. /**
  77158. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  77159. * @param radius The radius of the cylinder to emit from
  77160. * @param height The height of the emission cylinder
  77161. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  77162. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  77163. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  77164. * @returns the emitter
  77165. */
  77166. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  77167. /**
  77168. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  77169. * @param radius The radius of the cone to emit from
  77170. * @param angle The base angle of the cone
  77171. * @returns the emitter
  77172. */
  77173. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  77174. /**
  77175. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  77176. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  77177. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  77178. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  77179. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  77180. * @returns the emitter
  77181. */
  77182. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  77183. }
  77184. }
  77185. declare module BABYLON {
  77186. /**
  77187. * Type of sub emitter
  77188. */
  77189. export enum SubEmitterType {
  77190. /**
  77191. * Attached to the particle over it's lifetime
  77192. */
  77193. ATTACHED = 0,
  77194. /**
  77195. * Created when the particle dies
  77196. */
  77197. END = 1
  77198. }
  77199. /**
  77200. * Sub emitter class used to emit particles from an existing particle
  77201. */
  77202. export class SubEmitter {
  77203. /**
  77204. * the particle system to be used by the sub emitter
  77205. */
  77206. particleSystem: ParticleSystem;
  77207. /**
  77208. * Type of the submitter (Default: END)
  77209. */
  77210. type: SubEmitterType;
  77211. /**
  77212. * 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)
  77213. * Note: This only is supported when using an emitter of type Mesh
  77214. */
  77215. inheritDirection: boolean;
  77216. /**
  77217. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  77218. */
  77219. inheritedVelocityAmount: number;
  77220. /**
  77221. * Creates a sub emitter
  77222. * @param particleSystem the particle system to be used by the sub emitter
  77223. */
  77224. constructor(
  77225. /**
  77226. * the particle system to be used by the sub emitter
  77227. */
  77228. particleSystem: ParticleSystem);
  77229. /**
  77230. * Clones the sub emitter
  77231. * @returns the cloned sub emitter
  77232. */
  77233. clone(): SubEmitter;
  77234. /**
  77235. * Serialize current object to a JSON object
  77236. * @returns the serialized object
  77237. */
  77238. serialize(): any;
  77239. /** @hidden */
  77240. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  77241. /**
  77242. * Creates a new SubEmitter from a serialized JSON version
  77243. * @param serializationObject defines the JSON object to read from
  77244. * @param scene defines the hosting scene
  77245. * @param rootUrl defines the rootUrl for data loading
  77246. * @returns a new SubEmitter
  77247. */
  77248. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  77249. /** Release associated resources */
  77250. dispose(): void;
  77251. }
  77252. }
  77253. declare module BABYLON {
  77254. /** @hidden */
  77255. export var clipPlaneFragmentDeclaration: {
  77256. name: string;
  77257. shader: string;
  77258. };
  77259. }
  77260. declare module BABYLON {
  77261. /** @hidden */
  77262. export var imageProcessingDeclaration: {
  77263. name: string;
  77264. shader: string;
  77265. };
  77266. }
  77267. declare module BABYLON {
  77268. /** @hidden */
  77269. export var imageProcessingFunctions: {
  77270. name: string;
  77271. shader: string;
  77272. };
  77273. }
  77274. declare module BABYLON {
  77275. /** @hidden */
  77276. export var clipPlaneFragment: {
  77277. name: string;
  77278. shader: string;
  77279. };
  77280. }
  77281. declare module BABYLON {
  77282. /** @hidden */
  77283. export var particlesPixelShader: {
  77284. name: string;
  77285. shader: string;
  77286. };
  77287. }
  77288. declare module BABYLON {
  77289. /** @hidden */
  77290. export var clipPlaneVertexDeclaration: {
  77291. name: string;
  77292. shader: string;
  77293. };
  77294. }
  77295. declare module BABYLON {
  77296. /** @hidden */
  77297. export var clipPlaneVertex: {
  77298. name: string;
  77299. shader: string;
  77300. };
  77301. }
  77302. declare module BABYLON {
  77303. /** @hidden */
  77304. export var particlesVertexShader: {
  77305. name: string;
  77306. shader: string;
  77307. };
  77308. }
  77309. declare module BABYLON {
  77310. /**
  77311. * This represents a particle system in Babylon.
  77312. * 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.
  77313. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  77314. * @example https://doc.babylonjs.com/babylon101/particles
  77315. */
  77316. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  77317. /**
  77318. * Billboard mode will only apply to Y axis
  77319. */
  77320. static readonly BILLBOARDMODE_Y: number;
  77321. /**
  77322. * Billboard mode will apply to all axes
  77323. */
  77324. static readonly BILLBOARDMODE_ALL: number;
  77325. /**
  77326. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  77327. */
  77328. static readonly BILLBOARDMODE_STRETCHED: number;
  77329. /**
  77330. * This function can be defined to provide custom update for active particles.
  77331. * This function will be called instead of regular update (age, position, color, etc.).
  77332. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  77333. */
  77334. updateFunction: (particles: Particle[]) => void;
  77335. private _emitterWorldMatrix;
  77336. /**
  77337. * This function can be defined to specify initial direction for every new particle.
  77338. * It by default use the emitterType defined function
  77339. */
  77340. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  77341. /**
  77342. * This function can be defined to specify initial position for every new particle.
  77343. * It by default use the emitterType defined function
  77344. */
  77345. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  77346. /**
  77347. * @hidden
  77348. */
  77349. _inheritedVelocityOffset: Vector3;
  77350. /**
  77351. * An event triggered when the system is disposed
  77352. */
  77353. onDisposeObservable: Observable<ParticleSystem>;
  77354. private _onDisposeObserver;
  77355. /**
  77356. * Sets a callback that will be triggered when the system is disposed
  77357. */
  77358. onDispose: () => void;
  77359. private _particles;
  77360. private _epsilon;
  77361. private _capacity;
  77362. private _stockParticles;
  77363. private _newPartsExcess;
  77364. private _vertexData;
  77365. private _vertexBuffer;
  77366. private _vertexBuffers;
  77367. private _spriteBuffer;
  77368. private _indexBuffer;
  77369. private _effect;
  77370. private _customEffect;
  77371. private _cachedDefines;
  77372. private _scaledColorStep;
  77373. private _colorDiff;
  77374. private _scaledDirection;
  77375. private _scaledGravity;
  77376. private _currentRenderId;
  77377. private _alive;
  77378. private _useInstancing;
  77379. private _started;
  77380. private _stopped;
  77381. private _actualFrame;
  77382. private _scaledUpdateSpeed;
  77383. private _vertexBufferSize;
  77384. /** @hidden */
  77385. _currentEmitRateGradient: Nullable<FactorGradient>;
  77386. /** @hidden */
  77387. _currentEmitRate1: number;
  77388. /** @hidden */
  77389. _currentEmitRate2: number;
  77390. /** @hidden */
  77391. _currentStartSizeGradient: Nullable<FactorGradient>;
  77392. /** @hidden */
  77393. _currentStartSize1: number;
  77394. /** @hidden */
  77395. _currentStartSize2: number;
  77396. private readonly _rawTextureWidth;
  77397. private _rampGradientsTexture;
  77398. private _useRampGradients;
  77399. /** Gets or sets a boolean indicating that ramp gradients must be used
  77400. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  77401. */
  77402. useRampGradients: boolean;
  77403. /**
  77404. * 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.
  77405. * 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: [])
  77406. */
  77407. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  77408. private _subEmitters;
  77409. /**
  77410. * @hidden
  77411. * If the particle systems emitter should be disposed when the particle system is disposed
  77412. */
  77413. _disposeEmitterOnDispose: boolean;
  77414. /**
  77415. * The current active Sub-systems, this property is used by the root particle system only.
  77416. */
  77417. activeSubSystems: Array<ParticleSystem>;
  77418. private _rootParticleSystem;
  77419. /**
  77420. * Gets the current list of active particles
  77421. */
  77422. readonly particles: Particle[];
  77423. /**
  77424. * Returns the string "ParticleSystem"
  77425. * @returns a string containing the class name
  77426. */
  77427. getClassName(): string;
  77428. /**
  77429. * Instantiates a particle system.
  77430. * 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.
  77431. * @param name The name of the particle system
  77432. * @param capacity The max number of particles alive at the same time
  77433. * @param scene The scene the particle system belongs to
  77434. * @param customEffect a custom effect used to change the way particles are rendered by default
  77435. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  77436. * @param epsilon Offset used to render the particles
  77437. */
  77438. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  77439. private _addFactorGradient;
  77440. private _removeFactorGradient;
  77441. /**
  77442. * Adds a new life time gradient
  77443. * @param gradient defines the gradient to use (between 0 and 1)
  77444. * @param factor defines the life time factor to affect to the specified gradient
  77445. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  77446. * @returns the current particle system
  77447. */
  77448. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  77449. /**
  77450. * Remove a specific life time gradient
  77451. * @param gradient defines the gradient to remove
  77452. * @returns the current particle system
  77453. */
  77454. removeLifeTimeGradient(gradient: number): IParticleSystem;
  77455. /**
  77456. * Adds a new size gradient
  77457. * @param gradient defines the gradient to use (between 0 and 1)
  77458. * @param factor defines the size factor to affect to the specified gradient
  77459. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  77460. * @returns the current particle system
  77461. */
  77462. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  77463. /**
  77464. * Remove a specific size gradient
  77465. * @param gradient defines the gradient to remove
  77466. * @returns the current particle system
  77467. */
  77468. removeSizeGradient(gradient: number): IParticleSystem;
  77469. /**
  77470. * Adds a new color remap gradient
  77471. * @param gradient defines the gradient to use (between 0 and 1)
  77472. * @param min defines the color remap minimal range
  77473. * @param max defines the color remap maximal range
  77474. * @returns the current particle system
  77475. */
  77476. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  77477. /**
  77478. * Remove a specific color remap gradient
  77479. * @param gradient defines the gradient to remove
  77480. * @returns the current particle system
  77481. */
  77482. removeColorRemapGradient(gradient: number): IParticleSystem;
  77483. /**
  77484. * Adds a new alpha remap gradient
  77485. * @param gradient defines the gradient to use (between 0 and 1)
  77486. * @param min defines the alpha remap minimal range
  77487. * @param max defines the alpha remap maximal range
  77488. * @returns the current particle system
  77489. */
  77490. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  77491. /**
  77492. * Remove a specific alpha remap gradient
  77493. * @param gradient defines the gradient to remove
  77494. * @returns the current particle system
  77495. */
  77496. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  77497. /**
  77498. * Adds a new angular speed gradient
  77499. * @param gradient defines the gradient to use (between 0 and 1)
  77500. * @param factor defines the angular speed to affect to the specified gradient
  77501. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  77502. * @returns the current particle system
  77503. */
  77504. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  77505. /**
  77506. * Remove a specific angular speed gradient
  77507. * @param gradient defines the gradient to remove
  77508. * @returns the current particle system
  77509. */
  77510. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  77511. /**
  77512. * Adds a new velocity gradient
  77513. * @param gradient defines the gradient to use (between 0 and 1)
  77514. * @param factor defines the velocity to affect to the specified gradient
  77515. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  77516. * @returns the current particle system
  77517. */
  77518. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  77519. /**
  77520. * Remove a specific velocity gradient
  77521. * @param gradient defines the gradient to remove
  77522. * @returns the current particle system
  77523. */
  77524. removeVelocityGradient(gradient: number): IParticleSystem;
  77525. /**
  77526. * Adds a new limit velocity gradient
  77527. * @param gradient defines the gradient to use (between 0 and 1)
  77528. * @param factor defines the limit velocity value to affect to the specified gradient
  77529. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  77530. * @returns the current particle system
  77531. */
  77532. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  77533. /**
  77534. * Remove a specific limit velocity gradient
  77535. * @param gradient defines the gradient to remove
  77536. * @returns the current particle system
  77537. */
  77538. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  77539. /**
  77540. * Adds a new drag gradient
  77541. * @param gradient defines the gradient to use (between 0 and 1)
  77542. * @param factor defines the drag value to affect to the specified gradient
  77543. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  77544. * @returns the current particle system
  77545. */
  77546. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  77547. /**
  77548. * Remove a specific drag gradient
  77549. * @param gradient defines the gradient to remove
  77550. * @returns the current particle system
  77551. */
  77552. removeDragGradient(gradient: number): IParticleSystem;
  77553. /**
  77554. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  77555. * @param gradient defines the gradient to use (between 0 and 1)
  77556. * @param factor defines the emit rate value to affect to the specified gradient
  77557. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  77558. * @returns the current particle system
  77559. */
  77560. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  77561. /**
  77562. * Remove a specific emit rate gradient
  77563. * @param gradient defines the gradient to remove
  77564. * @returns the current particle system
  77565. */
  77566. removeEmitRateGradient(gradient: number): IParticleSystem;
  77567. /**
  77568. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  77569. * @param gradient defines the gradient to use (between 0 and 1)
  77570. * @param factor defines the start size value to affect to the specified gradient
  77571. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  77572. * @returns the current particle system
  77573. */
  77574. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  77575. /**
  77576. * Remove a specific start size gradient
  77577. * @param gradient defines the gradient to remove
  77578. * @returns the current particle system
  77579. */
  77580. removeStartSizeGradient(gradient: number): IParticleSystem;
  77581. private _createRampGradientTexture;
  77582. /**
  77583. * Gets the current list of ramp gradients.
  77584. * You must use addRampGradient and removeRampGradient to udpate this list
  77585. * @returns the list of ramp gradients
  77586. */
  77587. getRampGradients(): Nullable<Array<Color3Gradient>>;
  77588. /**
  77589. * Adds a new ramp gradient used to remap particle colors
  77590. * @param gradient defines the gradient to use (between 0 and 1)
  77591. * @param color defines the color to affect to the specified gradient
  77592. * @returns the current particle system
  77593. */
  77594. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  77595. /**
  77596. * Remove a specific ramp gradient
  77597. * @param gradient defines the gradient to remove
  77598. * @returns the current particle system
  77599. */
  77600. removeRampGradient(gradient: number): ParticleSystem;
  77601. /**
  77602. * Adds a new color gradient
  77603. * @param gradient defines the gradient to use (between 0 and 1)
  77604. * @param color1 defines the color to affect to the specified gradient
  77605. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  77606. * @returns this particle system
  77607. */
  77608. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  77609. /**
  77610. * Remove a specific color gradient
  77611. * @param gradient defines the gradient to remove
  77612. * @returns this particle system
  77613. */
  77614. removeColorGradient(gradient: number): IParticleSystem;
  77615. private _fetchR;
  77616. protected _reset(): void;
  77617. private _resetEffect;
  77618. private _createVertexBuffers;
  77619. private _createIndexBuffer;
  77620. /**
  77621. * Gets the maximum number of particles active at the same time.
  77622. * @returns The max number of active particles.
  77623. */
  77624. getCapacity(): number;
  77625. /**
  77626. * Gets whether there are still active particles in the system.
  77627. * @returns True if it is alive, otherwise false.
  77628. */
  77629. isAlive(): boolean;
  77630. /**
  77631. * Gets if the system has been started. (Note: this will still be true after stop is called)
  77632. * @returns True if it has been started, otherwise false.
  77633. */
  77634. isStarted(): boolean;
  77635. private _prepareSubEmitterInternalArray;
  77636. /**
  77637. * Starts the particle system and begins to emit
  77638. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  77639. */
  77640. start(delay?: number): void;
  77641. /**
  77642. * Stops the particle system.
  77643. * @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.
  77644. */
  77645. stop(stopSubEmitters?: boolean): void;
  77646. /**
  77647. * Remove all active particles
  77648. */
  77649. reset(): void;
  77650. /**
  77651. * @hidden (for internal use only)
  77652. */
  77653. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  77654. /**
  77655. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  77656. * Its lifetime will start back at 0.
  77657. */
  77658. recycleParticle: (particle: Particle) => void;
  77659. private _stopSubEmitters;
  77660. private _createParticle;
  77661. private _removeFromRoot;
  77662. private _emitFromParticle;
  77663. private _update;
  77664. /** @hidden */
  77665. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  77666. /** @hidden */
  77667. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  77668. /** @hidden */
  77669. private _getEffect;
  77670. /**
  77671. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  77672. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  77673. */
  77674. animate(preWarmOnly?: boolean): void;
  77675. private _appendParticleVertices;
  77676. /**
  77677. * Rebuilds the particle system.
  77678. */
  77679. rebuild(): void;
  77680. /**
  77681. * Is this system ready to be used/rendered
  77682. * @return true if the system is ready
  77683. */
  77684. isReady(): boolean;
  77685. private _render;
  77686. /**
  77687. * Renders the particle system in its current state.
  77688. * @returns the current number of particles
  77689. */
  77690. render(): number;
  77691. /**
  77692. * Disposes the particle system and free the associated resources
  77693. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  77694. */
  77695. dispose(disposeTexture?: boolean): void;
  77696. /**
  77697. * Clones the particle system.
  77698. * @param name The name of the cloned object
  77699. * @param newEmitter The new emitter to use
  77700. * @returns the cloned particle system
  77701. */
  77702. clone(name: string, newEmitter: any): ParticleSystem;
  77703. /**
  77704. * Serializes the particle system to a JSON object.
  77705. * @returns the JSON object
  77706. */
  77707. serialize(): any;
  77708. /** @hidden */
  77709. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  77710. /** @hidden */
  77711. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  77712. /**
  77713. * Parses a JSON object to create a particle system.
  77714. * @param parsedParticleSystem The JSON object to parse
  77715. * @param scene The scene to create the particle system in
  77716. * @param rootUrl The root url to use to load external dependencies like texture
  77717. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  77718. * @returns the Parsed particle system
  77719. */
  77720. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  77721. }
  77722. }
  77723. declare module BABYLON {
  77724. /**
  77725. * A particle represents one of the element emitted by a particle system.
  77726. * This is mainly define by its coordinates, direction, velocity and age.
  77727. */
  77728. export class Particle {
  77729. /**
  77730. * The particle system the particle belongs to.
  77731. */
  77732. particleSystem: ParticleSystem;
  77733. private static _Count;
  77734. /**
  77735. * Unique ID of the particle
  77736. */
  77737. id: number;
  77738. /**
  77739. * The world position of the particle in the scene.
  77740. */
  77741. position: Vector3;
  77742. /**
  77743. * The world direction of the particle in the scene.
  77744. */
  77745. direction: Vector3;
  77746. /**
  77747. * The color of the particle.
  77748. */
  77749. color: Color4;
  77750. /**
  77751. * The color change of the particle per step.
  77752. */
  77753. colorStep: Color4;
  77754. /**
  77755. * Defines how long will the life of the particle be.
  77756. */
  77757. lifeTime: number;
  77758. /**
  77759. * The current age of the particle.
  77760. */
  77761. age: number;
  77762. /**
  77763. * The current size of the particle.
  77764. */
  77765. size: number;
  77766. /**
  77767. * The current scale of the particle.
  77768. */
  77769. scale: Vector2;
  77770. /**
  77771. * The current angle of the particle.
  77772. */
  77773. angle: number;
  77774. /**
  77775. * Defines how fast is the angle changing.
  77776. */
  77777. angularSpeed: number;
  77778. /**
  77779. * Defines the cell index used by the particle to be rendered from a sprite.
  77780. */
  77781. cellIndex: number;
  77782. /**
  77783. * The information required to support color remapping
  77784. */
  77785. remapData: Vector4;
  77786. /** @hidden */
  77787. _randomCellOffset?: number;
  77788. /** @hidden */
  77789. _initialDirection: Nullable<Vector3>;
  77790. /** @hidden */
  77791. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  77792. /** @hidden */
  77793. _initialStartSpriteCellID: number;
  77794. /** @hidden */
  77795. _initialEndSpriteCellID: number;
  77796. /** @hidden */
  77797. _currentColorGradient: Nullable<ColorGradient>;
  77798. /** @hidden */
  77799. _currentColor1: Color4;
  77800. /** @hidden */
  77801. _currentColor2: Color4;
  77802. /** @hidden */
  77803. _currentSizeGradient: Nullable<FactorGradient>;
  77804. /** @hidden */
  77805. _currentSize1: number;
  77806. /** @hidden */
  77807. _currentSize2: number;
  77808. /** @hidden */
  77809. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  77810. /** @hidden */
  77811. _currentAngularSpeed1: number;
  77812. /** @hidden */
  77813. _currentAngularSpeed2: number;
  77814. /** @hidden */
  77815. _currentVelocityGradient: Nullable<FactorGradient>;
  77816. /** @hidden */
  77817. _currentVelocity1: number;
  77818. /** @hidden */
  77819. _currentVelocity2: number;
  77820. /** @hidden */
  77821. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  77822. /** @hidden */
  77823. _currentLimitVelocity1: number;
  77824. /** @hidden */
  77825. _currentLimitVelocity2: number;
  77826. /** @hidden */
  77827. _currentDragGradient: Nullable<FactorGradient>;
  77828. /** @hidden */
  77829. _currentDrag1: number;
  77830. /** @hidden */
  77831. _currentDrag2: number;
  77832. /** @hidden */
  77833. _randomNoiseCoordinates1: Vector3;
  77834. /** @hidden */
  77835. _randomNoiseCoordinates2: Vector3;
  77836. /**
  77837. * Creates a new instance Particle
  77838. * @param particleSystem the particle system the particle belongs to
  77839. */
  77840. constructor(
  77841. /**
  77842. * The particle system the particle belongs to.
  77843. */
  77844. particleSystem: ParticleSystem);
  77845. private updateCellInfoFromSystem;
  77846. /**
  77847. * Defines how the sprite cell index is updated for the particle
  77848. */
  77849. updateCellIndex(): void;
  77850. /** @hidden */
  77851. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  77852. /** @hidden */
  77853. _inheritParticleInfoToSubEmitters(): void;
  77854. /** @hidden */
  77855. _reset(): void;
  77856. /**
  77857. * Copy the properties of particle to another one.
  77858. * @param other the particle to copy the information to.
  77859. */
  77860. copyTo(other: Particle): void;
  77861. }
  77862. }
  77863. declare module BABYLON {
  77864. /**
  77865. * Particle emitter represents a volume emitting particles.
  77866. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  77867. */
  77868. export interface IParticleEmitterType {
  77869. /**
  77870. * Called by the particle System when the direction is computed for the created particle.
  77871. * @param worldMatrix is the world matrix of the particle system
  77872. * @param directionToUpdate is the direction vector to update with the result
  77873. * @param particle is the particle we are computed the direction for
  77874. */
  77875. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  77876. /**
  77877. * Called by the particle System when the position is computed for the created particle.
  77878. * @param worldMatrix is the world matrix of the particle system
  77879. * @param positionToUpdate is the position vector to update with the result
  77880. * @param particle is the particle we are computed the position for
  77881. */
  77882. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  77883. /**
  77884. * Clones the current emitter and returns a copy of it
  77885. * @returns the new emitter
  77886. */
  77887. clone(): IParticleEmitterType;
  77888. /**
  77889. * Called by the GPUParticleSystem to setup the update shader
  77890. * @param effect defines the update shader
  77891. */
  77892. applyToShader(effect: Effect): void;
  77893. /**
  77894. * Returns a string to use to update the GPU particles update shader
  77895. * @returns the effect defines string
  77896. */
  77897. getEffectDefines(): string;
  77898. /**
  77899. * Returns a string representing the class name
  77900. * @returns a string containing the class name
  77901. */
  77902. getClassName(): string;
  77903. /**
  77904. * Serializes the particle system to a JSON object.
  77905. * @returns the JSON object
  77906. */
  77907. serialize(): any;
  77908. /**
  77909. * Parse properties from a JSON object
  77910. * @param serializationObject defines the JSON object
  77911. */
  77912. parse(serializationObject: any): void;
  77913. }
  77914. }
  77915. declare module BABYLON {
  77916. /**
  77917. * Particle emitter emitting particles from the inside of a box.
  77918. * It emits the particles randomly between 2 given directions.
  77919. */
  77920. export class BoxParticleEmitter implements IParticleEmitterType {
  77921. /**
  77922. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  77923. */
  77924. direction1: Vector3;
  77925. /**
  77926. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  77927. */
  77928. direction2: Vector3;
  77929. /**
  77930. * 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.
  77931. */
  77932. minEmitBox: Vector3;
  77933. /**
  77934. * 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.
  77935. */
  77936. maxEmitBox: Vector3;
  77937. /**
  77938. * Creates a new instance BoxParticleEmitter
  77939. */
  77940. constructor();
  77941. /**
  77942. * Called by the particle System when the direction is computed for the created particle.
  77943. * @param worldMatrix is the world matrix of the particle system
  77944. * @param directionToUpdate is the direction vector to update with the result
  77945. * @param particle is the particle we are computed the direction for
  77946. */
  77947. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  77948. /**
  77949. * Called by the particle System when the position is computed for the created particle.
  77950. * @param worldMatrix is the world matrix of the particle system
  77951. * @param positionToUpdate is the position vector to update with the result
  77952. * @param particle is the particle we are computed the position for
  77953. */
  77954. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  77955. /**
  77956. * Clones the current emitter and returns a copy of it
  77957. * @returns the new emitter
  77958. */
  77959. clone(): BoxParticleEmitter;
  77960. /**
  77961. * Called by the GPUParticleSystem to setup the update shader
  77962. * @param effect defines the update shader
  77963. */
  77964. applyToShader(effect: Effect): void;
  77965. /**
  77966. * Returns a string to use to update the GPU particles update shader
  77967. * @returns a string containng the defines string
  77968. */
  77969. getEffectDefines(): string;
  77970. /**
  77971. * Returns the string "BoxParticleEmitter"
  77972. * @returns a string containing the class name
  77973. */
  77974. getClassName(): string;
  77975. /**
  77976. * Serializes the particle system to a JSON object.
  77977. * @returns the JSON object
  77978. */
  77979. serialize(): any;
  77980. /**
  77981. * Parse properties from a JSON object
  77982. * @param serializationObject defines the JSON object
  77983. */
  77984. parse(serializationObject: any): void;
  77985. }
  77986. }
  77987. declare module BABYLON {
  77988. /**
  77989. * Particle emitter emitting particles from the inside of a cone.
  77990. * It emits the particles alongside the cone volume from the base to the particle.
  77991. * The emission direction might be randomized.
  77992. */
  77993. export class ConeParticleEmitter implements IParticleEmitterType {
  77994. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  77995. directionRandomizer: number;
  77996. private _radius;
  77997. private _angle;
  77998. private _height;
  77999. /**
  78000. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  78001. */
  78002. radiusRange: number;
  78003. /**
  78004. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  78005. */
  78006. heightRange: number;
  78007. /**
  78008. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  78009. */
  78010. emitFromSpawnPointOnly: boolean;
  78011. /**
  78012. * Gets or sets the radius of the emission cone
  78013. */
  78014. radius: number;
  78015. /**
  78016. * Gets or sets the angle of the emission cone
  78017. */
  78018. angle: number;
  78019. private _buildHeight;
  78020. /**
  78021. * Creates a new instance ConeParticleEmitter
  78022. * @param radius the radius of the emission cone (1 by default)
  78023. * @param angle the cone base angle (PI by default)
  78024. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  78025. */
  78026. constructor(radius?: number, angle?: number,
  78027. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  78028. directionRandomizer?: number);
  78029. /**
  78030. * Called by the particle System when the direction is computed for the created particle.
  78031. * @param worldMatrix is the world matrix of the particle system
  78032. * @param directionToUpdate is the direction vector to update with the result
  78033. * @param particle is the particle we are computed the direction for
  78034. */
  78035. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  78036. /**
  78037. * Called by the particle System when the position is computed for the created particle.
  78038. * @param worldMatrix is the world matrix of the particle system
  78039. * @param positionToUpdate is the position vector to update with the result
  78040. * @param particle is the particle we are computed the position for
  78041. */
  78042. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  78043. /**
  78044. * Clones the current emitter and returns a copy of it
  78045. * @returns the new emitter
  78046. */
  78047. clone(): ConeParticleEmitter;
  78048. /**
  78049. * Called by the GPUParticleSystem to setup the update shader
  78050. * @param effect defines the update shader
  78051. */
  78052. applyToShader(effect: Effect): void;
  78053. /**
  78054. * Returns a string to use to update the GPU particles update shader
  78055. * @returns a string containng the defines string
  78056. */
  78057. getEffectDefines(): string;
  78058. /**
  78059. * Returns the string "ConeParticleEmitter"
  78060. * @returns a string containing the class name
  78061. */
  78062. getClassName(): string;
  78063. /**
  78064. * Serializes the particle system to a JSON object.
  78065. * @returns the JSON object
  78066. */
  78067. serialize(): any;
  78068. /**
  78069. * Parse properties from a JSON object
  78070. * @param serializationObject defines the JSON object
  78071. */
  78072. parse(serializationObject: any): void;
  78073. }
  78074. }
  78075. declare module BABYLON {
  78076. /**
  78077. * Particle emitter emitting particles from the inside of a cylinder.
  78078. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  78079. */
  78080. export class CylinderParticleEmitter implements IParticleEmitterType {
  78081. /**
  78082. * The radius of the emission cylinder.
  78083. */
  78084. radius: number;
  78085. /**
  78086. * The height of the emission cylinder.
  78087. */
  78088. height: number;
  78089. /**
  78090. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  78091. */
  78092. radiusRange: number;
  78093. /**
  78094. * How much to randomize the particle direction [0-1].
  78095. */
  78096. directionRandomizer: number;
  78097. /**
  78098. * Creates a new instance CylinderParticleEmitter
  78099. * @param radius the radius of the emission cylinder (1 by default)
  78100. * @param height the height of the emission cylinder (1 by default)
  78101. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  78102. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  78103. */
  78104. constructor(
  78105. /**
  78106. * The radius of the emission cylinder.
  78107. */
  78108. radius?: number,
  78109. /**
  78110. * The height of the emission cylinder.
  78111. */
  78112. height?: number,
  78113. /**
  78114. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  78115. */
  78116. radiusRange?: number,
  78117. /**
  78118. * How much to randomize the particle direction [0-1].
  78119. */
  78120. directionRandomizer?: number);
  78121. /**
  78122. * Called by the particle System when the direction is computed for the created particle.
  78123. * @param worldMatrix is the world matrix of the particle system
  78124. * @param directionToUpdate is the direction vector to update with the result
  78125. * @param particle is the particle we are computed the direction for
  78126. */
  78127. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  78128. /**
  78129. * Called by the particle System when the position is computed for the created particle.
  78130. * @param worldMatrix is the world matrix of the particle system
  78131. * @param positionToUpdate is the position vector to update with the result
  78132. * @param particle is the particle we are computed the position for
  78133. */
  78134. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  78135. /**
  78136. * Clones the current emitter and returns a copy of it
  78137. * @returns the new emitter
  78138. */
  78139. clone(): CylinderParticleEmitter;
  78140. /**
  78141. * Called by the GPUParticleSystem to setup the update shader
  78142. * @param effect defines the update shader
  78143. */
  78144. applyToShader(effect: Effect): void;
  78145. /**
  78146. * Returns a string to use to update the GPU particles update shader
  78147. * @returns a string containng the defines string
  78148. */
  78149. getEffectDefines(): string;
  78150. /**
  78151. * Returns the string "CylinderParticleEmitter"
  78152. * @returns a string containing the class name
  78153. */
  78154. getClassName(): string;
  78155. /**
  78156. * Serializes the particle system to a JSON object.
  78157. * @returns the JSON object
  78158. */
  78159. serialize(): any;
  78160. /**
  78161. * Parse properties from a JSON object
  78162. * @param serializationObject defines the JSON object
  78163. */
  78164. parse(serializationObject: any): void;
  78165. }
  78166. /**
  78167. * Particle emitter emitting particles from the inside of a cylinder.
  78168. * It emits the particles randomly between two vectors.
  78169. */
  78170. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  78171. /**
  78172. * The min limit of the emission direction.
  78173. */
  78174. direction1: Vector3;
  78175. /**
  78176. * The max limit of the emission direction.
  78177. */
  78178. direction2: Vector3;
  78179. /**
  78180. * Creates a new instance CylinderDirectedParticleEmitter
  78181. * @param radius the radius of the emission cylinder (1 by default)
  78182. * @param height the height of the emission cylinder (1 by default)
  78183. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  78184. * @param direction1 the min limit of the emission direction (up vector by default)
  78185. * @param direction2 the max limit of the emission direction (up vector by default)
  78186. */
  78187. constructor(radius?: number, height?: number, radiusRange?: number,
  78188. /**
  78189. * The min limit of the emission direction.
  78190. */
  78191. direction1?: Vector3,
  78192. /**
  78193. * The max limit of the emission direction.
  78194. */
  78195. direction2?: Vector3);
  78196. /**
  78197. * Called by the particle System when the direction is computed for the created particle.
  78198. * @param worldMatrix is the world matrix of the particle system
  78199. * @param directionToUpdate is the direction vector to update with the result
  78200. * @param particle is the particle we are computed the direction for
  78201. */
  78202. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  78203. /**
  78204. * Clones the current emitter and returns a copy of it
  78205. * @returns the new emitter
  78206. */
  78207. clone(): CylinderDirectedParticleEmitter;
  78208. /**
  78209. * Called by the GPUParticleSystem to setup the update shader
  78210. * @param effect defines the update shader
  78211. */
  78212. applyToShader(effect: Effect): void;
  78213. /**
  78214. * Returns a string to use to update the GPU particles update shader
  78215. * @returns a string containng the defines string
  78216. */
  78217. getEffectDefines(): string;
  78218. /**
  78219. * Returns the string "CylinderDirectedParticleEmitter"
  78220. * @returns a string containing the class name
  78221. */
  78222. getClassName(): string;
  78223. /**
  78224. * Serializes the particle system to a JSON object.
  78225. * @returns the JSON object
  78226. */
  78227. serialize(): any;
  78228. /**
  78229. * Parse properties from a JSON object
  78230. * @param serializationObject defines the JSON object
  78231. */
  78232. parse(serializationObject: any): void;
  78233. }
  78234. }
  78235. declare module BABYLON {
  78236. /**
  78237. * Particle emitter emitting particles from the inside of a hemisphere.
  78238. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  78239. */
  78240. export class HemisphericParticleEmitter implements IParticleEmitterType {
  78241. /**
  78242. * The radius of the emission hemisphere.
  78243. */
  78244. radius: number;
  78245. /**
  78246. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  78247. */
  78248. radiusRange: number;
  78249. /**
  78250. * How much to randomize the particle direction [0-1].
  78251. */
  78252. directionRandomizer: number;
  78253. /**
  78254. * Creates a new instance HemisphericParticleEmitter
  78255. * @param radius the radius of the emission hemisphere (1 by default)
  78256. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  78257. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  78258. */
  78259. constructor(
  78260. /**
  78261. * The radius of the emission hemisphere.
  78262. */
  78263. radius?: number,
  78264. /**
  78265. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  78266. */
  78267. radiusRange?: number,
  78268. /**
  78269. * How much to randomize the particle direction [0-1].
  78270. */
  78271. directionRandomizer?: number);
  78272. /**
  78273. * Called by the particle System when the direction is computed for the created particle.
  78274. * @param worldMatrix is the world matrix of the particle system
  78275. * @param directionToUpdate is the direction vector to update with the result
  78276. * @param particle is the particle we are computed the direction for
  78277. */
  78278. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  78279. /**
  78280. * Called by the particle System when the position is computed for the created particle.
  78281. * @param worldMatrix is the world matrix of the particle system
  78282. * @param positionToUpdate is the position vector to update with the result
  78283. * @param particle is the particle we are computed the position for
  78284. */
  78285. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  78286. /**
  78287. * Clones the current emitter and returns a copy of it
  78288. * @returns the new emitter
  78289. */
  78290. clone(): HemisphericParticleEmitter;
  78291. /**
  78292. * Called by the GPUParticleSystem to setup the update shader
  78293. * @param effect defines the update shader
  78294. */
  78295. applyToShader(effect: Effect): void;
  78296. /**
  78297. * Returns a string to use to update the GPU particles update shader
  78298. * @returns a string containng the defines string
  78299. */
  78300. getEffectDefines(): string;
  78301. /**
  78302. * Returns the string "HemisphericParticleEmitter"
  78303. * @returns a string containing the class name
  78304. */
  78305. getClassName(): string;
  78306. /**
  78307. * Serializes the particle system to a JSON object.
  78308. * @returns the JSON object
  78309. */
  78310. serialize(): any;
  78311. /**
  78312. * Parse properties from a JSON object
  78313. * @param serializationObject defines the JSON object
  78314. */
  78315. parse(serializationObject: any): void;
  78316. }
  78317. }
  78318. declare module BABYLON {
  78319. /**
  78320. * Particle emitter emitting particles from a point.
  78321. * It emits the particles randomly between 2 given directions.
  78322. */
  78323. export class PointParticleEmitter implements IParticleEmitterType {
  78324. /**
  78325. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  78326. */
  78327. direction1: Vector3;
  78328. /**
  78329. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  78330. */
  78331. direction2: Vector3;
  78332. /**
  78333. * Creates a new instance PointParticleEmitter
  78334. */
  78335. constructor();
  78336. /**
  78337. * Called by the particle System when the direction is computed for the created particle.
  78338. * @param worldMatrix is the world matrix of the particle system
  78339. * @param directionToUpdate is the direction vector to update with the result
  78340. * @param particle is the particle we are computed the direction for
  78341. */
  78342. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  78343. /**
  78344. * Called by the particle System when the position is computed for the created particle.
  78345. * @param worldMatrix is the world matrix of the particle system
  78346. * @param positionToUpdate is the position vector to update with the result
  78347. * @param particle is the particle we are computed the position for
  78348. */
  78349. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  78350. /**
  78351. * Clones the current emitter and returns a copy of it
  78352. * @returns the new emitter
  78353. */
  78354. clone(): PointParticleEmitter;
  78355. /**
  78356. * Called by the GPUParticleSystem to setup the update shader
  78357. * @param effect defines the update shader
  78358. */
  78359. applyToShader(effect: Effect): void;
  78360. /**
  78361. * Returns a string to use to update the GPU particles update shader
  78362. * @returns a string containng the defines string
  78363. */
  78364. getEffectDefines(): string;
  78365. /**
  78366. * Returns the string "PointParticleEmitter"
  78367. * @returns a string containing the class name
  78368. */
  78369. getClassName(): string;
  78370. /**
  78371. * Serializes the particle system to a JSON object.
  78372. * @returns the JSON object
  78373. */
  78374. serialize(): any;
  78375. /**
  78376. * Parse properties from a JSON object
  78377. * @param serializationObject defines the JSON object
  78378. */
  78379. parse(serializationObject: any): void;
  78380. }
  78381. }
  78382. declare module BABYLON {
  78383. /**
  78384. * Particle emitter emitting particles from the inside of a sphere.
  78385. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  78386. */
  78387. export class SphereParticleEmitter implements IParticleEmitterType {
  78388. /**
  78389. * The radius of the emission sphere.
  78390. */
  78391. radius: number;
  78392. /**
  78393. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  78394. */
  78395. radiusRange: number;
  78396. /**
  78397. * How much to randomize the particle direction [0-1].
  78398. */
  78399. directionRandomizer: number;
  78400. /**
  78401. * Creates a new instance SphereParticleEmitter
  78402. * @param radius the radius of the emission sphere (1 by default)
  78403. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  78404. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  78405. */
  78406. constructor(
  78407. /**
  78408. * The radius of the emission sphere.
  78409. */
  78410. radius?: number,
  78411. /**
  78412. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  78413. */
  78414. radiusRange?: number,
  78415. /**
  78416. * How much to randomize the particle direction [0-1].
  78417. */
  78418. directionRandomizer?: number);
  78419. /**
  78420. * Called by the particle System when the direction is computed for the created particle.
  78421. * @param worldMatrix is the world matrix of the particle system
  78422. * @param directionToUpdate is the direction vector to update with the result
  78423. * @param particle is the particle we are computed the direction for
  78424. */
  78425. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  78426. /**
  78427. * Called by the particle System when the position is computed for the created particle.
  78428. * @param worldMatrix is the world matrix of the particle system
  78429. * @param positionToUpdate is the position vector to update with the result
  78430. * @param particle is the particle we are computed the position for
  78431. */
  78432. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  78433. /**
  78434. * Clones the current emitter and returns a copy of it
  78435. * @returns the new emitter
  78436. */
  78437. clone(): SphereParticleEmitter;
  78438. /**
  78439. * Called by the GPUParticleSystem to setup the update shader
  78440. * @param effect defines the update shader
  78441. */
  78442. applyToShader(effect: Effect): void;
  78443. /**
  78444. * Returns a string to use to update the GPU particles update shader
  78445. * @returns a string containng the defines string
  78446. */
  78447. getEffectDefines(): string;
  78448. /**
  78449. * Returns the string "SphereParticleEmitter"
  78450. * @returns a string containing the class name
  78451. */
  78452. getClassName(): string;
  78453. /**
  78454. * Serializes the particle system to a JSON object.
  78455. * @returns the JSON object
  78456. */
  78457. serialize(): any;
  78458. /**
  78459. * Parse properties from a JSON object
  78460. * @param serializationObject defines the JSON object
  78461. */
  78462. parse(serializationObject: any): void;
  78463. }
  78464. /**
  78465. * Particle emitter emitting particles from the inside of a sphere.
  78466. * It emits the particles randomly between two vectors.
  78467. */
  78468. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  78469. /**
  78470. * The min limit of the emission direction.
  78471. */
  78472. direction1: Vector3;
  78473. /**
  78474. * The max limit of the emission direction.
  78475. */
  78476. direction2: Vector3;
  78477. /**
  78478. * Creates a new instance SphereDirectedParticleEmitter
  78479. * @param radius the radius of the emission sphere (1 by default)
  78480. * @param direction1 the min limit of the emission direction (up vector by default)
  78481. * @param direction2 the max limit of the emission direction (up vector by default)
  78482. */
  78483. constructor(radius?: number,
  78484. /**
  78485. * The min limit of the emission direction.
  78486. */
  78487. direction1?: Vector3,
  78488. /**
  78489. * The max limit of the emission direction.
  78490. */
  78491. direction2?: Vector3);
  78492. /**
  78493. * Called by the particle System when the direction is computed for the created particle.
  78494. * @param worldMatrix is the world matrix of the particle system
  78495. * @param directionToUpdate is the direction vector to update with the result
  78496. * @param particle is the particle we are computed the direction for
  78497. */
  78498. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  78499. /**
  78500. * Clones the current emitter and returns a copy of it
  78501. * @returns the new emitter
  78502. */
  78503. clone(): SphereDirectedParticleEmitter;
  78504. /**
  78505. * Called by the GPUParticleSystem to setup the update shader
  78506. * @param effect defines the update shader
  78507. */
  78508. applyToShader(effect: Effect): void;
  78509. /**
  78510. * Returns a string to use to update the GPU particles update shader
  78511. * @returns a string containng the defines string
  78512. */
  78513. getEffectDefines(): string;
  78514. /**
  78515. * Returns the string "SphereDirectedParticleEmitter"
  78516. * @returns a string containing the class name
  78517. */
  78518. getClassName(): string;
  78519. /**
  78520. * Serializes the particle system to a JSON object.
  78521. * @returns the JSON object
  78522. */
  78523. serialize(): any;
  78524. /**
  78525. * Parse properties from a JSON object
  78526. * @param serializationObject defines the JSON object
  78527. */
  78528. parse(serializationObject: any): void;
  78529. }
  78530. }
  78531. declare module BABYLON {
  78532. /**
  78533. * Interface representing a particle system in Babylon.js.
  78534. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  78535. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  78536. */
  78537. export interface IParticleSystem {
  78538. /**
  78539. * List of animations used by the particle system.
  78540. */
  78541. animations: Animation[];
  78542. /**
  78543. * The id of the Particle system.
  78544. */
  78545. id: string;
  78546. /**
  78547. * The name of the Particle system.
  78548. */
  78549. name: string;
  78550. /**
  78551. * The emitter represents the Mesh or position we are attaching the particle system to.
  78552. */
  78553. emitter: Nullable<AbstractMesh | Vector3>;
  78554. /**
  78555. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  78556. */
  78557. isBillboardBased: boolean;
  78558. /**
  78559. * The rendering group used by the Particle system to chose when to render.
  78560. */
  78561. renderingGroupId: number;
  78562. /**
  78563. * The layer mask we are rendering the particles through.
  78564. */
  78565. layerMask: number;
  78566. /**
  78567. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  78568. */
  78569. updateSpeed: number;
  78570. /**
  78571. * The amount of time the particle system is running (depends of the overall update speed).
  78572. */
  78573. targetStopDuration: number;
  78574. /**
  78575. * The texture used to render each particle. (this can be a spritesheet)
  78576. */
  78577. particleTexture: Nullable<Texture>;
  78578. /**
  78579. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  78580. */
  78581. blendMode: number;
  78582. /**
  78583. * Minimum life time of emitting particles.
  78584. */
  78585. minLifeTime: number;
  78586. /**
  78587. * Maximum life time of emitting particles.
  78588. */
  78589. maxLifeTime: number;
  78590. /**
  78591. * Minimum Size of emitting particles.
  78592. */
  78593. minSize: number;
  78594. /**
  78595. * Maximum Size of emitting particles.
  78596. */
  78597. maxSize: number;
  78598. /**
  78599. * Minimum scale of emitting particles on X axis.
  78600. */
  78601. minScaleX: number;
  78602. /**
  78603. * Maximum scale of emitting particles on X axis.
  78604. */
  78605. maxScaleX: number;
  78606. /**
  78607. * Minimum scale of emitting particles on Y axis.
  78608. */
  78609. minScaleY: number;
  78610. /**
  78611. * Maximum scale of emitting particles on Y axis.
  78612. */
  78613. maxScaleY: number;
  78614. /**
  78615. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  78616. */
  78617. color1: Color4;
  78618. /**
  78619. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  78620. */
  78621. color2: Color4;
  78622. /**
  78623. * Color the particle will have at the end of its lifetime.
  78624. */
  78625. colorDead: Color4;
  78626. /**
  78627. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  78628. */
  78629. emitRate: number;
  78630. /**
  78631. * You can use gravity if you want to give an orientation to your particles.
  78632. */
  78633. gravity: Vector3;
  78634. /**
  78635. * Minimum power of emitting particles.
  78636. */
  78637. minEmitPower: number;
  78638. /**
  78639. * Maximum power of emitting particles.
  78640. */
  78641. maxEmitPower: number;
  78642. /**
  78643. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  78644. */
  78645. minAngularSpeed: number;
  78646. /**
  78647. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  78648. */
  78649. maxAngularSpeed: number;
  78650. /**
  78651. * Gets or sets the minimal initial rotation in radians.
  78652. */
  78653. minInitialRotation: number;
  78654. /**
  78655. * Gets or sets the maximal initial rotation in radians.
  78656. */
  78657. maxInitialRotation: number;
  78658. /**
  78659. * The particle emitter type defines the emitter used by the particle system.
  78660. * It can be for example box, sphere, or cone...
  78661. */
  78662. particleEmitterType: Nullable<IParticleEmitterType>;
  78663. /**
  78664. * Defines the delay in milliseconds before starting the system (0 by default)
  78665. */
  78666. startDelay: number;
  78667. /**
  78668. * 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
  78669. */
  78670. preWarmCycles: number;
  78671. /**
  78672. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  78673. */
  78674. preWarmStepOffset: number;
  78675. /**
  78676. * 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)
  78677. */
  78678. spriteCellChangeSpeed: number;
  78679. /**
  78680. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  78681. */
  78682. startSpriteCellID: number;
  78683. /**
  78684. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  78685. */
  78686. endSpriteCellID: number;
  78687. /**
  78688. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  78689. */
  78690. spriteCellWidth: number;
  78691. /**
  78692. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  78693. */
  78694. spriteCellHeight: number;
  78695. /**
  78696. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  78697. */
  78698. spriteRandomStartCell: boolean;
  78699. /**
  78700. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  78701. */
  78702. isAnimationSheetEnabled: boolean;
  78703. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  78704. translationPivot: Vector2;
  78705. /**
  78706. * Gets or sets a texture used to add random noise to particle positions
  78707. */
  78708. noiseTexture: Nullable<BaseTexture>;
  78709. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  78710. noiseStrength: Vector3;
  78711. /**
  78712. * Gets or sets the billboard mode to use when isBillboardBased = true.
  78713. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  78714. */
  78715. billboardMode: number;
  78716. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  78717. limitVelocityDamping: number;
  78718. /**
  78719. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  78720. */
  78721. beginAnimationOnStart: boolean;
  78722. /**
  78723. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  78724. */
  78725. beginAnimationFrom: number;
  78726. /**
  78727. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  78728. */
  78729. beginAnimationTo: number;
  78730. /**
  78731. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  78732. */
  78733. beginAnimationLoop: boolean;
  78734. /**
  78735. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  78736. */
  78737. disposeOnStop: boolean;
  78738. /**
  78739. * Gets the maximum number of particles active at the same time.
  78740. * @returns The max number of active particles.
  78741. */
  78742. getCapacity(): number;
  78743. /**
  78744. * Gets if the system has been started. (Note: this will still be true after stop is called)
  78745. * @returns True if it has been started, otherwise false.
  78746. */
  78747. isStarted(): boolean;
  78748. /**
  78749. * Animates the particle system for this frame.
  78750. */
  78751. animate(): void;
  78752. /**
  78753. * Renders the particle system in its current state.
  78754. * @returns the current number of particles
  78755. */
  78756. render(): number;
  78757. /**
  78758. * Dispose the particle system and frees its associated resources.
  78759. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  78760. */
  78761. dispose(disposeTexture?: boolean): void;
  78762. /**
  78763. * Clones the particle system.
  78764. * @param name The name of the cloned object
  78765. * @param newEmitter The new emitter to use
  78766. * @returns the cloned particle system
  78767. */
  78768. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  78769. /**
  78770. * Serializes the particle system to a JSON object.
  78771. * @returns the JSON object
  78772. */
  78773. serialize(): any;
  78774. /**
  78775. * Rebuild the particle system
  78776. */
  78777. rebuild(): void;
  78778. /**
  78779. * Starts the particle system and begins to emit
  78780. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  78781. */
  78782. start(delay?: number): void;
  78783. /**
  78784. * Stops the particle system.
  78785. */
  78786. stop(): void;
  78787. /**
  78788. * Remove all active particles
  78789. */
  78790. reset(): void;
  78791. /**
  78792. * Is this system ready to be used/rendered
  78793. * @return true if the system is ready
  78794. */
  78795. isReady(): boolean;
  78796. /**
  78797. * Adds a new color gradient
  78798. * @param gradient defines the gradient to use (between 0 and 1)
  78799. * @param color1 defines the color to affect to the specified gradient
  78800. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  78801. * @returns the current particle system
  78802. */
  78803. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  78804. /**
  78805. * Remove a specific color gradient
  78806. * @param gradient defines the gradient to remove
  78807. * @returns the current particle system
  78808. */
  78809. removeColorGradient(gradient: number): IParticleSystem;
  78810. /**
  78811. * Adds a new size gradient
  78812. * @param gradient defines the gradient to use (between 0 and 1)
  78813. * @param factor defines the size factor to affect to the specified gradient
  78814. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  78815. * @returns the current particle system
  78816. */
  78817. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  78818. /**
  78819. * Remove a specific size gradient
  78820. * @param gradient defines the gradient to remove
  78821. * @returns the current particle system
  78822. */
  78823. removeSizeGradient(gradient: number): IParticleSystem;
  78824. /**
  78825. * Gets the current list of color gradients.
  78826. * You must use addColorGradient and removeColorGradient to udpate this list
  78827. * @returns the list of color gradients
  78828. */
  78829. getColorGradients(): Nullable<Array<ColorGradient>>;
  78830. /**
  78831. * Gets the current list of size gradients.
  78832. * You must use addSizeGradient and removeSizeGradient to udpate this list
  78833. * @returns the list of size gradients
  78834. */
  78835. getSizeGradients(): Nullable<Array<FactorGradient>>;
  78836. /**
  78837. * Gets the current list of angular speed gradients.
  78838. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  78839. * @returns the list of angular speed gradients
  78840. */
  78841. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  78842. /**
  78843. * Adds a new angular speed gradient
  78844. * @param gradient defines the gradient to use (between 0 and 1)
  78845. * @param factor defines the angular speed to affect to the specified gradient
  78846. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  78847. * @returns the current particle system
  78848. */
  78849. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  78850. /**
  78851. * Remove a specific angular speed gradient
  78852. * @param gradient defines the gradient to remove
  78853. * @returns the current particle system
  78854. */
  78855. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  78856. /**
  78857. * Gets the current list of velocity gradients.
  78858. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  78859. * @returns the list of velocity gradients
  78860. */
  78861. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  78862. /**
  78863. * Adds a new velocity gradient
  78864. * @param gradient defines the gradient to use (between 0 and 1)
  78865. * @param factor defines the velocity to affect to the specified gradient
  78866. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  78867. * @returns the current particle system
  78868. */
  78869. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  78870. /**
  78871. * Remove a specific velocity gradient
  78872. * @param gradient defines the gradient to remove
  78873. * @returns the current particle system
  78874. */
  78875. removeVelocityGradient(gradient: number): IParticleSystem;
  78876. /**
  78877. * Gets the current list of limit velocity gradients.
  78878. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  78879. * @returns the list of limit velocity gradients
  78880. */
  78881. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  78882. /**
  78883. * Adds a new limit velocity gradient
  78884. * @param gradient defines the gradient to use (between 0 and 1)
  78885. * @param factor defines the limit velocity to affect to the specified gradient
  78886. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  78887. * @returns the current particle system
  78888. */
  78889. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  78890. /**
  78891. * Remove a specific limit velocity gradient
  78892. * @param gradient defines the gradient to remove
  78893. * @returns the current particle system
  78894. */
  78895. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  78896. /**
  78897. * Adds a new drag gradient
  78898. * @param gradient defines the gradient to use (between 0 and 1)
  78899. * @param factor defines the drag to affect to the specified gradient
  78900. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  78901. * @returns the current particle system
  78902. */
  78903. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  78904. /**
  78905. * Remove a specific drag gradient
  78906. * @param gradient defines the gradient to remove
  78907. * @returns the current particle system
  78908. */
  78909. removeDragGradient(gradient: number): IParticleSystem;
  78910. /**
  78911. * Gets the current list of drag gradients.
  78912. * You must use addDragGradient and removeDragGradient to udpate this list
  78913. * @returns the list of drag gradients
  78914. */
  78915. getDragGradients(): Nullable<Array<FactorGradient>>;
  78916. /**
  78917. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  78918. * @param gradient defines the gradient to use (between 0 and 1)
  78919. * @param factor defines the emit rate to affect to the specified gradient
  78920. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  78921. * @returns the current particle system
  78922. */
  78923. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  78924. /**
  78925. * Remove a specific emit rate gradient
  78926. * @param gradient defines the gradient to remove
  78927. * @returns the current particle system
  78928. */
  78929. removeEmitRateGradient(gradient: number): IParticleSystem;
  78930. /**
  78931. * Gets the current list of emit rate gradients.
  78932. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  78933. * @returns the list of emit rate gradients
  78934. */
  78935. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  78936. /**
  78937. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  78938. * @param gradient defines the gradient to use (between 0 and 1)
  78939. * @param factor defines the start size to affect to the specified gradient
  78940. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  78941. * @returns the current particle system
  78942. */
  78943. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  78944. /**
  78945. * Remove a specific start size gradient
  78946. * @param gradient defines the gradient to remove
  78947. * @returns the current particle system
  78948. */
  78949. removeStartSizeGradient(gradient: number): IParticleSystem;
  78950. /**
  78951. * Gets the current list of start size gradients.
  78952. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  78953. * @returns the list of start size gradients
  78954. */
  78955. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  78956. /**
  78957. * Adds a new life time gradient
  78958. * @param gradient defines the gradient to use (between 0 and 1)
  78959. * @param factor defines the life time factor to affect to the specified gradient
  78960. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  78961. * @returns the current particle system
  78962. */
  78963. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  78964. /**
  78965. * Remove a specific life time gradient
  78966. * @param gradient defines the gradient to remove
  78967. * @returns the current particle system
  78968. */
  78969. removeLifeTimeGradient(gradient: number): IParticleSystem;
  78970. /**
  78971. * Gets the current list of life time gradients.
  78972. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  78973. * @returns the list of life time gradients
  78974. */
  78975. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  78976. /**
  78977. * Gets the current list of color gradients.
  78978. * You must use addColorGradient and removeColorGradient to udpate this list
  78979. * @returns the list of color gradients
  78980. */
  78981. getColorGradients(): Nullable<Array<ColorGradient>>;
  78982. /**
  78983. * Adds a new ramp gradient used to remap particle colors
  78984. * @param gradient defines the gradient to use (between 0 and 1)
  78985. * @param color defines the color to affect to the specified gradient
  78986. * @returns the current particle system
  78987. */
  78988. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  78989. /**
  78990. * Gets the current list of ramp gradients.
  78991. * You must use addRampGradient and removeRampGradient to udpate this list
  78992. * @returns the list of ramp gradients
  78993. */
  78994. getRampGradients(): Nullable<Array<Color3Gradient>>;
  78995. /** Gets or sets a boolean indicating that ramp gradients must be used
  78996. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  78997. */
  78998. useRampGradients: boolean;
  78999. /**
  79000. * Adds a new color remap gradient
  79001. * @param gradient defines the gradient to use (between 0 and 1)
  79002. * @param min defines the color remap minimal range
  79003. * @param max defines the color remap maximal range
  79004. * @returns the current particle system
  79005. */
  79006. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  79007. /**
  79008. * Gets the current list of color remap gradients.
  79009. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  79010. * @returns the list of color remap gradients
  79011. */
  79012. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  79013. /**
  79014. * Adds a new alpha remap gradient
  79015. * @param gradient defines the gradient to use (between 0 and 1)
  79016. * @param min defines the alpha remap minimal range
  79017. * @param max defines the alpha remap maximal range
  79018. * @returns the current particle system
  79019. */
  79020. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  79021. /**
  79022. * Gets the current list of alpha remap gradients.
  79023. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  79024. * @returns the list of alpha remap gradients
  79025. */
  79026. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  79027. /**
  79028. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  79029. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  79030. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  79031. * @returns the emitter
  79032. */
  79033. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  79034. /**
  79035. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  79036. * @param radius The radius of the hemisphere to emit from
  79037. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  79038. * @returns the emitter
  79039. */
  79040. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  79041. /**
  79042. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  79043. * @param radius The radius of the sphere to emit from
  79044. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  79045. * @returns the emitter
  79046. */
  79047. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  79048. /**
  79049. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  79050. * @param radius The radius of the sphere to emit from
  79051. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  79052. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  79053. * @returns the emitter
  79054. */
  79055. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  79056. /**
  79057. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  79058. * @param radius The radius of the emission cylinder
  79059. * @param height The height of the emission cylinder
  79060. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  79061. * @param directionRandomizer How much to randomize the particle direction [0-1]
  79062. * @returns the emitter
  79063. */
  79064. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  79065. /**
  79066. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  79067. * @param radius The radius of the cylinder to emit from
  79068. * @param height The height of the emission cylinder
  79069. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  79070. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  79071. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  79072. * @returns the emitter
  79073. */
  79074. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  79075. /**
  79076. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  79077. * @param radius The radius of the cone to emit from
  79078. * @param angle The base angle of the cone
  79079. * @returns the emitter
  79080. */
  79081. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  79082. /**
  79083. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  79084. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  79085. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  79086. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  79087. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  79088. * @returns the emitter
  79089. */
  79090. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  79091. /**
  79092. * Get hosting scene
  79093. * @returns the scene
  79094. */
  79095. getScene(): Scene;
  79096. }
  79097. }
  79098. declare module BABYLON {
  79099. /**
  79100. * Creates an instance based on a source mesh.
  79101. */
  79102. export class InstancedMesh extends AbstractMesh {
  79103. private _sourceMesh;
  79104. private _currentLOD;
  79105. /** @hidden */
  79106. _indexInSourceMeshInstanceArray: number;
  79107. constructor(name: string, source: Mesh);
  79108. /**
  79109. * Returns the string "InstancedMesh".
  79110. */
  79111. getClassName(): string;
  79112. /** Gets the list of lights affecting that mesh */
  79113. readonly lightSources: Light[];
  79114. _resyncLightSources(): void;
  79115. _resyncLighSource(light: Light): void;
  79116. _removeLightSource(light: Light): void;
  79117. /**
  79118. * If the source mesh receives shadows
  79119. */
  79120. readonly receiveShadows: boolean;
  79121. /**
  79122. * The material of the source mesh
  79123. */
  79124. readonly material: Nullable<Material>;
  79125. /**
  79126. * Visibility of the source mesh
  79127. */
  79128. readonly visibility: number;
  79129. /**
  79130. * Skeleton of the source mesh
  79131. */
  79132. readonly skeleton: Nullable<Skeleton>;
  79133. /**
  79134. * Rendering ground id of the source mesh
  79135. */
  79136. renderingGroupId: number;
  79137. /**
  79138. * Returns the total number of vertices (integer).
  79139. */
  79140. getTotalVertices(): number;
  79141. /**
  79142. * Returns a positive integer : the total number of indices in this mesh geometry.
  79143. * @returns the numner of indices or zero if the mesh has no geometry.
  79144. */
  79145. getTotalIndices(): number;
  79146. /**
  79147. * The source mesh of the instance
  79148. */
  79149. readonly sourceMesh: Mesh;
  79150. /**
  79151. * Is this node ready to be used/rendered
  79152. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  79153. * @return {boolean} is it ready
  79154. */
  79155. isReady(completeCheck?: boolean): boolean;
  79156. /**
  79157. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  79158. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  79159. * @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.
  79160. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  79161. */
  79162. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  79163. /**
  79164. * Sets the vertex data of the mesh geometry for the requested `kind`.
  79165. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  79166. * The `data` are either a numeric array either a Float32Array.
  79167. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  79168. * 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).
  79169. * Note that a new underlying VertexBuffer object is created each call.
  79170. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  79171. *
  79172. * Possible `kind` values :
  79173. * - VertexBuffer.PositionKind
  79174. * - VertexBuffer.UVKind
  79175. * - VertexBuffer.UV2Kind
  79176. * - VertexBuffer.UV3Kind
  79177. * - VertexBuffer.UV4Kind
  79178. * - VertexBuffer.UV5Kind
  79179. * - VertexBuffer.UV6Kind
  79180. * - VertexBuffer.ColorKind
  79181. * - VertexBuffer.MatricesIndicesKind
  79182. * - VertexBuffer.MatricesIndicesExtraKind
  79183. * - VertexBuffer.MatricesWeightsKind
  79184. * - VertexBuffer.MatricesWeightsExtraKind
  79185. *
  79186. * Returns the Mesh.
  79187. */
  79188. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  79189. /**
  79190. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  79191. * If the mesh has no geometry, it is simply returned as it is.
  79192. * The `data` are either a numeric array either a Float32Array.
  79193. * No new underlying VertexBuffer object is created.
  79194. * 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.
  79195. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  79196. *
  79197. * Possible `kind` values :
  79198. * - VertexBuffer.PositionKind
  79199. * - VertexBuffer.UVKind
  79200. * - VertexBuffer.UV2Kind
  79201. * - VertexBuffer.UV3Kind
  79202. * - VertexBuffer.UV4Kind
  79203. * - VertexBuffer.UV5Kind
  79204. * - VertexBuffer.UV6Kind
  79205. * - VertexBuffer.ColorKind
  79206. * - VertexBuffer.MatricesIndicesKind
  79207. * - VertexBuffer.MatricesIndicesExtraKind
  79208. * - VertexBuffer.MatricesWeightsKind
  79209. * - VertexBuffer.MatricesWeightsExtraKind
  79210. *
  79211. * Returns the Mesh.
  79212. */
  79213. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  79214. /**
  79215. * Sets the mesh indices.
  79216. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  79217. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  79218. * This method creates a new index buffer each call.
  79219. * Returns the Mesh.
  79220. */
  79221. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  79222. /**
  79223. * Boolean : True if the mesh owns the requested kind of data.
  79224. */
  79225. isVerticesDataPresent(kind: string): boolean;
  79226. /**
  79227. * Returns an array of indices (IndicesArray).
  79228. */
  79229. getIndices(): Nullable<IndicesArray>;
  79230. readonly _positions: Nullable<Vector3[]>;
  79231. /**
  79232. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  79233. * This means the mesh underlying bounding box and sphere are recomputed.
  79234. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  79235. * @returns the current mesh
  79236. */
  79237. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  79238. /** @hidden */
  79239. _preActivate(): InstancedMesh;
  79240. /** @hidden */
  79241. _activate(renderId: number, intermediateRendering: boolean): boolean;
  79242. /** @hidden */
  79243. _postActivate(): void;
  79244. getWorldMatrix(): Matrix;
  79245. readonly isAnInstance: boolean;
  79246. /**
  79247. * Returns the current associated LOD AbstractMesh.
  79248. */
  79249. getLOD(camera: Camera): AbstractMesh;
  79250. /** @hidden */
  79251. _syncSubMeshes(): InstancedMesh;
  79252. /** @hidden */
  79253. _generatePointsArray(): boolean;
  79254. /**
  79255. * Creates a new InstancedMesh from the current mesh.
  79256. * - name (string) : the cloned mesh name
  79257. * - newParent (optional Node) : the optional Node to parent the clone to.
  79258. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  79259. *
  79260. * Returns the clone.
  79261. */
  79262. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  79263. /**
  79264. * Disposes the InstancedMesh.
  79265. * Returns nothing.
  79266. */
  79267. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  79268. }
  79269. }
  79270. declare module BABYLON {
  79271. /**
  79272. * Defines the options associated with the creation of a shader material.
  79273. */
  79274. export interface IShaderMaterialOptions {
  79275. /**
  79276. * Does the material work in alpha blend mode
  79277. */
  79278. needAlphaBlending: boolean;
  79279. /**
  79280. * Does the material work in alpha test mode
  79281. */
  79282. needAlphaTesting: boolean;
  79283. /**
  79284. * The list of attribute names used in the shader
  79285. */
  79286. attributes: string[];
  79287. /**
  79288. * The list of unifrom names used in the shader
  79289. */
  79290. uniforms: string[];
  79291. /**
  79292. * The list of UBO names used in the shader
  79293. */
  79294. uniformBuffers: string[];
  79295. /**
  79296. * The list of sampler names used in the shader
  79297. */
  79298. samplers: string[];
  79299. /**
  79300. * The list of defines used in the shader
  79301. */
  79302. defines: string[];
  79303. }
  79304. /**
  79305. * 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.
  79306. *
  79307. * This returned material effects how the mesh will look based on the code in the shaders.
  79308. *
  79309. * @see http://doc.babylonjs.com/how_to/shader_material
  79310. */
  79311. export class ShaderMaterial extends Material {
  79312. private _shaderPath;
  79313. private _options;
  79314. private _textures;
  79315. private _textureArrays;
  79316. private _floats;
  79317. private _ints;
  79318. private _floatsArrays;
  79319. private _colors3;
  79320. private _colors3Arrays;
  79321. private _colors4;
  79322. private _vectors2;
  79323. private _vectors3;
  79324. private _vectors4;
  79325. private _matrices;
  79326. private _matrices3x3;
  79327. private _matrices2x2;
  79328. private _vectors2Arrays;
  79329. private _vectors3Arrays;
  79330. private _cachedWorldViewMatrix;
  79331. private _cachedWorldViewProjectionMatrix;
  79332. private _renderId;
  79333. /**
  79334. * Instantiate a new shader material.
  79335. * 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.
  79336. * This returned material effects how the mesh will look based on the code in the shaders.
  79337. * @see http://doc.babylonjs.com/how_to/shader_material
  79338. * @param name Define the name of the material in the scene
  79339. * @param scene Define the scene the material belongs to
  79340. * @param shaderPath Defines the route to the shader code in one of three ways:
  79341. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  79342. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  79343. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  79344. * @param options Define the options used to create the shader
  79345. */
  79346. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  79347. /**
  79348. * Gets the options used to compile the shader.
  79349. * They can be modified to trigger a new compilation
  79350. */
  79351. readonly options: IShaderMaterialOptions;
  79352. /**
  79353. * Gets the current class name of the material e.g. "ShaderMaterial"
  79354. * Mainly use in serialization.
  79355. * @returns the class name
  79356. */
  79357. getClassName(): string;
  79358. /**
  79359. * Specifies if the material will require alpha blending
  79360. * @returns a boolean specifying if alpha blending is needed
  79361. */
  79362. needAlphaBlending(): boolean;
  79363. /**
  79364. * Specifies if this material should be rendered in alpha test mode
  79365. * @returns a boolean specifying if an alpha test is needed.
  79366. */
  79367. needAlphaTesting(): boolean;
  79368. private _checkUniform;
  79369. /**
  79370. * Set a texture in the shader.
  79371. * @param name Define the name of the uniform samplers as defined in the shader
  79372. * @param texture Define the texture to bind to this sampler
  79373. * @return the material itself allowing "fluent" like uniform updates
  79374. */
  79375. setTexture(name: string, texture: Texture): ShaderMaterial;
  79376. /**
  79377. * Set a texture array in the shader.
  79378. * @param name Define the name of the uniform sampler array as defined in the shader
  79379. * @param textures Define the list of textures to bind to this sampler
  79380. * @return the material itself allowing "fluent" like uniform updates
  79381. */
  79382. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  79383. /**
  79384. * Set a float in the shader.
  79385. * @param name Define the name of the uniform as defined in the shader
  79386. * @param value Define the value to give to the uniform
  79387. * @return the material itself allowing "fluent" like uniform updates
  79388. */
  79389. setFloat(name: string, value: number): ShaderMaterial;
  79390. /**
  79391. * Set a int in the shader.
  79392. * @param name Define the name of the uniform as defined in the shader
  79393. * @param value Define the value to give to the uniform
  79394. * @return the material itself allowing "fluent" like uniform updates
  79395. */
  79396. setInt(name: string, value: number): ShaderMaterial;
  79397. /**
  79398. * Set an array of floats in the shader.
  79399. * @param name Define the name of the uniform as defined in the shader
  79400. * @param value Define the value to give to the uniform
  79401. * @return the material itself allowing "fluent" like uniform updates
  79402. */
  79403. setFloats(name: string, value: number[]): ShaderMaterial;
  79404. /**
  79405. * Set a vec3 in the shader from a Color3.
  79406. * @param name Define the name of the uniform as defined in the shader
  79407. * @param value Define the value to give to the uniform
  79408. * @return the material itself allowing "fluent" like uniform updates
  79409. */
  79410. setColor3(name: string, value: Color3): ShaderMaterial;
  79411. /**
  79412. * Set a vec3 array in the shader from a Color3 array.
  79413. * @param name Define the name of the uniform as defined in the shader
  79414. * @param value Define the value to give to the uniform
  79415. * @return the material itself allowing "fluent" like uniform updates
  79416. */
  79417. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  79418. /**
  79419. * Set a vec4 in the shader from a Color4.
  79420. * @param name Define the name of the uniform as defined in the shader
  79421. * @param value Define the value to give to the uniform
  79422. * @return the material itself allowing "fluent" like uniform updates
  79423. */
  79424. setColor4(name: string, value: Color4): ShaderMaterial;
  79425. /**
  79426. * Set a vec2 in the shader from a Vector2.
  79427. * @param name Define the name of the uniform as defined in the shader
  79428. * @param value Define the value to give to the uniform
  79429. * @return the material itself allowing "fluent" like uniform updates
  79430. */
  79431. setVector2(name: string, value: Vector2): ShaderMaterial;
  79432. /**
  79433. * Set a vec3 in the shader from a Vector3.
  79434. * @param name Define the name of the uniform as defined in the shader
  79435. * @param value Define the value to give to the uniform
  79436. * @return the material itself allowing "fluent" like uniform updates
  79437. */
  79438. setVector3(name: string, value: Vector3): ShaderMaterial;
  79439. /**
  79440. * Set a vec4 in the shader from a Vector4.
  79441. * @param name Define the name of the uniform as defined in the shader
  79442. * @param value Define the value to give to the uniform
  79443. * @return the material itself allowing "fluent" like uniform updates
  79444. */
  79445. setVector4(name: string, value: Vector4): ShaderMaterial;
  79446. /**
  79447. * Set a mat4 in the shader from a Matrix.
  79448. * @param name Define the name of the uniform as defined in the shader
  79449. * @param value Define the value to give to the uniform
  79450. * @return the material itself allowing "fluent" like uniform updates
  79451. */
  79452. setMatrix(name: string, value: Matrix): ShaderMaterial;
  79453. /**
  79454. * Set a mat3 in the shader from a Float32Array.
  79455. * @param name Define the name of the uniform as defined in the shader
  79456. * @param value Define the value to give to the uniform
  79457. * @return the material itself allowing "fluent" like uniform updates
  79458. */
  79459. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  79460. /**
  79461. * Set a mat2 in the shader from a Float32Array.
  79462. * @param name Define the name of the uniform as defined in the shader
  79463. * @param value Define the value to give to the uniform
  79464. * @return the material itself allowing "fluent" like uniform updates
  79465. */
  79466. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  79467. /**
  79468. * Set a vec2 array in the shader from a number array.
  79469. * @param name Define the name of the uniform as defined in the shader
  79470. * @param value Define the value to give to the uniform
  79471. * @return the material itself allowing "fluent" like uniform updates
  79472. */
  79473. setArray2(name: string, value: number[]): ShaderMaterial;
  79474. /**
  79475. * Set a vec3 array in the shader from a number array.
  79476. * @param name Define the name of the uniform as defined in the shader
  79477. * @param value Define the value to give to the uniform
  79478. * @return the material itself allowing "fluent" like uniform updates
  79479. */
  79480. setArray3(name: string, value: number[]): ShaderMaterial;
  79481. private _checkCache;
  79482. /**
  79483. * Specifies that the submesh is ready to be used
  79484. * @param mesh defines the mesh to check
  79485. * @param subMesh defines which submesh to check
  79486. * @param useInstances specifies that instances should be used
  79487. * @returns a boolean indicating that the submesh is ready or not
  79488. */
  79489. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  79490. /**
  79491. * Checks if the material is ready to render the requested mesh
  79492. * @param mesh Define the mesh to render
  79493. * @param useInstances Define whether or not the material is used with instances
  79494. * @returns true if ready, otherwise false
  79495. */
  79496. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  79497. /**
  79498. * Binds the world matrix to the material
  79499. * @param world defines the world transformation matrix
  79500. */
  79501. bindOnlyWorldMatrix(world: Matrix): void;
  79502. /**
  79503. * Binds the material to the mesh
  79504. * @param world defines the world transformation matrix
  79505. * @param mesh defines the mesh to bind the material to
  79506. */
  79507. bind(world: Matrix, mesh?: Mesh): void;
  79508. /**
  79509. * Gets the active textures from the material
  79510. * @returns an array of textures
  79511. */
  79512. getActiveTextures(): BaseTexture[];
  79513. /**
  79514. * Specifies if the material uses a texture
  79515. * @param texture defines the texture to check against the material
  79516. * @returns a boolean specifying if the material uses the texture
  79517. */
  79518. hasTexture(texture: BaseTexture): boolean;
  79519. /**
  79520. * Makes a duplicate of the material, and gives it a new name
  79521. * @param name defines the new name for the duplicated material
  79522. * @returns the cloned material
  79523. */
  79524. clone(name: string): ShaderMaterial;
  79525. /**
  79526. * Disposes the material
  79527. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  79528. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  79529. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  79530. */
  79531. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  79532. /**
  79533. * Serializes this material in a JSON representation
  79534. * @returns the serialized material object
  79535. */
  79536. serialize(): any;
  79537. /**
  79538. * Creates a shader material from parsed shader material data
  79539. * @param source defines the JSON represnetation of the material
  79540. * @param scene defines the hosting scene
  79541. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  79542. * @returns a new material
  79543. */
  79544. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  79545. }
  79546. }
  79547. declare module BABYLON {
  79548. /** @hidden */
  79549. export var colorPixelShader: {
  79550. name: string;
  79551. shader: string;
  79552. };
  79553. }
  79554. declare module BABYLON {
  79555. /** @hidden */
  79556. export var colorVertexShader: {
  79557. name: string;
  79558. shader: string;
  79559. };
  79560. }
  79561. declare module BABYLON {
  79562. /**
  79563. * Line mesh
  79564. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  79565. */
  79566. export class LinesMesh extends Mesh {
  79567. /**
  79568. * If vertex color should be applied to the mesh
  79569. */
  79570. readonly useVertexColor?: boolean | undefined;
  79571. /**
  79572. * If vertex alpha should be applied to the mesh
  79573. */
  79574. readonly useVertexAlpha?: boolean | undefined;
  79575. /**
  79576. * Color of the line (Default: White)
  79577. */
  79578. color: Color3;
  79579. /**
  79580. * Alpha of the line (Default: 1)
  79581. */
  79582. alpha: number;
  79583. /**
  79584. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  79585. * This margin is expressed in world space coordinates, so its value may vary.
  79586. * Default value is 0.1
  79587. */
  79588. intersectionThreshold: number;
  79589. private _colorShader;
  79590. private color4;
  79591. /**
  79592. * Creates a new LinesMesh
  79593. * @param name defines the name
  79594. * @param scene defines the hosting scene
  79595. * @param parent defines the parent mesh if any
  79596. * @param source defines the optional source LinesMesh used to clone data from
  79597. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  79598. * When false, achieved by calling a clone(), also passing False.
  79599. * This will make creation of children, recursive.
  79600. * @param useVertexColor defines if this LinesMesh supports vertex color
  79601. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  79602. */
  79603. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  79604. /**
  79605. * If vertex color should be applied to the mesh
  79606. */
  79607. useVertexColor?: boolean | undefined,
  79608. /**
  79609. * If vertex alpha should be applied to the mesh
  79610. */
  79611. useVertexAlpha?: boolean | undefined);
  79612. private _addClipPlaneDefine;
  79613. private _removeClipPlaneDefine;
  79614. isReady(): boolean;
  79615. /**
  79616. * Returns the string "LineMesh"
  79617. */
  79618. getClassName(): string;
  79619. /**
  79620. * @hidden
  79621. */
  79622. /**
  79623. * @hidden
  79624. */
  79625. material: Material;
  79626. /**
  79627. * @hidden
  79628. */
  79629. readonly checkCollisions: boolean;
  79630. /** @hidden */
  79631. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  79632. /** @hidden */
  79633. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  79634. /**
  79635. * Disposes of the line mesh
  79636. * @param doNotRecurse If children should be disposed
  79637. */
  79638. dispose(doNotRecurse?: boolean): void;
  79639. /**
  79640. * Returns a new LineMesh object cloned from the current one.
  79641. */
  79642. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  79643. /**
  79644. * Creates a new InstancedLinesMesh object from the mesh model.
  79645. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  79646. * @param name defines the name of the new instance
  79647. * @returns a new InstancedLinesMesh
  79648. */
  79649. createInstance(name: string): InstancedLinesMesh;
  79650. }
  79651. /**
  79652. * Creates an instance based on a source LinesMesh
  79653. */
  79654. export class InstancedLinesMesh extends InstancedMesh {
  79655. /**
  79656. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  79657. * This margin is expressed in world space coordinates, so its value may vary.
  79658. * Initilized with the intersectionThreshold value of the source LinesMesh
  79659. */
  79660. intersectionThreshold: number;
  79661. constructor(name: string, source: LinesMesh);
  79662. /**
  79663. * Returns the string "InstancedLinesMesh".
  79664. */
  79665. getClassName(): string;
  79666. }
  79667. }
  79668. declare module BABYLON {
  79669. /** @hidden */
  79670. export var linePixelShader: {
  79671. name: string;
  79672. shader: string;
  79673. };
  79674. }
  79675. declare module BABYLON {
  79676. /** @hidden */
  79677. export var lineVertexShader: {
  79678. name: string;
  79679. shader: string;
  79680. };
  79681. }
  79682. declare module BABYLON {
  79683. interface AbstractMesh {
  79684. /**
  79685. * Gets the edgesRenderer associated with the mesh
  79686. */
  79687. edgesRenderer: Nullable<EdgesRenderer>;
  79688. }
  79689. interface LinesMesh {
  79690. /**
  79691. * Enables the edge rendering mode on the mesh.
  79692. * This mode makes the mesh edges visible
  79693. * @param epsilon defines the maximal distance between two angles to detect a face
  79694. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  79695. * @returns the currentAbstractMesh
  79696. * @see https://www.babylonjs-playground.com/#19O9TU#0
  79697. */
  79698. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  79699. }
  79700. interface InstancedLinesMesh {
  79701. /**
  79702. * Enables the edge rendering mode on the mesh.
  79703. * This mode makes the mesh edges visible
  79704. * @param epsilon defines the maximal distance between two angles to detect a face
  79705. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  79706. * @returns the current InstancedLinesMesh
  79707. * @see https://www.babylonjs-playground.com/#19O9TU#0
  79708. */
  79709. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  79710. }
  79711. /**
  79712. * Defines the minimum contract an Edges renderer should follow.
  79713. */
  79714. export interface IEdgesRenderer extends IDisposable {
  79715. /**
  79716. * Gets or sets a boolean indicating if the edgesRenderer is active
  79717. */
  79718. isEnabled: boolean;
  79719. /**
  79720. * Renders the edges of the attached mesh,
  79721. */
  79722. render(): void;
  79723. /**
  79724. * Checks wether or not the edges renderer is ready to render.
  79725. * @return true if ready, otherwise false.
  79726. */
  79727. isReady(): boolean;
  79728. }
  79729. /**
  79730. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  79731. */
  79732. export class EdgesRenderer implements IEdgesRenderer {
  79733. /**
  79734. * Define the size of the edges with an orthographic camera
  79735. */
  79736. edgesWidthScalerForOrthographic: number;
  79737. /**
  79738. * Define the size of the edges with a perspective camera
  79739. */
  79740. edgesWidthScalerForPerspective: number;
  79741. protected _source: AbstractMesh;
  79742. protected _linesPositions: number[];
  79743. protected _linesNormals: number[];
  79744. protected _linesIndices: number[];
  79745. protected _epsilon: number;
  79746. protected _indicesCount: number;
  79747. protected _lineShader: ShaderMaterial;
  79748. protected _ib: DataBuffer;
  79749. protected _buffers: {
  79750. [key: string]: Nullable<VertexBuffer>;
  79751. };
  79752. protected _checkVerticesInsteadOfIndices: boolean;
  79753. private _meshRebuildObserver;
  79754. private _meshDisposeObserver;
  79755. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  79756. isEnabled: boolean;
  79757. /**
  79758. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  79759. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  79760. * @param source Mesh used to create edges
  79761. * @param epsilon sum of angles in adjacency to check for edge
  79762. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  79763. * @param generateEdgesLines - should generate Lines or only prepare resources.
  79764. */
  79765. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  79766. protected _prepareRessources(): void;
  79767. /** @hidden */
  79768. _rebuild(): void;
  79769. /**
  79770. * Releases the required resources for the edges renderer
  79771. */
  79772. dispose(): void;
  79773. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  79774. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  79775. /**
  79776. * Checks if the pair of p0 and p1 is en edge
  79777. * @param faceIndex
  79778. * @param edge
  79779. * @param faceNormals
  79780. * @param p0
  79781. * @param p1
  79782. * @private
  79783. */
  79784. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  79785. /**
  79786. * push line into the position, normal and index buffer
  79787. * @protected
  79788. */
  79789. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  79790. /**
  79791. * Generates lines edges from adjacencjes
  79792. * @private
  79793. */
  79794. _generateEdgesLines(): void;
  79795. /**
  79796. * Checks wether or not the edges renderer is ready to render.
  79797. * @return true if ready, otherwise false.
  79798. */
  79799. isReady(): boolean;
  79800. /**
  79801. * Renders the edges of the attached mesh,
  79802. */
  79803. render(): void;
  79804. }
  79805. /**
  79806. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  79807. */
  79808. export class LineEdgesRenderer extends EdgesRenderer {
  79809. /**
  79810. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  79811. * @param source LineMesh used to generate edges
  79812. * @param epsilon not important (specified angle for edge detection)
  79813. * @param checkVerticesInsteadOfIndices not important for LineMesh
  79814. */
  79815. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  79816. /**
  79817. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  79818. */
  79819. _generateEdgesLines(): void;
  79820. }
  79821. }
  79822. declare module BABYLON {
  79823. /**
  79824. * This represents the object necessary to create a rendering group.
  79825. * This is exclusively used and created by the rendering manager.
  79826. * To modify the behavior, you use the available helpers in your scene or meshes.
  79827. * @hidden
  79828. */
  79829. export class RenderingGroup {
  79830. index: number;
  79831. private static _zeroVector;
  79832. private _scene;
  79833. private _opaqueSubMeshes;
  79834. private _transparentSubMeshes;
  79835. private _alphaTestSubMeshes;
  79836. private _depthOnlySubMeshes;
  79837. private _particleSystems;
  79838. private _spriteManagers;
  79839. private _opaqueSortCompareFn;
  79840. private _alphaTestSortCompareFn;
  79841. private _transparentSortCompareFn;
  79842. private _renderOpaque;
  79843. private _renderAlphaTest;
  79844. private _renderTransparent;
  79845. /** @hidden */
  79846. _edgesRenderers: SmartArray<IEdgesRenderer>;
  79847. onBeforeTransparentRendering: () => void;
  79848. /**
  79849. * Set the opaque sort comparison function.
  79850. * If null the sub meshes will be render in the order they were created
  79851. */
  79852. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  79853. /**
  79854. * Set the alpha test sort comparison function.
  79855. * If null the sub meshes will be render in the order they were created
  79856. */
  79857. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  79858. /**
  79859. * Set the transparent sort comparison function.
  79860. * If null the sub meshes will be render in the order they were created
  79861. */
  79862. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  79863. /**
  79864. * Creates a new rendering group.
  79865. * @param index The rendering group index
  79866. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  79867. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  79868. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  79869. */
  79870. 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>);
  79871. /**
  79872. * Render all the sub meshes contained in the group.
  79873. * @param customRenderFunction Used to override the default render behaviour of the group.
  79874. * @returns true if rendered some submeshes.
  79875. */
  79876. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  79877. /**
  79878. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  79879. * @param subMeshes The submeshes to render
  79880. */
  79881. private renderOpaqueSorted;
  79882. /**
  79883. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  79884. * @param subMeshes The submeshes to render
  79885. */
  79886. private renderAlphaTestSorted;
  79887. /**
  79888. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  79889. * @param subMeshes The submeshes to render
  79890. */
  79891. private renderTransparentSorted;
  79892. /**
  79893. * Renders the submeshes in a specified order.
  79894. * @param subMeshes The submeshes to sort before render
  79895. * @param sortCompareFn The comparison function use to sort
  79896. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  79897. * @param transparent Specifies to activate blending if true
  79898. */
  79899. private static renderSorted;
  79900. /**
  79901. * Renders the submeshes in the order they were dispatched (no sort applied).
  79902. * @param subMeshes The submeshes to render
  79903. */
  79904. private static renderUnsorted;
  79905. /**
  79906. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  79907. * are rendered back to front if in the same alpha index.
  79908. *
  79909. * @param a The first submesh
  79910. * @param b The second submesh
  79911. * @returns The result of the comparison
  79912. */
  79913. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  79914. /**
  79915. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  79916. * are rendered back to front.
  79917. *
  79918. * @param a The first submesh
  79919. * @param b The second submesh
  79920. * @returns The result of the comparison
  79921. */
  79922. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  79923. /**
  79924. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  79925. * are rendered front to back (prevent overdraw).
  79926. *
  79927. * @param a The first submesh
  79928. * @param b The second submesh
  79929. * @returns The result of the comparison
  79930. */
  79931. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  79932. /**
  79933. * Resets the different lists of submeshes to prepare a new frame.
  79934. */
  79935. prepare(): void;
  79936. dispose(): void;
  79937. /**
  79938. * Inserts the submesh in its correct queue depending on its material.
  79939. * @param subMesh The submesh to dispatch
  79940. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  79941. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  79942. */
  79943. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  79944. dispatchSprites(spriteManager: ISpriteManager): void;
  79945. dispatchParticles(particleSystem: IParticleSystem): void;
  79946. private _renderParticles;
  79947. private _renderSprites;
  79948. }
  79949. }
  79950. declare module BABYLON {
  79951. /**
  79952. * Interface describing the different options available in the rendering manager
  79953. * regarding Auto Clear between groups.
  79954. */
  79955. export interface IRenderingManagerAutoClearSetup {
  79956. /**
  79957. * Defines whether or not autoclear is enable.
  79958. */
  79959. autoClear: boolean;
  79960. /**
  79961. * Defines whether or not to autoclear the depth buffer.
  79962. */
  79963. depth: boolean;
  79964. /**
  79965. * Defines whether or not to autoclear the stencil buffer.
  79966. */
  79967. stencil: boolean;
  79968. }
  79969. /**
  79970. * This class is used by the onRenderingGroupObservable
  79971. */
  79972. export class RenderingGroupInfo {
  79973. /**
  79974. * The Scene that being rendered
  79975. */
  79976. scene: Scene;
  79977. /**
  79978. * The camera currently used for the rendering pass
  79979. */
  79980. camera: Nullable<Camera>;
  79981. /**
  79982. * The ID of the renderingGroup being processed
  79983. */
  79984. renderingGroupId: number;
  79985. }
  79986. /**
  79987. * This is the manager responsible of all the rendering for meshes sprites and particles.
  79988. * It is enable to manage the different groups as well as the different necessary sort functions.
  79989. * This should not be used directly aside of the few static configurations
  79990. */
  79991. export class RenderingManager {
  79992. /**
  79993. * The max id used for rendering groups (not included)
  79994. */
  79995. static MAX_RENDERINGGROUPS: number;
  79996. /**
  79997. * The min id used for rendering groups (included)
  79998. */
  79999. static MIN_RENDERINGGROUPS: number;
  80000. /**
  80001. * Used to globally prevent autoclearing scenes.
  80002. */
  80003. static AUTOCLEAR: boolean;
  80004. /**
  80005. * @hidden
  80006. */
  80007. _useSceneAutoClearSetup: boolean;
  80008. private _scene;
  80009. private _renderingGroups;
  80010. private _depthStencilBufferAlreadyCleaned;
  80011. private _autoClearDepthStencil;
  80012. private _customOpaqueSortCompareFn;
  80013. private _customAlphaTestSortCompareFn;
  80014. private _customTransparentSortCompareFn;
  80015. private _renderingGroupInfo;
  80016. /**
  80017. * Instantiates a new rendering group for a particular scene
  80018. * @param scene Defines the scene the groups belongs to
  80019. */
  80020. constructor(scene: Scene);
  80021. private _clearDepthStencilBuffer;
  80022. /**
  80023. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  80024. * @hidden
  80025. */
  80026. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  80027. /**
  80028. * Resets the different information of the group to prepare a new frame
  80029. * @hidden
  80030. */
  80031. reset(): void;
  80032. /**
  80033. * Dispose and release the group and its associated resources.
  80034. * @hidden
  80035. */
  80036. dispose(): void;
  80037. /**
  80038. * Clear the info related to rendering groups preventing retention points during dispose.
  80039. */
  80040. freeRenderingGroups(): void;
  80041. private _prepareRenderingGroup;
  80042. /**
  80043. * Add a sprite manager to the rendering manager in order to render it this frame.
  80044. * @param spriteManager Define the sprite manager to render
  80045. */
  80046. dispatchSprites(spriteManager: ISpriteManager): void;
  80047. /**
  80048. * Add a particle system to the rendering manager in order to render it this frame.
  80049. * @param particleSystem Define the particle system to render
  80050. */
  80051. dispatchParticles(particleSystem: IParticleSystem): void;
  80052. /**
  80053. * Add a submesh to the manager in order to render it this frame
  80054. * @param subMesh The submesh to dispatch
  80055. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  80056. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  80057. */
  80058. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  80059. /**
  80060. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  80061. * This allowed control for front to back rendering or reversly depending of the special needs.
  80062. *
  80063. * @param renderingGroupId The rendering group id corresponding to its index
  80064. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  80065. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  80066. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  80067. */
  80068. 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;
  80069. /**
  80070. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  80071. *
  80072. * @param renderingGroupId The rendering group id corresponding to its index
  80073. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  80074. * @param depth Automatically clears depth between groups if true and autoClear is true.
  80075. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  80076. */
  80077. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  80078. /**
  80079. * Gets the current auto clear configuration for one rendering group of the rendering
  80080. * manager.
  80081. * @param index the rendering group index to get the information for
  80082. * @returns The auto clear setup for the requested rendering group
  80083. */
  80084. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  80085. }
  80086. }
  80087. declare module BABYLON {
  80088. /**
  80089. * This Helps creating a texture that will be created from a camera in your scene.
  80090. * It is basically a dynamic texture that could be used to create special effects for instance.
  80091. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  80092. */
  80093. export class RenderTargetTexture extends Texture {
  80094. isCube: boolean;
  80095. /**
  80096. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  80097. */
  80098. static readonly REFRESHRATE_RENDER_ONCE: number;
  80099. /**
  80100. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  80101. */
  80102. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  80103. /**
  80104. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  80105. * the central point of your effect and can save a lot of performances.
  80106. */
  80107. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  80108. /**
  80109. * Use this predicate to dynamically define the list of mesh you want to render.
  80110. * If set, the renderList property will be overwritten.
  80111. */
  80112. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  80113. private _renderList;
  80114. /**
  80115. * Use this list to define the list of mesh you want to render.
  80116. */
  80117. renderList: Nullable<Array<AbstractMesh>>;
  80118. private _hookArray;
  80119. /**
  80120. * Define if particles should be rendered in your texture.
  80121. */
  80122. renderParticles: boolean;
  80123. /**
  80124. * Define if sprites should be rendered in your texture.
  80125. */
  80126. renderSprites: boolean;
  80127. /**
  80128. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  80129. */
  80130. coordinatesMode: number;
  80131. /**
  80132. * Define the camera used to render the texture.
  80133. */
  80134. activeCamera: Nullable<Camera>;
  80135. /**
  80136. * Override the render function of the texture with your own one.
  80137. */
  80138. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  80139. /**
  80140. * Define if camera post processes should be use while rendering the texture.
  80141. */
  80142. useCameraPostProcesses: boolean;
  80143. /**
  80144. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  80145. */
  80146. ignoreCameraViewport: boolean;
  80147. private _postProcessManager;
  80148. private _postProcesses;
  80149. private _resizeObserver;
  80150. /**
  80151. * An event triggered when the texture is unbind.
  80152. */
  80153. onBeforeBindObservable: Observable<RenderTargetTexture>;
  80154. /**
  80155. * An event triggered when the texture is unbind.
  80156. */
  80157. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  80158. private _onAfterUnbindObserver;
  80159. /**
  80160. * Set a after unbind callback in the texture.
  80161. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  80162. */
  80163. onAfterUnbind: () => void;
  80164. /**
  80165. * An event triggered before rendering the texture
  80166. */
  80167. onBeforeRenderObservable: Observable<number>;
  80168. private _onBeforeRenderObserver;
  80169. /**
  80170. * Set a before render callback in the texture.
  80171. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  80172. */
  80173. onBeforeRender: (faceIndex: number) => void;
  80174. /**
  80175. * An event triggered after rendering the texture
  80176. */
  80177. onAfterRenderObservable: Observable<number>;
  80178. private _onAfterRenderObserver;
  80179. /**
  80180. * Set a after render callback in the texture.
  80181. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  80182. */
  80183. onAfterRender: (faceIndex: number) => void;
  80184. /**
  80185. * An event triggered after the texture clear
  80186. */
  80187. onClearObservable: Observable<Engine>;
  80188. private _onClearObserver;
  80189. /**
  80190. * Set a clear callback in the texture.
  80191. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  80192. */
  80193. onClear: (Engine: Engine) => void;
  80194. /**
  80195. * Define the clear color of the Render Target if it should be different from the scene.
  80196. */
  80197. clearColor: Color4;
  80198. protected _size: number | {
  80199. width: number;
  80200. height: number;
  80201. };
  80202. protected _initialSizeParameter: number | {
  80203. width: number;
  80204. height: number;
  80205. } | {
  80206. ratio: number;
  80207. };
  80208. protected _sizeRatio: Nullable<number>;
  80209. /** @hidden */
  80210. _generateMipMaps: boolean;
  80211. protected _renderingManager: RenderingManager;
  80212. /** @hidden */
  80213. _waitingRenderList: string[];
  80214. protected _doNotChangeAspectRatio: boolean;
  80215. protected _currentRefreshId: number;
  80216. protected _refreshRate: number;
  80217. protected _textureMatrix: Matrix;
  80218. protected _samples: number;
  80219. protected _renderTargetOptions: RenderTargetCreationOptions;
  80220. /**
  80221. * Gets render target creation options that were used.
  80222. */
  80223. readonly renderTargetOptions: RenderTargetCreationOptions;
  80224. protected _engine: Engine;
  80225. protected _onRatioRescale(): void;
  80226. /**
  80227. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  80228. * It must define where the camera used to render the texture is set
  80229. */
  80230. boundingBoxPosition: Vector3;
  80231. private _boundingBoxSize;
  80232. /**
  80233. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  80234. * When defined, the cubemap will switch to local mode
  80235. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  80236. * @example https://www.babylonjs-playground.com/#RNASML
  80237. */
  80238. boundingBoxSize: Vector3;
  80239. /**
  80240. * In case the RTT has been created with a depth texture, get the associated
  80241. * depth texture.
  80242. * Otherwise, return null.
  80243. */
  80244. depthStencilTexture: Nullable<InternalTexture>;
  80245. /**
  80246. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  80247. * or used a shadow, depth texture...
  80248. * @param name The friendly name of the texture
  80249. * @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)
  80250. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  80251. * @param generateMipMaps True if mip maps need to be generated after render.
  80252. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  80253. * @param type The type of the buffer in the RTT (int, half float, float...)
  80254. * @param isCube True if a cube texture needs to be created
  80255. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  80256. * @param generateDepthBuffer True to generate a depth buffer
  80257. * @param generateStencilBuffer True to generate a stencil buffer
  80258. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  80259. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  80260. * @param delayAllocation if the texture allocation should be delayed (default: false)
  80261. */
  80262. constructor(name: string, size: number | {
  80263. width: number;
  80264. height: number;
  80265. } | {
  80266. ratio: number;
  80267. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  80268. /**
  80269. * Creates a depth stencil texture.
  80270. * This is only available in WebGL 2 or with the depth texture extension available.
  80271. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  80272. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  80273. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  80274. */
  80275. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  80276. private _processSizeParameter;
  80277. /**
  80278. * Define the number of samples to use in case of MSAA.
  80279. * It defaults to one meaning no MSAA has been enabled.
  80280. */
  80281. samples: number;
  80282. /**
  80283. * Resets the refresh counter of the texture and start bak from scratch.
  80284. * Could be useful to regenerate the texture if it is setup to render only once.
  80285. */
  80286. resetRefreshCounter(): void;
  80287. /**
  80288. * Define the refresh rate of the texture or the rendering frequency.
  80289. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  80290. */
  80291. refreshRate: number;
  80292. /**
  80293. * Adds a post process to the render target rendering passes.
  80294. * @param postProcess define the post process to add
  80295. */
  80296. addPostProcess(postProcess: PostProcess): void;
  80297. /**
  80298. * Clear all the post processes attached to the render target
  80299. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  80300. */
  80301. clearPostProcesses(dispose?: boolean): void;
  80302. /**
  80303. * Remove one of the post process from the list of attached post processes to the texture
  80304. * @param postProcess define the post process to remove from the list
  80305. */
  80306. removePostProcess(postProcess: PostProcess): void;
  80307. /** @hidden */
  80308. _shouldRender(): boolean;
  80309. /**
  80310. * Gets the actual render size of the texture.
  80311. * @returns the width of the render size
  80312. */
  80313. getRenderSize(): number;
  80314. /**
  80315. * Gets the actual render width of the texture.
  80316. * @returns the width of the render size
  80317. */
  80318. getRenderWidth(): number;
  80319. /**
  80320. * Gets the actual render height of the texture.
  80321. * @returns the height of the render size
  80322. */
  80323. getRenderHeight(): number;
  80324. /**
  80325. * Get if the texture can be rescaled or not.
  80326. */
  80327. readonly canRescale: boolean;
  80328. /**
  80329. * Resize the texture using a ratio.
  80330. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  80331. */
  80332. scale(ratio: number): void;
  80333. /**
  80334. * Get the texture reflection matrix used to rotate/transform the reflection.
  80335. * @returns the reflection matrix
  80336. */
  80337. getReflectionTextureMatrix(): Matrix;
  80338. /**
  80339. * Resize the texture to a new desired size.
  80340. * Be carrefull as it will recreate all the data in the new texture.
  80341. * @param size Define the new size. It can be:
  80342. * - a number for squared texture,
  80343. * - an object containing { width: number, height: number }
  80344. * - or an object containing a ratio { ratio: number }
  80345. */
  80346. resize(size: number | {
  80347. width: number;
  80348. height: number;
  80349. } | {
  80350. ratio: number;
  80351. }): void;
  80352. /**
  80353. * Renders all the objects from the render list into the texture.
  80354. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  80355. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  80356. */
  80357. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  80358. private _bestReflectionRenderTargetDimension;
  80359. /**
  80360. * @hidden
  80361. * @param faceIndex face index to bind to if this is a cubetexture
  80362. */
  80363. _bindFrameBuffer(faceIndex?: number): void;
  80364. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  80365. private renderToTarget;
  80366. /**
  80367. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  80368. * This allowed control for front to back rendering or reversly depending of the special needs.
  80369. *
  80370. * @param renderingGroupId The rendering group id corresponding to its index
  80371. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  80372. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  80373. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  80374. */
  80375. 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;
  80376. /**
  80377. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  80378. *
  80379. * @param renderingGroupId The rendering group id corresponding to its index
  80380. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  80381. */
  80382. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  80383. /**
  80384. * Clones the texture.
  80385. * @returns the cloned texture
  80386. */
  80387. clone(): RenderTargetTexture;
  80388. /**
  80389. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  80390. * @returns The JSON representation of the texture
  80391. */
  80392. serialize(): any;
  80393. /**
  80394. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  80395. */
  80396. disposeFramebufferObjects(): void;
  80397. /**
  80398. * Dispose the texture and release its associated resources.
  80399. */
  80400. dispose(): void;
  80401. /** @hidden */
  80402. _rebuild(): void;
  80403. /**
  80404. * Clear the info related to rendering groups preventing retention point in material dispose.
  80405. */
  80406. freeRenderingGroups(): void;
  80407. /**
  80408. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  80409. * @returns the view count
  80410. */
  80411. getViewCount(): number;
  80412. }
  80413. }
  80414. declare module BABYLON {
  80415. /**
  80416. * Mirror texture can be used to simulate the view from a mirror in a scene.
  80417. * It will dynamically be rendered every frame to adapt to the camera point of view.
  80418. * You can then easily use it as a reflectionTexture on a flat surface.
  80419. * In case the surface is not a plane, please consider relying on reflection probes.
  80420. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80421. */
  80422. export class MirrorTexture extends RenderTargetTexture {
  80423. private scene;
  80424. /**
  80425. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  80426. * 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.
  80427. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80428. */
  80429. mirrorPlane: Plane;
  80430. /**
  80431. * Define the blur ratio used to blur the reflection if needed.
  80432. */
  80433. blurRatio: number;
  80434. /**
  80435. * Define the adaptive blur kernel used to blur the reflection if needed.
  80436. * This will autocompute the closest best match for the `blurKernel`
  80437. */
  80438. adaptiveBlurKernel: number;
  80439. /**
  80440. * Define the blur kernel used to blur the reflection if needed.
  80441. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80442. */
  80443. blurKernel: number;
  80444. /**
  80445. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  80446. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80447. */
  80448. blurKernelX: number;
  80449. /**
  80450. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  80451. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80452. */
  80453. blurKernelY: number;
  80454. private _autoComputeBlurKernel;
  80455. protected _onRatioRescale(): void;
  80456. private _updateGammaSpace;
  80457. private _imageProcessingConfigChangeObserver;
  80458. private _transformMatrix;
  80459. private _mirrorMatrix;
  80460. private _savedViewMatrix;
  80461. private _blurX;
  80462. private _blurY;
  80463. private _adaptiveBlurKernel;
  80464. private _blurKernelX;
  80465. private _blurKernelY;
  80466. private _blurRatio;
  80467. /**
  80468. * Instantiates a Mirror Texture.
  80469. * Mirror texture can be used to simulate the view from a mirror in a scene.
  80470. * It will dynamically be rendered every frame to adapt to the camera point of view.
  80471. * You can then easily use it as a reflectionTexture on a flat surface.
  80472. * In case the surface is not a plane, please consider relying on reflection probes.
  80473. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80474. * @param name
  80475. * @param size
  80476. * @param scene
  80477. * @param generateMipMaps
  80478. * @param type
  80479. * @param samplingMode
  80480. * @param generateDepthBuffer
  80481. */
  80482. constructor(name: string, size: number | {
  80483. width: number;
  80484. height: number;
  80485. } | {
  80486. ratio: number;
  80487. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  80488. private _preparePostProcesses;
  80489. /**
  80490. * Clone the mirror texture.
  80491. * @returns the cloned texture
  80492. */
  80493. clone(): MirrorTexture;
  80494. /**
  80495. * Serialize the texture to a JSON representation you could use in Parse later on
  80496. * @returns the serialized JSON representation
  80497. */
  80498. serialize(): any;
  80499. /**
  80500. * Dispose the texture and release its associated resources.
  80501. */
  80502. dispose(): void;
  80503. }
  80504. }
  80505. declare module BABYLON {
  80506. /**
  80507. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  80508. * @see http://doc.babylonjs.com/babylon101/materials#texture
  80509. */
  80510. export class Texture extends BaseTexture {
  80511. /** @hidden */
  80512. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  80513. /** @hidden */
  80514. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  80515. /** @hidden */
  80516. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  80517. /** nearest is mag = nearest and min = nearest and mip = linear */
  80518. static readonly NEAREST_SAMPLINGMODE: number;
  80519. /** nearest is mag = nearest and min = nearest and mip = linear */
  80520. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  80521. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80522. static readonly BILINEAR_SAMPLINGMODE: number;
  80523. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80524. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  80525. /** Trilinear is mag = linear and min = linear and mip = linear */
  80526. static readonly TRILINEAR_SAMPLINGMODE: number;
  80527. /** Trilinear is mag = linear and min = linear and mip = linear */
  80528. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  80529. /** mag = nearest and min = nearest and mip = nearest */
  80530. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  80531. /** mag = nearest and min = linear and mip = nearest */
  80532. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  80533. /** mag = nearest and min = linear and mip = linear */
  80534. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  80535. /** mag = nearest and min = linear and mip = none */
  80536. static readonly NEAREST_LINEAR: number;
  80537. /** mag = nearest and min = nearest and mip = none */
  80538. static readonly NEAREST_NEAREST: number;
  80539. /** mag = linear and min = nearest and mip = nearest */
  80540. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  80541. /** mag = linear and min = nearest and mip = linear */
  80542. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  80543. /** mag = linear and min = linear and mip = none */
  80544. static readonly LINEAR_LINEAR: number;
  80545. /** mag = linear and min = nearest and mip = none */
  80546. static readonly LINEAR_NEAREST: number;
  80547. /** Explicit coordinates mode */
  80548. static readonly EXPLICIT_MODE: number;
  80549. /** Spherical coordinates mode */
  80550. static readonly SPHERICAL_MODE: number;
  80551. /** Planar coordinates mode */
  80552. static readonly PLANAR_MODE: number;
  80553. /** Cubic coordinates mode */
  80554. static readonly CUBIC_MODE: number;
  80555. /** Projection coordinates mode */
  80556. static readonly PROJECTION_MODE: number;
  80557. /** Inverse Cubic coordinates mode */
  80558. static readonly SKYBOX_MODE: number;
  80559. /** Inverse Cubic coordinates mode */
  80560. static readonly INVCUBIC_MODE: number;
  80561. /** Equirectangular coordinates mode */
  80562. static readonly EQUIRECTANGULAR_MODE: number;
  80563. /** Equirectangular Fixed coordinates mode */
  80564. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  80565. /** Equirectangular Fixed Mirrored coordinates mode */
  80566. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  80567. /** Texture is not repeating outside of 0..1 UVs */
  80568. static readonly CLAMP_ADDRESSMODE: number;
  80569. /** Texture is repeating outside of 0..1 UVs */
  80570. static readonly WRAP_ADDRESSMODE: number;
  80571. /** Texture is repeating and mirrored */
  80572. static readonly MIRROR_ADDRESSMODE: number;
  80573. /**
  80574. * 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
  80575. */
  80576. static UseSerializedUrlIfAny: boolean;
  80577. /**
  80578. * Define the url of the texture.
  80579. */
  80580. url: Nullable<string>;
  80581. /**
  80582. * Define an offset on the texture to offset the u coordinates of the UVs
  80583. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  80584. */
  80585. uOffset: number;
  80586. /**
  80587. * Define an offset on the texture to offset the v coordinates of the UVs
  80588. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  80589. */
  80590. vOffset: number;
  80591. /**
  80592. * Define an offset on the texture to scale the u coordinates of the UVs
  80593. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  80594. */
  80595. uScale: number;
  80596. /**
  80597. * Define an offset on the texture to scale the v coordinates of the UVs
  80598. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  80599. */
  80600. vScale: number;
  80601. /**
  80602. * Define an offset on the texture to rotate around the u coordinates of the UVs
  80603. * @see http://doc.babylonjs.com/how_to/more_materials
  80604. */
  80605. uAng: number;
  80606. /**
  80607. * Define an offset on the texture to rotate around the v coordinates of the UVs
  80608. * @see http://doc.babylonjs.com/how_to/more_materials
  80609. */
  80610. vAng: number;
  80611. /**
  80612. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  80613. * @see http://doc.babylonjs.com/how_to/more_materials
  80614. */
  80615. wAng: number;
  80616. /**
  80617. * Defines the center of rotation (U)
  80618. */
  80619. uRotationCenter: number;
  80620. /**
  80621. * Defines the center of rotation (V)
  80622. */
  80623. vRotationCenter: number;
  80624. /**
  80625. * Defines the center of rotation (W)
  80626. */
  80627. wRotationCenter: number;
  80628. /**
  80629. * Are mip maps generated for this texture or not.
  80630. */
  80631. readonly noMipmap: boolean;
  80632. /**
  80633. * List of inspectable custom properties (used by the Inspector)
  80634. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80635. */
  80636. inspectableCustomProperties: Nullable<IInspectable[]>;
  80637. private _noMipmap;
  80638. /** @hidden */
  80639. _invertY: boolean;
  80640. private _rowGenerationMatrix;
  80641. private _cachedTextureMatrix;
  80642. private _projectionModeMatrix;
  80643. private _t0;
  80644. private _t1;
  80645. private _t2;
  80646. private _cachedUOffset;
  80647. private _cachedVOffset;
  80648. private _cachedUScale;
  80649. private _cachedVScale;
  80650. private _cachedUAng;
  80651. private _cachedVAng;
  80652. private _cachedWAng;
  80653. private _cachedProjectionMatrixId;
  80654. private _cachedCoordinatesMode;
  80655. /** @hidden */
  80656. protected _initialSamplingMode: number;
  80657. /** @hidden */
  80658. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  80659. private _deleteBuffer;
  80660. protected _format: Nullable<number>;
  80661. private _delayedOnLoad;
  80662. private _delayedOnError;
  80663. /**
  80664. * Observable triggered once the texture has been loaded.
  80665. */
  80666. onLoadObservable: Observable<Texture>;
  80667. protected _isBlocking: boolean;
  80668. /**
  80669. * Is the texture preventing material to render while loading.
  80670. * If false, a default texture will be used instead of the loading one during the preparation step.
  80671. */
  80672. isBlocking: boolean;
  80673. /**
  80674. * Get the current sampling mode associated with the texture.
  80675. */
  80676. readonly samplingMode: number;
  80677. /**
  80678. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  80679. */
  80680. readonly invertY: boolean;
  80681. /**
  80682. * Instantiates a new texture.
  80683. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  80684. * @see http://doc.babylonjs.com/babylon101/materials#texture
  80685. * @param url define the url of the picture to load as a texture
  80686. * @param scene define the scene the texture will belong to
  80687. * @param noMipmap define if the texture will require mip maps or not
  80688. * @param invertY define if the texture needs to be inverted on the y axis during loading
  80689. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  80690. * @param onLoad define a callback triggered when the texture has been loaded
  80691. * @param onError define a callback triggered when an error occurred during the loading session
  80692. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  80693. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  80694. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  80695. */
  80696. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  80697. /**
  80698. * Update the url (and optional buffer) of this texture if url was null during construction.
  80699. * @param url the url of the texture
  80700. * @param buffer the buffer of the texture (defaults to null)
  80701. * @param onLoad callback called when the texture is loaded (defaults to null)
  80702. */
  80703. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  80704. /**
  80705. * Finish the loading sequence of a texture flagged as delayed load.
  80706. * @hidden
  80707. */
  80708. delayLoad(): void;
  80709. private _prepareRowForTextureGeneration;
  80710. /**
  80711. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  80712. * @returns the transform matrix of the texture.
  80713. */
  80714. getTextureMatrix(): Matrix;
  80715. /**
  80716. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  80717. * @returns The reflection texture transform
  80718. */
  80719. getReflectionTextureMatrix(): Matrix;
  80720. /**
  80721. * Clones the texture.
  80722. * @returns the cloned texture
  80723. */
  80724. clone(): Texture;
  80725. /**
  80726. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  80727. * @returns The JSON representation of the texture
  80728. */
  80729. serialize(): any;
  80730. /**
  80731. * Get the current class name of the texture useful for serialization or dynamic coding.
  80732. * @returns "Texture"
  80733. */
  80734. getClassName(): string;
  80735. /**
  80736. * Dispose the texture and release its associated resources.
  80737. */
  80738. dispose(): void;
  80739. /**
  80740. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  80741. * @param parsedTexture Define the JSON representation of the texture
  80742. * @param scene Define the scene the parsed texture should be instantiated in
  80743. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  80744. * @returns The parsed texture if successful
  80745. */
  80746. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  80747. /**
  80748. * Creates a texture from its base 64 representation.
  80749. * @param data Define the base64 payload without the data: prefix
  80750. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  80751. * @param scene Define the scene the texture should belong to
  80752. * @param noMipmap Forces the texture to not create mip map information if true
  80753. * @param invertY define if the texture needs to be inverted on the y axis during loading
  80754. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  80755. * @param onLoad define a callback triggered when the texture has been loaded
  80756. * @param onError define a callback triggered when an error occurred during the loading session
  80757. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  80758. * @returns the created texture
  80759. */
  80760. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  80761. /**
  80762. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  80763. * @param data Define the base64 payload without the data: prefix
  80764. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  80765. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  80766. * @param scene Define the scene the texture should belong to
  80767. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  80768. * @param noMipmap Forces the texture to not create mip map information if true
  80769. * @param invertY define if the texture needs to be inverted on the y axis during loading
  80770. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  80771. * @param onLoad define a callback triggered when the texture has been loaded
  80772. * @param onError define a callback triggered when an error occurred during the loading session
  80773. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  80774. * @returns the created texture
  80775. */
  80776. 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;
  80777. }
  80778. }
  80779. declare module BABYLON {
  80780. interface Engine {
  80781. /**
  80782. * Creates a raw texture
  80783. * @param data defines the data to store in the texture
  80784. * @param width defines the width of the texture
  80785. * @param height defines the height of the texture
  80786. * @param format defines the format of the data
  80787. * @param generateMipMaps defines if the engine should generate the mip levels
  80788. * @param invertY defines if data must be stored with Y axis inverted
  80789. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  80790. * @param compression defines the compression used (null by default)
  80791. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80792. * @returns the raw texture inside an InternalTexture
  80793. */
  80794. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  80795. /**
  80796. * Update a raw texture
  80797. * @param texture defines the texture to update
  80798. * @param data defines the data to store in the texture
  80799. * @param format defines the format of the data
  80800. * @param invertY defines if data must be stored with Y axis inverted
  80801. */
  80802. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80803. /**
  80804. * Update a raw texture
  80805. * @param texture defines the texture to update
  80806. * @param data defines the data to store in the texture
  80807. * @param format defines the format of the data
  80808. * @param invertY defines if data must be stored with Y axis inverted
  80809. * @param compression defines the compression used (null by default)
  80810. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80811. */
  80812. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  80813. /**
  80814. * Creates a new raw cube texture
  80815. * @param data defines the array of data to use to create each face
  80816. * @param size defines the size of the textures
  80817. * @param format defines the format of the data
  80818. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80819. * @param generateMipMaps defines if the engine should generate the mip levels
  80820. * @param invertY defines if data must be stored with Y axis inverted
  80821. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80822. * @param compression defines the compression used (null by default)
  80823. * @returns the cube texture as an InternalTexture
  80824. */
  80825. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  80826. /**
  80827. * Update a raw cube texture
  80828. * @param texture defines the texture to udpdate
  80829. * @param data defines the data to store
  80830. * @param format defines the data format
  80831. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80832. * @param invertY defines if data must be stored with Y axis inverted
  80833. */
  80834. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  80835. /**
  80836. * Update a raw cube texture
  80837. * @param texture defines the texture to udpdate
  80838. * @param data defines the data to store
  80839. * @param format defines the data format
  80840. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80841. * @param invertY defines if data must be stored with Y axis inverted
  80842. * @param compression defines the compression used (null by default)
  80843. */
  80844. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  80845. /**
  80846. * Update a raw cube texture
  80847. * @param texture defines the texture to udpdate
  80848. * @param data defines the data to store
  80849. * @param format defines the data format
  80850. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80851. * @param invertY defines if data must be stored with Y axis inverted
  80852. * @param compression defines the compression used (null by default)
  80853. * @param level defines which level of the texture to update
  80854. */
  80855. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  80856. /**
  80857. * Creates a new raw cube texture from a specified url
  80858. * @param url defines the url where the data is located
  80859. * @param scene defines the current scene
  80860. * @param size defines the size of the textures
  80861. * @param format defines the format of the data
  80862. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80863. * @param noMipmap defines if the engine should avoid generating the mip levels
  80864. * @param callback defines a callback used to extract texture data from loaded data
  80865. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  80866. * @param onLoad defines a callback called when texture is loaded
  80867. * @param onError defines a callback called if there is an error
  80868. * @returns the cube texture as an InternalTexture
  80869. */
  80870. 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;
  80871. /**
  80872. * Creates a new raw cube texture from a specified url
  80873. * @param url defines the url where the data is located
  80874. * @param scene defines the current scene
  80875. * @param size defines the size of the textures
  80876. * @param format defines the format of the data
  80877. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80878. * @param noMipmap defines if the engine should avoid generating the mip levels
  80879. * @param callback defines a callback used to extract texture data from loaded data
  80880. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  80881. * @param onLoad defines a callback called when texture is loaded
  80882. * @param onError defines a callback called if there is an error
  80883. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80884. * @param invertY defines if data must be stored with Y axis inverted
  80885. * @returns the cube texture as an InternalTexture
  80886. */
  80887. 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;
  80888. /**
  80889. * Creates a new raw 3D texture
  80890. * @param data defines the data used to create the texture
  80891. * @param width defines the width of the texture
  80892. * @param height defines the height of the texture
  80893. * @param depth defines the depth of the texture
  80894. * @param format defines the format of the texture
  80895. * @param generateMipMaps defines if the engine must generate mip levels
  80896. * @param invertY defines if data must be stored with Y axis inverted
  80897. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80898. * @param compression defines the compressed used (can be null)
  80899. * @param textureType defines the compressed used (can be null)
  80900. * @returns a new raw 3D texture (stored in an InternalTexture)
  80901. */
  80902. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  80903. /**
  80904. * Update a raw 3D texture
  80905. * @param texture defines the texture to update
  80906. * @param data defines the data to store
  80907. * @param format defines the data format
  80908. * @param invertY defines if data must be stored with Y axis inverted
  80909. */
  80910. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80911. /**
  80912. * Update a raw 3D texture
  80913. * @param texture defines the texture to update
  80914. * @param data defines the data to store
  80915. * @param format defines the data format
  80916. * @param invertY defines if data must be stored with Y axis inverted
  80917. * @param compression defines the used compression (can be null)
  80918. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  80919. */
  80920. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  80921. }
  80922. }
  80923. declare module BABYLON {
  80924. /**
  80925. * Raw texture can help creating a texture directly from an array of data.
  80926. * This can be super useful if you either get the data from an uncompressed source or
  80927. * if you wish to create your texture pixel by pixel.
  80928. */
  80929. export class RawTexture extends Texture {
  80930. /**
  80931. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80932. */
  80933. format: number;
  80934. private _engine;
  80935. /**
  80936. * Instantiates a new RawTexture.
  80937. * Raw texture can help creating a texture directly from an array of data.
  80938. * This can be super useful if you either get the data from an uncompressed source or
  80939. * if you wish to create your texture pixel by pixel.
  80940. * @param data define the array of data to use to create the texture
  80941. * @param width define the width of the texture
  80942. * @param height define the height of the texture
  80943. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80944. * @param scene define the scene the texture belongs to
  80945. * @param generateMipMaps define whether mip maps should be generated or not
  80946. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80947. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80948. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80949. */
  80950. constructor(data: ArrayBufferView, width: number, height: number,
  80951. /**
  80952. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80953. */
  80954. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  80955. /**
  80956. * Updates the texture underlying data.
  80957. * @param data Define the new data of the texture
  80958. */
  80959. update(data: ArrayBufferView): void;
  80960. /**
  80961. * Creates a luminance texture from some data.
  80962. * @param data Define the texture data
  80963. * @param width Define the width of the texture
  80964. * @param height Define the height of the texture
  80965. * @param scene Define the scene the texture belongs to
  80966. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80967. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80968. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80969. * @returns the luminance texture
  80970. */
  80971. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80972. /**
  80973. * Creates a luminance alpha texture from some data.
  80974. * @param data Define the texture data
  80975. * @param width Define the width of the texture
  80976. * @param height Define the height of the texture
  80977. * @param scene Define the scene the texture belongs to
  80978. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80979. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80980. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80981. * @returns the luminance alpha texture
  80982. */
  80983. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80984. /**
  80985. * Creates an alpha texture from some data.
  80986. * @param data Define the texture data
  80987. * @param width Define the width of the texture
  80988. * @param height Define the height of the texture
  80989. * @param scene Define the scene the texture belongs to
  80990. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80991. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80992. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80993. * @returns the alpha texture
  80994. */
  80995. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80996. /**
  80997. * Creates a RGB texture from some data.
  80998. * @param data Define the texture data
  80999. * @param width Define the width of the texture
  81000. * @param height Define the height of the texture
  81001. * @param scene Define the scene the texture belongs to
  81002. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81003. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81004. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81005. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81006. * @returns the RGB alpha texture
  81007. */
  81008. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  81009. /**
  81010. * Creates a RGBA texture from some data.
  81011. * @param data Define the texture data
  81012. * @param width Define the width of the texture
  81013. * @param height Define the height of the texture
  81014. * @param scene Define the scene the texture belongs to
  81015. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81016. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81017. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81018. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81019. * @returns the RGBA texture
  81020. */
  81021. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  81022. /**
  81023. * Creates a R texture from some data.
  81024. * @param data Define the texture data
  81025. * @param width Define the width of the texture
  81026. * @param height Define the height of the texture
  81027. * @param scene Define the scene the texture belongs to
  81028. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81029. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81030. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81031. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81032. * @returns the R texture
  81033. */
  81034. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  81035. }
  81036. }
  81037. declare module BABYLON {
  81038. /**
  81039. * Defines a runtime animation
  81040. */
  81041. export class RuntimeAnimation {
  81042. private _events;
  81043. /**
  81044. * The current frame of the runtime animation
  81045. */
  81046. private _currentFrame;
  81047. /**
  81048. * The animation used by the runtime animation
  81049. */
  81050. private _animation;
  81051. /**
  81052. * The target of the runtime animation
  81053. */
  81054. private _target;
  81055. /**
  81056. * The initiating animatable
  81057. */
  81058. private _host;
  81059. /**
  81060. * The original value of the runtime animation
  81061. */
  81062. private _originalValue;
  81063. /**
  81064. * The original blend value of the runtime animation
  81065. */
  81066. private _originalBlendValue;
  81067. /**
  81068. * The offsets cache of the runtime animation
  81069. */
  81070. private _offsetsCache;
  81071. /**
  81072. * The high limits cache of the runtime animation
  81073. */
  81074. private _highLimitsCache;
  81075. /**
  81076. * Specifies if the runtime animation has been stopped
  81077. */
  81078. private _stopped;
  81079. /**
  81080. * The blending factor of the runtime animation
  81081. */
  81082. private _blendingFactor;
  81083. /**
  81084. * The BabylonJS scene
  81085. */
  81086. private _scene;
  81087. /**
  81088. * The current value of the runtime animation
  81089. */
  81090. private _currentValue;
  81091. /** @hidden */
  81092. _animationState: _IAnimationState;
  81093. /**
  81094. * The active target of the runtime animation
  81095. */
  81096. private _activeTargets;
  81097. private _currentActiveTarget;
  81098. private _directTarget;
  81099. /**
  81100. * The target path of the runtime animation
  81101. */
  81102. private _targetPath;
  81103. /**
  81104. * The weight of the runtime animation
  81105. */
  81106. private _weight;
  81107. /**
  81108. * The ratio offset of the runtime animation
  81109. */
  81110. private _ratioOffset;
  81111. /**
  81112. * The previous delay of the runtime animation
  81113. */
  81114. private _previousDelay;
  81115. /**
  81116. * The previous ratio of the runtime animation
  81117. */
  81118. private _previousRatio;
  81119. private _enableBlending;
  81120. private _keys;
  81121. private _minFrame;
  81122. private _maxFrame;
  81123. private _minValue;
  81124. private _maxValue;
  81125. private _targetIsArray;
  81126. /**
  81127. * Gets the current frame of the runtime animation
  81128. */
  81129. readonly currentFrame: number;
  81130. /**
  81131. * Gets the weight of the runtime animation
  81132. */
  81133. readonly weight: number;
  81134. /**
  81135. * Gets the current value of the runtime animation
  81136. */
  81137. readonly currentValue: any;
  81138. /**
  81139. * Gets the target path of the runtime animation
  81140. */
  81141. readonly targetPath: string;
  81142. /**
  81143. * Gets the actual target of the runtime animation
  81144. */
  81145. readonly target: any;
  81146. /** @hidden */
  81147. _onLoop: () => void;
  81148. /**
  81149. * Create a new RuntimeAnimation object
  81150. * @param target defines the target of the animation
  81151. * @param animation defines the source animation object
  81152. * @param scene defines the hosting scene
  81153. * @param host defines the initiating Animatable
  81154. */
  81155. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  81156. private _preparePath;
  81157. /**
  81158. * Gets the animation from the runtime animation
  81159. */
  81160. readonly animation: Animation;
  81161. /**
  81162. * Resets the runtime animation to the beginning
  81163. * @param restoreOriginal defines whether to restore the target property to the original value
  81164. */
  81165. reset(restoreOriginal?: boolean): void;
  81166. /**
  81167. * Specifies if the runtime animation is stopped
  81168. * @returns Boolean specifying if the runtime animation is stopped
  81169. */
  81170. isStopped(): boolean;
  81171. /**
  81172. * Disposes of the runtime animation
  81173. */
  81174. dispose(): void;
  81175. /**
  81176. * Apply the interpolated value to the target
  81177. * @param currentValue defines the value computed by the animation
  81178. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  81179. */
  81180. setValue(currentValue: any, weight: number): void;
  81181. private _getOriginalValues;
  81182. private _setValue;
  81183. /**
  81184. * Gets the loop pmode of the runtime animation
  81185. * @returns Loop Mode
  81186. */
  81187. private _getCorrectLoopMode;
  81188. /**
  81189. * Move the current animation to a given frame
  81190. * @param frame defines the frame to move to
  81191. */
  81192. goToFrame(frame: number): void;
  81193. /**
  81194. * @hidden Internal use only
  81195. */
  81196. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  81197. /**
  81198. * Execute the current animation
  81199. * @param delay defines the delay to add to the current frame
  81200. * @param from defines the lower bound of the animation range
  81201. * @param to defines the upper bound of the animation range
  81202. * @param loop defines if the current animation must loop
  81203. * @param speedRatio defines the current speed ratio
  81204. * @param weight defines the weight of the animation (default is -1 so no weight)
  81205. * @param onLoop optional callback called when animation loops
  81206. * @returns a boolean indicating if the animation is running
  81207. */
  81208. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  81209. }
  81210. }
  81211. declare module BABYLON {
  81212. /**
  81213. * Class used to store an actual running animation
  81214. */
  81215. export class Animatable {
  81216. /** defines the target object */
  81217. target: any;
  81218. /** defines the starting frame number (default is 0) */
  81219. fromFrame: number;
  81220. /** defines the ending frame number (default is 100) */
  81221. toFrame: number;
  81222. /** defines if the animation must loop (default is false) */
  81223. loopAnimation: boolean;
  81224. /** defines a callback to call when animation ends if it is not looping */
  81225. onAnimationEnd?: (() => void) | null | undefined;
  81226. /** defines a callback to call when animation loops */
  81227. onAnimationLoop?: (() => void) | null | undefined;
  81228. private _localDelayOffset;
  81229. private _pausedDelay;
  81230. private _runtimeAnimations;
  81231. private _paused;
  81232. private _scene;
  81233. private _speedRatio;
  81234. private _weight;
  81235. private _syncRoot;
  81236. /**
  81237. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  81238. * This will only apply for non looping animation (default is true)
  81239. */
  81240. disposeOnEnd: boolean;
  81241. /**
  81242. * Gets a boolean indicating if the animation has started
  81243. */
  81244. animationStarted: boolean;
  81245. /**
  81246. * Observer raised when the animation ends
  81247. */
  81248. onAnimationEndObservable: Observable<Animatable>;
  81249. /**
  81250. * Observer raised when the animation loops
  81251. */
  81252. onAnimationLoopObservable: Observable<Animatable>;
  81253. /**
  81254. * Gets the root Animatable used to synchronize and normalize animations
  81255. */
  81256. readonly syncRoot: Nullable<Animatable>;
  81257. /**
  81258. * Gets the current frame of the first RuntimeAnimation
  81259. * Used to synchronize Animatables
  81260. */
  81261. readonly masterFrame: number;
  81262. /**
  81263. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  81264. */
  81265. weight: number;
  81266. /**
  81267. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  81268. */
  81269. speedRatio: number;
  81270. /**
  81271. * Creates a new Animatable
  81272. * @param scene defines the hosting scene
  81273. * @param target defines the target object
  81274. * @param fromFrame defines the starting frame number (default is 0)
  81275. * @param toFrame defines the ending frame number (default is 100)
  81276. * @param loopAnimation defines if the animation must loop (default is false)
  81277. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  81278. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  81279. * @param animations defines a group of animation to add to the new Animatable
  81280. * @param onAnimationLoop defines a callback to call when animation loops
  81281. */
  81282. constructor(scene: Scene,
  81283. /** defines the target object */
  81284. target: any,
  81285. /** defines the starting frame number (default is 0) */
  81286. fromFrame?: number,
  81287. /** defines the ending frame number (default is 100) */
  81288. toFrame?: number,
  81289. /** defines if the animation must loop (default is false) */
  81290. loopAnimation?: boolean, speedRatio?: number,
  81291. /** defines a callback to call when animation ends if it is not looping */
  81292. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  81293. /** defines a callback to call when animation loops */
  81294. onAnimationLoop?: (() => void) | null | undefined);
  81295. /**
  81296. * Synchronize and normalize current Animatable with a source Animatable
  81297. * This is useful when using animation weights and when animations are not of the same length
  81298. * @param root defines the root Animatable to synchronize with
  81299. * @returns the current Animatable
  81300. */
  81301. syncWith(root: Animatable): Animatable;
  81302. /**
  81303. * Gets the list of runtime animations
  81304. * @returns an array of RuntimeAnimation
  81305. */
  81306. getAnimations(): RuntimeAnimation[];
  81307. /**
  81308. * Adds more animations to the current animatable
  81309. * @param target defines the target of the animations
  81310. * @param animations defines the new animations to add
  81311. */
  81312. appendAnimations(target: any, animations: Animation[]): void;
  81313. /**
  81314. * Gets the source animation for a specific property
  81315. * @param property defines the propertyu to look for
  81316. * @returns null or the source animation for the given property
  81317. */
  81318. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  81319. /**
  81320. * Gets the runtime animation for a specific property
  81321. * @param property defines the propertyu to look for
  81322. * @returns null or the runtime animation for the given property
  81323. */
  81324. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  81325. /**
  81326. * Resets the animatable to its original state
  81327. */
  81328. reset(): void;
  81329. /**
  81330. * Allows the animatable to blend with current running animations
  81331. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81332. * @param blendingSpeed defines the blending speed to use
  81333. */
  81334. enableBlending(blendingSpeed: number): void;
  81335. /**
  81336. * Disable animation blending
  81337. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81338. */
  81339. disableBlending(): void;
  81340. /**
  81341. * Jump directly to a given frame
  81342. * @param frame defines the frame to jump to
  81343. */
  81344. goToFrame(frame: number): void;
  81345. /**
  81346. * Pause the animation
  81347. */
  81348. pause(): void;
  81349. /**
  81350. * Restart the animation
  81351. */
  81352. restart(): void;
  81353. private _raiseOnAnimationEnd;
  81354. /**
  81355. * Stop and delete the current animation
  81356. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  81357. * @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)
  81358. */
  81359. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  81360. /**
  81361. * Wait asynchronously for the animation to end
  81362. * @returns a promise which will be fullfilled when the animation ends
  81363. */
  81364. waitAsync(): Promise<Animatable>;
  81365. /** @hidden */
  81366. _animate(delay: number): boolean;
  81367. }
  81368. interface Scene {
  81369. /** @hidden */
  81370. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  81371. /** @hidden */
  81372. _processLateAnimationBindingsForMatrices(holder: {
  81373. totalWeight: number;
  81374. animations: RuntimeAnimation[];
  81375. originalValue: Matrix;
  81376. }): any;
  81377. /** @hidden */
  81378. _processLateAnimationBindingsForQuaternions(holder: {
  81379. totalWeight: number;
  81380. animations: RuntimeAnimation[];
  81381. originalValue: Quaternion;
  81382. }, refQuaternion: Quaternion): Quaternion;
  81383. /** @hidden */
  81384. _processLateAnimationBindings(): void;
  81385. /**
  81386. * Will start the animation sequence of a given target
  81387. * @param target defines the target
  81388. * @param from defines from which frame should animation start
  81389. * @param to defines until which frame should animation run.
  81390. * @param weight defines the weight to apply to the animation (1.0 by default)
  81391. * @param loop defines if the animation loops
  81392. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81393. * @param onAnimationEnd defines the function to be executed when the animation ends
  81394. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81395. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  81396. * @param onAnimationLoop defines the callback to call when an animation loops
  81397. * @returns the animatable object created for this animation
  81398. */
  81399. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  81400. /**
  81401. * Will start the animation sequence of a given target
  81402. * @param target defines the target
  81403. * @param from defines from which frame should animation start
  81404. * @param to defines until which frame should animation run.
  81405. * @param loop defines if the animation loops
  81406. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81407. * @param onAnimationEnd defines the function to be executed when the animation ends
  81408. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81409. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  81410. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  81411. * @param onAnimationLoop defines the callback to call when an animation loops
  81412. * @returns the animatable object created for this animation
  81413. */
  81414. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  81415. /**
  81416. * Will start the animation sequence of a given target and its hierarchy
  81417. * @param target defines the target
  81418. * @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.
  81419. * @param from defines from which frame should animation start
  81420. * @param to defines until which frame should animation run.
  81421. * @param loop defines if the animation loops
  81422. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81423. * @param onAnimationEnd defines the function to be executed when the animation ends
  81424. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81425. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  81426. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  81427. * @param onAnimationLoop defines the callback to call when an animation loops
  81428. * @returns the list of created animatables
  81429. */
  81430. 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[];
  81431. /**
  81432. * Begin a new animation on a given node
  81433. * @param target defines the target where the animation will take place
  81434. * @param animations defines the list of animations to start
  81435. * @param from defines the initial value
  81436. * @param to defines the final value
  81437. * @param loop defines if you want animation to loop (off by default)
  81438. * @param speedRatio defines the speed ratio to apply to all animations
  81439. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81440. * @param onAnimationLoop defines the callback to call when an animation loops
  81441. * @returns the list of created animatables
  81442. */
  81443. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  81444. /**
  81445. * Begin a new animation on a given node and its hierarchy
  81446. * @param target defines the root node where the animation will take place
  81447. * @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.
  81448. * @param animations defines the list of animations to start
  81449. * @param from defines the initial value
  81450. * @param to defines the final value
  81451. * @param loop defines if you want animation to loop (off by default)
  81452. * @param speedRatio defines the speed ratio to apply to all animations
  81453. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81454. * @param onAnimationLoop defines the callback to call when an animation loops
  81455. * @returns the list of animatables created for all nodes
  81456. */
  81457. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  81458. /**
  81459. * Gets the animatable associated with a specific target
  81460. * @param target defines the target of the animatable
  81461. * @returns the required animatable if found
  81462. */
  81463. getAnimatableByTarget(target: any): Nullable<Animatable>;
  81464. /**
  81465. * Gets all animatables associated with a given target
  81466. * @param target defines the target to look animatables for
  81467. * @returns an array of Animatables
  81468. */
  81469. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  81470. /**
  81471. * Stops and removes all animations that have been applied to the scene
  81472. */
  81473. stopAllAnimations(): void;
  81474. }
  81475. interface Bone {
  81476. /**
  81477. * Copy an animation range from another bone
  81478. * @param source defines the source bone
  81479. * @param rangeName defines the range name to copy
  81480. * @param frameOffset defines the frame offset
  81481. * @param rescaleAsRequired defines if rescaling must be applied if required
  81482. * @param skelDimensionsRatio defines the scaling ratio
  81483. * @returns true if operation was successful
  81484. */
  81485. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  81486. }
  81487. }
  81488. declare module BABYLON {
  81489. /**
  81490. * Class used to handle skinning animations
  81491. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81492. */
  81493. export class Skeleton implements IAnimatable {
  81494. /** defines the skeleton name */
  81495. name: string;
  81496. /** defines the skeleton Id */
  81497. id: string;
  81498. /**
  81499. * Defines the list of child bones
  81500. */
  81501. bones: Bone[];
  81502. /**
  81503. * Defines an estimate of the dimension of the skeleton at rest
  81504. */
  81505. dimensionsAtRest: Vector3;
  81506. /**
  81507. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  81508. */
  81509. needInitialSkinMatrix: boolean;
  81510. /**
  81511. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  81512. */
  81513. overrideMesh: Nullable<AbstractMesh>;
  81514. /**
  81515. * Gets the list of animations attached to this skeleton
  81516. */
  81517. animations: Array<Animation>;
  81518. private _scene;
  81519. private _isDirty;
  81520. private _transformMatrices;
  81521. private _transformMatrixTexture;
  81522. private _meshesWithPoseMatrix;
  81523. private _animatables;
  81524. private _identity;
  81525. private _synchronizedWithMesh;
  81526. private _ranges;
  81527. private _lastAbsoluteTransformsUpdateId;
  81528. private _canUseTextureForBones;
  81529. private _uniqueId;
  81530. /** @hidden */
  81531. _numBonesWithLinkedTransformNode: number;
  81532. /** @hidden */
  81533. _hasWaitingData: Nullable<boolean>;
  81534. /**
  81535. * Specifies if the skeleton should be serialized
  81536. */
  81537. doNotSerialize: boolean;
  81538. private _useTextureToStoreBoneMatrices;
  81539. /**
  81540. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  81541. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  81542. */
  81543. useTextureToStoreBoneMatrices: boolean;
  81544. private _animationPropertiesOverride;
  81545. /**
  81546. * Gets or sets the animation properties override
  81547. */
  81548. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81549. /**
  81550. * List of inspectable custom properties (used by the Inspector)
  81551. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81552. */
  81553. inspectableCustomProperties: IInspectable[];
  81554. /**
  81555. * An observable triggered before computing the skeleton's matrices
  81556. */
  81557. onBeforeComputeObservable: Observable<Skeleton>;
  81558. /**
  81559. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  81560. */
  81561. readonly isUsingTextureForMatrices: boolean;
  81562. /**
  81563. * Gets the unique ID of this skeleton
  81564. */
  81565. readonly uniqueId: number;
  81566. /**
  81567. * Creates a new skeleton
  81568. * @param name defines the skeleton name
  81569. * @param id defines the skeleton Id
  81570. * @param scene defines the hosting scene
  81571. */
  81572. constructor(
  81573. /** defines the skeleton name */
  81574. name: string,
  81575. /** defines the skeleton Id */
  81576. id: string, scene: Scene);
  81577. /**
  81578. * Gets the current object class name.
  81579. * @return the class name
  81580. */
  81581. getClassName(): string;
  81582. /**
  81583. * Returns an array containing the root bones
  81584. * @returns an array containing the root bones
  81585. */
  81586. getChildren(): Array<Bone>;
  81587. /**
  81588. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  81589. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  81590. * @returns a Float32Array containing matrices data
  81591. */
  81592. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  81593. /**
  81594. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  81595. * @returns a raw texture containing the data
  81596. */
  81597. getTransformMatrixTexture(): Nullable<RawTexture>;
  81598. /**
  81599. * Gets the current hosting scene
  81600. * @returns a scene object
  81601. */
  81602. getScene(): Scene;
  81603. /**
  81604. * Gets a string representing the current skeleton data
  81605. * @param fullDetails defines a boolean indicating if we want a verbose version
  81606. * @returns a string representing the current skeleton data
  81607. */
  81608. toString(fullDetails?: boolean): string;
  81609. /**
  81610. * Get bone's index searching by name
  81611. * @param name defines bone's name to search for
  81612. * @return the indice of the bone. Returns -1 if not found
  81613. */
  81614. getBoneIndexByName(name: string): number;
  81615. /**
  81616. * Creater a new animation range
  81617. * @param name defines the name of the range
  81618. * @param from defines the start key
  81619. * @param to defines the end key
  81620. */
  81621. createAnimationRange(name: string, from: number, to: number): void;
  81622. /**
  81623. * Delete a specific animation range
  81624. * @param name defines the name of the range
  81625. * @param deleteFrames defines if frames must be removed as well
  81626. */
  81627. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  81628. /**
  81629. * Gets a specific animation range
  81630. * @param name defines the name of the range to look for
  81631. * @returns the requested animation range or null if not found
  81632. */
  81633. getAnimationRange(name: string): Nullable<AnimationRange>;
  81634. /**
  81635. * Gets the list of all animation ranges defined on this skeleton
  81636. * @returns an array
  81637. */
  81638. getAnimationRanges(): Nullable<AnimationRange>[];
  81639. /**
  81640. * Copy animation range from a source skeleton.
  81641. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  81642. * @param source defines the source skeleton
  81643. * @param name defines the name of the range to copy
  81644. * @param rescaleAsRequired defines if rescaling must be applied if required
  81645. * @returns true if operation was successful
  81646. */
  81647. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  81648. /**
  81649. * Forces the skeleton to go to rest pose
  81650. */
  81651. returnToRest(): void;
  81652. private _getHighestAnimationFrame;
  81653. /**
  81654. * Begin a specific animation range
  81655. * @param name defines the name of the range to start
  81656. * @param loop defines if looping must be turned on (false by default)
  81657. * @param speedRatio defines the speed ratio to apply (1 by default)
  81658. * @param onAnimationEnd defines a callback which will be called when animation will end
  81659. * @returns a new animatable
  81660. */
  81661. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  81662. /** @hidden */
  81663. _markAsDirty(): void;
  81664. /** @hidden */
  81665. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  81666. /** @hidden */
  81667. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  81668. private _computeTransformMatrices;
  81669. /**
  81670. * Build all resources required to render a skeleton
  81671. */
  81672. prepare(): void;
  81673. /**
  81674. * Gets the list of animatables currently running for this skeleton
  81675. * @returns an array of animatables
  81676. */
  81677. getAnimatables(): IAnimatable[];
  81678. /**
  81679. * Clone the current skeleton
  81680. * @param name defines the name of the new skeleton
  81681. * @param id defines the id of the new skeleton
  81682. * @returns the new skeleton
  81683. */
  81684. clone(name: string, id: string): Skeleton;
  81685. /**
  81686. * Enable animation blending for this skeleton
  81687. * @param blendingSpeed defines the blending speed to apply
  81688. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81689. */
  81690. enableBlending(blendingSpeed?: number): void;
  81691. /**
  81692. * Releases all resources associated with the current skeleton
  81693. */
  81694. dispose(): void;
  81695. /**
  81696. * Serialize the skeleton in a JSON object
  81697. * @returns a JSON object
  81698. */
  81699. serialize(): any;
  81700. /**
  81701. * Creates a new skeleton from serialized data
  81702. * @param parsedSkeleton defines the serialized data
  81703. * @param scene defines the hosting scene
  81704. * @returns a new skeleton
  81705. */
  81706. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  81707. /**
  81708. * Compute all node absolute transforms
  81709. * @param forceUpdate defines if computation must be done even if cache is up to date
  81710. */
  81711. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  81712. /**
  81713. * Gets the root pose matrix
  81714. * @returns a matrix
  81715. */
  81716. getPoseMatrix(): Nullable<Matrix>;
  81717. /**
  81718. * Sorts bones per internal index
  81719. */
  81720. sortBones(): void;
  81721. private _sortBones;
  81722. }
  81723. }
  81724. declare module BABYLON {
  81725. /**
  81726. * Defines a target to use with MorphTargetManager
  81727. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  81728. */
  81729. export class MorphTarget implements IAnimatable {
  81730. /** defines the name of the target */
  81731. name: string;
  81732. /**
  81733. * Gets or sets the list of animations
  81734. */
  81735. animations: Animation[];
  81736. private _scene;
  81737. private _positions;
  81738. private _normals;
  81739. private _tangents;
  81740. private _influence;
  81741. /**
  81742. * Observable raised when the influence changes
  81743. */
  81744. onInfluenceChanged: Observable<boolean>;
  81745. /** @hidden */
  81746. _onDataLayoutChanged: Observable<void>;
  81747. /**
  81748. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  81749. */
  81750. influence: number;
  81751. /**
  81752. * Gets or sets the id of the morph Target
  81753. */
  81754. id: string;
  81755. private _animationPropertiesOverride;
  81756. /**
  81757. * Gets or sets the animation properties override
  81758. */
  81759. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81760. /**
  81761. * Creates a new MorphTarget
  81762. * @param name defines the name of the target
  81763. * @param influence defines the influence to use
  81764. * @param scene defines the scene the morphtarget belongs to
  81765. */
  81766. constructor(
  81767. /** defines the name of the target */
  81768. name: string, influence?: number, scene?: Nullable<Scene>);
  81769. /**
  81770. * Gets a boolean defining if the target contains position data
  81771. */
  81772. readonly hasPositions: boolean;
  81773. /**
  81774. * Gets a boolean defining if the target contains normal data
  81775. */
  81776. readonly hasNormals: boolean;
  81777. /**
  81778. * Gets a boolean defining if the target contains tangent data
  81779. */
  81780. readonly hasTangents: boolean;
  81781. /**
  81782. * Affects position data to this target
  81783. * @param data defines the position data to use
  81784. */
  81785. setPositions(data: Nullable<FloatArray>): void;
  81786. /**
  81787. * Gets the position data stored in this target
  81788. * @returns a FloatArray containing the position data (or null if not present)
  81789. */
  81790. getPositions(): Nullable<FloatArray>;
  81791. /**
  81792. * Affects normal data to this target
  81793. * @param data defines the normal data to use
  81794. */
  81795. setNormals(data: Nullable<FloatArray>): void;
  81796. /**
  81797. * Gets the normal data stored in this target
  81798. * @returns a FloatArray containing the normal data (or null if not present)
  81799. */
  81800. getNormals(): Nullable<FloatArray>;
  81801. /**
  81802. * Affects tangent data to this target
  81803. * @param data defines the tangent data to use
  81804. */
  81805. setTangents(data: Nullable<FloatArray>): void;
  81806. /**
  81807. * Gets the tangent data stored in this target
  81808. * @returns a FloatArray containing the tangent data (or null if not present)
  81809. */
  81810. getTangents(): Nullable<FloatArray>;
  81811. /**
  81812. * Serializes the current target into a Serialization object
  81813. * @returns the serialized object
  81814. */
  81815. serialize(): any;
  81816. /**
  81817. * Returns the string "MorphTarget"
  81818. * @returns "MorphTarget"
  81819. */
  81820. getClassName(): string;
  81821. /**
  81822. * Creates a new target from serialized data
  81823. * @param serializationObject defines the serialized data to use
  81824. * @returns a new MorphTarget
  81825. */
  81826. static Parse(serializationObject: any): MorphTarget;
  81827. /**
  81828. * Creates a MorphTarget from mesh data
  81829. * @param mesh defines the source mesh
  81830. * @param name defines the name to use for the new target
  81831. * @param influence defines the influence to attach to the target
  81832. * @returns a new MorphTarget
  81833. */
  81834. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  81835. }
  81836. }
  81837. declare module BABYLON {
  81838. /**
  81839. * This class is used to deform meshes using morphing between different targets
  81840. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  81841. */
  81842. export class MorphTargetManager {
  81843. private _targets;
  81844. private _targetInfluenceChangedObservers;
  81845. private _targetDataLayoutChangedObservers;
  81846. private _activeTargets;
  81847. private _scene;
  81848. private _influences;
  81849. private _supportsNormals;
  81850. private _supportsTangents;
  81851. private _vertexCount;
  81852. private _uniqueId;
  81853. private _tempInfluences;
  81854. /**
  81855. * Creates a new MorphTargetManager
  81856. * @param scene defines the current scene
  81857. */
  81858. constructor(scene?: Nullable<Scene>);
  81859. /**
  81860. * Gets the unique ID of this manager
  81861. */
  81862. readonly uniqueId: number;
  81863. /**
  81864. * Gets the number of vertices handled by this manager
  81865. */
  81866. readonly vertexCount: number;
  81867. /**
  81868. * Gets a boolean indicating if this manager supports morphing of normals
  81869. */
  81870. readonly supportsNormals: boolean;
  81871. /**
  81872. * Gets a boolean indicating if this manager supports morphing of tangents
  81873. */
  81874. readonly supportsTangents: boolean;
  81875. /**
  81876. * Gets the number of targets stored in this manager
  81877. */
  81878. readonly numTargets: number;
  81879. /**
  81880. * Gets the number of influencers (ie. the number of targets with influences > 0)
  81881. */
  81882. readonly numInfluencers: number;
  81883. /**
  81884. * Gets the list of influences (one per target)
  81885. */
  81886. readonly influences: Float32Array;
  81887. /**
  81888. * Gets the active target at specified index. An active target is a target with an influence > 0
  81889. * @param index defines the index to check
  81890. * @returns the requested target
  81891. */
  81892. getActiveTarget(index: number): MorphTarget;
  81893. /**
  81894. * Gets the target at specified index
  81895. * @param index defines the index to check
  81896. * @returns the requested target
  81897. */
  81898. getTarget(index: number): MorphTarget;
  81899. /**
  81900. * Add a new target to this manager
  81901. * @param target defines the target to add
  81902. */
  81903. addTarget(target: MorphTarget): void;
  81904. /**
  81905. * Removes a target from the manager
  81906. * @param target defines the target to remove
  81907. */
  81908. removeTarget(target: MorphTarget): void;
  81909. /**
  81910. * Serializes the current manager into a Serialization object
  81911. * @returns the serialized object
  81912. */
  81913. serialize(): any;
  81914. private _syncActiveTargets;
  81915. /**
  81916. * Syncrhonize the targets with all the meshes using this morph target manager
  81917. */
  81918. synchronize(): void;
  81919. /**
  81920. * Creates a new MorphTargetManager from serialized data
  81921. * @param serializationObject defines the serialized data
  81922. * @param scene defines the hosting scene
  81923. * @returns the new MorphTargetManager
  81924. */
  81925. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  81926. }
  81927. }
  81928. declare module BABYLON {
  81929. /**
  81930. * Class used to represent a specific level of detail of a mesh
  81931. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  81932. */
  81933. export class MeshLODLevel {
  81934. /** Defines the distance where this level should star being displayed */
  81935. distance: number;
  81936. /** Defines the mesh to use to render this level */
  81937. mesh: Nullable<Mesh>;
  81938. /**
  81939. * Creates a new LOD level
  81940. * @param distance defines the distance where this level should star being displayed
  81941. * @param mesh defines the mesh to use to render this level
  81942. */
  81943. constructor(
  81944. /** Defines the distance where this level should star being displayed */
  81945. distance: number,
  81946. /** Defines the mesh to use to render this level */
  81947. mesh: Nullable<Mesh>);
  81948. }
  81949. }
  81950. declare module BABYLON {
  81951. /**
  81952. * Mesh representing the gorund
  81953. */
  81954. export class GroundMesh extends Mesh {
  81955. /** If octree should be generated */
  81956. generateOctree: boolean;
  81957. private _heightQuads;
  81958. /** @hidden */
  81959. _subdivisionsX: number;
  81960. /** @hidden */
  81961. _subdivisionsY: number;
  81962. /** @hidden */
  81963. _width: number;
  81964. /** @hidden */
  81965. _height: number;
  81966. /** @hidden */
  81967. _minX: number;
  81968. /** @hidden */
  81969. _maxX: number;
  81970. /** @hidden */
  81971. _minZ: number;
  81972. /** @hidden */
  81973. _maxZ: number;
  81974. constructor(name: string, scene: Scene);
  81975. /**
  81976. * "GroundMesh"
  81977. * @returns "GroundMesh"
  81978. */
  81979. getClassName(): string;
  81980. /**
  81981. * The minimum of x and y subdivisions
  81982. */
  81983. readonly subdivisions: number;
  81984. /**
  81985. * X subdivisions
  81986. */
  81987. readonly subdivisionsX: number;
  81988. /**
  81989. * Y subdivisions
  81990. */
  81991. readonly subdivisionsY: number;
  81992. /**
  81993. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  81994. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  81995. * @param chunksCount the number of subdivisions for x and y
  81996. * @param octreeBlocksSize (Default: 32)
  81997. */
  81998. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  81999. /**
  82000. * Returns a height (y) value in the Worl system :
  82001. * the ground altitude at the coordinates (x, z) expressed in the World system.
  82002. * @param x x coordinate
  82003. * @param z z coordinate
  82004. * @returns the ground y position if (x, z) are outside the ground surface.
  82005. */
  82006. getHeightAtCoordinates(x: number, z: number): number;
  82007. /**
  82008. * Returns a normalized vector (Vector3) orthogonal to the ground
  82009. * at the ground coordinates (x, z) expressed in the World system.
  82010. * @param x x coordinate
  82011. * @param z z coordinate
  82012. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  82013. */
  82014. getNormalAtCoordinates(x: number, z: number): Vector3;
  82015. /**
  82016. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  82017. * at the ground coordinates (x, z) expressed in the World system.
  82018. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  82019. * @param x x coordinate
  82020. * @param z z coordinate
  82021. * @param ref vector to store the result
  82022. * @returns the GroundMesh.
  82023. */
  82024. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  82025. /**
  82026. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  82027. * if the ground has been updated.
  82028. * This can be used in the render loop.
  82029. * @returns the GroundMesh.
  82030. */
  82031. updateCoordinateHeights(): GroundMesh;
  82032. private _getFacetAt;
  82033. private _initHeightQuads;
  82034. private _computeHeightQuads;
  82035. /**
  82036. * Serializes this ground mesh
  82037. * @param serializationObject object to write serialization to
  82038. */
  82039. serialize(serializationObject: any): void;
  82040. /**
  82041. * Parses a serialized ground mesh
  82042. * @param parsedMesh the serialized mesh
  82043. * @param scene the scene to create the ground mesh in
  82044. * @returns the created ground mesh
  82045. */
  82046. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  82047. }
  82048. }
  82049. declare module BABYLON {
  82050. /**
  82051. * Interface for Physics-Joint data
  82052. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82053. */
  82054. export interface PhysicsJointData {
  82055. /**
  82056. * The main pivot of the joint
  82057. */
  82058. mainPivot?: Vector3;
  82059. /**
  82060. * The connected pivot of the joint
  82061. */
  82062. connectedPivot?: Vector3;
  82063. /**
  82064. * The main axis of the joint
  82065. */
  82066. mainAxis?: Vector3;
  82067. /**
  82068. * The connected axis of the joint
  82069. */
  82070. connectedAxis?: Vector3;
  82071. /**
  82072. * The collision of the joint
  82073. */
  82074. collision?: boolean;
  82075. /**
  82076. * Native Oimo/Cannon/Energy data
  82077. */
  82078. nativeParams?: any;
  82079. }
  82080. /**
  82081. * This is a holder class for the physics joint created by the physics plugin
  82082. * It holds a set of functions to control the underlying joint
  82083. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82084. */
  82085. export class PhysicsJoint {
  82086. /**
  82087. * The type of the physics joint
  82088. */
  82089. type: number;
  82090. /**
  82091. * The data for the physics joint
  82092. */
  82093. jointData: PhysicsJointData;
  82094. private _physicsJoint;
  82095. protected _physicsPlugin: IPhysicsEnginePlugin;
  82096. /**
  82097. * Initializes the physics joint
  82098. * @param type The type of the physics joint
  82099. * @param jointData The data for the physics joint
  82100. */
  82101. constructor(
  82102. /**
  82103. * The type of the physics joint
  82104. */
  82105. type: number,
  82106. /**
  82107. * The data for the physics joint
  82108. */
  82109. jointData: PhysicsJointData);
  82110. /**
  82111. * Gets the physics joint
  82112. */
  82113. /**
  82114. * Sets the physics joint
  82115. */
  82116. physicsJoint: any;
  82117. /**
  82118. * Sets the physics plugin
  82119. */
  82120. physicsPlugin: IPhysicsEnginePlugin;
  82121. /**
  82122. * Execute a function that is physics-plugin specific.
  82123. * @param {Function} func the function that will be executed.
  82124. * It accepts two parameters: the physics world and the physics joint
  82125. */
  82126. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  82127. /**
  82128. * Distance-Joint type
  82129. */
  82130. static DistanceJoint: number;
  82131. /**
  82132. * Hinge-Joint type
  82133. */
  82134. static HingeJoint: number;
  82135. /**
  82136. * Ball-and-Socket joint type
  82137. */
  82138. static BallAndSocketJoint: number;
  82139. /**
  82140. * Wheel-Joint type
  82141. */
  82142. static WheelJoint: number;
  82143. /**
  82144. * Slider-Joint type
  82145. */
  82146. static SliderJoint: number;
  82147. /**
  82148. * Prismatic-Joint type
  82149. */
  82150. static PrismaticJoint: number;
  82151. /**
  82152. * Universal-Joint type
  82153. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  82154. */
  82155. static UniversalJoint: number;
  82156. /**
  82157. * Hinge-Joint 2 type
  82158. */
  82159. static Hinge2Joint: number;
  82160. /**
  82161. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  82162. */
  82163. static PointToPointJoint: number;
  82164. /**
  82165. * Spring-Joint type
  82166. */
  82167. static SpringJoint: number;
  82168. /**
  82169. * Lock-Joint type
  82170. */
  82171. static LockJoint: number;
  82172. }
  82173. /**
  82174. * A class representing a physics distance joint
  82175. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82176. */
  82177. export class DistanceJoint extends PhysicsJoint {
  82178. /**
  82179. *
  82180. * @param jointData The data for the Distance-Joint
  82181. */
  82182. constructor(jointData: DistanceJointData);
  82183. /**
  82184. * Update the predefined distance.
  82185. * @param maxDistance The maximum preferred distance
  82186. * @param minDistance The minimum preferred distance
  82187. */
  82188. updateDistance(maxDistance: number, minDistance?: number): void;
  82189. }
  82190. /**
  82191. * Represents a Motor-Enabled Joint
  82192. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82193. */
  82194. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  82195. /**
  82196. * Initializes the Motor-Enabled Joint
  82197. * @param type The type of the joint
  82198. * @param jointData The physica joint data for the joint
  82199. */
  82200. constructor(type: number, jointData: PhysicsJointData);
  82201. /**
  82202. * Set the motor values.
  82203. * Attention, this function is plugin specific. Engines won't react 100% the same.
  82204. * @param force the force to apply
  82205. * @param maxForce max force for this motor.
  82206. */
  82207. setMotor(force?: number, maxForce?: number): void;
  82208. /**
  82209. * Set the motor's limits.
  82210. * Attention, this function is plugin specific. Engines won't react 100% the same.
  82211. * @param upperLimit The upper limit of the motor
  82212. * @param lowerLimit The lower limit of the motor
  82213. */
  82214. setLimit(upperLimit: number, lowerLimit?: number): void;
  82215. }
  82216. /**
  82217. * This class represents a single physics Hinge-Joint
  82218. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82219. */
  82220. export class HingeJoint extends MotorEnabledJoint {
  82221. /**
  82222. * Initializes the Hinge-Joint
  82223. * @param jointData The joint data for the Hinge-Joint
  82224. */
  82225. constructor(jointData: PhysicsJointData);
  82226. /**
  82227. * Set the motor values.
  82228. * Attention, this function is plugin specific. Engines won't react 100% the same.
  82229. * @param {number} force the force to apply
  82230. * @param {number} maxForce max force for this motor.
  82231. */
  82232. setMotor(force?: number, maxForce?: number): void;
  82233. /**
  82234. * Set the motor's limits.
  82235. * Attention, this function is plugin specific. Engines won't react 100% the same.
  82236. * @param upperLimit The upper limit of the motor
  82237. * @param lowerLimit The lower limit of the motor
  82238. */
  82239. setLimit(upperLimit: number, lowerLimit?: number): void;
  82240. }
  82241. /**
  82242. * This class represents a dual hinge physics joint (same as wheel joint)
  82243. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82244. */
  82245. export class Hinge2Joint extends MotorEnabledJoint {
  82246. /**
  82247. * Initializes the Hinge2-Joint
  82248. * @param jointData The joint data for the Hinge2-Joint
  82249. */
  82250. constructor(jointData: PhysicsJointData);
  82251. /**
  82252. * Set the motor values.
  82253. * Attention, this function is plugin specific. Engines won't react 100% the same.
  82254. * @param {number} targetSpeed the speed the motor is to reach
  82255. * @param {number} maxForce max force for this motor.
  82256. * @param {motorIndex} the motor's index, 0 or 1.
  82257. */
  82258. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  82259. /**
  82260. * Set the motor limits.
  82261. * Attention, this function is plugin specific. Engines won't react 100% the same.
  82262. * @param {number} upperLimit the upper limit
  82263. * @param {number} lowerLimit lower limit
  82264. * @param {motorIndex} the motor's index, 0 or 1.
  82265. */
  82266. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  82267. }
  82268. /**
  82269. * Interface for a motor enabled joint
  82270. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82271. */
  82272. export interface IMotorEnabledJoint {
  82273. /**
  82274. * Physics joint
  82275. */
  82276. physicsJoint: any;
  82277. /**
  82278. * Sets the motor of the motor-enabled joint
  82279. * @param force The force of the motor
  82280. * @param maxForce The maximum force of the motor
  82281. * @param motorIndex The index of the motor
  82282. */
  82283. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  82284. /**
  82285. * Sets the limit of the motor
  82286. * @param upperLimit The upper limit of the motor
  82287. * @param lowerLimit The lower limit of the motor
  82288. * @param motorIndex The index of the motor
  82289. */
  82290. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  82291. }
  82292. /**
  82293. * Joint data for a Distance-Joint
  82294. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82295. */
  82296. export interface DistanceJointData extends PhysicsJointData {
  82297. /**
  82298. * Max distance the 2 joint objects can be apart
  82299. */
  82300. maxDistance: number;
  82301. }
  82302. /**
  82303. * Joint data from a spring joint
  82304. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82305. */
  82306. export interface SpringJointData extends PhysicsJointData {
  82307. /**
  82308. * Length of the spring
  82309. */
  82310. length: number;
  82311. /**
  82312. * Stiffness of the spring
  82313. */
  82314. stiffness: number;
  82315. /**
  82316. * Damping of the spring
  82317. */
  82318. damping: number;
  82319. /** this callback will be called when applying the force to the impostors. */
  82320. forceApplicationCallback: () => void;
  82321. }
  82322. }
  82323. declare module BABYLON {
  82324. /**
  82325. * Holds the data for the raycast result
  82326. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82327. */
  82328. export class PhysicsRaycastResult {
  82329. private _hasHit;
  82330. private _hitDistance;
  82331. private _hitNormalWorld;
  82332. private _hitPointWorld;
  82333. private _rayFromWorld;
  82334. private _rayToWorld;
  82335. /**
  82336. * Gets if there was a hit
  82337. */
  82338. readonly hasHit: boolean;
  82339. /**
  82340. * Gets the distance from the hit
  82341. */
  82342. readonly hitDistance: number;
  82343. /**
  82344. * Gets the hit normal/direction in the world
  82345. */
  82346. readonly hitNormalWorld: Vector3;
  82347. /**
  82348. * Gets the hit point in the world
  82349. */
  82350. readonly hitPointWorld: Vector3;
  82351. /**
  82352. * Gets the ray "start point" of the ray in the world
  82353. */
  82354. readonly rayFromWorld: Vector3;
  82355. /**
  82356. * Gets the ray "end point" of the ray in the world
  82357. */
  82358. readonly rayToWorld: Vector3;
  82359. /**
  82360. * Sets the hit data (normal & point in world space)
  82361. * @param hitNormalWorld defines the normal in world space
  82362. * @param hitPointWorld defines the point in world space
  82363. */
  82364. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  82365. /**
  82366. * Sets the distance from the start point to the hit point
  82367. * @param distance
  82368. */
  82369. setHitDistance(distance: number): void;
  82370. /**
  82371. * Calculates the distance manually
  82372. */
  82373. calculateHitDistance(): void;
  82374. /**
  82375. * Resets all the values to default
  82376. * @param from The from point on world space
  82377. * @param to The to point on world space
  82378. */
  82379. reset(from?: Vector3, to?: Vector3): void;
  82380. }
  82381. /**
  82382. * Interface for the size containing width and height
  82383. */
  82384. interface IXYZ {
  82385. /**
  82386. * X
  82387. */
  82388. x: number;
  82389. /**
  82390. * Y
  82391. */
  82392. y: number;
  82393. /**
  82394. * Z
  82395. */
  82396. z: number;
  82397. }
  82398. }
  82399. declare module BABYLON {
  82400. /**
  82401. * Interface used to describe a physics joint
  82402. */
  82403. export interface PhysicsImpostorJoint {
  82404. /** Defines the main impostor to which the joint is linked */
  82405. mainImpostor: PhysicsImpostor;
  82406. /** Defines the impostor that is connected to the main impostor using this joint */
  82407. connectedImpostor: PhysicsImpostor;
  82408. /** Defines the joint itself */
  82409. joint: PhysicsJoint;
  82410. }
  82411. /** @hidden */
  82412. export interface IPhysicsEnginePlugin {
  82413. world: any;
  82414. name: string;
  82415. setGravity(gravity: Vector3): void;
  82416. setTimeStep(timeStep: number): void;
  82417. getTimeStep(): number;
  82418. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  82419. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  82420. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  82421. generatePhysicsBody(impostor: PhysicsImpostor): void;
  82422. removePhysicsBody(impostor: PhysicsImpostor): void;
  82423. generateJoint(joint: PhysicsImpostorJoint): void;
  82424. removeJoint(joint: PhysicsImpostorJoint): void;
  82425. isSupported(): boolean;
  82426. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  82427. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  82428. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  82429. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  82430. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  82431. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  82432. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  82433. getBodyMass(impostor: PhysicsImpostor): number;
  82434. getBodyFriction(impostor: PhysicsImpostor): number;
  82435. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  82436. getBodyRestitution(impostor: PhysicsImpostor): number;
  82437. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  82438. getBodyPressure?(impostor: PhysicsImpostor): number;
  82439. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  82440. getBodyStiffness?(impostor: PhysicsImpostor): number;
  82441. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  82442. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  82443. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  82444. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  82445. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  82446. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  82447. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  82448. sleepBody(impostor: PhysicsImpostor): void;
  82449. wakeUpBody(impostor: PhysicsImpostor): void;
  82450. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  82451. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  82452. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  82453. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  82454. getRadius(impostor: PhysicsImpostor): number;
  82455. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  82456. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  82457. dispose(): void;
  82458. }
  82459. /**
  82460. * Interface used to define a physics engine
  82461. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  82462. */
  82463. export interface IPhysicsEngine {
  82464. /**
  82465. * Gets the gravity vector used by the simulation
  82466. */
  82467. gravity: Vector3;
  82468. /**
  82469. * Sets the gravity vector used by the simulation
  82470. * @param gravity defines the gravity vector to use
  82471. */
  82472. setGravity(gravity: Vector3): void;
  82473. /**
  82474. * Set the time step of the physics engine.
  82475. * Default is 1/60.
  82476. * To slow it down, enter 1/600 for example.
  82477. * To speed it up, 1/30
  82478. * @param newTimeStep the new timestep to apply to this world.
  82479. */
  82480. setTimeStep(newTimeStep: number): void;
  82481. /**
  82482. * Get the time step of the physics engine.
  82483. * @returns the current time step
  82484. */
  82485. getTimeStep(): number;
  82486. /**
  82487. * Release all resources
  82488. */
  82489. dispose(): void;
  82490. /**
  82491. * Gets the name of the current physics plugin
  82492. * @returns the name of the plugin
  82493. */
  82494. getPhysicsPluginName(): string;
  82495. /**
  82496. * Adding a new impostor for the impostor tracking.
  82497. * This will be done by the impostor itself.
  82498. * @param impostor the impostor to add
  82499. */
  82500. addImpostor(impostor: PhysicsImpostor): void;
  82501. /**
  82502. * Remove an impostor from the engine.
  82503. * This impostor and its mesh will not longer be updated by the physics engine.
  82504. * @param impostor the impostor to remove
  82505. */
  82506. removeImpostor(impostor: PhysicsImpostor): void;
  82507. /**
  82508. * Add a joint to the physics engine
  82509. * @param mainImpostor defines the main impostor to which the joint is added.
  82510. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  82511. * @param joint defines the joint that will connect both impostors.
  82512. */
  82513. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  82514. /**
  82515. * Removes a joint from the simulation
  82516. * @param mainImpostor defines the impostor used with the joint
  82517. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  82518. * @param joint defines the joint to remove
  82519. */
  82520. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  82521. /**
  82522. * Gets the current plugin used to run the simulation
  82523. * @returns current plugin
  82524. */
  82525. getPhysicsPlugin(): IPhysicsEnginePlugin;
  82526. /**
  82527. * Gets the list of physic impostors
  82528. * @returns an array of PhysicsImpostor
  82529. */
  82530. getImpostors(): Array<PhysicsImpostor>;
  82531. /**
  82532. * Gets the impostor for a physics enabled object
  82533. * @param object defines the object impersonated by the impostor
  82534. * @returns the PhysicsImpostor or null if not found
  82535. */
  82536. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  82537. /**
  82538. * Gets the impostor for a physics body object
  82539. * @param body defines physics body used by the impostor
  82540. * @returns the PhysicsImpostor or null if not found
  82541. */
  82542. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  82543. /**
  82544. * Does a raycast in the physics world
  82545. * @param from when should the ray start?
  82546. * @param to when should the ray end?
  82547. * @returns PhysicsRaycastResult
  82548. */
  82549. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  82550. /**
  82551. * Called by the scene. No need to call it.
  82552. * @param delta defines the timespam between frames
  82553. */
  82554. _step(delta: number): void;
  82555. }
  82556. }
  82557. declare module BABYLON {
  82558. /**
  82559. * The interface for the physics imposter parameters
  82560. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82561. */
  82562. export interface PhysicsImpostorParameters {
  82563. /**
  82564. * The mass of the physics imposter
  82565. */
  82566. mass: number;
  82567. /**
  82568. * The friction of the physics imposter
  82569. */
  82570. friction?: number;
  82571. /**
  82572. * The coefficient of restitution of the physics imposter
  82573. */
  82574. restitution?: number;
  82575. /**
  82576. * The native options of the physics imposter
  82577. */
  82578. nativeOptions?: any;
  82579. /**
  82580. * Specifies if the parent should be ignored
  82581. */
  82582. ignoreParent?: boolean;
  82583. /**
  82584. * Specifies if bi-directional transformations should be disabled
  82585. */
  82586. disableBidirectionalTransformation?: boolean;
  82587. /**
  82588. * The pressure inside the physics imposter, soft object only
  82589. */
  82590. pressure?: number;
  82591. /**
  82592. * The stiffness the physics imposter, soft object only
  82593. */
  82594. stiffness?: number;
  82595. /**
  82596. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  82597. */
  82598. velocityIterations?: number;
  82599. /**
  82600. * The number of iterations used in maintaining consistent vertex positions, soft object only
  82601. */
  82602. positionIterations?: number;
  82603. /**
  82604. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  82605. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  82606. * Add to fix multiple points
  82607. */
  82608. fixedPoints?: number;
  82609. /**
  82610. * The collision margin around a soft object
  82611. */
  82612. margin?: number;
  82613. /**
  82614. * The collision margin around a soft object
  82615. */
  82616. damping?: number;
  82617. /**
  82618. * The path for a rope based on an extrusion
  82619. */
  82620. path?: any;
  82621. /**
  82622. * The shape of an extrusion used for a rope based on an extrusion
  82623. */
  82624. shape?: any;
  82625. }
  82626. /**
  82627. * Interface for a physics-enabled object
  82628. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82629. */
  82630. export interface IPhysicsEnabledObject {
  82631. /**
  82632. * The position of the physics-enabled object
  82633. */
  82634. position: Vector3;
  82635. /**
  82636. * The rotation of the physics-enabled object
  82637. */
  82638. rotationQuaternion: Nullable<Quaternion>;
  82639. /**
  82640. * The scale of the physics-enabled object
  82641. */
  82642. scaling: Vector3;
  82643. /**
  82644. * The rotation of the physics-enabled object
  82645. */
  82646. rotation?: Vector3;
  82647. /**
  82648. * The parent of the physics-enabled object
  82649. */
  82650. parent?: any;
  82651. /**
  82652. * The bounding info of the physics-enabled object
  82653. * @returns The bounding info of the physics-enabled object
  82654. */
  82655. getBoundingInfo(): BoundingInfo;
  82656. /**
  82657. * Computes the world matrix
  82658. * @param force Specifies if the world matrix should be computed by force
  82659. * @returns A world matrix
  82660. */
  82661. computeWorldMatrix(force: boolean): Matrix;
  82662. /**
  82663. * Gets the world matrix
  82664. * @returns A world matrix
  82665. */
  82666. getWorldMatrix?(): Matrix;
  82667. /**
  82668. * Gets the child meshes
  82669. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  82670. * @returns An array of abstract meshes
  82671. */
  82672. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  82673. /**
  82674. * Gets the vertex data
  82675. * @param kind The type of vertex data
  82676. * @returns A nullable array of numbers, or a float32 array
  82677. */
  82678. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  82679. /**
  82680. * Gets the indices from the mesh
  82681. * @returns A nullable array of index arrays
  82682. */
  82683. getIndices?(): Nullable<IndicesArray>;
  82684. /**
  82685. * Gets the scene from the mesh
  82686. * @returns the indices array or null
  82687. */
  82688. getScene?(): Scene;
  82689. /**
  82690. * Gets the absolute position from the mesh
  82691. * @returns the absolute position
  82692. */
  82693. getAbsolutePosition(): Vector3;
  82694. /**
  82695. * Gets the absolute pivot point from the mesh
  82696. * @returns the absolute pivot point
  82697. */
  82698. getAbsolutePivotPoint(): Vector3;
  82699. /**
  82700. * Rotates the mesh
  82701. * @param axis The axis of rotation
  82702. * @param amount The amount of rotation
  82703. * @param space The space of the rotation
  82704. * @returns The rotation transform node
  82705. */
  82706. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  82707. /**
  82708. * Translates the mesh
  82709. * @param axis The axis of translation
  82710. * @param distance The distance of translation
  82711. * @param space The space of the translation
  82712. * @returns The transform node
  82713. */
  82714. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  82715. /**
  82716. * Sets the absolute position of the mesh
  82717. * @param absolutePosition The absolute position of the mesh
  82718. * @returns The transform node
  82719. */
  82720. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  82721. /**
  82722. * Gets the class name of the mesh
  82723. * @returns The class name
  82724. */
  82725. getClassName(): string;
  82726. }
  82727. /**
  82728. * Represents a physics imposter
  82729. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82730. */
  82731. export class PhysicsImpostor {
  82732. /**
  82733. * The physics-enabled object used as the physics imposter
  82734. */
  82735. object: IPhysicsEnabledObject;
  82736. /**
  82737. * The type of the physics imposter
  82738. */
  82739. type: number;
  82740. private _options;
  82741. private _scene?;
  82742. /**
  82743. * The default object size of the imposter
  82744. */
  82745. static DEFAULT_OBJECT_SIZE: Vector3;
  82746. /**
  82747. * The identity quaternion of the imposter
  82748. */
  82749. static IDENTITY_QUATERNION: Quaternion;
  82750. /** @hidden */
  82751. _pluginData: any;
  82752. private _physicsEngine;
  82753. private _physicsBody;
  82754. private _bodyUpdateRequired;
  82755. private _onBeforePhysicsStepCallbacks;
  82756. private _onAfterPhysicsStepCallbacks;
  82757. /** @hidden */
  82758. _onPhysicsCollideCallbacks: Array<{
  82759. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  82760. otherImpostors: Array<PhysicsImpostor>;
  82761. }>;
  82762. private _deltaPosition;
  82763. private _deltaRotation;
  82764. private _deltaRotationConjugated;
  82765. /** @hidden */
  82766. _isFromLine: boolean;
  82767. private _parent;
  82768. private _isDisposed;
  82769. private static _tmpVecs;
  82770. private static _tmpQuat;
  82771. /**
  82772. * Specifies if the physics imposter is disposed
  82773. */
  82774. readonly isDisposed: boolean;
  82775. /**
  82776. * Gets the mass of the physics imposter
  82777. */
  82778. mass: number;
  82779. /**
  82780. * Gets the coefficient of friction
  82781. */
  82782. /**
  82783. * Sets the coefficient of friction
  82784. */
  82785. friction: number;
  82786. /**
  82787. * Gets the coefficient of restitution
  82788. */
  82789. /**
  82790. * Sets the coefficient of restitution
  82791. */
  82792. restitution: number;
  82793. /**
  82794. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  82795. */
  82796. /**
  82797. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  82798. */
  82799. pressure: number;
  82800. /**
  82801. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  82802. */
  82803. /**
  82804. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  82805. */
  82806. stiffness: number;
  82807. /**
  82808. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  82809. */
  82810. /**
  82811. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  82812. */
  82813. velocityIterations: number;
  82814. /**
  82815. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  82816. */
  82817. /**
  82818. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  82819. */
  82820. positionIterations: number;
  82821. /**
  82822. * The unique id of the physics imposter
  82823. * set by the physics engine when adding this impostor to the array
  82824. */
  82825. uniqueId: number;
  82826. /**
  82827. * @hidden
  82828. */
  82829. soft: boolean;
  82830. /**
  82831. * @hidden
  82832. */
  82833. segments: number;
  82834. private _joints;
  82835. /**
  82836. * Initializes the physics imposter
  82837. * @param object The physics-enabled object used as the physics imposter
  82838. * @param type The type of the physics imposter
  82839. * @param _options The options for the physics imposter
  82840. * @param _scene The Babylon scene
  82841. */
  82842. constructor(
  82843. /**
  82844. * The physics-enabled object used as the physics imposter
  82845. */
  82846. object: IPhysicsEnabledObject,
  82847. /**
  82848. * The type of the physics imposter
  82849. */
  82850. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  82851. /**
  82852. * This function will completly initialize this impostor.
  82853. * It will create a new body - but only if this mesh has no parent.
  82854. * If it has, this impostor will not be used other than to define the impostor
  82855. * of the child mesh.
  82856. * @hidden
  82857. */
  82858. _init(): void;
  82859. private _getPhysicsParent;
  82860. /**
  82861. * Should a new body be generated.
  82862. * @returns boolean specifying if body initialization is required
  82863. */
  82864. isBodyInitRequired(): boolean;
  82865. /**
  82866. * Sets the updated scaling
  82867. * @param updated Specifies if the scaling is updated
  82868. */
  82869. setScalingUpdated(): void;
  82870. /**
  82871. * Force a regeneration of this or the parent's impostor's body.
  82872. * Use under cautious - This will remove all joints already implemented.
  82873. */
  82874. forceUpdate(): void;
  82875. /**
  82876. * Gets the body that holds this impostor. Either its own, or its parent.
  82877. */
  82878. /**
  82879. * Set the physics body. Used mainly by the physics engine/plugin
  82880. */
  82881. physicsBody: any;
  82882. /**
  82883. * Get the parent of the physics imposter
  82884. * @returns Physics imposter or null
  82885. */
  82886. /**
  82887. * Sets the parent of the physics imposter
  82888. */
  82889. parent: Nullable<PhysicsImpostor>;
  82890. /**
  82891. * Resets the update flags
  82892. */
  82893. resetUpdateFlags(): void;
  82894. /**
  82895. * Gets the object extend size
  82896. * @returns the object extend size
  82897. */
  82898. getObjectExtendSize(): Vector3;
  82899. /**
  82900. * Gets the object center
  82901. * @returns The object center
  82902. */
  82903. getObjectCenter(): Vector3;
  82904. /**
  82905. * Get a specific parametes from the options parameter
  82906. * @param paramName The object parameter name
  82907. * @returns The object parameter
  82908. */
  82909. getParam(paramName: string): any;
  82910. /**
  82911. * Sets a specific parameter in the options given to the physics plugin
  82912. * @param paramName The parameter name
  82913. * @param value The value of the parameter
  82914. */
  82915. setParam(paramName: string, value: number): void;
  82916. /**
  82917. * Specifically change the body's mass option. Won't recreate the physics body object
  82918. * @param mass The mass of the physics imposter
  82919. */
  82920. setMass(mass: number): void;
  82921. /**
  82922. * Gets the linear velocity
  82923. * @returns linear velocity or null
  82924. */
  82925. getLinearVelocity(): Nullable<Vector3>;
  82926. /**
  82927. * Sets the linear velocity
  82928. * @param velocity linear velocity or null
  82929. */
  82930. setLinearVelocity(velocity: Nullable<Vector3>): void;
  82931. /**
  82932. * Gets the angular velocity
  82933. * @returns angular velocity or null
  82934. */
  82935. getAngularVelocity(): Nullable<Vector3>;
  82936. /**
  82937. * Sets the angular velocity
  82938. * @param velocity The velocity or null
  82939. */
  82940. setAngularVelocity(velocity: Nullable<Vector3>): void;
  82941. /**
  82942. * Execute a function with the physics plugin native code
  82943. * Provide a function the will have two variables - the world object and the physics body object
  82944. * @param func The function to execute with the physics plugin native code
  82945. */
  82946. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  82947. /**
  82948. * Register a function that will be executed before the physics world is stepping forward
  82949. * @param func The function to execute before the physics world is stepped forward
  82950. */
  82951. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  82952. /**
  82953. * Unregister a function that will be executed before the physics world is stepping forward
  82954. * @param func The function to execute before the physics world is stepped forward
  82955. */
  82956. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  82957. /**
  82958. * Register a function that will be executed after the physics step
  82959. * @param func The function to execute after physics step
  82960. */
  82961. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  82962. /**
  82963. * Unregisters a function that will be executed after the physics step
  82964. * @param func The function to execute after physics step
  82965. */
  82966. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  82967. /**
  82968. * register a function that will be executed when this impostor collides against a different body
  82969. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  82970. * @param func Callback that is executed on collision
  82971. */
  82972. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  82973. /**
  82974. * Unregisters the physics imposter on contact
  82975. * @param collideAgainst The physics object to collide against
  82976. * @param func Callback to execute on collision
  82977. */
  82978. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  82979. private _tmpQuat;
  82980. private _tmpQuat2;
  82981. /**
  82982. * Get the parent rotation
  82983. * @returns The parent rotation
  82984. */
  82985. getParentsRotation(): Quaternion;
  82986. /**
  82987. * this function is executed by the physics engine.
  82988. */
  82989. beforeStep: () => void;
  82990. /**
  82991. * this function is executed by the physics engine
  82992. */
  82993. afterStep: () => void;
  82994. /**
  82995. * Legacy collision detection event support
  82996. */
  82997. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  82998. /**
  82999. * event and body object due to cannon's event-based architecture.
  83000. */
  83001. onCollide: (e: {
  83002. body: any;
  83003. }) => void;
  83004. /**
  83005. * Apply a force
  83006. * @param force The force to apply
  83007. * @param contactPoint The contact point for the force
  83008. * @returns The physics imposter
  83009. */
  83010. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  83011. /**
  83012. * Apply an impulse
  83013. * @param force The impulse force
  83014. * @param contactPoint The contact point for the impulse force
  83015. * @returns The physics imposter
  83016. */
  83017. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  83018. /**
  83019. * A help function to create a joint
  83020. * @param otherImpostor A physics imposter used to create a joint
  83021. * @param jointType The type of joint
  83022. * @param jointData The data for the joint
  83023. * @returns The physics imposter
  83024. */
  83025. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  83026. /**
  83027. * Add a joint to this impostor with a different impostor
  83028. * @param otherImpostor A physics imposter used to add a joint
  83029. * @param joint The joint to add
  83030. * @returns The physics imposter
  83031. */
  83032. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  83033. /**
  83034. * Add an anchor to a cloth impostor
  83035. * @param otherImpostor rigid impostor to anchor to
  83036. * @param width ratio across width from 0 to 1
  83037. * @param height ratio up height from 0 to 1
  83038. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  83039. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  83040. * @returns impostor the soft imposter
  83041. */
  83042. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  83043. /**
  83044. * Add a hook to a rope impostor
  83045. * @param otherImpostor rigid impostor to anchor to
  83046. * @param length ratio across rope from 0 to 1
  83047. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  83048. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  83049. * @returns impostor the rope imposter
  83050. */
  83051. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  83052. /**
  83053. * Will keep this body still, in a sleep mode.
  83054. * @returns the physics imposter
  83055. */
  83056. sleep(): PhysicsImpostor;
  83057. /**
  83058. * Wake the body up.
  83059. * @returns The physics imposter
  83060. */
  83061. wakeUp(): PhysicsImpostor;
  83062. /**
  83063. * Clones the physics imposter
  83064. * @param newObject The physics imposter clones to this physics-enabled object
  83065. * @returns A nullable physics imposter
  83066. */
  83067. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  83068. /**
  83069. * Disposes the physics imposter
  83070. */
  83071. dispose(): void;
  83072. /**
  83073. * Sets the delta position
  83074. * @param position The delta position amount
  83075. */
  83076. setDeltaPosition(position: Vector3): void;
  83077. /**
  83078. * Sets the delta rotation
  83079. * @param rotation The delta rotation amount
  83080. */
  83081. setDeltaRotation(rotation: Quaternion): void;
  83082. /**
  83083. * Gets the box size of the physics imposter and stores the result in the input parameter
  83084. * @param result Stores the box size
  83085. * @returns The physics imposter
  83086. */
  83087. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  83088. /**
  83089. * Gets the radius of the physics imposter
  83090. * @returns Radius of the physics imposter
  83091. */
  83092. getRadius(): number;
  83093. /**
  83094. * Sync a bone with this impostor
  83095. * @param bone The bone to sync to the impostor.
  83096. * @param boneMesh The mesh that the bone is influencing.
  83097. * @param jointPivot The pivot of the joint / bone in local space.
  83098. * @param distToJoint Optional distance from the impostor to the joint.
  83099. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  83100. */
  83101. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  83102. /**
  83103. * Sync impostor to a bone
  83104. * @param bone The bone that the impostor will be synced to.
  83105. * @param boneMesh The mesh that the bone is influencing.
  83106. * @param jointPivot The pivot of the joint / bone in local space.
  83107. * @param distToJoint Optional distance from the impostor to the joint.
  83108. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  83109. * @param boneAxis Optional vector3 axis the bone is aligned with
  83110. */
  83111. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  83112. /**
  83113. * No-Imposter type
  83114. */
  83115. static NoImpostor: number;
  83116. /**
  83117. * Sphere-Imposter type
  83118. */
  83119. static SphereImpostor: number;
  83120. /**
  83121. * Box-Imposter type
  83122. */
  83123. static BoxImpostor: number;
  83124. /**
  83125. * Plane-Imposter type
  83126. */
  83127. static PlaneImpostor: number;
  83128. /**
  83129. * Mesh-imposter type
  83130. */
  83131. static MeshImpostor: number;
  83132. /**
  83133. * Cylinder-Imposter type
  83134. */
  83135. static CylinderImpostor: number;
  83136. /**
  83137. * Particle-Imposter type
  83138. */
  83139. static ParticleImpostor: number;
  83140. /**
  83141. * Heightmap-Imposter type
  83142. */
  83143. static HeightmapImpostor: number;
  83144. /**
  83145. * ConvexHull-Impostor type (Ammo.js plugin only)
  83146. */
  83147. static ConvexHullImpostor: number;
  83148. /**
  83149. * Rope-Imposter type
  83150. */
  83151. static RopeImpostor: number;
  83152. /**
  83153. * Cloth-Imposter type
  83154. */
  83155. static ClothImpostor: number;
  83156. /**
  83157. * Softbody-Imposter type
  83158. */
  83159. static SoftbodyImpostor: number;
  83160. }
  83161. }
  83162. declare module BABYLON {
  83163. /**
  83164. * @hidden
  83165. **/
  83166. export class _CreationDataStorage {
  83167. closePath?: boolean;
  83168. closeArray?: boolean;
  83169. idx: number[];
  83170. dashSize: number;
  83171. gapSize: number;
  83172. path3D: Path3D;
  83173. pathArray: Vector3[][];
  83174. arc: number;
  83175. radius: number;
  83176. cap: number;
  83177. tessellation: number;
  83178. }
  83179. /**
  83180. * @hidden
  83181. **/
  83182. class _InstanceDataStorage {
  83183. visibleInstances: any;
  83184. batchCache: _InstancesBatch;
  83185. instancesBufferSize: number;
  83186. instancesBuffer: Nullable<Buffer>;
  83187. instancesData: Float32Array;
  83188. overridenInstanceCount: number;
  83189. isFrozen: boolean;
  83190. previousBatch: _InstancesBatch;
  83191. hardwareInstancedRendering: boolean;
  83192. sideOrientation: number;
  83193. }
  83194. /**
  83195. * @hidden
  83196. **/
  83197. export class _InstancesBatch {
  83198. mustReturn: boolean;
  83199. visibleInstances: Nullable<InstancedMesh[]>[];
  83200. renderSelf: boolean[];
  83201. hardwareInstancedRendering: boolean[];
  83202. }
  83203. /**
  83204. * Class used to represent renderable models
  83205. */
  83206. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  83207. /**
  83208. * Mesh side orientation : usually the external or front surface
  83209. */
  83210. static readonly FRONTSIDE: number;
  83211. /**
  83212. * Mesh side orientation : usually the internal or back surface
  83213. */
  83214. static readonly BACKSIDE: number;
  83215. /**
  83216. * Mesh side orientation : both internal and external or front and back surfaces
  83217. */
  83218. static readonly DOUBLESIDE: number;
  83219. /**
  83220. * Mesh side orientation : by default, `FRONTSIDE`
  83221. */
  83222. static readonly DEFAULTSIDE: number;
  83223. /**
  83224. * Mesh cap setting : no cap
  83225. */
  83226. static readonly NO_CAP: number;
  83227. /**
  83228. * Mesh cap setting : one cap at the beginning of the mesh
  83229. */
  83230. static readonly CAP_START: number;
  83231. /**
  83232. * Mesh cap setting : one cap at the end of the mesh
  83233. */
  83234. static readonly CAP_END: number;
  83235. /**
  83236. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  83237. */
  83238. static readonly CAP_ALL: number;
  83239. /**
  83240. * Mesh pattern setting : no flip or rotate
  83241. */
  83242. static readonly NO_FLIP: number;
  83243. /**
  83244. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  83245. */
  83246. static readonly FLIP_TILE: number;
  83247. /**
  83248. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  83249. */
  83250. static readonly ROTATE_TILE: number;
  83251. /**
  83252. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  83253. */
  83254. static readonly FLIP_ROW: number;
  83255. /**
  83256. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  83257. */
  83258. static readonly ROTATE_ROW: number;
  83259. /**
  83260. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  83261. */
  83262. static readonly FLIP_N_ROTATE_TILE: number;
  83263. /**
  83264. * Mesh pattern setting : rotate pattern and rotate
  83265. */
  83266. static readonly FLIP_N_ROTATE_ROW: number;
  83267. /**
  83268. * Mesh tile positioning : part tiles same on left/right or top/bottom
  83269. */
  83270. static readonly CENTER: number;
  83271. /**
  83272. * Mesh tile positioning : part tiles on left
  83273. */
  83274. static readonly LEFT: number;
  83275. /**
  83276. * Mesh tile positioning : part tiles on right
  83277. */
  83278. static readonly RIGHT: number;
  83279. /**
  83280. * Mesh tile positioning : part tiles on top
  83281. */
  83282. static readonly TOP: number;
  83283. /**
  83284. * Mesh tile positioning : part tiles on bottom
  83285. */
  83286. static readonly BOTTOM: number;
  83287. /**
  83288. * Gets the default side orientation.
  83289. * @param orientation the orientation to value to attempt to get
  83290. * @returns the default orientation
  83291. * @hidden
  83292. */
  83293. static _GetDefaultSideOrientation(orientation?: number): number;
  83294. private _internalMeshDataInfo;
  83295. /**
  83296. * An event triggered before rendering the mesh
  83297. */
  83298. readonly onBeforeRenderObservable: Observable<Mesh>;
  83299. /**
  83300. * An event triggered before binding the mesh
  83301. */
  83302. readonly onBeforeBindObservable: Observable<Mesh>;
  83303. /**
  83304. * An event triggered after rendering the mesh
  83305. */
  83306. readonly onAfterRenderObservable: Observable<Mesh>;
  83307. /**
  83308. * An event triggered before drawing the mesh
  83309. */
  83310. readonly onBeforeDrawObservable: Observable<Mesh>;
  83311. private _onBeforeDrawObserver;
  83312. /**
  83313. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  83314. */
  83315. onBeforeDraw: () => void;
  83316. /**
  83317. * Gets the delay loading state of the mesh (when delay loading is turned on)
  83318. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  83319. */
  83320. delayLoadState: number;
  83321. /**
  83322. * Gets the list of instances created from this mesh
  83323. * it is not supposed to be modified manually.
  83324. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  83325. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  83326. */
  83327. instances: InstancedMesh[];
  83328. /**
  83329. * Gets the file containing delay loading data for this mesh
  83330. */
  83331. delayLoadingFile: string;
  83332. /** @hidden */
  83333. _binaryInfo: any;
  83334. /**
  83335. * User defined function used to change how LOD level selection is done
  83336. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  83337. */
  83338. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  83339. /**
  83340. * Gets or sets the morph target manager
  83341. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  83342. */
  83343. morphTargetManager: Nullable<MorphTargetManager>;
  83344. /** @hidden */
  83345. _creationDataStorage: Nullable<_CreationDataStorage>;
  83346. /** @hidden */
  83347. _geometry: Nullable<Geometry>;
  83348. /** @hidden */
  83349. _delayInfo: Array<string>;
  83350. /** @hidden */
  83351. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  83352. /** @hidden */
  83353. _instanceDataStorage: _InstanceDataStorage;
  83354. private _effectiveMaterial;
  83355. /** @hidden */
  83356. _shouldGenerateFlatShading: boolean;
  83357. /** @hidden */
  83358. _originalBuilderSideOrientation: number;
  83359. /**
  83360. * Use this property to change the original side orientation defined at construction time
  83361. */
  83362. overrideMaterialSideOrientation: Nullable<number>;
  83363. /**
  83364. * Gets the source mesh (the one used to clone this one from)
  83365. */
  83366. readonly source: Nullable<Mesh>;
  83367. /**
  83368. * Gets or sets a boolean indicating that this mesh does not use index buffer
  83369. */
  83370. isUnIndexed: boolean;
  83371. /**
  83372. * @constructor
  83373. * @param name The value used by scene.getMeshByName() to do a lookup.
  83374. * @param scene The scene to add this mesh to.
  83375. * @param parent The parent of this mesh, if it has one
  83376. * @param source An optional Mesh from which geometry is shared, cloned.
  83377. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  83378. * When false, achieved by calling a clone(), also passing False.
  83379. * This will make creation of children, recursive.
  83380. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  83381. */
  83382. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  83383. /**
  83384. * Gets the class name
  83385. * @returns the string "Mesh".
  83386. */
  83387. getClassName(): string;
  83388. /** @hidden */
  83389. readonly _isMesh: boolean;
  83390. /**
  83391. * Returns a description of this mesh
  83392. * @param fullDetails define if full details about this mesh must be used
  83393. * @returns a descriptive string representing this mesh
  83394. */
  83395. toString(fullDetails?: boolean): string;
  83396. /** @hidden */
  83397. _unBindEffect(): void;
  83398. /**
  83399. * Gets a boolean indicating if this mesh has LOD
  83400. */
  83401. readonly hasLODLevels: boolean;
  83402. /**
  83403. * Gets the list of MeshLODLevel associated with the current mesh
  83404. * @returns an array of MeshLODLevel
  83405. */
  83406. getLODLevels(): MeshLODLevel[];
  83407. private _sortLODLevels;
  83408. /**
  83409. * Add a mesh as LOD level triggered at the given distance.
  83410. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  83411. * @param distance The distance from the center of the object to show this level
  83412. * @param mesh The mesh to be added as LOD level (can be null)
  83413. * @return This mesh (for chaining)
  83414. */
  83415. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  83416. /**
  83417. * Returns the LOD level mesh at the passed distance or null if not found.
  83418. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  83419. * @param distance The distance from the center of the object to show this level
  83420. * @returns a Mesh or `null`
  83421. */
  83422. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  83423. /**
  83424. * Remove a mesh from the LOD array
  83425. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  83426. * @param mesh defines the mesh to be removed
  83427. * @return This mesh (for chaining)
  83428. */
  83429. removeLODLevel(mesh: Mesh): Mesh;
  83430. /**
  83431. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  83432. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  83433. * @param camera defines the camera to use to compute distance
  83434. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  83435. * @return This mesh (for chaining)
  83436. */
  83437. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  83438. /**
  83439. * Gets the mesh internal Geometry object
  83440. */
  83441. readonly geometry: Nullable<Geometry>;
  83442. /**
  83443. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  83444. * @returns the total number of vertices
  83445. */
  83446. getTotalVertices(): number;
  83447. /**
  83448. * Returns the content of an associated vertex buffer
  83449. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  83450. * - VertexBuffer.PositionKind
  83451. * - VertexBuffer.UVKind
  83452. * - VertexBuffer.UV2Kind
  83453. * - VertexBuffer.UV3Kind
  83454. * - VertexBuffer.UV4Kind
  83455. * - VertexBuffer.UV5Kind
  83456. * - VertexBuffer.UV6Kind
  83457. * - VertexBuffer.ColorKind
  83458. * - VertexBuffer.MatricesIndicesKind
  83459. * - VertexBuffer.MatricesIndicesExtraKind
  83460. * - VertexBuffer.MatricesWeightsKind
  83461. * - VertexBuffer.MatricesWeightsExtraKind
  83462. * @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
  83463. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  83464. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  83465. */
  83466. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  83467. /**
  83468. * Returns the mesh VertexBuffer object from the requested `kind`
  83469. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  83470. * - VertexBuffer.PositionKind
  83471. * - VertexBuffer.NormalKind
  83472. * - VertexBuffer.UVKind
  83473. * - VertexBuffer.UV2Kind
  83474. * - VertexBuffer.UV3Kind
  83475. * - VertexBuffer.UV4Kind
  83476. * - VertexBuffer.UV5Kind
  83477. * - VertexBuffer.UV6Kind
  83478. * - VertexBuffer.ColorKind
  83479. * - VertexBuffer.MatricesIndicesKind
  83480. * - VertexBuffer.MatricesIndicesExtraKind
  83481. * - VertexBuffer.MatricesWeightsKind
  83482. * - VertexBuffer.MatricesWeightsExtraKind
  83483. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  83484. */
  83485. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  83486. /**
  83487. * Tests if a specific vertex buffer is associated with this mesh
  83488. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  83489. * - VertexBuffer.PositionKind
  83490. * - VertexBuffer.NormalKind
  83491. * - VertexBuffer.UVKind
  83492. * - VertexBuffer.UV2Kind
  83493. * - VertexBuffer.UV3Kind
  83494. * - VertexBuffer.UV4Kind
  83495. * - VertexBuffer.UV5Kind
  83496. * - VertexBuffer.UV6Kind
  83497. * - VertexBuffer.ColorKind
  83498. * - VertexBuffer.MatricesIndicesKind
  83499. * - VertexBuffer.MatricesIndicesExtraKind
  83500. * - VertexBuffer.MatricesWeightsKind
  83501. * - VertexBuffer.MatricesWeightsExtraKind
  83502. * @returns a boolean
  83503. */
  83504. isVerticesDataPresent(kind: string): boolean;
  83505. /**
  83506. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  83507. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  83508. * - VertexBuffer.PositionKind
  83509. * - VertexBuffer.UVKind
  83510. * - VertexBuffer.UV2Kind
  83511. * - VertexBuffer.UV3Kind
  83512. * - VertexBuffer.UV4Kind
  83513. * - VertexBuffer.UV5Kind
  83514. * - VertexBuffer.UV6Kind
  83515. * - VertexBuffer.ColorKind
  83516. * - VertexBuffer.MatricesIndicesKind
  83517. * - VertexBuffer.MatricesIndicesExtraKind
  83518. * - VertexBuffer.MatricesWeightsKind
  83519. * - VertexBuffer.MatricesWeightsExtraKind
  83520. * @returns a boolean
  83521. */
  83522. isVertexBufferUpdatable(kind: string): boolean;
  83523. /**
  83524. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  83525. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  83526. * - VertexBuffer.PositionKind
  83527. * - VertexBuffer.NormalKind
  83528. * - VertexBuffer.UVKind
  83529. * - VertexBuffer.UV2Kind
  83530. * - VertexBuffer.UV3Kind
  83531. * - VertexBuffer.UV4Kind
  83532. * - VertexBuffer.UV5Kind
  83533. * - VertexBuffer.UV6Kind
  83534. * - VertexBuffer.ColorKind
  83535. * - VertexBuffer.MatricesIndicesKind
  83536. * - VertexBuffer.MatricesIndicesExtraKind
  83537. * - VertexBuffer.MatricesWeightsKind
  83538. * - VertexBuffer.MatricesWeightsExtraKind
  83539. * @returns an array of strings
  83540. */
  83541. getVerticesDataKinds(): string[];
  83542. /**
  83543. * Returns a positive integer : the total number of indices in this mesh geometry.
  83544. * @returns the numner of indices or zero if the mesh has no geometry.
  83545. */
  83546. getTotalIndices(): number;
  83547. /**
  83548. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  83549. * @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.
  83550. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  83551. * @returns the indices array or an empty array if the mesh has no geometry
  83552. */
  83553. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  83554. readonly isBlocked: boolean;
  83555. /**
  83556. * Determine if the current mesh is ready to be rendered
  83557. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  83558. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  83559. * @returns true if all associated assets are ready (material, textures, shaders)
  83560. */
  83561. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  83562. /**
  83563. * 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.
  83564. */
  83565. readonly areNormalsFrozen: boolean;
  83566. /**
  83567. * 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.
  83568. * @returns the current mesh
  83569. */
  83570. freezeNormals(): Mesh;
  83571. /**
  83572. * 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
  83573. * @returns the current mesh
  83574. */
  83575. unfreezeNormals(): Mesh;
  83576. /**
  83577. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  83578. */
  83579. overridenInstanceCount: number;
  83580. /** @hidden */
  83581. _preActivate(): Mesh;
  83582. /** @hidden */
  83583. _preActivateForIntermediateRendering(renderId: number): Mesh;
  83584. /** @hidden */
  83585. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  83586. /**
  83587. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  83588. * This means the mesh underlying bounding box and sphere are recomputed.
  83589. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  83590. * @returns the current mesh
  83591. */
  83592. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  83593. /** @hidden */
  83594. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  83595. /**
  83596. * This function will subdivide the mesh into multiple submeshes
  83597. * @param count defines the expected number of submeshes
  83598. */
  83599. subdivide(count: number): void;
  83600. /**
  83601. * Copy a FloatArray into a specific associated vertex buffer
  83602. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  83603. * - VertexBuffer.PositionKind
  83604. * - VertexBuffer.UVKind
  83605. * - VertexBuffer.UV2Kind
  83606. * - VertexBuffer.UV3Kind
  83607. * - VertexBuffer.UV4Kind
  83608. * - VertexBuffer.UV5Kind
  83609. * - VertexBuffer.UV6Kind
  83610. * - VertexBuffer.ColorKind
  83611. * - VertexBuffer.MatricesIndicesKind
  83612. * - VertexBuffer.MatricesIndicesExtraKind
  83613. * - VertexBuffer.MatricesWeightsKind
  83614. * - VertexBuffer.MatricesWeightsExtraKind
  83615. * @param data defines the data source
  83616. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  83617. * @param stride defines the data stride size (can be null)
  83618. * @returns the current mesh
  83619. */
  83620. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  83621. /**
  83622. * Flags an associated vertex buffer as updatable
  83623. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  83624. * - VertexBuffer.PositionKind
  83625. * - VertexBuffer.UVKind
  83626. * - VertexBuffer.UV2Kind
  83627. * - VertexBuffer.UV3Kind
  83628. * - VertexBuffer.UV4Kind
  83629. * - VertexBuffer.UV5Kind
  83630. * - VertexBuffer.UV6Kind
  83631. * - VertexBuffer.ColorKind
  83632. * - VertexBuffer.MatricesIndicesKind
  83633. * - VertexBuffer.MatricesIndicesExtraKind
  83634. * - VertexBuffer.MatricesWeightsKind
  83635. * - VertexBuffer.MatricesWeightsExtraKind
  83636. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  83637. */
  83638. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  83639. /**
  83640. * Sets the mesh global Vertex Buffer
  83641. * @param buffer defines the buffer to use
  83642. * @returns the current mesh
  83643. */
  83644. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  83645. /**
  83646. * Update a specific associated vertex buffer
  83647. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  83648. * - VertexBuffer.PositionKind
  83649. * - VertexBuffer.UVKind
  83650. * - VertexBuffer.UV2Kind
  83651. * - VertexBuffer.UV3Kind
  83652. * - VertexBuffer.UV4Kind
  83653. * - VertexBuffer.UV5Kind
  83654. * - VertexBuffer.UV6Kind
  83655. * - VertexBuffer.ColorKind
  83656. * - VertexBuffer.MatricesIndicesKind
  83657. * - VertexBuffer.MatricesIndicesExtraKind
  83658. * - VertexBuffer.MatricesWeightsKind
  83659. * - VertexBuffer.MatricesWeightsExtraKind
  83660. * @param data defines the data source
  83661. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  83662. * @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)
  83663. * @returns the current mesh
  83664. */
  83665. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  83666. /**
  83667. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  83668. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  83669. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  83670. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  83671. * @returns the current mesh
  83672. */
  83673. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  83674. /**
  83675. * Creates a un-shared specific occurence of the geometry for the mesh.
  83676. * @returns the current mesh
  83677. */
  83678. makeGeometryUnique(): Mesh;
  83679. /**
  83680. * Set the index buffer of this mesh
  83681. * @param indices defines the source data
  83682. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  83683. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  83684. * @returns the current mesh
  83685. */
  83686. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  83687. /**
  83688. * Update the current index buffer
  83689. * @param indices defines the source data
  83690. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  83691. * @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)
  83692. * @returns the current mesh
  83693. */
  83694. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  83695. /**
  83696. * Invert the geometry to move from a right handed system to a left handed one.
  83697. * @returns the current mesh
  83698. */
  83699. toLeftHanded(): Mesh;
  83700. /** @hidden */
  83701. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  83702. /** @hidden */
  83703. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  83704. /**
  83705. * Registers for this mesh a javascript function called just before the rendering process
  83706. * @param func defines the function to call before rendering this mesh
  83707. * @returns the current mesh
  83708. */
  83709. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  83710. /**
  83711. * Disposes a previously registered javascript function called before the rendering
  83712. * @param func defines the function to remove
  83713. * @returns the current mesh
  83714. */
  83715. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  83716. /**
  83717. * Registers for this mesh a javascript function called just after the rendering is complete
  83718. * @param func defines the function to call after rendering this mesh
  83719. * @returns the current mesh
  83720. */
  83721. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  83722. /**
  83723. * Disposes a previously registered javascript function called after the rendering.
  83724. * @param func defines the function to remove
  83725. * @returns the current mesh
  83726. */
  83727. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  83728. /** @hidden */
  83729. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  83730. /** @hidden */
  83731. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  83732. /** @hidden */
  83733. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  83734. /** @hidden */
  83735. _freeze(): void;
  83736. /** @hidden */
  83737. _unFreeze(): void;
  83738. /**
  83739. * 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
  83740. * @param subMesh defines the subMesh to render
  83741. * @param enableAlphaMode defines if alpha mode can be changed
  83742. * @returns the current mesh
  83743. */
  83744. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  83745. private _onBeforeDraw;
  83746. /**
  83747. * Renormalize the mesh and patch it up if there are no weights
  83748. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  83749. * However in the case of zero weights then we set just a single influence to 1.
  83750. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  83751. */
  83752. cleanMatrixWeights(): void;
  83753. private normalizeSkinFourWeights;
  83754. private normalizeSkinWeightsAndExtra;
  83755. /**
  83756. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  83757. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  83758. * the user know there was an issue with importing the mesh
  83759. * @returns a validation object with skinned, valid and report string
  83760. */
  83761. validateSkinning(): {
  83762. skinned: boolean;
  83763. valid: boolean;
  83764. report: string;
  83765. };
  83766. /** @hidden */
  83767. _checkDelayState(): Mesh;
  83768. private _queueLoad;
  83769. /**
  83770. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  83771. * A mesh is in the frustum if its bounding box intersects the frustum
  83772. * @param frustumPlanes defines the frustum to test
  83773. * @returns true if the mesh is in the frustum planes
  83774. */
  83775. isInFrustum(frustumPlanes: Plane[]): boolean;
  83776. /**
  83777. * Sets the mesh material by the material or multiMaterial `id` property
  83778. * @param id is a string identifying the material or the multiMaterial
  83779. * @returns the current mesh
  83780. */
  83781. setMaterialByID(id: string): Mesh;
  83782. /**
  83783. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  83784. * @returns an array of IAnimatable
  83785. */
  83786. getAnimatables(): IAnimatable[];
  83787. /**
  83788. * Modifies the mesh geometry according to the passed transformation matrix.
  83789. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  83790. * The mesh normals are modified using the same transformation.
  83791. * Note that, under the hood, this method sets a new VertexBuffer each call.
  83792. * @param transform defines the transform matrix to use
  83793. * @see http://doc.babylonjs.com/resources/baking_transformations
  83794. * @returns the current mesh
  83795. */
  83796. bakeTransformIntoVertices(transform: Matrix): Mesh;
  83797. /**
  83798. * Modifies the mesh geometry according to its own current World Matrix.
  83799. * The mesh World Matrix is then reset.
  83800. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  83801. * Note that, under the hood, this method sets a new VertexBuffer each call.
  83802. * @see http://doc.babylonjs.com/resources/baking_transformations
  83803. * @returns the current mesh
  83804. */
  83805. bakeCurrentTransformIntoVertices(): Mesh;
  83806. /** @hidden */
  83807. readonly _positions: Nullable<Vector3[]>;
  83808. /** @hidden */
  83809. _resetPointsArrayCache(): Mesh;
  83810. /** @hidden */
  83811. _generatePointsArray(): boolean;
  83812. /**
  83813. * Returns a new Mesh object generated from the current mesh properties.
  83814. * This method must not get confused with createInstance()
  83815. * @param name is a string, the name given to the new mesh
  83816. * @param newParent can be any Node object (default `null`)
  83817. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  83818. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  83819. * @returns a new mesh
  83820. */
  83821. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  83822. /**
  83823. * Releases resources associated with this mesh.
  83824. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  83825. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  83826. */
  83827. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83828. /**
  83829. * Modifies the mesh geometry according to a displacement map.
  83830. * 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.
  83831. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  83832. * @param url is a string, the URL from the image file is to be downloaded.
  83833. * @param minHeight is the lower limit of the displacement.
  83834. * @param maxHeight is the upper limit of the displacement.
  83835. * @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.
  83836. * @param uvOffset is an optional vector2 used to offset UV.
  83837. * @param uvScale is an optional vector2 used to scale UV.
  83838. * @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.
  83839. * @returns the Mesh.
  83840. */
  83841. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  83842. /**
  83843. * Modifies the mesh geometry according to a displacementMap buffer.
  83844. * 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.
  83845. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  83846. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  83847. * @param heightMapWidth is the width of the buffer image.
  83848. * @param heightMapHeight is the height of the buffer image.
  83849. * @param minHeight is the lower limit of the displacement.
  83850. * @param maxHeight is the upper limit of the displacement.
  83851. * @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.
  83852. * @param uvOffset is an optional vector2 used to offset UV.
  83853. * @param uvScale is an optional vector2 used to scale UV.
  83854. * @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.
  83855. * @returns the Mesh.
  83856. */
  83857. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  83858. /**
  83859. * Modify the mesh to get a flat shading rendering.
  83860. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  83861. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  83862. * @returns current mesh
  83863. */
  83864. convertToFlatShadedMesh(): Mesh;
  83865. /**
  83866. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  83867. * In other words, more vertices, no more indices and a single bigger VBO.
  83868. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  83869. * @returns current mesh
  83870. */
  83871. convertToUnIndexedMesh(): Mesh;
  83872. /**
  83873. * Inverses facet orientations.
  83874. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  83875. * @param flipNormals will also inverts the normals
  83876. * @returns current mesh
  83877. */
  83878. flipFaces(flipNormals?: boolean): Mesh;
  83879. /**
  83880. * Increase the number of facets and hence vertices in a mesh
  83881. * Vertex normals are interpolated from existing vertex normals
  83882. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  83883. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  83884. */
  83885. increaseVertices(numberPerEdge: number): void;
  83886. /**
  83887. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  83888. * This will undo any application of covertToFlatShadedMesh
  83889. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  83890. */
  83891. forceSharedVertices(): void;
  83892. /** @hidden */
  83893. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  83894. /** @hidden */
  83895. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  83896. /**
  83897. * Creates a new InstancedMesh object from the mesh model.
  83898. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  83899. * @param name defines the name of the new instance
  83900. * @returns a new InstancedMesh
  83901. */
  83902. createInstance(name: string): InstancedMesh;
  83903. /**
  83904. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  83905. * After this call, all the mesh instances have the same submeshes than the current mesh.
  83906. * @returns the current mesh
  83907. */
  83908. synchronizeInstances(): Mesh;
  83909. /**
  83910. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  83911. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  83912. * This should be used together with the simplification to avoid disappearing triangles.
  83913. * @param successCallback an optional success callback to be called after the optimization finished.
  83914. * @returns the current mesh
  83915. */
  83916. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  83917. /**
  83918. * Serialize current mesh
  83919. * @param serializationObject defines the object which will receive the serialization data
  83920. */
  83921. serialize(serializationObject: any): void;
  83922. /** @hidden */
  83923. _syncGeometryWithMorphTargetManager(): void;
  83924. /** @hidden */
  83925. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  83926. /**
  83927. * Returns a new Mesh object parsed from the source provided.
  83928. * @param parsedMesh is the source
  83929. * @param scene defines the hosting scene
  83930. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  83931. * @returns a new Mesh
  83932. */
  83933. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  83934. /**
  83935. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  83936. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  83937. * @param name defines the name of the mesh to create
  83938. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  83939. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  83940. * @param closePath creates a seam between the first and the last points of each path of the path array
  83941. * @param offset is taken in account only if the `pathArray` is containing a single path
  83942. * @param scene defines the hosting scene
  83943. * @param updatable defines if the mesh must be flagged as updatable
  83944. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83945. * @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)
  83946. * @returns a new Mesh
  83947. */
  83948. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  83949. /**
  83950. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  83951. * @param name defines the name of the mesh to create
  83952. * @param radius sets the radius size (float) of the polygon (default 0.5)
  83953. * @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
  83954. * @param scene defines the hosting scene
  83955. * @param updatable defines if the mesh must be flagged as updatable
  83956. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83957. * @returns a new Mesh
  83958. */
  83959. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  83960. /**
  83961. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  83962. * @param name defines the name of the mesh to create
  83963. * @param size sets the size (float) of each box side (default 1)
  83964. * @param scene defines the hosting scene
  83965. * @param updatable defines if the mesh must be flagged as updatable
  83966. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83967. * @returns a new Mesh
  83968. */
  83969. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  83970. /**
  83971. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  83972. * @param name defines the name of the mesh to create
  83973. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  83974. * @param diameter sets the diameter size (float) of the sphere (default 1)
  83975. * @param scene defines the hosting scene
  83976. * @param updatable defines if the mesh must be flagged as updatable
  83977. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83978. * @returns a new Mesh
  83979. */
  83980. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  83981. /**
  83982. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  83983. * @param name defines the name of the mesh to create
  83984. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  83985. * @param diameter sets the diameter size (float) of the sphere (default 1)
  83986. * @param scene defines the hosting scene
  83987. * @returns a new Mesh
  83988. */
  83989. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  83990. /**
  83991. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  83992. * @param name defines the name of the mesh to create
  83993. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  83994. * @param diameterTop set the top cap diameter (floats, default 1)
  83995. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  83996. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  83997. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  83998. * @param scene defines the hosting scene
  83999. * @param updatable defines if the mesh must be flagged as updatable
  84000. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  84001. * @returns a new Mesh
  84002. */
  84003. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  84004. /**
  84005. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  84006. * @param name defines the name of the mesh to create
  84007. * @param diameter sets the diameter size (float) of the torus (default 1)
  84008. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  84009. * @param tessellation sets the number of torus sides (postive integer, default 16)
  84010. * @param scene defines the hosting scene
  84011. * @param updatable defines if the mesh must be flagged as updatable
  84012. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  84013. * @returns a new Mesh
  84014. */
  84015. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  84016. /**
  84017. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  84018. * @param name defines the name of the mesh to create
  84019. * @param radius sets the global radius size (float) of the torus knot (default 2)
  84020. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  84021. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  84022. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  84023. * @param p the number of windings on X axis (positive integers, default 2)
  84024. * @param q the number of windings on Y axis (positive integers, default 3)
  84025. * @param scene defines the hosting scene
  84026. * @param updatable defines if the mesh must be flagged as updatable
  84027. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  84028. * @returns a new Mesh
  84029. */
  84030. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  84031. /**
  84032. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  84033. * @param name defines the name of the mesh to create
  84034. * @param points is an array successive Vector3
  84035. * @param scene defines the hosting scene
  84036. * @param updatable defines if the mesh must be flagged as updatable
  84037. * @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).
  84038. * @returns a new Mesh
  84039. */
  84040. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  84041. /**
  84042. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  84043. * @param name defines the name of the mesh to create
  84044. * @param points is an array successive Vector3
  84045. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  84046. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  84047. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  84048. * @param scene defines the hosting scene
  84049. * @param updatable defines if the mesh must be flagged as updatable
  84050. * @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)
  84051. * @returns a new Mesh
  84052. */
  84053. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  84054. /**
  84055. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  84056. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  84057. * 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.
  84058. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84059. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  84060. * Remember you can only change the shape positions, not their number when updating a polygon.
  84061. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  84062. * @param name defines the name of the mesh to create
  84063. * @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
  84064. * @param scene defines the hosting scene
  84065. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  84066. * @param updatable defines if the mesh must be flagged as updatable
  84067. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  84068. * @param earcutInjection can be used to inject your own earcut reference
  84069. * @returns a new Mesh
  84070. */
  84071. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  84072. /**
  84073. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  84074. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  84075. * @param name defines the name of the mesh to create
  84076. * @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
  84077. * @param depth defines the height of extrusion
  84078. * @param scene defines the hosting scene
  84079. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  84080. * @param updatable defines if the mesh must be flagged as updatable
  84081. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  84082. * @param earcutInjection can be used to inject your own earcut reference
  84083. * @returns a new Mesh
  84084. */
  84085. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  84086. /**
  84087. * Creates an extruded shape mesh.
  84088. * 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
  84089. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  84090. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  84091. * @param name defines the name of the mesh to create
  84092. * @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
  84093. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  84094. * @param scale is the value to scale the shape
  84095. * @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
  84096. * @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
  84097. * @param scene defines the hosting scene
  84098. * @param updatable defines if the mesh must be flagged as updatable
  84099. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  84100. * @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)
  84101. * @returns a new Mesh
  84102. */
  84103. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  84104. /**
  84105. * Creates an custom extruded shape mesh.
  84106. * The custom extrusion is a parametric shape.
  84107. * It has no predefined shape. Its final shape will depend on the input parameters.
  84108. * Please consider using the same method from the MeshBuilder class instead
  84109. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  84110. * @param name defines the name of the mesh to create
  84111. * @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
  84112. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  84113. * @param scaleFunction is a custom Javascript function called on each path point
  84114. * @param rotationFunction is a custom Javascript function called on each path point
  84115. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  84116. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  84117. * @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
  84118. * @param scene defines the hosting scene
  84119. * @param updatable defines if the mesh must be flagged as updatable
  84120. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  84121. * @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)
  84122. * @returns a new Mesh
  84123. */
  84124. 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;
  84125. /**
  84126. * Creates lathe mesh.
  84127. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  84128. * Please consider using the same method from the MeshBuilder class instead
  84129. * @param name defines the name of the mesh to create
  84130. * @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
  84131. * @param radius is the radius value of the lathe
  84132. * @param tessellation is the side number of the lathe.
  84133. * @param scene defines the hosting scene
  84134. * @param updatable defines if the mesh must be flagged as updatable
  84135. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  84136. * @returns a new Mesh
  84137. */
  84138. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  84139. /**
  84140. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  84141. * @param name defines the name of the mesh to create
  84142. * @param size sets the size (float) of both sides of the plane at once (default 1)
  84143. * @param scene defines the hosting scene
  84144. * @param updatable defines if the mesh must be flagged as updatable
  84145. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  84146. * @returns a new Mesh
  84147. */
  84148. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  84149. /**
  84150. * Creates a ground mesh.
  84151. * Please consider using the same method from the MeshBuilder class instead
  84152. * @param name defines the name of the mesh to create
  84153. * @param width set the width of the ground
  84154. * @param height set the height of the ground
  84155. * @param subdivisions sets the number of subdivisions per side
  84156. * @param scene defines the hosting scene
  84157. * @param updatable defines if the mesh must be flagged as updatable
  84158. * @returns a new Mesh
  84159. */
  84160. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  84161. /**
  84162. * Creates a tiled ground mesh.
  84163. * Please consider using the same method from the MeshBuilder class instead
  84164. * @param name defines the name of the mesh to create
  84165. * @param xmin set the ground minimum X coordinate
  84166. * @param zmin set the ground minimum Y coordinate
  84167. * @param xmax set the ground maximum X coordinate
  84168. * @param zmax set the ground maximum Z coordinate
  84169. * @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
  84170. * @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
  84171. * @param scene defines the hosting scene
  84172. * @param updatable defines if the mesh must be flagged as updatable
  84173. * @returns a new Mesh
  84174. */
  84175. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  84176. w: number;
  84177. h: number;
  84178. }, precision: {
  84179. w: number;
  84180. h: number;
  84181. }, scene: Scene, updatable?: boolean): Mesh;
  84182. /**
  84183. * Creates a ground mesh from a height map.
  84184. * Please consider using the same method from the MeshBuilder class instead
  84185. * @see http://doc.babylonjs.com/babylon101/height_map
  84186. * @param name defines the name of the mesh to create
  84187. * @param url sets the URL of the height map image resource
  84188. * @param width set the ground width size
  84189. * @param height set the ground height size
  84190. * @param subdivisions sets the number of subdivision per side
  84191. * @param minHeight is the minimum altitude on the ground
  84192. * @param maxHeight is the maximum altitude on the ground
  84193. * @param scene defines the hosting scene
  84194. * @param updatable defines if the mesh must be flagged as updatable
  84195. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  84196. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  84197. * @returns a new Mesh
  84198. */
  84199. 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;
  84200. /**
  84201. * Creates a tube mesh.
  84202. * The tube is a parametric shape.
  84203. * It has no predefined shape. Its final shape will depend on the input parameters.
  84204. * Please consider using the same method from the MeshBuilder class instead
  84205. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  84206. * @param name defines the name of the mesh to create
  84207. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  84208. * @param radius sets the tube radius size
  84209. * @param tessellation is the number of sides on the tubular surface
  84210. * @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
  84211. * @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
  84212. * @param scene defines the hosting scene
  84213. * @param updatable defines if the mesh must be flagged as updatable
  84214. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  84215. * @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)
  84216. * @returns a new Mesh
  84217. */
  84218. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  84219. (i: number, distance: number): number;
  84220. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  84221. /**
  84222. * Creates a polyhedron mesh.
  84223. * Please consider using the same method from the MeshBuilder class instead.
  84224. * * 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
  84225. * * The parameter `size` (positive float, default 1) sets the polygon size
  84226. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  84227. * * 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`
  84228. * * 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
  84229. * * 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)`)
  84230. * * 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
  84231. * * 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
  84232. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84233. * * If you create a double-sided mesh, you can choose what parts of 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
  84234. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  84235. * @param name defines the name of the mesh to create
  84236. * @param options defines the options used to create the mesh
  84237. * @param scene defines the hosting scene
  84238. * @returns a new Mesh
  84239. */
  84240. static CreatePolyhedron(name: string, options: {
  84241. type?: number;
  84242. size?: number;
  84243. sizeX?: number;
  84244. sizeY?: number;
  84245. sizeZ?: number;
  84246. custom?: any;
  84247. faceUV?: Vector4[];
  84248. faceColors?: Color4[];
  84249. updatable?: boolean;
  84250. sideOrientation?: number;
  84251. }, scene: Scene): Mesh;
  84252. /**
  84253. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  84254. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  84255. * * 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`)
  84256. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  84257. * * 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
  84258. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84259. * * If you create a double-sided mesh, you can choose what parts of 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
  84260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  84261. * @param name defines the name of the mesh
  84262. * @param options defines the options used to create the mesh
  84263. * @param scene defines the hosting scene
  84264. * @returns a new Mesh
  84265. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  84266. */
  84267. static CreateIcoSphere(name: string, options: {
  84268. radius?: number;
  84269. flat?: boolean;
  84270. subdivisions?: number;
  84271. sideOrientation?: number;
  84272. updatable?: boolean;
  84273. }, scene: Scene): Mesh;
  84274. /**
  84275. * Creates a decal mesh.
  84276. * Please consider using the same method from the MeshBuilder class instead.
  84277. * A decal is a mesh usually applied as a model onto the surface of another mesh
  84278. * @param name defines the name of the mesh
  84279. * @param sourceMesh defines the mesh receiving the decal
  84280. * @param position sets the position of the decal in world coordinates
  84281. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  84282. * @param size sets the decal scaling
  84283. * @param angle sets the angle to rotate the decal
  84284. * @returns a new Mesh
  84285. */
  84286. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  84287. /**
  84288. * Prepare internal position array for software CPU skinning
  84289. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  84290. */
  84291. setPositionsForCPUSkinning(): Float32Array;
  84292. /**
  84293. * Prepare internal normal array for software CPU skinning
  84294. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  84295. */
  84296. setNormalsForCPUSkinning(): Float32Array;
  84297. /**
  84298. * Updates the vertex buffer by applying transformation from the bones
  84299. * @param skeleton defines the skeleton to apply to current mesh
  84300. * @returns the current mesh
  84301. */
  84302. applySkeleton(skeleton: Skeleton): Mesh;
  84303. /**
  84304. * 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
  84305. * @param meshes defines the list of meshes to scan
  84306. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  84307. */
  84308. static MinMax(meshes: AbstractMesh[]): {
  84309. min: Vector3;
  84310. max: Vector3;
  84311. };
  84312. /**
  84313. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  84314. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  84315. * @returns a vector3
  84316. */
  84317. static Center(meshesOrMinMaxVector: {
  84318. min: Vector3;
  84319. max: Vector3;
  84320. } | AbstractMesh[]): Vector3;
  84321. /**
  84322. * Merge the array of meshes into a single mesh for performance reasons.
  84323. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  84324. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  84325. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  84326. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  84327. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  84328. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  84329. * @returns a new mesh
  84330. */
  84331. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  84332. /** @hidden */
  84333. addInstance(instance: InstancedMesh): void;
  84334. /** @hidden */
  84335. removeInstance(instance: InstancedMesh): void;
  84336. }
  84337. }
  84338. declare module BABYLON {
  84339. /**
  84340. * Base class for the main features of a material in Babylon.js
  84341. */
  84342. export class Material implements IAnimatable {
  84343. /**
  84344. * Returns the triangle fill mode
  84345. */
  84346. static readonly TriangleFillMode: number;
  84347. /**
  84348. * Returns the wireframe mode
  84349. */
  84350. static readonly WireFrameFillMode: number;
  84351. /**
  84352. * Returns the point fill mode
  84353. */
  84354. static readonly PointFillMode: number;
  84355. /**
  84356. * Returns the point list draw mode
  84357. */
  84358. static readonly PointListDrawMode: number;
  84359. /**
  84360. * Returns the line list draw mode
  84361. */
  84362. static readonly LineListDrawMode: number;
  84363. /**
  84364. * Returns the line loop draw mode
  84365. */
  84366. static readonly LineLoopDrawMode: number;
  84367. /**
  84368. * Returns the line strip draw mode
  84369. */
  84370. static readonly LineStripDrawMode: number;
  84371. /**
  84372. * Returns the triangle strip draw mode
  84373. */
  84374. static readonly TriangleStripDrawMode: number;
  84375. /**
  84376. * Returns the triangle fan draw mode
  84377. */
  84378. static readonly TriangleFanDrawMode: number;
  84379. /**
  84380. * Stores the clock-wise side orientation
  84381. */
  84382. static readonly ClockWiseSideOrientation: number;
  84383. /**
  84384. * Stores the counter clock-wise side orientation
  84385. */
  84386. static readonly CounterClockWiseSideOrientation: number;
  84387. /**
  84388. * The dirty texture flag value
  84389. */
  84390. static readonly TextureDirtyFlag: number;
  84391. /**
  84392. * The dirty light flag value
  84393. */
  84394. static readonly LightDirtyFlag: number;
  84395. /**
  84396. * The dirty fresnel flag value
  84397. */
  84398. static readonly FresnelDirtyFlag: number;
  84399. /**
  84400. * The dirty attribute flag value
  84401. */
  84402. static readonly AttributesDirtyFlag: number;
  84403. /**
  84404. * The dirty misc flag value
  84405. */
  84406. static readonly MiscDirtyFlag: number;
  84407. /**
  84408. * The all dirty flag value
  84409. */
  84410. static readonly AllDirtyFlag: number;
  84411. /**
  84412. * The ID of the material
  84413. */
  84414. id: string;
  84415. /**
  84416. * Gets or sets the unique id of the material
  84417. */
  84418. uniqueId: number;
  84419. /**
  84420. * The name of the material
  84421. */
  84422. name: string;
  84423. /**
  84424. * Gets or sets user defined metadata
  84425. */
  84426. metadata: any;
  84427. /**
  84428. * For internal use only. Please do not use.
  84429. */
  84430. reservedDataStore: any;
  84431. /**
  84432. * Specifies if the ready state should be checked on each call
  84433. */
  84434. checkReadyOnEveryCall: boolean;
  84435. /**
  84436. * Specifies if the ready state should be checked once
  84437. */
  84438. checkReadyOnlyOnce: boolean;
  84439. /**
  84440. * The state of the material
  84441. */
  84442. state: string;
  84443. /**
  84444. * The alpha value of the material
  84445. */
  84446. protected _alpha: number;
  84447. /**
  84448. * List of inspectable custom properties (used by the Inspector)
  84449. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84450. */
  84451. inspectableCustomProperties: IInspectable[];
  84452. /**
  84453. * Sets the alpha value of the material
  84454. */
  84455. /**
  84456. * Gets the alpha value of the material
  84457. */
  84458. alpha: number;
  84459. /**
  84460. * Specifies if back face culling is enabled
  84461. */
  84462. protected _backFaceCulling: boolean;
  84463. /**
  84464. * Sets the back-face culling state
  84465. */
  84466. /**
  84467. * Gets the back-face culling state
  84468. */
  84469. backFaceCulling: boolean;
  84470. /**
  84471. * Stores the value for side orientation
  84472. */
  84473. sideOrientation: number;
  84474. /**
  84475. * Callback triggered when the material is compiled
  84476. */
  84477. onCompiled: Nullable<(effect: Effect) => void>;
  84478. /**
  84479. * Callback triggered when an error occurs
  84480. */
  84481. onError: Nullable<(effect: Effect, errors: string) => void>;
  84482. /**
  84483. * Callback triggered to get the render target textures
  84484. */
  84485. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  84486. /**
  84487. * Gets a boolean indicating that current material needs to register RTT
  84488. */
  84489. readonly hasRenderTargetTextures: boolean;
  84490. /**
  84491. * Specifies if the material should be serialized
  84492. */
  84493. doNotSerialize: boolean;
  84494. /**
  84495. * @hidden
  84496. */
  84497. _storeEffectOnSubMeshes: boolean;
  84498. /**
  84499. * Stores the animations for the material
  84500. */
  84501. animations: Nullable<Array<Animation>>;
  84502. /**
  84503. * An event triggered when the material is disposed
  84504. */
  84505. onDisposeObservable: Observable<Material>;
  84506. /**
  84507. * An observer which watches for dispose events
  84508. */
  84509. private _onDisposeObserver;
  84510. private _onUnBindObservable;
  84511. /**
  84512. * Called during a dispose event
  84513. */
  84514. onDispose: () => void;
  84515. private _onBindObservable;
  84516. /**
  84517. * An event triggered when the material is bound
  84518. */
  84519. readonly onBindObservable: Observable<AbstractMesh>;
  84520. /**
  84521. * An observer which watches for bind events
  84522. */
  84523. private _onBindObserver;
  84524. /**
  84525. * Called during a bind event
  84526. */
  84527. onBind: (Mesh: AbstractMesh) => void;
  84528. /**
  84529. * An event triggered when the material is unbound
  84530. */
  84531. readonly onUnBindObservable: Observable<Material>;
  84532. /**
  84533. * Stores the value of the alpha mode
  84534. */
  84535. private _alphaMode;
  84536. /**
  84537. * Sets the value of the alpha mode.
  84538. *
  84539. * | Value | Type | Description |
  84540. * | --- | --- | --- |
  84541. * | 0 | ALPHA_DISABLE | |
  84542. * | 1 | ALPHA_ADD | |
  84543. * | 2 | ALPHA_COMBINE | |
  84544. * | 3 | ALPHA_SUBTRACT | |
  84545. * | 4 | ALPHA_MULTIPLY | |
  84546. * | 5 | ALPHA_MAXIMIZED | |
  84547. * | 6 | ALPHA_ONEONE | |
  84548. * | 7 | ALPHA_PREMULTIPLIED | |
  84549. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  84550. * | 9 | ALPHA_INTERPOLATE | |
  84551. * | 10 | ALPHA_SCREENMODE | |
  84552. *
  84553. */
  84554. /**
  84555. * Gets the value of the alpha mode
  84556. */
  84557. alphaMode: number;
  84558. /**
  84559. * Stores the state of the need depth pre-pass value
  84560. */
  84561. private _needDepthPrePass;
  84562. /**
  84563. * Sets the need depth pre-pass value
  84564. */
  84565. /**
  84566. * Gets the depth pre-pass value
  84567. */
  84568. needDepthPrePass: boolean;
  84569. /**
  84570. * Specifies if depth writing should be disabled
  84571. */
  84572. disableDepthWrite: boolean;
  84573. /**
  84574. * Specifies if depth writing should be forced
  84575. */
  84576. forceDepthWrite: boolean;
  84577. /**
  84578. * Specifies if there should be a separate pass for culling
  84579. */
  84580. separateCullingPass: boolean;
  84581. /**
  84582. * Stores the state specifing if fog should be enabled
  84583. */
  84584. private _fogEnabled;
  84585. /**
  84586. * Sets the state for enabling fog
  84587. */
  84588. /**
  84589. * Gets the value of the fog enabled state
  84590. */
  84591. fogEnabled: boolean;
  84592. /**
  84593. * Stores the size of points
  84594. */
  84595. pointSize: number;
  84596. /**
  84597. * Stores the z offset value
  84598. */
  84599. zOffset: number;
  84600. /**
  84601. * Gets a value specifying if wireframe mode is enabled
  84602. */
  84603. /**
  84604. * Sets the state of wireframe mode
  84605. */
  84606. wireframe: boolean;
  84607. /**
  84608. * Gets the value specifying if point clouds are enabled
  84609. */
  84610. /**
  84611. * Sets the state of point cloud mode
  84612. */
  84613. pointsCloud: boolean;
  84614. /**
  84615. * Gets the material fill mode
  84616. */
  84617. /**
  84618. * Sets the material fill mode
  84619. */
  84620. fillMode: number;
  84621. /**
  84622. * @hidden
  84623. * Stores the effects for the material
  84624. */
  84625. _effect: Nullable<Effect>;
  84626. /**
  84627. * @hidden
  84628. * Specifies if the material was previously ready
  84629. */
  84630. _wasPreviouslyReady: boolean;
  84631. /**
  84632. * Specifies if uniform buffers should be used
  84633. */
  84634. private _useUBO;
  84635. /**
  84636. * Stores a reference to the scene
  84637. */
  84638. private _scene;
  84639. /**
  84640. * Stores the fill mode state
  84641. */
  84642. private _fillMode;
  84643. /**
  84644. * Specifies if the depth write state should be cached
  84645. */
  84646. private _cachedDepthWriteState;
  84647. /**
  84648. * Stores the uniform buffer
  84649. */
  84650. protected _uniformBuffer: UniformBuffer;
  84651. /** @hidden */
  84652. _indexInSceneMaterialArray: number;
  84653. /** @hidden */
  84654. meshMap: Nullable<{
  84655. [id: string]: AbstractMesh | undefined;
  84656. }>;
  84657. /**
  84658. * Creates a material instance
  84659. * @param name defines the name of the material
  84660. * @param scene defines the scene to reference
  84661. * @param doNotAdd specifies if the material should be added to the scene
  84662. */
  84663. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  84664. /**
  84665. * Returns a string representation of the current material
  84666. * @param fullDetails defines a boolean indicating which levels of logging is desired
  84667. * @returns a string with material information
  84668. */
  84669. toString(fullDetails?: boolean): string;
  84670. /**
  84671. * Gets the class name of the material
  84672. * @returns a string with the class name of the material
  84673. */
  84674. getClassName(): string;
  84675. /**
  84676. * Specifies if updates for the material been locked
  84677. */
  84678. readonly isFrozen: boolean;
  84679. /**
  84680. * Locks updates for the material
  84681. */
  84682. freeze(): void;
  84683. /**
  84684. * Unlocks updates for the material
  84685. */
  84686. unfreeze(): void;
  84687. /**
  84688. * Specifies if the material is ready to be used
  84689. * @param mesh defines the mesh to check
  84690. * @param useInstances specifies if instances should be used
  84691. * @returns a boolean indicating if the material is ready to be used
  84692. */
  84693. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  84694. /**
  84695. * Specifies that the submesh is ready to be used
  84696. * @param mesh defines the mesh to check
  84697. * @param subMesh defines which submesh to check
  84698. * @param useInstances specifies that instances should be used
  84699. * @returns a boolean indicating that the submesh is ready or not
  84700. */
  84701. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  84702. /**
  84703. * Returns the material effect
  84704. * @returns the effect associated with the material
  84705. */
  84706. getEffect(): Nullable<Effect>;
  84707. /**
  84708. * Returns the current scene
  84709. * @returns a Scene
  84710. */
  84711. getScene(): Scene;
  84712. /**
  84713. * Specifies if the material will require alpha blending
  84714. * @returns a boolean specifying if alpha blending is needed
  84715. */
  84716. needAlphaBlending(): boolean;
  84717. /**
  84718. * Specifies if the mesh will require alpha blending
  84719. * @param mesh defines the mesh to check
  84720. * @returns a boolean specifying if alpha blending is needed for the mesh
  84721. */
  84722. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  84723. /**
  84724. * Specifies if this material should be rendered in alpha test mode
  84725. * @returns a boolean specifying if an alpha test is needed.
  84726. */
  84727. needAlphaTesting(): boolean;
  84728. /**
  84729. * Gets the texture used for the alpha test
  84730. * @returns the texture to use for alpha testing
  84731. */
  84732. getAlphaTestTexture(): Nullable<BaseTexture>;
  84733. /**
  84734. * Marks the material to indicate that it needs to be re-calculated
  84735. */
  84736. markDirty(): void;
  84737. /** @hidden */
  84738. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  84739. /**
  84740. * Binds the material to the mesh
  84741. * @param world defines the world transformation matrix
  84742. * @param mesh defines the mesh to bind the material to
  84743. */
  84744. bind(world: Matrix, mesh?: Mesh): void;
  84745. /**
  84746. * Binds the submesh to the material
  84747. * @param world defines the world transformation matrix
  84748. * @param mesh defines the mesh containing the submesh
  84749. * @param subMesh defines the submesh to bind the material to
  84750. */
  84751. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  84752. /**
  84753. * Binds the world matrix to the material
  84754. * @param world defines the world transformation matrix
  84755. */
  84756. bindOnlyWorldMatrix(world: Matrix): void;
  84757. /**
  84758. * Binds the scene's uniform buffer to the effect.
  84759. * @param effect defines the effect to bind to the scene uniform buffer
  84760. * @param sceneUbo defines the uniform buffer storing scene data
  84761. */
  84762. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  84763. /**
  84764. * Binds the view matrix to the effect
  84765. * @param effect defines the effect to bind the view matrix to
  84766. */
  84767. bindView(effect: Effect): void;
  84768. /**
  84769. * Binds the view projection matrix to the effect
  84770. * @param effect defines the effect to bind the view projection matrix to
  84771. */
  84772. bindViewProjection(effect: Effect): void;
  84773. /**
  84774. * Specifies if material alpha testing should be turned on for the mesh
  84775. * @param mesh defines the mesh to check
  84776. */
  84777. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  84778. /**
  84779. * Processes to execute after binding the material to a mesh
  84780. * @param mesh defines the rendered mesh
  84781. */
  84782. protected _afterBind(mesh?: Mesh): void;
  84783. /**
  84784. * Unbinds the material from the mesh
  84785. */
  84786. unbind(): void;
  84787. /**
  84788. * Gets the active textures from the material
  84789. * @returns an array of textures
  84790. */
  84791. getActiveTextures(): BaseTexture[];
  84792. /**
  84793. * Specifies if the material uses a texture
  84794. * @param texture defines the texture to check against the material
  84795. * @returns a boolean specifying if the material uses the texture
  84796. */
  84797. hasTexture(texture: BaseTexture): boolean;
  84798. /**
  84799. * Makes a duplicate of the material, and gives it a new name
  84800. * @param name defines the new name for the duplicated material
  84801. * @returns the cloned material
  84802. */
  84803. clone(name: string): Nullable<Material>;
  84804. /**
  84805. * Gets the meshes bound to the material
  84806. * @returns an array of meshes bound to the material
  84807. */
  84808. getBindedMeshes(): AbstractMesh[];
  84809. /**
  84810. * Force shader compilation
  84811. * @param mesh defines the mesh associated with this material
  84812. * @param onCompiled defines a function to execute once the material is compiled
  84813. * @param options defines the options to configure the compilation
  84814. */
  84815. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  84816. clipPlane: boolean;
  84817. }>): void;
  84818. /**
  84819. * Force shader compilation
  84820. * @param mesh defines the mesh that will use this material
  84821. * @param options defines additional options for compiling the shaders
  84822. * @returns a promise that resolves when the compilation completes
  84823. */
  84824. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  84825. clipPlane: boolean;
  84826. }>): Promise<void>;
  84827. private static readonly _AllDirtyCallBack;
  84828. private static readonly _ImageProcessingDirtyCallBack;
  84829. private static readonly _TextureDirtyCallBack;
  84830. private static readonly _FresnelDirtyCallBack;
  84831. private static readonly _MiscDirtyCallBack;
  84832. private static readonly _LightsDirtyCallBack;
  84833. private static readonly _AttributeDirtyCallBack;
  84834. private static _FresnelAndMiscDirtyCallBack;
  84835. private static _TextureAndMiscDirtyCallBack;
  84836. private static readonly _DirtyCallbackArray;
  84837. private static readonly _RunDirtyCallBacks;
  84838. /**
  84839. * Marks a define in the material to indicate that it needs to be re-computed
  84840. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  84841. */
  84842. markAsDirty(flag: number): void;
  84843. /**
  84844. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  84845. * @param func defines a function which checks material defines against the submeshes
  84846. */
  84847. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  84848. /**
  84849. * Indicates that we need to re-calculated for all submeshes
  84850. */
  84851. protected _markAllSubMeshesAsAllDirty(): void;
  84852. /**
  84853. * Indicates that image processing needs to be re-calculated for all submeshes
  84854. */
  84855. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  84856. /**
  84857. * Indicates that textures need to be re-calculated for all submeshes
  84858. */
  84859. protected _markAllSubMeshesAsTexturesDirty(): void;
  84860. /**
  84861. * Indicates that fresnel needs to be re-calculated for all submeshes
  84862. */
  84863. protected _markAllSubMeshesAsFresnelDirty(): void;
  84864. /**
  84865. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  84866. */
  84867. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  84868. /**
  84869. * Indicates that lights need to be re-calculated for all submeshes
  84870. */
  84871. protected _markAllSubMeshesAsLightsDirty(): void;
  84872. /**
  84873. * Indicates that attributes need to be re-calculated for all submeshes
  84874. */
  84875. protected _markAllSubMeshesAsAttributesDirty(): void;
  84876. /**
  84877. * Indicates that misc needs to be re-calculated for all submeshes
  84878. */
  84879. protected _markAllSubMeshesAsMiscDirty(): void;
  84880. /**
  84881. * Indicates that textures and misc need to be re-calculated for all submeshes
  84882. */
  84883. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  84884. /**
  84885. * Disposes the material
  84886. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  84887. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  84888. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  84889. */
  84890. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  84891. /** @hidden */
  84892. private releaseVertexArrayObject;
  84893. /**
  84894. * Serializes this material
  84895. * @returns the serialized material object
  84896. */
  84897. serialize(): any;
  84898. /**
  84899. * Creates a material from parsed material data
  84900. * @param parsedMaterial defines parsed material data
  84901. * @param scene defines the hosting scene
  84902. * @param rootUrl defines the root URL to use to load textures
  84903. * @returns a new material
  84904. */
  84905. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  84906. }
  84907. }
  84908. declare module BABYLON {
  84909. /**
  84910. * Base class for submeshes
  84911. */
  84912. export class BaseSubMesh {
  84913. /** @hidden */
  84914. _materialDefines: Nullable<MaterialDefines>;
  84915. /** @hidden */
  84916. _materialEffect: Nullable<Effect>;
  84917. /**
  84918. * Gets associated effect
  84919. */
  84920. readonly effect: Nullable<Effect>;
  84921. /**
  84922. * Sets associated effect (effect used to render this submesh)
  84923. * @param effect defines the effect to associate with
  84924. * @param defines defines the set of defines used to compile this effect
  84925. */
  84926. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  84927. }
  84928. /**
  84929. * Defines a subdivision inside a mesh
  84930. */
  84931. export class SubMesh extends BaseSubMesh implements ICullable {
  84932. /** the material index to use */
  84933. materialIndex: number;
  84934. /** vertex index start */
  84935. verticesStart: number;
  84936. /** vertices count */
  84937. verticesCount: number;
  84938. /** index start */
  84939. indexStart: number;
  84940. /** indices count */
  84941. indexCount: number;
  84942. /** @hidden */
  84943. _linesIndexCount: number;
  84944. private _mesh;
  84945. private _renderingMesh;
  84946. private _boundingInfo;
  84947. private _linesIndexBuffer;
  84948. /** @hidden */
  84949. _lastColliderWorldVertices: Nullable<Vector3[]>;
  84950. /** @hidden */
  84951. _trianglePlanes: Plane[];
  84952. /** @hidden */
  84953. _lastColliderTransformMatrix: Nullable<Matrix>;
  84954. /** @hidden */
  84955. _renderId: number;
  84956. /** @hidden */
  84957. _alphaIndex: number;
  84958. /** @hidden */
  84959. _distanceToCamera: number;
  84960. /** @hidden */
  84961. _id: number;
  84962. private _currentMaterial;
  84963. /**
  84964. * Add a new submesh to a mesh
  84965. * @param materialIndex defines the material index to use
  84966. * @param verticesStart defines vertex index start
  84967. * @param verticesCount defines vertices count
  84968. * @param indexStart defines index start
  84969. * @param indexCount defines indices count
  84970. * @param mesh defines the parent mesh
  84971. * @param renderingMesh defines an optional rendering mesh
  84972. * @param createBoundingBox defines if bounding box should be created for this submesh
  84973. * @returns the new submesh
  84974. */
  84975. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  84976. /**
  84977. * Creates a new submesh
  84978. * @param materialIndex defines the material index to use
  84979. * @param verticesStart defines vertex index start
  84980. * @param verticesCount defines vertices count
  84981. * @param indexStart defines index start
  84982. * @param indexCount defines indices count
  84983. * @param mesh defines the parent mesh
  84984. * @param renderingMesh defines an optional rendering mesh
  84985. * @param createBoundingBox defines if bounding box should be created for this submesh
  84986. */
  84987. constructor(
  84988. /** the material index to use */
  84989. materialIndex: number,
  84990. /** vertex index start */
  84991. verticesStart: number,
  84992. /** vertices count */
  84993. verticesCount: number,
  84994. /** index start */
  84995. indexStart: number,
  84996. /** indices count */
  84997. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  84998. /**
  84999. * Returns true if this submesh covers the entire parent mesh
  85000. * @ignorenaming
  85001. */
  85002. readonly IsGlobal: boolean;
  85003. /**
  85004. * Returns the submesh BoudingInfo object
  85005. * @returns current bounding info (or mesh's one if the submesh is global)
  85006. */
  85007. getBoundingInfo(): BoundingInfo;
  85008. /**
  85009. * Sets the submesh BoundingInfo
  85010. * @param boundingInfo defines the new bounding info to use
  85011. * @returns the SubMesh
  85012. */
  85013. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  85014. /**
  85015. * Returns the mesh of the current submesh
  85016. * @return the parent mesh
  85017. */
  85018. getMesh(): AbstractMesh;
  85019. /**
  85020. * Returns the rendering mesh of the submesh
  85021. * @returns the rendering mesh (could be different from parent mesh)
  85022. */
  85023. getRenderingMesh(): Mesh;
  85024. /**
  85025. * Returns the submesh material
  85026. * @returns null or the current material
  85027. */
  85028. getMaterial(): Nullable<Material>;
  85029. /**
  85030. * Sets a new updated BoundingInfo object to the submesh
  85031. * @param data defines an optional position array to use to determine the bounding info
  85032. * @returns the SubMesh
  85033. */
  85034. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  85035. /** @hidden */
  85036. _checkCollision(collider: Collider): boolean;
  85037. /**
  85038. * Updates the submesh BoundingInfo
  85039. * @param world defines the world matrix to use to update the bounding info
  85040. * @returns the submesh
  85041. */
  85042. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  85043. /**
  85044. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  85045. * @param frustumPlanes defines the frustum planes
  85046. * @returns true if the submesh is intersecting with the frustum
  85047. */
  85048. isInFrustum(frustumPlanes: Plane[]): boolean;
  85049. /**
  85050. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  85051. * @param frustumPlanes defines the frustum planes
  85052. * @returns true if the submesh is inside the frustum
  85053. */
  85054. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  85055. /**
  85056. * Renders the submesh
  85057. * @param enableAlphaMode defines if alpha needs to be used
  85058. * @returns the submesh
  85059. */
  85060. render(enableAlphaMode: boolean): SubMesh;
  85061. /**
  85062. * @hidden
  85063. */
  85064. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  85065. /**
  85066. * Checks if the submesh intersects with a ray
  85067. * @param ray defines the ray to test
  85068. * @returns true is the passed ray intersects the submesh bounding box
  85069. */
  85070. canIntersects(ray: Ray): boolean;
  85071. /**
  85072. * Intersects current submesh with a ray
  85073. * @param ray defines the ray to test
  85074. * @param positions defines mesh's positions array
  85075. * @param indices defines mesh's indices array
  85076. * @param fastCheck defines if only bounding info should be used
  85077. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  85078. * @returns intersection info or null if no intersection
  85079. */
  85080. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  85081. /** @hidden */
  85082. private _intersectLines;
  85083. /** @hidden */
  85084. private _intersectUnIndexedLines;
  85085. /** @hidden */
  85086. private _intersectTriangles;
  85087. /** @hidden */
  85088. private _intersectUnIndexedTriangles;
  85089. /** @hidden */
  85090. _rebuild(): void;
  85091. /**
  85092. * Creates a new submesh from the passed mesh
  85093. * @param newMesh defines the new hosting mesh
  85094. * @param newRenderingMesh defines an optional rendering mesh
  85095. * @returns the new submesh
  85096. */
  85097. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  85098. /**
  85099. * Release associated resources
  85100. */
  85101. dispose(): void;
  85102. /**
  85103. * Gets the class name
  85104. * @returns the string "SubMesh".
  85105. */
  85106. getClassName(): string;
  85107. /**
  85108. * Creates a new submesh from indices data
  85109. * @param materialIndex the index of the main mesh material
  85110. * @param startIndex the index where to start the copy in the mesh indices array
  85111. * @param indexCount the number of indices to copy then from the startIndex
  85112. * @param mesh the main mesh to create the submesh from
  85113. * @param renderingMesh the optional rendering mesh
  85114. * @returns a new submesh
  85115. */
  85116. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  85117. }
  85118. }
  85119. declare module BABYLON {
  85120. /**
  85121. * Class used to store geometry data (vertex buffers + index buffer)
  85122. */
  85123. export class Geometry implements IGetSetVerticesData {
  85124. /**
  85125. * Gets or sets the ID of the geometry
  85126. */
  85127. id: string;
  85128. /**
  85129. * Gets or sets the unique ID of the geometry
  85130. */
  85131. uniqueId: number;
  85132. /**
  85133. * Gets the delay loading state of the geometry (none by default which means not delayed)
  85134. */
  85135. delayLoadState: number;
  85136. /**
  85137. * Gets the file containing the data to load when running in delay load state
  85138. */
  85139. delayLoadingFile: Nullable<string>;
  85140. /**
  85141. * Callback called when the geometry is updated
  85142. */
  85143. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  85144. private _scene;
  85145. private _engine;
  85146. private _meshes;
  85147. private _totalVertices;
  85148. /** @hidden */
  85149. _indices: IndicesArray;
  85150. /** @hidden */
  85151. _vertexBuffers: {
  85152. [key: string]: VertexBuffer;
  85153. };
  85154. private _isDisposed;
  85155. private _extend;
  85156. private _boundingBias;
  85157. /** @hidden */
  85158. _delayInfo: Array<string>;
  85159. private _indexBuffer;
  85160. private _indexBufferIsUpdatable;
  85161. /** @hidden */
  85162. _boundingInfo: Nullable<BoundingInfo>;
  85163. /** @hidden */
  85164. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  85165. /** @hidden */
  85166. _softwareSkinningFrameId: number;
  85167. private _vertexArrayObjects;
  85168. private _updatable;
  85169. /** @hidden */
  85170. _positions: Nullable<Vector3[]>;
  85171. /**
  85172. * 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
  85173. */
  85174. /**
  85175. * 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
  85176. */
  85177. boundingBias: Vector2;
  85178. /**
  85179. * Static function used to attach a new empty geometry to a mesh
  85180. * @param mesh defines the mesh to attach the geometry to
  85181. * @returns the new Geometry
  85182. */
  85183. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  85184. /**
  85185. * Creates a new geometry
  85186. * @param id defines the unique ID
  85187. * @param scene defines the hosting scene
  85188. * @param vertexData defines the VertexData used to get geometry data
  85189. * @param updatable defines if geometry must be updatable (false by default)
  85190. * @param mesh defines the mesh that will be associated with the geometry
  85191. */
  85192. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  85193. /**
  85194. * Gets the current extend of the geometry
  85195. */
  85196. readonly extend: {
  85197. minimum: Vector3;
  85198. maximum: Vector3;
  85199. };
  85200. /**
  85201. * Gets the hosting scene
  85202. * @returns the hosting Scene
  85203. */
  85204. getScene(): Scene;
  85205. /**
  85206. * Gets the hosting engine
  85207. * @returns the hosting Engine
  85208. */
  85209. getEngine(): Engine;
  85210. /**
  85211. * Defines if the geometry is ready to use
  85212. * @returns true if the geometry is ready to be used
  85213. */
  85214. isReady(): boolean;
  85215. /**
  85216. * Gets a value indicating that the geometry should not be serialized
  85217. */
  85218. readonly doNotSerialize: boolean;
  85219. /** @hidden */
  85220. _rebuild(): void;
  85221. /**
  85222. * Affects all geometry data in one call
  85223. * @param vertexData defines the geometry data
  85224. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  85225. */
  85226. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  85227. /**
  85228. * Set specific vertex data
  85229. * @param kind defines the data kind (Position, normal, etc...)
  85230. * @param data defines the vertex data to use
  85231. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85232. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85233. */
  85234. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  85235. /**
  85236. * Removes a specific vertex data
  85237. * @param kind defines the data kind (Position, normal, etc...)
  85238. */
  85239. removeVerticesData(kind: string): void;
  85240. /**
  85241. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  85242. * @param buffer defines the vertex buffer to use
  85243. * @param totalVertices defines the total number of vertices for position kind (could be null)
  85244. */
  85245. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  85246. /**
  85247. * Update a specific vertex buffer
  85248. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  85249. * It will do nothing if the buffer is not updatable
  85250. * @param kind defines the data kind (Position, normal, etc...)
  85251. * @param data defines the data to use
  85252. * @param offset defines the offset in the target buffer where to store the data
  85253. * @param useBytes set to true if the offset is in bytes
  85254. */
  85255. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  85256. /**
  85257. * Update a specific vertex buffer
  85258. * This function will create a new buffer if the current one is not updatable
  85259. * @param kind defines the data kind (Position, normal, etc...)
  85260. * @param data defines the data to use
  85261. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  85262. */
  85263. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  85264. private _updateBoundingInfo;
  85265. /** @hidden */
  85266. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  85267. /**
  85268. * Gets total number of vertices
  85269. * @returns the total number of vertices
  85270. */
  85271. getTotalVertices(): number;
  85272. /**
  85273. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85274. * @param kind defines the data kind (Position, normal, etc...)
  85275. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85276. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85277. * @returns a float array containing vertex data
  85278. */
  85279. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85280. /**
  85281. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  85282. * @param kind defines the data kind (Position, normal, etc...)
  85283. * @returns true if the vertex buffer with the specified kind is updatable
  85284. */
  85285. isVertexBufferUpdatable(kind: string): boolean;
  85286. /**
  85287. * Gets a specific vertex buffer
  85288. * @param kind defines the data kind (Position, normal, etc...)
  85289. * @returns a VertexBuffer
  85290. */
  85291. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  85292. /**
  85293. * Returns all vertex buffers
  85294. * @return an object holding all vertex buffers indexed by kind
  85295. */
  85296. getVertexBuffers(): Nullable<{
  85297. [key: string]: VertexBuffer;
  85298. }>;
  85299. /**
  85300. * Gets a boolean indicating if specific vertex buffer is present
  85301. * @param kind defines the data kind (Position, normal, etc...)
  85302. * @returns true if data is present
  85303. */
  85304. isVerticesDataPresent(kind: string): boolean;
  85305. /**
  85306. * Gets a list of all attached data kinds (Position, normal, etc...)
  85307. * @returns a list of string containing all kinds
  85308. */
  85309. getVerticesDataKinds(): string[];
  85310. /**
  85311. * Update index buffer
  85312. * @param indices defines the indices to store in the index buffer
  85313. * @param offset defines the offset in the target buffer where to store the data
  85314. * @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)
  85315. */
  85316. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  85317. /**
  85318. * Creates a new index buffer
  85319. * @param indices defines the indices to store in the index buffer
  85320. * @param totalVertices defines the total number of vertices (could be null)
  85321. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85322. */
  85323. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  85324. /**
  85325. * Return the total number of indices
  85326. * @returns the total number of indices
  85327. */
  85328. getTotalIndices(): number;
  85329. /**
  85330. * Gets the index buffer array
  85331. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85332. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85333. * @returns the index buffer array
  85334. */
  85335. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  85336. /**
  85337. * Gets the index buffer
  85338. * @return the index buffer
  85339. */
  85340. getIndexBuffer(): Nullable<DataBuffer>;
  85341. /** @hidden */
  85342. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  85343. /**
  85344. * Release the associated resources for a specific mesh
  85345. * @param mesh defines the source mesh
  85346. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  85347. */
  85348. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  85349. /**
  85350. * Apply current geometry to a given mesh
  85351. * @param mesh defines the mesh to apply geometry to
  85352. */
  85353. applyToMesh(mesh: Mesh): void;
  85354. private _updateExtend;
  85355. private _applyToMesh;
  85356. private notifyUpdate;
  85357. /**
  85358. * Load the geometry if it was flagged as delay loaded
  85359. * @param scene defines the hosting scene
  85360. * @param onLoaded defines a callback called when the geometry is loaded
  85361. */
  85362. load(scene: Scene, onLoaded?: () => void): void;
  85363. private _queueLoad;
  85364. /**
  85365. * Invert the geometry to move from a right handed system to a left handed one.
  85366. */
  85367. toLeftHanded(): void;
  85368. /** @hidden */
  85369. _resetPointsArrayCache(): void;
  85370. /** @hidden */
  85371. _generatePointsArray(): boolean;
  85372. /**
  85373. * Gets a value indicating if the geometry is disposed
  85374. * @returns true if the geometry was disposed
  85375. */
  85376. isDisposed(): boolean;
  85377. private _disposeVertexArrayObjects;
  85378. /**
  85379. * Free all associated resources
  85380. */
  85381. dispose(): void;
  85382. /**
  85383. * Clone the current geometry into a new geometry
  85384. * @param id defines the unique ID of the new geometry
  85385. * @returns a new geometry object
  85386. */
  85387. copy(id: string): Geometry;
  85388. /**
  85389. * Serialize the current geometry info (and not the vertices data) into a JSON object
  85390. * @return a JSON representation of the current geometry data (without the vertices data)
  85391. */
  85392. serialize(): any;
  85393. private toNumberArray;
  85394. /**
  85395. * Serialize all vertices data into a JSON oject
  85396. * @returns a JSON representation of the current geometry data
  85397. */
  85398. serializeVerticeData(): any;
  85399. /**
  85400. * Extracts a clone of a mesh geometry
  85401. * @param mesh defines the source mesh
  85402. * @param id defines the unique ID of the new geometry object
  85403. * @returns the new geometry object
  85404. */
  85405. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  85406. /**
  85407. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  85408. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  85409. * Be aware Math.random() could cause collisions, but:
  85410. * "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"
  85411. * @returns a string containing a new GUID
  85412. */
  85413. static RandomId(): string;
  85414. /** @hidden */
  85415. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  85416. private static _CleanMatricesWeights;
  85417. /**
  85418. * Create a new geometry from persisted data (Using .babylon file format)
  85419. * @param parsedVertexData defines the persisted data
  85420. * @param scene defines the hosting scene
  85421. * @param rootUrl defines the root url to use to load assets (like delayed data)
  85422. * @returns the new geometry object
  85423. */
  85424. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  85425. }
  85426. }
  85427. declare module BABYLON {
  85428. /**
  85429. * Define an interface for all classes that will get and set the data on vertices
  85430. */
  85431. export interface IGetSetVerticesData {
  85432. /**
  85433. * Gets a boolean indicating if specific vertex data is present
  85434. * @param kind defines the vertex data kind to use
  85435. * @returns true is data kind is present
  85436. */
  85437. isVerticesDataPresent(kind: string): boolean;
  85438. /**
  85439. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85440. * @param kind defines the data kind (Position, normal, etc...)
  85441. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85442. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85443. * @returns a float array containing vertex data
  85444. */
  85445. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85446. /**
  85447. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  85448. * @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.
  85449. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85450. * @returns the indices array or an empty array if the mesh has no geometry
  85451. */
  85452. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  85453. /**
  85454. * Set specific vertex data
  85455. * @param kind defines the data kind (Position, normal, etc...)
  85456. * @param data defines the vertex data to use
  85457. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85458. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85459. */
  85460. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  85461. /**
  85462. * Update a specific associated vertex buffer
  85463. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  85464. * - VertexBuffer.PositionKind
  85465. * - VertexBuffer.UVKind
  85466. * - VertexBuffer.UV2Kind
  85467. * - VertexBuffer.UV3Kind
  85468. * - VertexBuffer.UV4Kind
  85469. * - VertexBuffer.UV5Kind
  85470. * - VertexBuffer.UV6Kind
  85471. * - VertexBuffer.ColorKind
  85472. * - VertexBuffer.MatricesIndicesKind
  85473. * - VertexBuffer.MatricesIndicesExtraKind
  85474. * - VertexBuffer.MatricesWeightsKind
  85475. * - VertexBuffer.MatricesWeightsExtraKind
  85476. * @param data defines the data source
  85477. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  85478. * @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)
  85479. */
  85480. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  85481. /**
  85482. * Creates a new index buffer
  85483. * @param indices defines the indices to store in the index buffer
  85484. * @param totalVertices defines the total number of vertices (could be null)
  85485. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85486. */
  85487. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  85488. }
  85489. /**
  85490. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  85491. */
  85492. export class VertexData {
  85493. /**
  85494. * Mesh side orientation : usually the external or front surface
  85495. */
  85496. static readonly FRONTSIDE: number;
  85497. /**
  85498. * Mesh side orientation : usually the internal or back surface
  85499. */
  85500. static readonly BACKSIDE: number;
  85501. /**
  85502. * Mesh side orientation : both internal and external or front and back surfaces
  85503. */
  85504. static readonly DOUBLESIDE: number;
  85505. /**
  85506. * Mesh side orientation : by default, `FRONTSIDE`
  85507. */
  85508. static readonly DEFAULTSIDE: number;
  85509. /**
  85510. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  85511. */
  85512. positions: Nullable<FloatArray>;
  85513. /**
  85514. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  85515. */
  85516. normals: Nullable<FloatArray>;
  85517. /**
  85518. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  85519. */
  85520. tangents: Nullable<FloatArray>;
  85521. /**
  85522. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85523. */
  85524. uvs: Nullable<FloatArray>;
  85525. /**
  85526. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85527. */
  85528. uvs2: Nullable<FloatArray>;
  85529. /**
  85530. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85531. */
  85532. uvs3: Nullable<FloatArray>;
  85533. /**
  85534. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85535. */
  85536. uvs4: Nullable<FloatArray>;
  85537. /**
  85538. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85539. */
  85540. uvs5: Nullable<FloatArray>;
  85541. /**
  85542. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85543. */
  85544. uvs6: Nullable<FloatArray>;
  85545. /**
  85546. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  85547. */
  85548. colors: Nullable<FloatArray>;
  85549. /**
  85550. * 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).
  85551. */
  85552. matricesIndices: Nullable<FloatArray>;
  85553. /**
  85554. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  85555. */
  85556. matricesWeights: Nullable<FloatArray>;
  85557. /**
  85558. * An array extending the number of possible indices
  85559. */
  85560. matricesIndicesExtra: Nullable<FloatArray>;
  85561. /**
  85562. * An array extending the number of possible weights when the number of indices is extended
  85563. */
  85564. matricesWeightsExtra: Nullable<FloatArray>;
  85565. /**
  85566. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  85567. */
  85568. indices: Nullable<IndicesArray>;
  85569. /**
  85570. * Uses the passed data array to set the set the values for the specified kind of data
  85571. * @param data a linear array of floating numbers
  85572. * @param kind the type of data that is being set, eg positions, colors etc
  85573. */
  85574. set(data: FloatArray, kind: string): void;
  85575. /**
  85576. * Associates the vertexData to the passed Mesh.
  85577. * Sets it as updatable or not (default `false`)
  85578. * @param mesh the mesh the vertexData is applied to
  85579. * @param updatable when used and having the value true allows new data to update the vertexData
  85580. * @returns the VertexData
  85581. */
  85582. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  85583. /**
  85584. * Associates the vertexData to the passed Geometry.
  85585. * Sets it as updatable or not (default `false`)
  85586. * @param geometry the geometry the vertexData is applied to
  85587. * @param updatable when used and having the value true allows new data to update the vertexData
  85588. * @returns VertexData
  85589. */
  85590. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  85591. /**
  85592. * Updates the associated mesh
  85593. * @param mesh the mesh to be updated
  85594. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  85595. * @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
  85596. * @returns VertexData
  85597. */
  85598. updateMesh(mesh: Mesh): VertexData;
  85599. /**
  85600. * Updates the associated geometry
  85601. * @param geometry the geometry to be updated
  85602. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  85603. * @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
  85604. * @returns VertexData.
  85605. */
  85606. updateGeometry(geometry: Geometry): VertexData;
  85607. private _applyTo;
  85608. private _update;
  85609. /**
  85610. * Transforms each position and each normal of the vertexData according to the passed Matrix
  85611. * @param matrix the transforming matrix
  85612. * @returns the VertexData
  85613. */
  85614. transform(matrix: Matrix): VertexData;
  85615. /**
  85616. * Merges the passed VertexData into the current one
  85617. * @param other the VertexData to be merged into the current one
  85618. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  85619. * @returns the modified VertexData
  85620. */
  85621. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  85622. private _mergeElement;
  85623. private _validate;
  85624. /**
  85625. * Serializes the VertexData
  85626. * @returns a serialized object
  85627. */
  85628. serialize(): any;
  85629. /**
  85630. * Extracts the vertexData from a mesh
  85631. * @param mesh the mesh from which to extract the VertexData
  85632. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  85633. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  85634. * @returns the object VertexData associated to the passed mesh
  85635. */
  85636. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  85637. /**
  85638. * Extracts the vertexData from the geometry
  85639. * @param geometry the geometry from which to extract the VertexData
  85640. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  85641. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  85642. * @returns the object VertexData associated to the passed mesh
  85643. */
  85644. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  85645. private static _ExtractFrom;
  85646. /**
  85647. * Creates the VertexData for a Ribbon
  85648. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  85649. * * pathArray array of paths, each of which an array of successive Vector3
  85650. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  85651. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  85652. * * 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
  85653. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85654. * * 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)
  85655. * * 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)
  85656. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  85657. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  85658. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  85659. * @returns the VertexData of the ribbon
  85660. */
  85661. static CreateRibbon(options: {
  85662. pathArray: Vector3[][];
  85663. closeArray?: boolean;
  85664. closePath?: boolean;
  85665. offset?: number;
  85666. sideOrientation?: number;
  85667. frontUVs?: Vector4;
  85668. backUVs?: Vector4;
  85669. invertUV?: boolean;
  85670. uvs?: Vector2[];
  85671. colors?: Color4[];
  85672. }): VertexData;
  85673. /**
  85674. * Creates the VertexData for a box
  85675. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85676. * * size sets the width, height and depth of the box to the value of size, optional default 1
  85677. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  85678. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  85679. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  85680. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  85681. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  85682. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85683. * * 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)
  85684. * * 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)
  85685. * @returns the VertexData of the box
  85686. */
  85687. static CreateBox(options: {
  85688. size?: number;
  85689. width?: number;
  85690. height?: number;
  85691. depth?: number;
  85692. faceUV?: Vector4[];
  85693. faceColors?: Color4[];
  85694. sideOrientation?: number;
  85695. frontUVs?: Vector4;
  85696. backUVs?: Vector4;
  85697. }): VertexData;
  85698. /**
  85699. * Creates the VertexData for a tiled box
  85700. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85701. * * faceTiles sets the pattern, tile size and number of tiles for a face
  85702. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  85703. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  85704. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85705. * @returns the VertexData of the box
  85706. */
  85707. static CreateTiledBox(options: {
  85708. pattern?: number;
  85709. width?: number;
  85710. height?: number;
  85711. depth?: number;
  85712. tileSize?: number;
  85713. tileWidth?: number;
  85714. tileHeight?: number;
  85715. alignHorizontal?: number;
  85716. alignVertical?: number;
  85717. faceUV?: Vector4[];
  85718. faceColors?: Color4[];
  85719. sideOrientation?: number;
  85720. }): VertexData;
  85721. /**
  85722. * Creates the VertexData for a tiled plane
  85723. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85724. * * pattern a limited pattern arrangement depending on the number
  85725. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  85726. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  85727. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  85728. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85729. * * 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)
  85730. * * 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)
  85731. * @returns the VertexData of the tiled plane
  85732. */
  85733. static CreateTiledPlane(options: {
  85734. pattern?: number;
  85735. tileSize?: number;
  85736. tileWidth?: number;
  85737. tileHeight?: number;
  85738. size?: number;
  85739. width?: number;
  85740. height?: number;
  85741. alignHorizontal?: number;
  85742. alignVertical?: number;
  85743. sideOrientation?: number;
  85744. frontUVs?: Vector4;
  85745. backUVs?: Vector4;
  85746. }): VertexData;
  85747. /**
  85748. * Creates the VertexData for an ellipsoid, defaults to a sphere
  85749. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85750. * * segments sets the number of horizontal strips optional, default 32
  85751. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  85752. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  85753. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  85754. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  85755. * * 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
  85756. * * 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
  85757. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85758. * * 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)
  85759. * * 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)
  85760. * @returns the VertexData of the ellipsoid
  85761. */
  85762. static CreateSphere(options: {
  85763. segments?: number;
  85764. diameter?: number;
  85765. diameterX?: number;
  85766. diameterY?: number;
  85767. diameterZ?: number;
  85768. arc?: number;
  85769. slice?: number;
  85770. sideOrientation?: number;
  85771. frontUVs?: Vector4;
  85772. backUVs?: Vector4;
  85773. }): VertexData;
  85774. /**
  85775. * Creates the VertexData for a cylinder, cone or prism
  85776. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85777. * * height sets the height (y direction) of the cylinder, optional, default 2
  85778. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  85779. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  85780. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  85781. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  85782. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  85783. * * 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
  85784. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85785. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85786. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  85787. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  85788. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85789. * * 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)
  85790. * * 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)
  85791. * @returns the VertexData of the cylinder, cone or prism
  85792. */
  85793. static CreateCylinder(options: {
  85794. height?: number;
  85795. diameterTop?: number;
  85796. diameterBottom?: number;
  85797. diameter?: number;
  85798. tessellation?: number;
  85799. subdivisions?: number;
  85800. arc?: number;
  85801. faceColors?: Color4[];
  85802. faceUV?: Vector4[];
  85803. hasRings?: boolean;
  85804. enclose?: boolean;
  85805. sideOrientation?: number;
  85806. frontUVs?: Vector4;
  85807. backUVs?: Vector4;
  85808. }): VertexData;
  85809. /**
  85810. * Creates the VertexData for a torus
  85811. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85812. * * diameter the diameter of the torus, optional default 1
  85813. * * thickness the diameter of the tube forming the torus, optional default 0.5
  85814. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  85815. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85816. * * 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)
  85817. * * 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)
  85818. * @returns the VertexData of the torus
  85819. */
  85820. static CreateTorus(options: {
  85821. diameter?: number;
  85822. thickness?: number;
  85823. tessellation?: number;
  85824. sideOrientation?: number;
  85825. frontUVs?: Vector4;
  85826. backUVs?: Vector4;
  85827. }): VertexData;
  85828. /**
  85829. * Creates the VertexData of the LineSystem
  85830. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  85831. * - lines an array of lines, each line being an array of successive Vector3
  85832. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  85833. * @returns the VertexData of the LineSystem
  85834. */
  85835. static CreateLineSystem(options: {
  85836. lines: Vector3[][];
  85837. colors?: Nullable<Color4[][]>;
  85838. }): VertexData;
  85839. /**
  85840. * Create the VertexData for a DashedLines
  85841. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  85842. * - points an array successive Vector3
  85843. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  85844. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  85845. * - dashNb the intended total number of dashes, optional, default 200
  85846. * @returns the VertexData for the DashedLines
  85847. */
  85848. static CreateDashedLines(options: {
  85849. points: Vector3[];
  85850. dashSize?: number;
  85851. gapSize?: number;
  85852. dashNb?: number;
  85853. }): VertexData;
  85854. /**
  85855. * Creates the VertexData for a Ground
  85856. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  85857. * - width the width (x direction) of the ground, optional, default 1
  85858. * - height the height (z direction) of the ground, optional, default 1
  85859. * - subdivisions the number of subdivisions per side, optional, default 1
  85860. * @returns the VertexData of the Ground
  85861. */
  85862. static CreateGround(options: {
  85863. width?: number;
  85864. height?: number;
  85865. subdivisions?: number;
  85866. subdivisionsX?: number;
  85867. subdivisionsY?: number;
  85868. }): VertexData;
  85869. /**
  85870. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  85871. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  85872. * * xmin the ground minimum X coordinate, optional, default -1
  85873. * * zmin the ground minimum Z coordinate, optional, default -1
  85874. * * xmax the ground maximum X coordinate, optional, default 1
  85875. * * zmax the ground maximum Z coordinate, optional, default 1
  85876. * * 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}
  85877. * * 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}
  85878. * @returns the VertexData of the TiledGround
  85879. */
  85880. static CreateTiledGround(options: {
  85881. xmin: number;
  85882. zmin: number;
  85883. xmax: number;
  85884. zmax: number;
  85885. subdivisions?: {
  85886. w: number;
  85887. h: number;
  85888. };
  85889. precision?: {
  85890. w: number;
  85891. h: number;
  85892. };
  85893. }): VertexData;
  85894. /**
  85895. * Creates the VertexData of the Ground designed from a heightmap
  85896. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  85897. * * width the width (x direction) of the ground
  85898. * * height the height (z direction) of the ground
  85899. * * subdivisions the number of subdivisions per side
  85900. * * minHeight the minimum altitude on the ground, optional, default 0
  85901. * * maxHeight the maximum altitude on the ground, optional default 1
  85902. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  85903. * * buffer the array holding the image color data
  85904. * * bufferWidth the width of image
  85905. * * bufferHeight the height of image
  85906. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  85907. * @returns the VertexData of the Ground designed from a heightmap
  85908. */
  85909. static CreateGroundFromHeightMap(options: {
  85910. width: number;
  85911. height: number;
  85912. subdivisions: number;
  85913. minHeight: number;
  85914. maxHeight: number;
  85915. colorFilter: Color3;
  85916. buffer: Uint8Array;
  85917. bufferWidth: number;
  85918. bufferHeight: number;
  85919. alphaFilter: number;
  85920. }): VertexData;
  85921. /**
  85922. * Creates the VertexData for a Plane
  85923. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  85924. * * size sets the width and height of the plane to the value of size, optional default 1
  85925. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  85926. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  85927. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85928. * * 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)
  85929. * * 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)
  85930. * @returns the VertexData of the box
  85931. */
  85932. static CreatePlane(options: {
  85933. size?: number;
  85934. width?: number;
  85935. height?: number;
  85936. sideOrientation?: number;
  85937. frontUVs?: Vector4;
  85938. backUVs?: Vector4;
  85939. }): VertexData;
  85940. /**
  85941. * Creates the VertexData of the Disc or regular Polygon
  85942. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  85943. * * radius the radius of the disc, optional default 0.5
  85944. * * tessellation the number of polygon sides, optional, default 64
  85945. * * 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
  85946. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85947. * * 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)
  85948. * * 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)
  85949. * @returns the VertexData of the box
  85950. */
  85951. static CreateDisc(options: {
  85952. radius?: number;
  85953. tessellation?: number;
  85954. arc?: number;
  85955. sideOrientation?: number;
  85956. frontUVs?: Vector4;
  85957. backUVs?: Vector4;
  85958. }): VertexData;
  85959. /**
  85960. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  85961. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  85962. * @param polygon a mesh built from polygonTriangulation.build()
  85963. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85964. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85965. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85966. * @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)
  85967. * @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)
  85968. * @returns the VertexData of the Polygon
  85969. */
  85970. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  85971. /**
  85972. * Creates the VertexData of the IcoSphere
  85973. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  85974. * * radius the radius of the IcoSphere, optional default 1
  85975. * * radiusX allows stretching in the x direction, optional, default radius
  85976. * * radiusY allows stretching in the y direction, optional, default radius
  85977. * * radiusZ allows stretching in the z direction, optional, default radius
  85978. * * flat when true creates a flat shaded mesh, optional, default true
  85979. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  85980. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85981. * * 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)
  85982. * * 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)
  85983. * @returns the VertexData of the IcoSphere
  85984. */
  85985. static CreateIcoSphere(options: {
  85986. radius?: number;
  85987. radiusX?: number;
  85988. radiusY?: number;
  85989. radiusZ?: number;
  85990. flat?: boolean;
  85991. subdivisions?: number;
  85992. sideOrientation?: number;
  85993. frontUVs?: Vector4;
  85994. backUVs?: Vector4;
  85995. }): VertexData;
  85996. /**
  85997. * Creates the VertexData for a Polyhedron
  85998. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  85999. * * type provided types are:
  86000. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  86001. * * 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)
  86002. * * size the size of the IcoSphere, optional default 1
  86003. * * sizeX allows stretching in the x direction, optional, default size
  86004. * * sizeY allows stretching in the y direction, optional, default size
  86005. * * sizeZ allows stretching in the z direction, optional, default size
  86006. * * 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
  86007. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86008. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86009. * * flat when true creates a flat shaded mesh, optional, default true
  86010. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86011. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86012. * * 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)
  86013. * * 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)
  86014. * @returns the VertexData of the Polyhedron
  86015. */
  86016. static CreatePolyhedron(options: {
  86017. type?: number;
  86018. size?: number;
  86019. sizeX?: number;
  86020. sizeY?: number;
  86021. sizeZ?: number;
  86022. custom?: any;
  86023. faceUV?: Vector4[];
  86024. faceColors?: Color4[];
  86025. flat?: boolean;
  86026. sideOrientation?: number;
  86027. frontUVs?: Vector4;
  86028. backUVs?: Vector4;
  86029. }): VertexData;
  86030. /**
  86031. * Creates the VertexData for a TorusKnot
  86032. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  86033. * * radius the radius of the torus knot, optional, default 2
  86034. * * tube the thickness of the tube, optional, default 0.5
  86035. * * radialSegments the number of sides on each tube segments, optional, default 32
  86036. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  86037. * * p the number of windings around the z axis, optional, default 2
  86038. * * q the number of windings around the x axis, optional, default 3
  86039. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86040. * * 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)
  86041. * * 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)
  86042. * @returns the VertexData of the Torus Knot
  86043. */
  86044. static CreateTorusKnot(options: {
  86045. radius?: number;
  86046. tube?: number;
  86047. radialSegments?: number;
  86048. tubularSegments?: number;
  86049. p?: number;
  86050. q?: number;
  86051. sideOrientation?: number;
  86052. frontUVs?: Vector4;
  86053. backUVs?: Vector4;
  86054. }): VertexData;
  86055. /**
  86056. * Compute normals for given positions and indices
  86057. * @param positions an array of vertex positions, [...., x, y, z, ......]
  86058. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  86059. * @param normals an array of vertex normals, [...., x, y, z, ......]
  86060. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  86061. * * facetNormals : optional array of facet normals (vector3)
  86062. * * facetPositions : optional array of facet positions (vector3)
  86063. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  86064. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  86065. * * bInfo : optional bounding info, required for facetPartitioning computation
  86066. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  86067. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  86068. * * useRightHandedSystem: optional boolean to for right handed system computation
  86069. * * depthSort : optional boolean to enable the facet depth sort computation
  86070. * * distanceTo : optional Vector3 to compute the facet depth from this location
  86071. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  86072. */
  86073. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  86074. facetNormals?: any;
  86075. facetPositions?: any;
  86076. facetPartitioning?: any;
  86077. ratio?: number;
  86078. bInfo?: any;
  86079. bbSize?: Vector3;
  86080. subDiv?: any;
  86081. useRightHandedSystem?: boolean;
  86082. depthSort?: boolean;
  86083. distanceTo?: Vector3;
  86084. depthSortedFacets?: any;
  86085. }): void;
  86086. /** @hidden */
  86087. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  86088. /**
  86089. * Applies VertexData created from the imported parameters to the geometry
  86090. * @param parsedVertexData the parsed data from an imported file
  86091. * @param geometry the geometry to apply the VertexData to
  86092. */
  86093. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  86094. }
  86095. }
  86096. declare module BABYLON {
  86097. /**
  86098. * Class containing static functions to help procedurally build meshes
  86099. */
  86100. export class DiscBuilder {
  86101. /**
  86102. * Creates a plane polygonal mesh. By default, this is a disc
  86103. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  86104. * * 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
  86105. * * 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
  86106. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86107. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  86108. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86109. * @param name defines the name of the mesh
  86110. * @param options defines the options used to create the mesh
  86111. * @param scene defines the hosting scene
  86112. * @returns the plane polygonal mesh
  86113. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  86114. */
  86115. static CreateDisc(name: string, options: {
  86116. radius?: number;
  86117. tessellation?: number;
  86118. arc?: number;
  86119. updatable?: boolean;
  86120. sideOrientation?: number;
  86121. frontUVs?: Vector4;
  86122. backUVs?: Vector4;
  86123. }, scene?: Nullable<Scene>): Mesh;
  86124. }
  86125. }
  86126. declare module BABYLON {
  86127. /**
  86128. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  86129. *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.
  86130. * The SPS is also a particle system. It provides some methods to manage the particles.
  86131. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  86132. *
  86133. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  86134. */
  86135. export class SolidParticleSystem implements IDisposable {
  86136. /**
  86137. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  86138. * Example : var p = SPS.particles[i];
  86139. */
  86140. particles: SolidParticle[];
  86141. /**
  86142. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  86143. */
  86144. nbParticles: number;
  86145. /**
  86146. * If the particles must ever face the camera (default false). Useful for planar particles.
  86147. */
  86148. billboard: boolean;
  86149. /**
  86150. * Recompute normals when adding a shape
  86151. */
  86152. recomputeNormals: boolean;
  86153. /**
  86154. * This a counter ofr your own usage. It's not set by any SPS functions.
  86155. */
  86156. counter: number;
  86157. /**
  86158. * The SPS name. This name is also given to the underlying mesh.
  86159. */
  86160. name: string;
  86161. /**
  86162. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  86163. */
  86164. mesh: Mesh;
  86165. /**
  86166. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  86167. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  86168. */
  86169. vars: any;
  86170. /**
  86171. * This array is populated when the SPS is set as 'pickable'.
  86172. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  86173. * Each element of this array is an object `{idx: int, faceId: int}`.
  86174. * `idx` is the picked particle index in the `SPS.particles` array
  86175. * `faceId` is the picked face index counted within this particle.
  86176. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  86177. */
  86178. pickedParticles: {
  86179. idx: number;
  86180. faceId: number;
  86181. }[];
  86182. /**
  86183. * This array is populated when `enableDepthSort` is set to true.
  86184. * Each element of this array is an instance of the class DepthSortedParticle.
  86185. */
  86186. depthSortedParticles: DepthSortedParticle[];
  86187. /**
  86188. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  86189. * @hidden
  86190. */
  86191. _bSphereOnly: boolean;
  86192. /**
  86193. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  86194. * @hidden
  86195. */
  86196. _bSphereRadiusFactor: number;
  86197. private _scene;
  86198. private _positions;
  86199. private _indices;
  86200. private _normals;
  86201. private _colors;
  86202. private _uvs;
  86203. private _indices32;
  86204. private _positions32;
  86205. private _normals32;
  86206. private _fixedNormal32;
  86207. private _colors32;
  86208. private _uvs32;
  86209. private _index;
  86210. private _updatable;
  86211. private _pickable;
  86212. private _isVisibilityBoxLocked;
  86213. private _alwaysVisible;
  86214. private _depthSort;
  86215. private _shapeCounter;
  86216. private _copy;
  86217. private _color;
  86218. private _computeParticleColor;
  86219. private _computeParticleTexture;
  86220. private _computeParticleRotation;
  86221. private _computeParticleVertex;
  86222. private _computeBoundingBox;
  86223. private _depthSortParticles;
  86224. private _camera;
  86225. private _mustUnrotateFixedNormals;
  86226. private _particlesIntersect;
  86227. private _needs32Bits;
  86228. /**
  86229. * Creates a SPS (Solid Particle System) object.
  86230. * @param name (String) is the SPS name, this will be the underlying mesh name.
  86231. * @param scene (Scene) is the scene in which the SPS is added.
  86232. * @param options defines the options of the sps e.g.
  86233. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  86234. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  86235. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  86236. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  86237. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  86238. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  86239. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  86240. */
  86241. constructor(name: string, scene: Scene, options?: {
  86242. updatable?: boolean;
  86243. isPickable?: boolean;
  86244. enableDepthSort?: boolean;
  86245. particleIntersection?: boolean;
  86246. boundingSphereOnly?: boolean;
  86247. bSphereRadiusFactor?: number;
  86248. });
  86249. /**
  86250. * Builds the SPS underlying mesh. Returns a standard Mesh.
  86251. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  86252. * @returns the created mesh
  86253. */
  86254. buildMesh(): Mesh;
  86255. /**
  86256. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  86257. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  86258. * Thus the particles generated from `digest()` have their property `position` set yet.
  86259. * @param mesh ( Mesh ) is the mesh to be digested
  86260. * @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
  86261. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  86262. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  86263. * @returns the current SPS
  86264. */
  86265. digest(mesh: Mesh, options?: {
  86266. facetNb?: number;
  86267. number?: number;
  86268. delta?: number;
  86269. }): SolidParticleSystem;
  86270. private _unrotateFixedNormals;
  86271. private _resetCopy;
  86272. private _meshBuilder;
  86273. private _posToShape;
  86274. private _uvsToShapeUV;
  86275. private _addParticle;
  86276. /**
  86277. * Adds some particles to the SPS from the model shape. Returns the shape id.
  86278. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  86279. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  86280. * @param nb (positive integer) the number of particles to be created from this model
  86281. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  86282. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  86283. * @returns the number of shapes in the system
  86284. */
  86285. addShape(mesh: Mesh, nb: number, options?: {
  86286. positionFunction?: any;
  86287. vertexFunction?: any;
  86288. }): number;
  86289. private _rebuildParticle;
  86290. /**
  86291. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  86292. * @returns the SPS.
  86293. */
  86294. rebuildMesh(): SolidParticleSystem;
  86295. /**
  86296. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  86297. * This method calls `updateParticle()` for each particle of the SPS.
  86298. * For an animated SPS, it is usually called within the render loop.
  86299. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  86300. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  86301. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  86302. * @returns the SPS.
  86303. */
  86304. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  86305. /**
  86306. * Disposes the SPS.
  86307. */
  86308. dispose(): void;
  86309. /**
  86310. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  86311. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86312. * @returns the SPS.
  86313. */
  86314. refreshVisibleSize(): SolidParticleSystem;
  86315. /**
  86316. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  86317. * @param size the size (float) of the visibility box
  86318. * note : this doesn't lock the SPS mesh bounding box.
  86319. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86320. */
  86321. setVisibilityBox(size: number): void;
  86322. /**
  86323. * Gets whether the SPS as always visible or not
  86324. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86325. */
  86326. /**
  86327. * Sets the SPS as always visible or not
  86328. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86329. */
  86330. isAlwaysVisible: boolean;
  86331. /**
  86332. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  86333. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86334. */
  86335. /**
  86336. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  86337. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86338. */
  86339. isVisibilityBoxLocked: boolean;
  86340. /**
  86341. * Tells to `setParticles()` to compute the particle rotations or not.
  86342. * Default value : true. The SPS is faster when it's set to false.
  86343. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  86344. */
  86345. /**
  86346. * Gets if `setParticles()` computes the particle rotations or not.
  86347. * Default value : true. The SPS is faster when it's set to false.
  86348. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  86349. */
  86350. computeParticleRotation: boolean;
  86351. /**
  86352. * Tells to `setParticles()` to compute the particle colors or not.
  86353. * Default value : true. The SPS is faster when it's set to false.
  86354. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  86355. */
  86356. /**
  86357. * Gets if `setParticles()` computes the particle colors or not.
  86358. * Default value : true. The SPS is faster when it's set to false.
  86359. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  86360. */
  86361. computeParticleColor: boolean;
  86362. /**
  86363. * Gets if `setParticles()` computes the particle textures or not.
  86364. * Default value : true. The SPS is faster when it's set to false.
  86365. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  86366. */
  86367. computeParticleTexture: boolean;
  86368. /**
  86369. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  86370. * Default value : false. The SPS is faster when it's set to false.
  86371. * Note : the particle custom vertex positions aren't stored values.
  86372. */
  86373. /**
  86374. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  86375. * Default value : false. The SPS is faster when it's set to false.
  86376. * Note : the particle custom vertex positions aren't stored values.
  86377. */
  86378. computeParticleVertex: boolean;
  86379. /**
  86380. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  86381. */
  86382. /**
  86383. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  86384. */
  86385. computeBoundingBox: boolean;
  86386. /**
  86387. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  86388. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  86389. * Default : `true`
  86390. */
  86391. /**
  86392. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  86393. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  86394. * Default : `true`
  86395. */
  86396. depthSortParticles: boolean;
  86397. /**
  86398. * This function does nothing. It may be overwritten to set all the particle first values.
  86399. * The SPS doesn't call this function, you may have to call it by your own.
  86400. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  86401. */
  86402. initParticles(): void;
  86403. /**
  86404. * This function does nothing. It may be overwritten to recycle a particle.
  86405. * The SPS doesn't call this function, you may have to call it by your own.
  86406. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  86407. * @param particle The particle to recycle
  86408. * @returns the recycled particle
  86409. */
  86410. recycleParticle(particle: SolidParticle): SolidParticle;
  86411. /**
  86412. * Updates a particle : this function should be overwritten by the user.
  86413. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  86414. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  86415. * @example : just set a particle position or velocity and recycle conditions
  86416. * @param particle The particle to update
  86417. * @returns the updated particle
  86418. */
  86419. updateParticle(particle: SolidParticle): SolidParticle;
  86420. /**
  86421. * Updates a vertex of a particle : it can be overwritten by the user.
  86422. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  86423. * @param particle the current particle
  86424. * @param vertex the current index of the current particle
  86425. * @param pt the index of the current vertex in the particle shape
  86426. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  86427. * @example : just set a vertex particle position
  86428. * @returns the updated vertex
  86429. */
  86430. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  86431. /**
  86432. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  86433. * This does nothing and may be overwritten by the user.
  86434. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86435. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86436. * @param update the boolean update value actually passed to setParticles()
  86437. */
  86438. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  86439. /**
  86440. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  86441. * This will be passed three parameters.
  86442. * This does nothing and may be overwritten by the user.
  86443. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86444. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86445. * @param update the boolean update value actually passed to setParticles()
  86446. */
  86447. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  86448. }
  86449. }
  86450. declare module BABYLON {
  86451. /**
  86452. * Represents one particle of a solid particle system.
  86453. */
  86454. export class SolidParticle {
  86455. /**
  86456. * particle global index
  86457. */
  86458. idx: number;
  86459. /**
  86460. * The color of the particle
  86461. */
  86462. color: Nullable<Color4>;
  86463. /**
  86464. * The world space position of the particle.
  86465. */
  86466. position: Vector3;
  86467. /**
  86468. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  86469. */
  86470. rotation: Vector3;
  86471. /**
  86472. * The world space rotation quaternion of the particle.
  86473. */
  86474. rotationQuaternion: Nullable<Quaternion>;
  86475. /**
  86476. * The scaling of the particle.
  86477. */
  86478. scaling: Vector3;
  86479. /**
  86480. * The uvs of the particle.
  86481. */
  86482. uvs: Vector4;
  86483. /**
  86484. * The current speed of the particle.
  86485. */
  86486. velocity: Vector3;
  86487. /**
  86488. * The pivot point in the particle local space.
  86489. */
  86490. pivot: Vector3;
  86491. /**
  86492. * Must the particle be translated from its pivot point in its local space ?
  86493. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  86494. * Default : false
  86495. */
  86496. translateFromPivot: boolean;
  86497. /**
  86498. * Is the particle active or not ?
  86499. */
  86500. alive: boolean;
  86501. /**
  86502. * Is the particle visible or not ?
  86503. */
  86504. isVisible: boolean;
  86505. /**
  86506. * Index of this particle in the global "positions" array (Internal use)
  86507. * @hidden
  86508. */
  86509. _pos: number;
  86510. /**
  86511. * @hidden Index of this particle in the global "indices" array (Internal use)
  86512. */
  86513. _ind: number;
  86514. /**
  86515. * @hidden ModelShape of this particle (Internal use)
  86516. */
  86517. _model: ModelShape;
  86518. /**
  86519. * ModelShape id of this particle
  86520. */
  86521. shapeId: number;
  86522. /**
  86523. * Index of the particle in its shape id (Internal use)
  86524. */
  86525. idxInShape: number;
  86526. /**
  86527. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  86528. */
  86529. _modelBoundingInfo: BoundingInfo;
  86530. /**
  86531. * @hidden Particle BoundingInfo object (Internal use)
  86532. */
  86533. _boundingInfo: BoundingInfo;
  86534. /**
  86535. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  86536. */
  86537. _sps: SolidParticleSystem;
  86538. /**
  86539. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  86540. */
  86541. _stillInvisible: boolean;
  86542. /**
  86543. * @hidden Last computed particle rotation matrix
  86544. */
  86545. _rotationMatrix: number[];
  86546. /**
  86547. * Parent particle Id, if any.
  86548. * Default null.
  86549. */
  86550. parentId: Nullable<number>;
  86551. /**
  86552. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  86553. * The possible values are :
  86554. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  86555. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  86556. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  86557. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  86558. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  86559. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  86560. * */
  86561. cullingStrategy: number;
  86562. /**
  86563. * @hidden Internal global position in the SPS.
  86564. */
  86565. _globalPosition: Vector3;
  86566. /**
  86567. * Creates a Solid Particle object.
  86568. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  86569. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  86570. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  86571. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  86572. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  86573. * @param shapeId (integer) is the model shape identifier in the SPS.
  86574. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  86575. * @param sps defines the sps it is associated to
  86576. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  86577. */
  86578. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  86579. /**
  86580. * Legacy support, changed scale to scaling
  86581. */
  86582. /**
  86583. * Legacy support, changed scale to scaling
  86584. */
  86585. scale: Vector3;
  86586. /**
  86587. * Legacy support, changed quaternion to rotationQuaternion
  86588. */
  86589. /**
  86590. * Legacy support, changed quaternion to rotationQuaternion
  86591. */
  86592. quaternion: Nullable<Quaternion>;
  86593. /**
  86594. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  86595. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  86596. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  86597. * @returns true if it intersects
  86598. */
  86599. intersectsMesh(target: Mesh | SolidParticle): boolean;
  86600. /**
  86601. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  86602. * A particle is in the frustum if its bounding box intersects the frustum
  86603. * @param frustumPlanes defines the frustum to test
  86604. * @returns true if the particle is in the frustum planes
  86605. */
  86606. isInFrustum(frustumPlanes: Plane[]): boolean;
  86607. /**
  86608. * get the rotation matrix of the particle
  86609. * @hidden
  86610. */
  86611. getRotationMatrix(m: Matrix): void;
  86612. }
  86613. /**
  86614. * Represents the shape of the model used by one particle of a solid particle system.
  86615. * SPS internal tool, don't use it manually.
  86616. */
  86617. export class ModelShape {
  86618. /**
  86619. * The shape id
  86620. * @hidden
  86621. */
  86622. shapeID: number;
  86623. /**
  86624. * flat array of model positions (internal use)
  86625. * @hidden
  86626. */
  86627. _shape: Vector3[];
  86628. /**
  86629. * flat array of model UVs (internal use)
  86630. * @hidden
  86631. */
  86632. _shapeUV: number[];
  86633. /**
  86634. * length of the shape in the model indices array (internal use)
  86635. * @hidden
  86636. */
  86637. _indicesLength: number;
  86638. /**
  86639. * Custom position function (internal use)
  86640. * @hidden
  86641. */
  86642. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  86643. /**
  86644. * Custom vertex function (internal use)
  86645. * @hidden
  86646. */
  86647. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  86648. /**
  86649. * 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.
  86650. * SPS internal tool, don't use it manually.
  86651. * @hidden
  86652. */
  86653. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  86654. }
  86655. /**
  86656. * Represents a Depth Sorted Particle in the solid particle system.
  86657. */
  86658. export class DepthSortedParticle {
  86659. /**
  86660. * Index of the particle in the "indices" array
  86661. */
  86662. ind: number;
  86663. /**
  86664. * Length of the particle shape in the "indices" array
  86665. */
  86666. indicesLength: number;
  86667. /**
  86668. * Squared distance from the particle to the camera
  86669. */
  86670. sqDistance: number;
  86671. }
  86672. }
  86673. declare module BABYLON {
  86674. /**
  86675. * @hidden
  86676. */
  86677. export class _MeshCollisionData {
  86678. _checkCollisions: boolean;
  86679. _collisionMask: number;
  86680. _collisionGroup: number;
  86681. _collider: Nullable<Collider>;
  86682. _oldPositionForCollisions: Vector3;
  86683. _diffPositionForCollisions: Vector3;
  86684. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  86685. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  86686. }
  86687. }
  86688. declare module BABYLON {
  86689. /** @hidden */
  86690. class _FacetDataStorage {
  86691. facetPositions: Vector3[];
  86692. facetNormals: Vector3[];
  86693. facetPartitioning: number[][];
  86694. facetNb: number;
  86695. partitioningSubdivisions: number;
  86696. partitioningBBoxRatio: number;
  86697. facetDataEnabled: boolean;
  86698. facetParameters: any;
  86699. bbSize: Vector3;
  86700. subDiv: {
  86701. max: number;
  86702. X: number;
  86703. Y: number;
  86704. Z: number;
  86705. };
  86706. facetDepthSort: boolean;
  86707. facetDepthSortEnabled: boolean;
  86708. depthSortedIndices: IndicesArray;
  86709. depthSortedFacets: {
  86710. ind: number;
  86711. sqDistance: number;
  86712. }[];
  86713. facetDepthSortFunction: (f1: {
  86714. ind: number;
  86715. sqDistance: number;
  86716. }, f2: {
  86717. ind: number;
  86718. sqDistance: number;
  86719. }) => number;
  86720. facetDepthSortFrom: Vector3;
  86721. facetDepthSortOrigin: Vector3;
  86722. invertedMatrix: Matrix;
  86723. }
  86724. /**
  86725. * @hidden
  86726. **/
  86727. class _InternalAbstractMeshDataInfo {
  86728. _hasVertexAlpha: boolean;
  86729. _useVertexColors: boolean;
  86730. _numBoneInfluencers: number;
  86731. _applyFog: boolean;
  86732. _receiveShadows: boolean;
  86733. _facetData: _FacetDataStorage;
  86734. _visibility: number;
  86735. _skeleton: Nullable<Skeleton>;
  86736. _layerMask: number;
  86737. _computeBonesUsingShaders: boolean;
  86738. _isActive: boolean;
  86739. _onlyForInstances: boolean;
  86740. _isActiveIntermediate: boolean;
  86741. _onlyForInstancesIntermediate: boolean;
  86742. }
  86743. /**
  86744. * Class used to store all common mesh properties
  86745. */
  86746. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  86747. /** No occlusion */
  86748. static OCCLUSION_TYPE_NONE: number;
  86749. /** Occlusion set to optimisitic */
  86750. static OCCLUSION_TYPE_OPTIMISTIC: number;
  86751. /** Occlusion set to strict */
  86752. static OCCLUSION_TYPE_STRICT: number;
  86753. /** Use an accurante occlusion algorithm */
  86754. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  86755. /** Use a conservative occlusion algorithm */
  86756. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  86757. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  86758. * Test order :
  86759. * Is the bounding sphere outside the frustum ?
  86760. * If not, are the bounding box vertices outside the frustum ?
  86761. * It not, then the cullable object is in the frustum.
  86762. */
  86763. static readonly CULLINGSTRATEGY_STANDARD: number;
  86764. /** Culling strategy : Bounding Sphere Only.
  86765. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  86766. * It's also less accurate than the standard because some not visible objects can still be selected.
  86767. * Test : is the bounding sphere outside the frustum ?
  86768. * If not, then the cullable object is in the frustum.
  86769. */
  86770. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  86771. /** Culling strategy : Optimistic Inclusion.
  86772. * This in an inclusion test first, then the standard exclusion test.
  86773. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  86774. * 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.
  86775. * Anyway, it's as accurate as the standard strategy.
  86776. * Test :
  86777. * Is the cullable object bounding sphere center in the frustum ?
  86778. * If not, apply the default culling strategy.
  86779. */
  86780. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  86781. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  86782. * This in an inclusion test first, then the bounding sphere only exclusion test.
  86783. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  86784. * 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.
  86785. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  86786. * Test :
  86787. * Is the cullable object bounding sphere center in the frustum ?
  86788. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  86789. */
  86790. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  86791. /**
  86792. * No billboard
  86793. */
  86794. static readonly BILLBOARDMODE_NONE: number;
  86795. /** Billboard on X axis */
  86796. static readonly BILLBOARDMODE_X: number;
  86797. /** Billboard on Y axis */
  86798. static readonly BILLBOARDMODE_Y: number;
  86799. /** Billboard on Z axis */
  86800. static readonly BILLBOARDMODE_Z: number;
  86801. /** Billboard on all axes */
  86802. static readonly BILLBOARDMODE_ALL: number;
  86803. /** @hidden */
  86804. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  86805. /**
  86806. * The culling strategy to use to check whether the mesh must be rendered or not.
  86807. * This value can be changed at any time and will be used on the next render mesh selection.
  86808. * The possible values are :
  86809. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  86810. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  86811. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  86812. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  86813. * Please read each static variable documentation to get details about the culling process.
  86814. * */
  86815. cullingStrategy: number;
  86816. /**
  86817. * Gets the number of facets in the mesh
  86818. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  86819. */
  86820. readonly facetNb: number;
  86821. /**
  86822. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  86823. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  86824. */
  86825. partitioningSubdivisions: number;
  86826. /**
  86827. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  86828. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  86829. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  86830. */
  86831. partitioningBBoxRatio: number;
  86832. /**
  86833. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  86834. * Works only for updatable meshes.
  86835. * Doesn't work with multi-materials
  86836. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  86837. */
  86838. mustDepthSortFacets: boolean;
  86839. /**
  86840. * The location (Vector3) where the facet depth sort must be computed from.
  86841. * By default, the active camera position.
  86842. * Used only when facet depth sort is enabled
  86843. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  86844. */
  86845. facetDepthSortFrom: Vector3;
  86846. /**
  86847. * gets a boolean indicating if facetData is enabled
  86848. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  86849. */
  86850. readonly isFacetDataEnabled: boolean;
  86851. /** @hidden */
  86852. _updateNonUniformScalingState(value: boolean): boolean;
  86853. /**
  86854. * An event triggered when this mesh collides with another one
  86855. */
  86856. onCollideObservable: Observable<AbstractMesh>;
  86857. /** Set a function to call when this mesh collides with another one */
  86858. onCollide: () => void;
  86859. /**
  86860. * An event triggered when the collision's position changes
  86861. */
  86862. onCollisionPositionChangeObservable: Observable<Vector3>;
  86863. /** Set a function to call when the collision's position changes */
  86864. onCollisionPositionChange: () => void;
  86865. /**
  86866. * An event triggered when material is changed
  86867. */
  86868. onMaterialChangedObservable: Observable<AbstractMesh>;
  86869. /**
  86870. * Gets or sets the orientation for POV movement & rotation
  86871. */
  86872. definedFacingForward: boolean;
  86873. /** @hidden */
  86874. _occlusionQuery: Nullable<WebGLQuery>;
  86875. /** @hidden */
  86876. _renderingGroup: Nullable<RenderingGroup>;
  86877. /**
  86878. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  86879. */
  86880. /**
  86881. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  86882. */
  86883. visibility: number;
  86884. /** Gets or sets the alpha index used to sort transparent meshes
  86885. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  86886. */
  86887. alphaIndex: number;
  86888. /**
  86889. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  86890. */
  86891. isVisible: boolean;
  86892. /**
  86893. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  86894. */
  86895. isPickable: boolean;
  86896. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  86897. showSubMeshesBoundingBox: boolean;
  86898. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  86899. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  86900. */
  86901. isBlocker: boolean;
  86902. /**
  86903. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  86904. */
  86905. enablePointerMoveEvents: boolean;
  86906. /**
  86907. * Specifies the rendering group id for this mesh (0 by default)
  86908. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  86909. */
  86910. renderingGroupId: number;
  86911. private _material;
  86912. /** Gets or sets current material */
  86913. material: Nullable<Material>;
  86914. /**
  86915. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  86916. * @see http://doc.babylonjs.com/babylon101/shadows
  86917. */
  86918. receiveShadows: boolean;
  86919. /** Defines color to use when rendering outline */
  86920. outlineColor: Color3;
  86921. /** Define width to use when rendering outline */
  86922. outlineWidth: number;
  86923. /** Defines color to use when rendering overlay */
  86924. overlayColor: Color3;
  86925. /** Defines alpha to use when rendering overlay */
  86926. overlayAlpha: number;
  86927. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  86928. hasVertexAlpha: boolean;
  86929. /** 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) */
  86930. useVertexColors: boolean;
  86931. /**
  86932. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  86933. */
  86934. computeBonesUsingShaders: boolean;
  86935. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  86936. numBoneInfluencers: number;
  86937. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  86938. applyFog: boolean;
  86939. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  86940. useOctreeForRenderingSelection: boolean;
  86941. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  86942. useOctreeForPicking: boolean;
  86943. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  86944. useOctreeForCollisions: boolean;
  86945. /**
  86946. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  86947. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  86948. */
  86949. layerMask: number;
  86950. /**
  86951. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  86952. */
  86953. alwaysSelectAsActiveMesh: boolean;
  86954. /**
  86955. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  86956. */
  86957. doNotSyncBoundingInfo: boolean;
  86958. /**
  86959. * Gets or sets the current action manager
  86960. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86961. */
  86962. actionManager: Nullable<AbstractActionManager>;
  86963. private _meshCollisionData;
  86964. /**
  86965. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  86966. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  86967. */
  86968. ellipsoid: Vector3;
  86969. /**
  86970. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  86971. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  86972. */
  86973. ellipsoidOffset: Vector3;
  86974. /**
  86975. * Gets or sets a collision mask used to mask collisions (default is -1).
  86976. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  86977. */
  86978. collisionMask: number;
  86979. /**
  86980. * Gets or sets the current collision group mask (-1 by default).
  86981. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  86982. */
  86983. collisionGroup: number;
  86984. /**
  86985. * Defines edge width used when edgesRenderer is enabled
  86986. * @see https://www.babylonjs-playground.com/#10OJSG#13
  86987. */
  86988. edgesWidth: number;
  86989. /**
  86990. * Defines edge color used when edgesRenderer is enabled
  86991. * @see https://www.babylonjs-playground.com/#10OJSG#13
  86992. */
  86993. edgesColor: Color4;
  86994. /** @hidden */
  86995. _edgesRenderer: Nullable<IEdgesRenderer>;
  86996. /** @hidden */
  86997. _masterMesh: Nullable<AbstractMesh>;
  86998. /** @hidden */
  86999. _boundingInfo: Nullable<BoundingInfo>;
  87000. /** @hidden */
  87001. _renderId: number;
  87002. /**
  87003. * Gets or sets the list of subMeshes
  87004. * @see http://doc.babylonjs.com/how_to/multi_materials
  87005. */
  87006. subMeshes: SubMesh[];
  87007. /** @hidden */
  87008. _intersectionsInProgress: AbstractMesh[];
  87009. /** @hidden */
  87010. _unIndexed: boolean;
  87011. /** @hidden */
  87012. _lightSources: Light[];
  87013. /** Gets the list of lights affecting that mesh */
  87014. readonly lightSources: Light[];
  87015. /** @hidden */
  87016. readonly _positions: Nullable<Vector3[]>;
  87017. /** @hidden */
  87018. _waitingData: {
  87019. lods: Nullable<any>;
  87020. actions: Nullable<any>;
  87021. freezeWorldMatrix: Nullable<boolean>;
  87022. };
  87023. /** @hidden */
  87024. _bonesTransformMatrices: Nullable<Float32Array>;
  87025. /**
  87026. * Gets or sets a skeleton to apply skining transformations
  87027. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  87028. */
  87029. skeleton: Nullable<Skeleton>;
  87030. /**
  87031. * An event triggered when the mesh is rebuilt.
  87032. */
  87033. onRebuildObservable: Observable<AbstractMesh>;
  87034. /**
  87035. * Creates a new AbstractMesh
  87036. * @param name defines the name of the mesh
  87037. * @param scene defines the hosting scene
  87038. */
  87039. constructor(name: string, scene?: Nullable<Scene>);
  87040. /**
  87041. * Returns the string "AbstractMesh"
  87042. * @returns "AbstractMesh"
  87043. */
  87044. getClassName(): string;
  87045. /**
  87046. * Gets a string representation of the current mesh
  87047. * @param fullDetails defines a boolean indicating if full details must be included
  87048. * @returns a string representation of the current mesh
  87049. */
  87050. toString(fullDetails?: boolean): string;
  87051. /**
  87052. * @hidden
  87053. */
  87054. protected _getEffectiveParent(): Nullable<Node>;
  87055. /** @hidden */
  87056. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  87057. /** @hidden */
  87058. _rebuild(): void;
  87059. /** @hidden */
  87060. _resyncLightSources(): void;
  87061. /** @hidden */
  87062. _resyncLighSource(light: Light): void;
  87063. /** @hidden */
  87064. _unBindEffect(): void;
  87065. /** @hidden */
  87066. _removeLightSource(light: Light): void;
  87067. private _markSubMeshesAsDirty;
  87068. /** @hidden */
  87069. _markSubMeshesAsLightDirty(): void;
  87070. /** @hidden */
  87071. _markSubMeshesAsAttributesDirty(): void;
  87072. /** @hidden */
  87073. _markSubMeshesAsMiscDirty(): void;
  87074. /**
  87075. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  87076. */
  87077. scaling: Vector3;
  87078. /**
  87079. * Returns true if the mesh is blocked. Implemented by child classes
  87080. */
  87081. readonly isBlocked: boolean;
  87082. /**
  87083. * Returns the mesh itself by default. Implemented by child classes
  87084. * @param camera defines the camera to use to pick the right LOD level
  87085. * @returns the currentAbstractMesh
  87086. */
  87087. getLOD(camera: Camera): Nullable<AbstractMesh>;
  87088. /**
  87089. * Returns 0 by default. Implemented by child classes
  87090. * @returns an integer
  87091. */
  87092. getTotalVertices(): number;
  87093. /**
  87094. * Returns a positive integer : the total number of indices in this mesh geometry.
  87095. * @returns the numner of indices or zero if the mesh has no geometry.
  87096. */
  87097. getTotalIndices(): number;
  87098. /**
  87099. * Returns null by default. Implemented by child classes
  87100. * @returns null
  87101. */
  87102. getIndices(): Nullable<IndicesArray>;
  87103. /**
  87104. * Returns the array of the requested vertex data kind. Implemented by child classes
  87105. * @param kind defines the vertex data kind to use
  87106. * @returns null
  87107. */
  87108. getVerticesData(kind: string): Nullable<FloatArray>;
  87109. /**
  87110. * Sets the vertex data of the mesh geometry for the requested `kind`.
  87111. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  87112. * Note that a new underlying VertexBuffer object is created each call.
  87113. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  87114. * @param kind defines vertex data kind:
  87115. * * VertexBuffer.PositionKind
  87116. * * VertexBuffer.UVKind
  87117. * * VertexBuffer.UV2Kind
  87118. * * VertexBuffer.UV3Kind
  87119. * * VertexBuffer.UV4Kind
  87120. * * VertexBuffer.UV5Kind
  87121. * * VertexBuffer.UV6Kind
  87122. * * VertexBuffer.ColorKind
  87123. * * VertexBuffer.MatricesIndicesKind
  87124. * * VertexBuffer.MatricesIndicesExtraKind
  87125. * * VertexBuffer.MatricesWeightsKind
  87126. * * VertexBuffer.MatricesWeightsExtraKind
  87127. * @param data defines the data source
  87128. * @param updatable defines if the data must be flagged as updatable (or static)
  87129. * @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
  87130. * @returns the current mesh
  87131. */
  87132. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  87133. /**
  87134. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  87135. * If the mesh has no geometry, it is simply returned as it is.
  87136. * @param kind defines vertex data kind:
  87137. * * VertexBuffer.PositionKind
  87138. * * VertexBuffer.UVKind
  87139. * * VertexBuffer.UV2Kind
  87140. * * VertexBuffer.UV3Kind
  87141. * * VertexBuffer.UV4Kind
  87142. * * VertexBuffer.UV5Kind
  87143. * * VertexBuffer.UV6Kind
  87144. * * VertexBuffer.ColorKind
  87145. * * VertexBuffer.MatricesIndicesKind
  87146. * * VertexBuffer.MatricesIndicesExtraKind
  87147. * * VertexBuffer.MatricesWeightsKind
  87148. * * VertexBuffer.MatricesWeightsExtraKind
  87149. * @param data defines the data source
  87150. * @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
  87151. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  87152. * @returns the current mesh
  87153. */
  87154. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  87155. /**
  87156. * Sets the mesh indices,
  87157. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  87158. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  87159. * @param totalVertices Defines the total number of vertices
  87160. * @returns the current mesh
  87161. */
  87162. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  87163. /**
  87164. * Gets a boolean indicating if specific vertex data is present
  87165. * @param kind defines the vertex data kind to use
  87166. * @returns true is data kind is present
  87167. */
  87168. isVerticesDataPresent(kind: string): boolean;
  87169. /**
  87170. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  87171. * @returns a BoundingInfo
  87172. */
  87173. getBoundingInfo(): BoundingInfo;
  87174. /**
  87175. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87176. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87177. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87178. * @returns the current mesh
  87179. */
  87180. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  87181. /**
  87182. * Overwrite the current bounding info
  87183. * @param boundingInfo defines the new bounding info
  87184. * @returns the current mesh
  87185. */
  87186. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  87187. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  87188. readonly useBones: boolean;
  87189. /** @hidden */
  87190. _preActivate(): void;
  87191. /** @hidden */
  87192. _preActivateForIntermediateRendering(renderId: number): void;
  87193. /** @hidden */
  87194. _activate(renderId: number, intermediateRendering: boolean): boolean;
  87195. /** @hidden */
  87196. _postActivate(): void;
  87197. /** @hidden */
  87198. _freeze(): void;
  87199. /** @hidden */
  87200. _unFreeze(): void;
  87201. /**
  87202. * Gets the current world matrix
  87203. * @returns a Matrix
  87204. */
  87205. getWorldMatrix(): Matrix;
  87206. /** @hidden */
  87207. _getWorldMatrixDeterminant(): number;
  87208. /**
  87209. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  87210. */
  87211. readonly isAnInstance: boolean;
  87212. /**
  87213. * Perform relative position change from the point of view of behind the front of the mesh.
  87214. * This is performed taking into account the meshes current rotation, so you do not have to care.
  87215. * Supports definition of mesh facing forward or backward
  87216. * @param amountRight defines the distance on the right axis
  87217. * @param amountUp defines the distance on the up axis
  87218. * @param amountForward defines the distance on the forward axis
  87219. * @returns the current mesh
  87220. */
  87221. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  87222. /**
  87223. * Calculate relative position change from the point of view of behind the front of the mesh.
  87224. * This is performed taking into account the meshes current rotation, so you do not have to care.
  87225. * Supports definition of mesh facing forward or backward
  87226. * @param amountRight defines the distance on the right axis
  87227. * @param amountUp defines the distance on the up axis
  87228. * @param amountForward defines the distance on the forward axis
  87229. * @returns the new displacement vector
  87230. */
  87231. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  87232. /**
  87233. * Perform relative rotation change from the point of view of behind the front of the mesh.
  87234. * Supports definition of mesh facing forward or backward
  87235. * @param flipBack defines the flip
  87236. * @param twirlClockwise defines the twirl
  87237. * @param tiltRight defines the tilt
  87238. * @returns the current mesh
  87239. */
  87240. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  87241. /**
  87242. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  87243. * Supports definition of mesh facing forward or backward.
  87244. * @param flipBack defines the flip
  87245. * @param twirlClockwise defines the twirl
  87246. * @param tiltRight defines the tilt
  87247. * @returns the new rotation vector
  87248. */
  87249. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  87250. /**
  87251. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  87252. * This means the mesh underlying bounding box and sphere are recomputed.
  87253. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  87254. * @returns the current mesh
  87255. */
  87256. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  87257. /** @hidden */
  87258. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  87259. /** @hidden */
  87260. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  87261. /** @hidden */
  87262. _updateBoundingInfo(): AbstractMesh;
  87263. /** @hidden */
  87264. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  87265. /** @hidden */
  87266. protected _afterComputeWorldMatrix(): void;
  87267. /** @hidden */
  87268. readonly _effectiveMesh: AbstractMesh;
  87269. /**
  87270. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  87271. * A mesh is in the frustum if its bounding box intersects the frustum
  87272. * @param frustumPlanes defines the frustum to test
  87273. * @returns true if the mesh is in the frustum planes
  87274. */
  87275. isInFrustum(frustumPlanes: Plane[]): boolean;
  87276. /**
  87277. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  87278. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  87279. * @param frustumPlanes defines the frustum to test
  87280. * @returns true if the mesh is completely in the frustum planes
  87281. */
  87282. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87283. /**
  87284. * True if the mesh intersects another mesh or a SolidParticle object
  87285. * @param mesh defines a target mesh or SolidParticle to test
  87286. * @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)
  87287. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  87288. * @returns true if there is an intersection
  87289. */
  87290. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  87291. /**
  87292. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  87293. * @param point defines the point to test
  87294. * @returns true if there is an intersection
  87295. */
  87296. intersectsPoint(point: Vector3): boolean;
  87297. /**
  87298. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  87299. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87300. */
  87301. checkCollisions: boolean;
  87302. /**
  87303. * Gets Collider object used to compute collisions (not physics)
  87304. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87305. */
  87306. readonly collider: Nullable<Collider>;
  87307. /**
  87308. * Move the mesh using collision engine
  87309. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87310. * @param displacement defines the requested displacement vector
  87311. * @returns the current mesh
  87312. */
  87313. moveWithCollisions(displacement: Vector3): AbstractMesh;
  87314. private _onCollisionPositionChange;
  87315. /** @hidden */
  87316. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  87317. /** @hidden */
  87318. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  87319. /** @hidden */
  87320. _checkCollision(collider: Collider): AbstractMesh;
  87321. /** @hidden */
  87322. _generatePointsArray(): boolean;
  87323. /**
  87324. * Checks if the passed Ray intersects with the mesh
  87325. * @param ray defines the ray to use
  87326. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  87327. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  87328. * @returns the picking info
  87329. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87330. */
  87331. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  87332. /**
  87333. * Clones the current mesh
  87334. * @param name defines the mesh name
  87335. * @param newParent defines the new mesh parent
  87336. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  87337. * @returns the new mesh
  87338. */
  87339. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  87340. /**
  87341. * Disposes all the submeshes of the current meshnp
  87342. * @returns the current mesh
  87343. */
  87344. releaseSubMeshes(): AbstractMesh;
  87345. /**
  87346. * Releases resources associated with this abstract mesh.
  87347. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87348. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87349. */
  87350. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87351. /**
  87352. * Adds the passed mesh as a child to the current mesh
  87353. * @param mesh defines the child mesh
  87354. * @returns the current mesh
  87355. */
  87356. addChild(mesh: AbstractMesh): AbstractMesh;
  87357. /**
  87358. * Removes the passed mesh from the current mesh children list
  87359. * @param mesh defines the child mesh
  87360. * @returns the current mesh
  87361. */
  87362. removeChild(mesh: AbstractMesh): AbstractMesh;
  87363. /** @hidden */
  87364. private _initFacetData;
  87365. /**
  87366. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  87367. * This method can be called within the render loop.
  87368. * 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
  87369. * @returns the current mesh
  87370. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87371. */
  87372. updateFacetData(): AbstractMesh;
  87373. /**
  87374. * Returns the facetLocalNormals array.
  87375. * The normals are expressed in the mesh local spac
  87376. * @returns an array of Vector3
  87377. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87378. */
  87379. getFacetLocalNormals(): Vector3[];
  87380. /**
  87381. * Returns the facetLocalPositions array.
  87382. * The facet positions are expressed in the mesh local space
  87383. * @returns an array of Vector3
  87384. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87385. */
  87386. getFacetLocalPositions(): Vector3[];
  87387. /**
  87388. * Returns the facetLocalPartioning array
  87389. * @returns an array of array of numbers
  87390. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87391. */
  87392. getFacetLocalPartitioning(): number[][];
  87393. /**
  87394. * Returns the i-th facet position in the world system.
  87395. * This method allocates a new Vector3 per call
  87396. * @param i defines the facet index
  87397. * @returns a new Vector3
  87398. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87399. */
  87400. getFacetPosition(i: number): Vector3;
  87401. /**
  87402. * Sets the reference Vector3 with the i-th facet position in the world system
  87403. * @param i defines the facet index
  87404. * @param ref defines the target vector
  87405. * @returns the current mesh
  87406. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87407. */
  87408. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  87409. /**
  87410. * Returns the i-th facet normal in the world system.
  87411. * This method allocates a new Vector3 per call
  87412. * @param i defines the facet index
  87413. * @returns a new Vector3
  87414. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87415. */
  87416. getFacetNormal(i: number): Vector3;
  87417. /**
  87418. * Sets the reference Vector3 with the i-th facet normal in the world system
  87419. * @param i defines the facet index
  87420. * @param ref defines the target vector
  87421. * @returns the current mesh
  87422. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87423. */
  87424. getFacetNormalToRef(i: number, ref: Vector3): this;
  87425. /**
  87426. * 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)
  87427. * @param x defines x coordinate
  87428. * @param y defines y coordinate
  87429. * @param z defines z coordinate
  87430. * @returns the array of facet indexes
  87431. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87432. */
  87433. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  87434. /**
  87435. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  87436. * @param projected sets as the (x,y,z) world projection on the facet
  87437. * @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
  87438. * @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
  87439. * @param x defines x coordinate
  87440. * @param y defines y coordinate
  87441. * @param z defines z coordinate
  87442. * @returns the face index if found (or null instead)
  87443. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87444. */
  87445. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  87446. /**
  87447. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  87448. * @param projected sets as the (x,y,z) local projection on the facet
  87449. * @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
  87450. * @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
  87451. * @param x defines x coordinate
  87452. * @param y defines y coordinate
  87453. * @param z defines z coordinate
  87454. * @returns the face index if found (or null instead)
  87455. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87456. */
  87457. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  87458. /**
  87459. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  87460. * @returns the parameters
  87461. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87462. */
  87463. getFacetDataParameters(): any;
  87464. /**
  87465. * Disables the feature FacetData and frees the related memory
  87466. * @returns the current mesh
  87467. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87468. */
  87469. disableFacetData(): AbstractMesh;
  87470. /**
  87471. * Updates the AbstractMesh indices array
  87472. * @param indices defines the data source
  87473. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  87474. * @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)
  87475. * @returns the current mesh
  87476. */
  87477. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  87478. /**
  87479. * Creates new normals data for the mesh
  87480. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  87481. * @returns the current mesh
  87482. */
  87483. createNormals(updatable: boolean): AbstractMesh;
  87484. /**
  87485. * Align the mesh with a normal
  87486. * @param normal defines the normal to use
  87487. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  87488. * @returns the current mesh
  87489. */
  87490. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  87491. /** @hidden */
  87492. _checkOcclusionQuery(): boolean;
  87493. /**
  87494. * Disables the mesh edge rendering mode
  87495. * @returns the currentAbstractMesh
  87496. */
  87497. disableEdgesRendering(): AbstractMesh;
  87498. /**
  87499. * Enables the edge rendering mode on the mesh.
  87500. * This mode makes the mesh edges visible
  87501. * @param epsilon defines the maximal distance between two angles to detect a face
  87502. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  87503. * @returns the currentAbstractMesh
  87504. * @see https://www.babylonjs-playground.com/#19O9TU#0
  87505. */
  87506. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  87507. }
  87508. }
  87509. declare module BABYLON {
  87510. /**
  87511. * Interface used to define ActionEvent
  87512. */
  87513. export interface IActionEvent {
  87514. /** The mesh or sprite that triggered the action */
  87515. source: any;
  87516. /** The X mouse cursor position at the time of the event */
  87517. pointerX: number;
  87518. /** The Y mouse cursor position at the time of the event */
  87519. pointerY: number;
  87520. /** The mesh that is currently pointed at (can be null) */
  87521. meshUnderPointer: Nullable<AbstractMesh>;
  87522. /** the original (browser) event that triggered the ActionEvent */
  87523. sourceEvent?: any;
  87524. /** additional data for the event */
  87525. additionalData?: any;
  87526. }
  87527. /**
  87528. * ActionEvent is the event being sent when an action is triggered.
  87529. */
  87530. export class ActionEvent implements IActionEvent {
  87531. /** The mesh or sprite that triggered the action */
  87532. source: any;
  87533. /** The X mouse cursor position at the time of the event */
  87534. pointerX: number;
  87535. /** The Y mouse cursor position at the time of the event */
  87536. pointerY: number;
  87537. /** The mesh that is currently pointed at (can be null) */
  87538. meshUnderPointer: Nullable<AbstractMesh>;
  87539. /** the original (browser) event that triggered the ActionEvent */
  87540. sourceEvent?: any;
  87541. /** additional data for the event */
  87542. additionalData?: any;
  87543. /**
  87544. * Creates a new ActionEvent
  87545. * @param source The mesh or sprite that triggered the action
  87546. * @param pointerX The X mouse cursor position at the time of the event
  87547. * @param pointerY The Y mouse cursor position at the time of the event
  87548. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  87549. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  87550. * @param additionalData additional data for the event
  87551. */
  87552. constructor(
  87553. /** The mesh or sprite that triggered the action */
  87554. source: any,
  87555. /** The X mouse cursor position at the time of the event */
  87556. pointerX: number,
  87557. /** The Y mouse cursor position at the time of the event */
  87558. pointerY: number,
  87559. /** The mesh that is currently pointed at (can be null) */
  87560. meshUnderPointer: Nullable<AbstractMesh>,
  87561. /** the original (browser) event that triggered the ActionEvent */
  87562. sourceEvent?: any,
  87563. /** additional data for the event */
  87564. additionalData?: any);
  87565. /**
  87566. * Helper function to auto-create an ActionEvent from a source mesh.
  87567. * @param source The source mesh that triggered the event
  87568. * @param evt The original (browser) event
  87569. * @param additionalData additional data for the event
  87570. * @returns the new ActionEvent
  87571. */
  87572. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  87573. /**
  87574. * Helper function to auto-create an ActionEvent from a source sprite
  87575. * @param source The source sprite that triggered the event
  87576. * @param scene Scene associated with the sprite
  87577. * @param evt The original (browser) event
  87578. * @param additionalData additional data for the event
  87579. * @returns the new ActionEvent
  87580. */
  87581. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  87582. /**
  87583. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  87584. * @param scene the scene where the event occurred
  87585. * @param evt The original (browser) event
  87586. * @returns the new ActionEvent
  87587. */
  87588. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  87589. /**
  87590. * Helper function to auto-create an ActionEvent from a primitive
  87591. * @param prim defines the target primitive
  87592. * @param pointerPos defines the pointer position
  87593. * @param evt The original (browser) event
  87594. * @param additionalData additional data for the event
  87595. * @returns the new ActionEvent
  87596. */
  87597. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  87598. }
  87599. }
  87600. declare module BABYLON {
  87601. /**
  87602. * Abstract class used to decouple action Manager from scene and meshes.
  87603. * Do not instantiate.
  87604. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87605. */
  87606. export abstract class AbstractActionManager implements IDisposable {
  87607. /** Gets the list of active triggers */
  87608. static Triggers: {
  87609. [key: string]: number;
  87610. };
  87611. /** Gets the cursor to use when hovering items */
  87612. hoverCursor: string;
  87613. /** Gets the list of actions */
  87614. actions: IAction[];
  87615. /**
  87616. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  87617. */
  87618. isRecursive: boolean;
  87619. /**
  87620. * Releases all associated resources
  87621. */
  87622. abstract dispose(): void;
  87623. /**
  87624. * Does this action manager has pointer triggers
  87625. */
  87626. abstract readonly hasPointerTriggers: boolean;
  87627. /**
  87628. * Does this action manager has pick triggers
  87629. */
  87630. abstract readonly hasPickTriggers: boolean;
  87631. /**
  87632. * Process a specific trigger
  87633. * @param trigger defines the trigger to process
  87634. * @param evt defines the event details to be processed
  87635. */
  87636. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  87637. /**
  87638. * Does this action manager handles actions of any of the given triggers
  87639. * @param triggers defines the triggers to be tested
  87640. * @return a boolean indicating whether one (or more) of the triggers is handled
  87641. */
  87642. abstract hasSpecificTriggers(triggers: number[]): boolean;
  87643. /**
  87644. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  87645. * speed.
  87646. * @param triggerA defines the trigger to be tested
  87647. * @param triggerB defines the trigger to be tested
  87648. * @return a boolean indicating whether one (or more) of the triggers is handled
  87649. */
  87650. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  87651. /**
  87652. * Does this action manager handles actions of a given trigger
  87653. * @param trigger defines the trigger to be tested
  87654. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  87655. * @return whether the trigger is handled
  87656. */
  87657. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  87658. /**
  87659. * Serialize this manager to a JSON object
  87660. * @param name defines the property name to store this manager
  87661. * @returns a JSON representation of this manager
  87662. */
  87663. abstract serialize(name: string): any;
  87664. /**
  87665. * Registers an action to this action manager
  87666. * @param action defines the action to be registered
  87667. * @return the action amended (prepared) after registration
  87668. */
  87669. abstract registerAction(action: IAction): Nullable<IAction>;
  87670. /**
  87671. * Unregisters an action to this action manager
  87672. * @param action defines the action to be unregistered
  87673. * @return a boolean indicating whether the action has been unregistered
  87674. */
  87675. abstract unregisterAction(action: IAction): Boolean;
  87676. /**
  87677. * Does exist one action manager with at least one trigger
  87678. **/
  87679. static readonly HasTriggers: boolean;
  87680. /**
  87681. * Does exist one action manager with at least one pick trigger
  87682. **/
  87683. static readonly HasPickTriggers: boolean;
  87684. /**
  87685. * Does exist one action manager that handles actions of a given trigger
  87686. * @param trigger defines the trigger to be tested
  87687. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  87688. **/
  87689. static HasSpecificTrigger(trigger: number): boolean;
  87690. }
  87691. }
  87692. declare module BABYLON {
  87693. /**
  87694. * Defines how a node can be built from a string name.
  87695. */
  87696. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  87697. /**
  87698. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  87699. */
  87700. export class Node implements IBehaviorAware<Node> {
  87701. /** @hidden */
  87702. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  87703. private static _NodeConstructors;
  87704. /**
  87705. * Add a new node constructor
  87706. * @param type defines the type name of the node to construct
  87707. * @param constructorFunc defines the constructor function
  87708. */
  87709. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  87710. /**
  87711. * Returns a node constructor based on type name
  87712. * @param type defines the type name
  87713. * @param name defines the new node name
  87714. * @param scene defines the hosting scene
  87715. * @param options defines optional options to transmit to constructors
  87716. * @returns the new constructor or null
  87717. */
  87718. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  87719. /**
  87720. * Gets or sets the name of the node
  87721. */
  87722. name: string;
  87723. /**
  87724. * Gets or sets the id of the node
  87725. */
  87726. id: string;
  87727. /**
  87728. * Gets or sets the unique id of the node
  87729. */
  87730. uniqueId: number;
  87731. /**
  87732. * Gets or sets a string used to store user defined state for the node
  87733. */
  87734. state: string;
  87735. /**
  87736. * Gets or sets an object used to store user defined information for the node
  87737. */
  87738. metadata: any;
  87739. /**
  87740. * For internal use only. Please do not use.
  87741. */
  87742. reservedDataStore: any;
  87743. /**
  87744. * List of inspectable custom properties (used by the Inspector)
  87745. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  87746. */
  87747. inspectableCustomProperties: IInspectable[];
  87748. /**
  87749. * Gets or sets a boolean used to define if the node must be serialized
  87750. */
  87751. doNotSerialize: boolean;
  87752. /** @hidden */
  87753. _isDisposed: boolean;
  87754. /**
  87755. * Gets a list of Animations associated with the node
  87756. */
  87757. animations: Animation[];
  87758. protected _ranges: {
  87759. [name: string]: Nullable<AnimationRange>;
  87760. };
  87761. /**
  87762. * Callback raised when the node is ready to be used
  87763. */
  87764. onReady: Nullable<(node: Node) => void>;
  87765. private _isEnabled;
  87766. private _isParentEnabled;
  87767. private _isReady;
  87768. /** @hidden */
  87769. _currentRenderId: number;
  87770. private _parentUpdateId;
  87771. /** @hidden */
  87772. _childUpdateId: number;
  87773. /** @hidden */
  87774. _waitingParentId: Nullable<string>;
  87775. /** @hidden */
  87776. _scene: Scene;
  87777. /** @hidden */
  87778. _cache: any;
  87779. private _parentNode;
  87780. private _children;
  87781. /** @hidden */
  87782. _worldMatrix: Matrix;
  87783. /** @hidden */
  87784. _worldMatrixDeterminant: number;
  87785. /** @hidden */
  87786. _worldMatrixDeterminantIsDirty: boolean;
  87787. /** @hidden */
  87788. private _sceneRootNodesIndex;
  87789. /**
  87790. * Gets a boolean indicating if the node has been disposed
  87791. * @returns true if the node was disposed
  87792. */
  87793. isDisposed(): boolean;
  87794. /**
  87795. * Gets or sets the parent of the node (without keeping the current position in the scene)
  87796. * @see https://doc.babylonjs.com/how_to/parenting
  87797. */
  87798. parent: Nullable<Node>;
  87799. private addToSceneRootNodes;
  87800. private removeFromSceneRootNodes;
  87801. private _animationPropertiesOverride;
  87802. /**
  87803. * Gets or sets the animation properties override
  87804. */
  87805. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  87806. /**
  87807. * Gets a string idenfifying the name of the class
  87808. * @returns "Node" string
  87809. */
  87810. getClassName(): string;
  87811. /** @hidden */
  87812. readonly _isNode: boolean;
  87813. /**
  87814. * An event triggered when the mesh is disposed
  87815. */
  87816. onDisposeObservable: Observable<Node>;
  87817. private _onDisposeObserver;
  87818. /**
  87819. * Sets a callback that will be raised when the node will be disposed
  87820. */
  87821. onDispose: () => void;
  87822. /**
  87823. * Creates a new Node
  87824. * @param name the name and id to be given to this node
  87825. * @param scene the scene this node will be added to
  87826. * @param addToRootNodes the node will be added to scene.rootNodes
  87827. */
  87828. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  87829. /**
  87830. * Gets the scene of the node
  87831. * @returns a scene
  87832. */
  87833. getScene(): Scene;
  87834. /**
  87835. * Gets the engine of the node
  87836. * @returns a Engine
  87837. */
  87838. getEngine(): Engine;
  87839. private _behaviors;
  87840. /**
  87841. * Attach a behavior to the node
  87842. * @see http://doc.babylonjs.com/features/behaviour
  87843. * @param behavior defines the behavior to attach
  87844. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  87845. * @returns the current Node
  87846. */
  87847. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  87848. /**
  87849. * Remove an attached behavior
  87850. * @see http://doc.babylonjs.com/features/behaviour
  87851. * @param behavior defines the behavior to attach
  87852. * @returns the current Node
  87853. */
  87854. removeBehavior(behavior: Behavior<Node>): Node;
  87855. /**
  87856. * Gets the list of attached behaviors
  87857. * @see http://doc.babylonjs.com/features/behaviour
  87858. */
  87859. readonly behaviors: Behavior<Node>[];
  87860. /**
  87861. * Gets an attached behavior by name
  87862. * @param name defines the name of the behavior to look for
  87863. * @see http://doc.babylonjs.com/features/behaviour
  87864. * @returns null if behavior was not found else the requested behavior
  87865. */
  87866. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  87867. /**
  87868. * Returns the latest update of the World matrix
  87869. * @returns a Matrix
  87870. */
  87871. getWorldMatrix(): Matrix;
  87872. /** @hidden */
  87873. _getWorldMatrixDeterminant(): number;
  87874. /**
  87875. * Returns directly the latest state of the mesh World matrix.
  87876. * A Matrix is returned.
  87877. */
  87878. readonly worldMatrixFromCache: Matrix;
  87879. /** @hidden */
  87880. _initCache(): void;
  87881. /** @hidden */
  87882. updateCache(force?: boolean): void;
  87883. /** @hidden */
  87884. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  87885. /** @hidden */
  87886. _updateCache(ignoreParentClass?: boolean): void;
  87887. /** @hidden */
  87888. _isSynchronized(): boolean;
  87889. /** @hidden */
  87890. _markSyncedWithParent(): void;
  87891. /** @hidden */
  87892. isSynchronizedWithParent(): boolean;
  87893. /** @hidden */
  87894. isSynchronized(): boolean;
  87895. /**
  87896. * Is this node ready to be used/rendered
  87897. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  87898. * @return true if the node is ready
  87899. */
  87900. isReady(completeCheck?: boolean): boolean;
  87901. /**
  87902. * Is this node enabled?
  87903. * 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
  87904. * @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
  87905. * @return whether this node (and its parent) is enabled
  87906. */
  87907. isEnabled(checkAncestors?: boolean): boolean;
  87908. /** @hidden */
  87909. protected _syncParentEnabledState(): void;
  87910. /**
  87911. * Set the enabled state of this node
  87912. * @param value defines the new enabled state
  87913. */
  87914. setEnabled(value: boolean): void;
  87915. /**
  87916. * Is this node a descendant of the given node?
  87917. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  87918. * @param ancestor defines the parent node to inspect
  87919. * @returns a boolean indicating if this node is a descendant of the given node
  87920. */
  87921. isDescendantOf(ancestor: Node): boolean;
  87922. /** @hidden */
  87923. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  87924. /**
  87925. * Will return all nodes that have this node as ascendant
  87926. * @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
  87927. * @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
  87928. * @return all children nodes of all types
  87929. */
  87930. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  87931. /**
  87932. * Get all child-meshes of this node
  87933. * @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)
  87934. * @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
  87935. * @returns an array of AbstractMesh
  87936. */
  87937. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  87938. /**
  87939. * Get all direct children of this node
  87940. * @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
  87941. * @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)
  87942. * @returns an array of Node
  87943. */
  87944. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  87945. /** @hidden */
  87946. _setReady(state: boolean): void;
  87947. /**
  87948. * Get an animation by name
  87949. * @param name defines the name of the animation to look for
  87950. * @returns null if not found else the requested animation
  87951. */
  87952. getAnimationByName(name: string): Nullable<Animation>;
  87953. /**
  87954. * Creates an animation range for this node
  87955. * @param name defines the name of the range
  87956. * @param from defines the starting key
  87957. * @param to defines the end key
  87958. */
  87959. createAnimationRange(name: string, from: number, to: number): void;
  87960. /**
  87961. * Delete a specific animation range
  87962. * @param name defines the name of the range to delete
  87963. * @param deleteFrames defines if animation frames from the range must be deleted as well
  87964. */
  87965. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  87966. /**
  87967. * Get an animation range by name
  87968. * @param name defines the name of the animation range to look for
  87969. * @returns null if not found else the requested animation range
  87970. */
  87971. getAnimationRange(name: string): Nullable<AnimationRange>;
  87972. /**
  87973. * Gets the list of all animation ranges defined on this node
  87974. * @returns an array
  87975. */
  87976. getAnimationRanges(): Nullable<AnimationRange>[];
  87977. /**
  87978. * Will start the animation sequence
  87979. * @param name defines the range frames for animation sequence
  87980. * @param loop defines if the animation should loop (false by default)
  87981. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  87982. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  87983. * @returns the object created for this animation. If range does not exist, it will return null
  87984. */
  87985. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  87986. /**
  87987. * Serialize animation ranges into a JSON compatible object
  87988. * @returns serialization object
  87989. */
  87990. serializeAnimationRanges(): any;
  87991. /**
  87992. * Computes the world matrix of the node
  87993. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87994. * @returns the world matrix
  87995. */
  87996. computeWorldMatrix(force?: boolean): Matrix;
  87997. /**
  87998. * Releases resources associated with this node.
  87999. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88000. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88001. */
  88002. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88003. /**
  88004. * Parse animation range data from a serialization object and store them into a given node
  88005. * @param node defines where to store the animation ranges
  88006. * @param parsedNode defines the serialization object to read data from
  88007. * @param scene defines the hosting scene
  88008. */
  88009. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  88010. /**
  88011. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  88012. * @param includeDescendants Include bounding info from descendants as well (true by default)
  88013. * @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
  88014. * @returns the new bounding vectors
  88015. */
  88016. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  88017. min: Vector3;
  88018. max: Vector3;
  88019. };
  88020. }
  88021. }
  88022. declare module BABYLON {
  88023. /**
  88024. * @hidden
  88025. */
  88026. export class _IAnimationState {
  88027. key: number;
  88028. repeatCount: number;
  88029. workValue?: any;
  88030. loopMode?: number;
  88031. offsetValue?: any;
  88032. highLimitValue?: any;
  88033. }
  88034. /**
  88035. * Class used to store any kind of animation
  88036. */
  88037. export class Animation {
  88038. /**Name of the animation */
  88039. name: string;
  88040. /**Property to animate */
  88041. targetProperty: string;
  88042. /**The frames per second of the animation */
  88043. framePerSecond: number;
  88044. /**The data type of the animation */
  88045. dataType: number;
  88046. /**The loop mode of the animation */
  88047. loopMode?: number | undefined;
  88048. /**Specifies if blending should be enabled */
  88049. enableBlending?: boolean | undefined;
  88050. /**
  88051. * Use matrix interpolation instead of using direct key value when animating matrices
  88052. */
  88053. static AllowMatricesInterpolation: boolean;
  88054. /**
  88055. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  88056. */
  88057. static AllowMatrixDecomposeForInterpolation: boolean;
  88058. /**
  88059. * Stores the key frames of the animation
  88060. */
  88061. private _keys;
  88062. /**
  88063. * Stores the easing function of the animation
  88064. */
  88065. private _easingFunction;
  88066. /**
  88067. * @hidden Internal use only
  88068. */
  88069. _runtimeAnimations: RuntimeAnimation[];
  88070. /**
  88071. * The set of event that will be linked to this animation
  88072. */
  88073. private _events;
  88074. /**
  88075. * Stores an array of target property paths
  88076. */
  88077. targetPropertyPath: string[];
  88078. /**
  88079. * Stores the blending speed of the animation
  88080. */
  88081. blendingSpeed: number;
  88082. /**
  88083. * Stores the animation ranges for the animation
  88084. */
  88085. private _ranges;
  88086. /**
  88087. * @hidden Internal use
  88088. */
  88089. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  88090. /**
  88091. * Sets up an animation
  88092. * @param property The property to animate
  88093. * @param animationType The animation type to apply
  88094. * @param framePerSecond The frames per second of the animation
  88095. * @param easingFunction The easing function used in the animation
  88096. * @returns The created animation
  88097. */
  88098. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  88099. /**
  88100. * Create and start an animation on a node
  88101. * @param name defines the name of the global animation that will be run on all nodes
  88102. * @param node defines the root node where the animation will take place
  88103. * @param targetProperty defines property to animate
  88104. * @param framePerSecond defines the number of frame per second yo use
  88105. * @param totalFrame defines the number of frames in total
  88106. * @param from defines the initial value
  88107. * @param to defines the final value
  88108. * @param loopMode defines which loop mode you want to use (off by default)
  88109. * @param easingFunction defines the easing function to use (linear by default)
  88110. * @param onAnimationEnd defines the callback to call when animation end
  88111. * @returns the animatable created for this animation
  88112. */
  88113. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  88114. /**
  88115. * Create and start an animation on a node and its descendants
  88116. * @param name defines the name of the global animation that will be run on all nodes
  88117. * @param node defines the root node where the animation will take place
  88118. * @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
  88119. * @param targetProperty defines property to animate
  88120. * @param framePerSecond defines the number of frame per second to use
  88121. * @param totalFrame defines the number of frames in total
  88122. * @param from defines the initial value
  88123. * @param to defines the final value
  88124. * @param loopMode defines which loop mode you want to use (off by default)
  88125. * @param easingFunction defines the easing function to use (linear by default)
  88126. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88127. * @returns the list of animatables created for all nodes
  88128. * @example https://www.babylonjs-playground.com/#MH0VLI
  88129. */
  88130. 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[]>;
  88131. /**
  88132. * Creates a new animation, merges it with the existing animations and starts it
  88133. * @param name Name of the animation
  88134. * @param node Node which contains the scene that begins the animations
  88135. * @param targetProperty Specifies which property to animate
  88136. * @param framePerSecond The frames per second of the animation
  88137. * @param totalFrame The total number of frames
  88138. * @param from The frame at the beginning of the animation
  88139. * @param to The frame at the end of the animation
  88140. * @param loopMode Specifies the loop mode of the animation
  88141. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  88142. * @param onAnimationEnd Callback to run once the animation is complete
  88143. * @returns Nullable animation
  88144. */
  88145. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  88146. /**
  88147. * Transition property of an host to the target Value
  88148. * @param property The property to transition
  88149. * @param targetValue The target Value of the property
  88150. * @param host The object where the property to animate belongs
  88151. * @param scene Scene used to run the animation
  88152. * @param frameRate Framerate (in frame/s) to use
  88153. * @param transition The transition type we want to use
  88154. * @param duration The duration of the animation, in milliseconds
  88155. * @param onAnimationEnd Callback trigger at the end of the animation
  88156. * @returns Nullable animation
  88157. */
  88158. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  88159. /**
  88160. * Return the array of runtime animations currently using this animation
  88161. */
  88162. readonly runtimeAnimations: RuntimeAnimation[];
  88163. /**
  88164. * Specifies if any of the runtime animations are currently running
  88165. */
  88166. readonly hasRunningRuntimeAnimations: boolean;
  88167. /**
  88168. * Initializes the animation
  88169. * @param name Name of the animation
  88170. * @param targetProperty Property to animate
  88171. * @param framePerSecond The frames per second of the animation
  88172. * @param dataType The data type of the animation
  88173. * @param loopMode The loop mode of the animation
  88174. * @param enableBlending Specifies if blending should be enabled
  88175. */
  88176. constructor(
  88177. /**Name of the animation */
  88178. name: string,
  88179. /**Property to animate */
  88180. targetProperty: string,
  88181. /**The frames per second of the animation */
  88182. framePerSecond: number,
  88183. /**The data type of the animation */
  88184. dataType: number,
  88185. /**The loop mode of the animation */
  88186. loopMode?: number | undefined,
  88187. /**Specifies if blending should be enabled */
  88188. enableBlending?: boolean | undefined);
  88189. /**
  88190. * Converts the animation to a string
  88191. * @param fullDetails support for multiple levels of logging within scene loading
  88192. * @returns String form of the animation
  88193. */
  88194. toString(fullDetails?: boolean): string;
  88195. /**
  88196. * Add an event to this animation
  88197. * @param event Event to add
  88198. */
  88199. addEvent(event: AnimationEvent): void;
  88200. /**
  88201. * Remove all events found at the given frame
  88202. * @param frame The frame to remove events from
  88203. */
  88204. removeEvents(frame: number): void;
  88205. /**
  88206. * Retrieves all the events from the animation
  88207. * @returns Events from the animation
  88208. */
  88209. getEvents(): AnimationEvent[];
  88210. /**
  88211. * Creates an animation range
  88212. * @param name Name of the animation range
  88213. * @param from Starting frame of the animation range
  88214. * @param to Ending frame of the animation
  88215. */
  88216. createRange(name: string, from: number, to: number): void;
  88217. /**
  88218. * Deletes an animation range by name
  88219. * @param name Name of the animation range to delete
  88220. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  88221. */
  88222. deleteRange(name: string, deleteFrames?: boolean): void;
  88223. /**
  88224. * Gets the animation range by name, or null if not defined
  88225. * @param name Name of the animation range
  88226. * @returns Nullable animation range
  88227. */
  88228. getRange(name: string): Nullable<AnimationRange>;
  88229. /**
  88230. * Gets the key frames from the animation
  88231. * @returns The key frames of the animation
  88232. */
  88233. getKeys(): Array<IAnimationKey>;
  88234. /**
  88235. * Gets the highest frame rate of the animation
  88236. * @returns Highest frame rate of the animation
  88237. */
  88238. getHighestFrame(): number;
  88239. /**
  88240. * Gets the easing function of the animation
  88241. * @returns Easing function of the animation
  88242. */
  88243. getEasingFunction(): IEasingFunction;
  88244. /**
  88245. * Sets the easing function of the animation
  88246. * @param easingFunction A custom mathematical formula for animation
  88247. */
  88248. setEasingFunction(easingFunction: EasingFunction): void;
  88249. /**
  88250. * Interpolates a scalar linearly
  88251. * @param startValue Start value of the animation curve
  88252. * @param endValue End value of the animation curve
  88253. * @param gradient Scalar amount to interpolate
  88254. * @returns Interpolated scalar value
  88255. */
  88256. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  88257. /**
  88258. * Interpolates a scalar cubically
  88259. * @param startValue Start value of the animation curve
  88260. * @param outTangent End tangent of the animation
  88261. * @param endValue End value of the animation curve
  88262. * @param inTangent Start tangent of the animation curve
  88263. * @param gradient Scalar amount to interpolate
  88264. * @returns Interpolated scalar value
  88265. */
  88266. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  88267. /**
  88268. * Interpolates a quaternion using a spherical linear interpolation
  88269. * @param startValue Start value of the animation curve
  88270. * @param endValue End value of the animation curve
  88271. * @param gradient Scalar amount to interpolate
  88272. * @returns Interpolated quaternion value
  88273. */
  88274. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  88275. /**
  88276. * Interpolates a quaternion cubically
  88277. * @param startValue Start value of the animation curve
  88278. * @param outTangent End tangent of the animation curve
  88279. * @param endValue End value of the animation curve
  88280. * @param inTangent Start tangent of the animation curve
  88281. * @param gradient Scalar amount to interpolate
  88282. * @returns Interpolated quaternion value
  88283. */
  88284. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  88285. /**
  88286. * Interpolates a Vector3 linearl
  88287. * @param startValue Start value of the animation curve
  88288. * @param endValue End value of the animation curve
  88289. * @param gradient Scalar amount to interpolate
  88290. * @returns Interpolated scalar value
  88291. */
  88292. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  88293. /**
  88294. * Interpolates a Vector3 cubically
  88295. * @param startValue Start value of the animation curve
  88296. * @param outTangent End tangent of the animation
  88297. * @param endValue End value of the animation curve
  88298. * @param inTangent Start tangent of the animation curve
  88299. * @param gradient Scalar amount to interpolate
  88300. * @returns InterpolatedVector3 value
  88301. */
  88302. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  88303. /**
  88304. * Interpolates a Vector2 linearly
  88305. * @param startValue Start value of the animation curve
  88306. * @param endValue End value of the animation curve
  88307. * @param gradient Scalar amount to interpolate
  88308. * @returns Interpolated Vector2 value
  88309. */
  88310. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  88311. /**
  88312. * Interpolates a Vector2 cubically
  88313. * @param startValue Start value of the animation curve
  88314. * @param outTangent End tangent of the animation
  88315. * @param endValue End value of the animation curve
  88316. * @param inTangent Start tangent of the animation curve
  88317. * @param gradient Scalar amount to interpolate
  88318. * @returns Interpolated Vector2 value
  88319. */
  88320. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  88321. /**
  88322. * Interpolates a size linearly
  88323. * @param startValue Start value of the animation curve
  88324. * @param endValue End value of the animation curve
  88325. * @param gradient Scalar amount to interpolate
  88326. * @returns Interpolated Size value
  88327. */
  88328. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  88329. /**
  88330. * Interpolates a Color3 linearly
  88331. * @param startValue Start value of the animation curve
  88332. * @param endValue End value of the animation curve
  88333. * @param gradient Scalar amount to interpolate
  88334. * @returns Interpolated Color3 value
  88335. */
  88336. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  88337. /**
  88338. * @hidden Internal use only
  88339. */
  88340. _getKeyValue(value: any): any;
  88341. /**
  88342. * @hidden Internal use only
  88343. */
  88344. _interpolate(currentFrame: number, state: _IAnimationState): any;
  88345. /**
  88346. * Defines the function to use to interpolate matrices
  88347. * @param startValue defines the start matrix
  88348. * @param endValue defines the end matrix
  88349. * @param gradient defines the gradient between both matrices
  88350. * @param result defines an optional target matrix where to store the interpolation
  88351. * @returns the interpolated matrix
  88352. */
  88353. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  88354. /**
  88355. * Makes a copy of the animation
  88356. * @returns Cloned animation
  88357. */
  88358. clone(): Animation;
  88359. /**
  88360. * Sets the key frames of the animation
  88361. * @param values The animation key frames to set
  88362. */
  88363. setKeys(values: Array<IAnimationKey>): void;
  88364. /**
  88365. * Serializes the animation to an object
  88366. * @returns Serialized object
  88367. */
  88368. serialize(): any;
  88369. /**
  88370. * Float animation type
  88371. */
  88372. private static _ANIMATIONTYPE_FLOAT;
  88373. /**
  88374. * Vector3 animation type
  88375. */
  88376. private static _ANIMATIONTYPE_VECTOR3;
  88377. /**
  88378. * Quaternion animation type
  88379. */
  88380. private static _ANIMATIONTYPE_QUATERNION;
  88381. /**
  88382. * Matrix animation type
  88383. */
  88384. private static _ANIMATIONTYPE_MATRIX;
  88385. /**
  88386. * Color3 animation type
  88387. */
  88388. private static _ANIMATIONTYPE_COLOR3;
  88389. /**
  88390. * Vector2 animation type
  88391. */
  88392. private static _ANIMATIONTYPE_VECTOR2;
  88393. /**
  88394. * Size animation type
  88395. */
  88396. private static _ANIMATIONTYPE_SIZE;
  88397. /**
  88398. * Relative Loop Mode
  88399. */
  88400. private static _ANIMATIONLOOPMODE_RELATIVE;
  88401. /**
  88402. * Cycle Loop Mode
  88403. */
  88404. private static _ANIMATIONLOOPMODE_CYCLE;
  88405. /**
  88406. * Constant Loop Mode
  88407. */
  88408. private static _ANIMATIONLOOPMODE_CONSTANT;
  88409. /**
  88410. * Get the float animation type
  88411. */
  88412. static readonly ANIMATIONTYPE_FLOAT: number;
  88413. /**
  88414. * Get the Vector3 animation type
  88415. */
  88416. static readonly ANIMATIONTYPE_VECTOR3: number;
  88417. /**
  88418. * Get the Vector2 animation type
  88419. */
  88420. static readonly ANIMATIONTYPE_VECTOR2: number;
  88421. /**
  88422. * Get the Size animation type
  88423. */
  88424. static readonly ANIMATIONTYPE_SIZE: number;
  88425. /**
  88426. * Get the Quaternion animation type
  88427. */
  88428. static readonly ANIMATIONTYPE_QUATERNION: number;
  88429. /**
  88430. * Get the Matrix animation type
  88431. */
  88432. static readonly ANIMATIONTYPE_MATRIX: number;
  88433. /**
  88434. * Get the Color3 animation type
  88435. */
  88436. static readonly ANIMATIONTYPE_COLOR3: number;
  88437. /**
  88438. * Get the Relative Loop Mode
  88439. */
  88440. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  88441. /**
  88442. * Get the Cycle Loop Mode
  88443. */
  88444. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  88445. /**
  88446. * Get the Constant Loop Mode
  88447. */
  88448. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  88449. /** @hidden */
  88450. static _UniversalLerp(left: any, right: any, amount: number): any;
  88451. /**
  88452. * Parses an animation object and creates an animation
  88453. * @param parsedAnimation Parsed animation object
  88454. * @returns Animation object
  88455. */
  88456. static Parse(parsedAnimation: any): Animation;
  88457. /**
  88458. * Appends the serialized animations from the source animations
  88459. * @param source Source containing the animations
  88460. * @param destination Target to store the animations
  88461. */
  88462. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  88463. }
  88464. }
  88465. declare module BABYLON {
  88466. /**
  88467. * Base class of all the textures in babylon.
  88468. * It groups all the common properties the materials, post process, lights... might need
  88469. * in order to make a correct use of the texture.
  88470. */
  88471. export class BaseTexture implements IAnimatable {
  88472. /**
  88473. * Default anisotropic filtering level for the application.
  88474. * It is set to 4 as a good tradeoff between perf and quality.
  88475. */
  88476. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  88477. /**
  88478. * Gets or sets the unique id of the texture
  88479. */
  88480. uniqueId: number;
  88481. /**
  88482. * Define the name of the texture.
  88483. */
  88484. name: string;
  88485. /**
  88486. * Gets or sets an object used to store user defined information.
  88487. */
  88488. metadata: any;
  88489. /**
  88490. * For internal use only. Please do not use.
  88491. */
  88492. reservedDataStore: any;
  88493. private _hasAlpha;
  88494. /**
  88495. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  88496. */
  88497. hasAlpha: boolean;
  88498. /**
  88499. * Defines if the alpha value should be determined via the rgb values.
  88500. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  88501. */
  88502. getAlphaFromRGB: boolean;
  88503. /**
  88504. * Intensity or strength of the texture.
  88505. * It is commonly used by materials to fine tune the intensity of the texture
  88506. */
  88507. level: number;
  88508. /**
  88509. * Define the UV chanel to use starting from 0 and defaulting to 0.
  88510. * This is part of the texture as textures usually maps to one uv set.
  88511. */
  88512. coordinatesIndex: number;
  88513. private _coordinatesMode;
  88514. /**
  88515. * How a texture is mapped.
  88516. *
  88517. * | Value | Type | Description |
  88518. * | ----- | ----------------------------------- | ----------- |
  88519. * | 0 | EXPLICIT_MODE | |
  88520. * | 1 | SPHERICAL_MODE | |
  88521. * | 2 | PLANAR_MODE | |
  88522. * | 3 | CUBIC_MODE | |
  88523. * | 4 | PROJECTION_MODE | |
  88524. * | 5 | SKYBOX_MODE | |
  88525. * | 6 | INVCUBIC_MODE | |
  88526. * | 7 | EQUIRECTANGULAR_MODE | |
  88527. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  88528. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  88529. */
  88530. coordinatesMode: number;
  88531. /**
  88532. * | Value | Type | Description |
  88533. * | ----- | ------------------ | ----------- |
  88534. * | 0 | CLAMP_ADDRESSMODE | |
  88535. * | 1 | WRAP_ADDRESSMODE | |
  88536. * | 2 | MIRROR_ADDRESSMODE | |
  88537. */
  88538. wrapU: number;
  88539. /**
  88540. * | Value | Type | Description |
  88541. * | ----- | ------------------ | ----------- |
  88542. * | 0 | CLAMP_ADDRESSMODE | |
  88543. * | 1 | WRAP_ADDRESSMODE | |
  88544. * | 2 | MIRROR_ADDRESSMODE | |
  88545. */
  88546. wrapV: number;
  88547. /**
  88548. * | Value | Type | Description |
  88549. * | ----- | ------------------ | ----------- |
  88550. * | 0 | CLAMP_ADDRESSMODE | |
  88551. * | 1 | WRAP_ADDRESSMODE | |
  88552. * | 2 | MIRROR_ADDRESSMODE | |
  88553. */
  88554. wrapR: number;
  88555. /**
  88556. * With compliant hardware and browser (supporting anisotropic filtering)
  88557. * this defines the level of anisotropic filtering in the texture.
  88558. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  88559. */
  88560. anisotropicFilteringLevel: number;
  88561. /**
  88562. * Define if the texture is a cube texture or if false a 2d texture.
  88563. */
  88564. isCube: boolean;
  88565. /**
  88566. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  88567. */
  88568. is3D: boolean;
  88569. /**
  88570. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  88571. * HDR texture are usually stored in linear space.
  88572. * This only impacts the PBR and Background materials
  88573. */
  88574. gammaSpace: boolean;
  88575. /**
  88576. * Gets whether or not the texture contains RGBD data.
  88577. */
  88578. readonly isRGBD: boolean;
  88579. /**
  88580. * Is Z inverted in the texture (useful in a cube texture).
  88581. */
  88582. invertZ: boolean;
  88583. /**
  88584. * Are mip maps generated for this texture or not.
  88585. */
  88586. readonly noMipmap: boolean;
  88587. /**
  88588. * @hidden
  88589. */
  88590. lodLevelInAlpha: boolean;
  88591. /**
  88592. * With prefiltered texture, defined the offset used during the prefiltering steps.
  88593. */
  88594. lodGenerationOffset: number;
  88595. /**
  88596. * With prefiltered texture, defined the scale used during the prefiltering steps.
  88597. */
  88598. lodGenerationScale: number;
  88599. /**
  88600. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  88601. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  88602. * average roughness values.
  88603. */
  88604. linearSpecularLOD: boolean;
  88605. /**
  88606. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  88607. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  88608. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  88609. */
  88610. irradianceTexture: Nullable<BaseTexture>;
  88611. /**
  88612. * Define if the texture is a render target.
  88613. */
  88614. isRenderTarget: boolean;
  88615. /**
  88616. * Define the unique id of the texture in the scene.
  88617. */
  88618. readonly uid: string;
  88619. /**
  88620. * Return a string representation of the texture.
  88621. * @returns the texture as a string
  88622. */
  88623. toString(): string;
  88624. /**
  88625. * Get the class name of the texture.
  88626. * @returns "BaseTexture"
  88627. */
  88628. getClassName(): string;
  88629. /**
  88630. * Define the list of animation attached to the texture.
  88631. */
  88632. animations: Animation[];
  88633. /**
  88634. * An event triggered when the texture is disposed.
  88635. */
  88636. onDisposeObservable: Observable<BaseTexture>;
  88637. private _onDisposeObserver;
  88638. /**
  88639. * Callback triggered when the texture has been disposed.
  88640. * Kept for back compatibility, you can use the onDisposeObservable instead.
  88641. */
  88642. onDispose: () => void;
  88643. /**
  88644. * Define the current state of the loading sequence when in delayed load mode.
  88645. */
  88646. delayLoadState: number;
  88647. private _scene;
  88648. /** @hidden */
  88649. _texture: Nullable<InternalTexture>;
  88650. private _uid;
  88651. /**
  88652. * Define if the texture is preventinga material to render or not.
  88653. * If not and the texture is not ready, the engine will use a default black texture instead.
  88654. */
  88655. readonly isBlocking: boolean;
  88656. /**
  88657. * Instantiates a new BaseTexture.
  88658. * Base class of all the textures in babylon.
  88659. * It groups all the common properties the materials, post process, lights... might need
  88660. * in order to make a correct use of the texture.
  88661. * @param scene Define the scene the texture blongs to
  88662. */
  88663. constructor(scene: Nullable<Scene>);
  88664. /**
  88665. * Get the scene the texture belongs to.
  88666. * @returns the scene or null if undefined
  88667. */
  88668. getScene(): Nullable<Scene>;
  88669. /**
  88670. * Get the texture transform matrix used to offset tile the texture for istance.
  88671. * @returns the transformation matrix
  88672. */
  88673. getTextureMatrix(): Matrix;
  88674. /**
  88675. * Get the texture reflection matrix used to rotate/transform the reflection.
  88676. * @returns the reflection matrix
  88677. */
  88678. getReflectionTextureMatrix(): Matrix;
  88679. /**
  88680. * Get the underlying lower level texture from Babylon.
  88681. * @returns the insternal texture
  88682. */
  88683. getInternalTexture(): Nullable<InternalTexture>;
  88684. /**
  88685. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  88686. * @returns true if ready or not blocking
  88687. */
  88688. isReadyOrNotBlocking(): boolean;
  88689. /**
  88690. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  88691. * @returns true if fully ready
  88692. */
  88693. isReady(): boolean;
  88694. private _cachedSize;
  88695. /**
  88696. * Get the size of the texture.
  88697. * @returns the texture size.
  88698. */
  88699. getSize(): ISize;
  88700. /**
  88701. * Get the base size of the texture.
  88702. * It can be different from the size if the texture has been resized for POT for instance
  88703. * @returns the base size
  88704. */
  88705. getBaseSize(): ISize;
  88706. /**
  88707. * Update the sampling mode of the texture.
  88708. * Default is Trilinear mode.
  88709. *
  88710. * | Value | Type | Description |
  88711. * | ----- | ------------------ | ----------- |
  88712. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  88713. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  88714. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  88715. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  88716. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  88717. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  88718. * | 7 | NEAREST_LINEAR | |
  88719. * | 8 | NEAREST_NEAREST | |
  88720. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  88721. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  88722. * | 11 | LINEAR_LINEAR | |
  88723. * | 12 | LINEAR_NEAREST | |
  88724. *
  88725. * > _mag_: magnification filter (close to the viewer)
  88726. * > _min_: minification filter (far from the viewer)
  88727. * > _mip_: filter used between mip map levels
  88728. *@param samplingMode Define the new sampling mode of the texture
  88729. */
  88730. updateSamplingMode(samplingMode: number): void;
  88731. /**
  88732. * Scales the texture if is `canRescale()`
  88733. * @param ratio the resize factor we want to use to rescale
  88734. */
  88735. scale(ratio: number): void;
  88736. /**
  88737. * Get if the texture can rescale.
  88738. */
  88739. readonly canRescale: boolean;
  88740. /** @hidden */
  88741. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  88742. /** @hidden */
  88743. _rebuild(): void;
  88744. /**
  88745. * Triggers the load sequence in delayed load mode.
  88746. */
  88747. delayLoad(): void;
  88748. /**
  88749. * Clones the texture.
  88750. * @returns the cloned texture
  88751. */
  88752. clone(): Nullable<BaseTexture>;
  88753. /**
  88754. * Get the texture underlying type (INT, FLOAT...)
  88755. */
  88756. readonly textureType: number;
  88757. /**
  88758. * Get the texture underlying format (RGB, RGBA...)
  88759. */
  88760. readonly textureFormat: number;
  88761. /**
  88762. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  88763. * This will returns an RGBA array buffer containing either in values (0-255) or
  88764. * float values (0-1) depending of the underlying buffer type.
  88765. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  88766. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  88767. * @param buffer defines a user defined buffer to fill with data (can be null)
  88768. * @returns The Array buffer containing the pixels data.
  88769. */
  88770. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  88771. /**
  88772. * Release and destroy the underlying lower level texture aka internalTexture.
  88773. */
  88774. releaseInternalTexture(): void;
  88775. /**
  88776. * Get the polynomial representation of the texture data.
  88777. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  88778. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  88779. */
  88780. sphericalPolynomial: Nullable<SphericalPolynomial>;
  88781. /** @hidden */
  88782. readonly _lodTextureHigh: Nullable<BaseTexture>;
  88783. /** @hidden */
  88784. readonly _lodTextureMid: Nullable<BaseTexture>;
  88785. /** @hidden */
  88786. readonly _lodTextureLow: Nullable<BaseTexture>;
  88787. /**
  88788. * Dispose the texture and release its associated resources.
  88789. */
  88790. dispose(): void;
  88791. /**
  88792. * Serialize the texture into a JSON representation that can be parsed later on.
  88793. * @returns the JSON representation of the texture
  88794. */
  88795. serialize(): any;
  88796. /**
  88797. * Helper function to be called back once a list of texture contains only ready textures.
  88798. * @param textures Define the list of textures to wait for
  88799. * @param callback Define the callback triggered once the entire list will be ready
  88800. */
  88801. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  88802. }
  88803. }
  88804. declare module BABYLON {
  88805. /**
  88806. * Uniform buffer objects.
  88807. *
  88808. * Handles blocks of uniform on the GPU.
  88809. *
  88810. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  88811. *
  88812. * For more information, please refer to :
  88813. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  88814. */
  88815. export class UniformBuffer {
  88816. private _engine;
  88817. private _buffer;
  88818. private _data;
  88819. private _bufferData;
  88820. private _dynamic?;
  88821. private _uniformLocations;
  88822. private _uniformSizes;
  88823. private _uniformLocationPointer;
  88824. private _needSync;
  88825. private _noUBO;
  88826. private _currentEffect;
  88827. private static _MAX_UNIFORM_SIZE;
  88828. private static _tempBuffer;
  88829. /**
  88830. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  88831. * This is dynamic to allow compat with webgl 1 and 2.
  88832. * You will need to pass the name of the uniform as well as the value.
  88833. */
  88834. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  88835. /**
  88836. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  88837. * This is dynamic to allow compat with webgl 1 and 2.
  88838. * You will need to pass the name of the uniform as well as the value.
  88839. */
  88840. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  88841. /**
  88842. * Lambda to Update a single float in a uniform buffer.
  88843. * This is dynamic to allow compat with webgl 1 and 2.
  88844. * You will need to pass the name of the uniform as well as the value.
  88845. */
  88846. updateFloat: (name: string, x: number) => void;
  88847. /**
  88848. * Lambda to Update a vec2 of float in a uniform buffer.
  88849. * This is dynamic to allow compat with webgl 1 and 2.
  88850. * You will need to pass the name of the uniform as well as the value.
  88851. */
  88852. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  88853. /**
  88854. * Lambda to Update a vec3 of float in a uniform buffer.
  88855. * This is dynamic to allow compat with webgl 1 and 2.
  88856. * You will need to pass the name of the uniform as well as the value.
  88857. */
  88858. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  88859. /**
  88860. * Lambda to Update a vec4 of float in a uniform buffer.
  88861. * This is dynamic to allow compat with webgl 1 and 2.
  88862. * You will need to pass the name of the uniform as well as the value.
  88863. */
  88864. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  88865. /**
  88866. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  88867. * This is dynamic to allow compat with webgl 1 and 2.
  88868. * You will need to pass the name of the uniform as well as the value.
  88869. */
  88870. updateMatrix: (name: string, mat: Matrix) => void;
  88871. /**
  88872. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  88873. * This is dynamic to allow compat with webgl 1 and 2.
  88874. * You will need to pass the name of the uniform as well as the value.
  88875. */
  88876. updateVector3: (name: string, vector: Vector3) => void;
  88877. /**
  88878. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  88879. * This is dynamic to allow compat with webgl 1 and 2.
  88880. * You will need to pass the name of the uniform as well as the value.
  88881. */
  88882. updateVector4: (name: string, vector: Vector4) => void;
  88883. /**
  88884. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  88885. * This is dynamic to allow compat with webgl 1 and 2.
  88886. * You will need to pass the name of the uniform as well as the value.
  88887. */
  88888. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  88889. /**
  88890. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  88891. * This is dynamic to allow compat with webgl 1 and 2.
  88892. * You will need to pass the name of the uniform as well as the value.
  88893. */
  88894. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  88895. /**
  88896. * Instantiates a new Uniform buffer objects.
  88897. *
  88898. * Handles blocks of uniform on the GPU.
  88899. *
  88900. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  88901. *
  88902. * For more information, please refer to :
  88903. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  88904. * @param engine Define the engine the buffer is associated with
  88905. * @param data Define the data contained in the buffer
  88906. * @param dynamic Define if the buffer is updatable
  88907. */
  88908. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  88909. /**
  88910. * Indicates if the buffer is using the WebGL2 UBO implementation,
  88911. * or just falling back on setUniformXXX calls.
  88912. */
  88913. readonly useUbo: boolean;
  88914. /**
  88915. * Indicates if the WebGL underlying uniform buffer is in sync
  88916. * with the javascript cache data.
  88917. */
  88918. readonly isSync: boolean;
  88919. /**
  88920. * Indicates if the WebGL underlying uniform buffer is dynamic.
  88921. * Also, a dynamic UniformBuffer will disable cache verification and always
  88922. * update the underlying WebGL uniform buffer to the GPU.
  88923. * @returns if Dynamic, otherwise false
  88924. */
  88925. isDynamic(): boolean;
  88926. /**
  88927. * The data cache on JS side.
  88928. * @returns the underlying data as a float array
  88929. */
  88930. getData(): Float32Array;
  88931. /**
  88932. * The underlying WebGL Uniform buffer.
  88933. * @returns the webgl buffer
  88934. */
  88935. getBuffer(): Nullable<DataBuffer>;
  88936. /**
  88937. * std140 layout specifies how to align data within an UBO structure.
  88938. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  88939. * for specs.
  88940. */
  88941. private _fillAlignment;
  88942. /**
  88943. * Adds an uniform in the buffer.
  88944. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  88945. * for the layout to be correct !
  88946. * @param name Name of the uniform, as used in the uniform block in the shader.
  88947. * @param size Data size, or data directly.
  88948. */
  88949. addUniform(name: string, size: number | number[]): void;
  88950. /**
  88951. * Adds a Matrix 4x4 to the uniform buffer.
  88952. * @param name Name of the uniform, as used in the uniform block in the shader.
  88953. * @param mat A 4x4 matrix.
  88954. */
  88955. addMatrix(name: string, mat: Matrix): void;
  88956. /**
  88957. * Adds a vec2 to the uniform buffer.
  88958. * @param name Name of the uniform, as used in the uniform block in the shader.
  88959. * @param x Define the x component value of the vec2
  88960. * @param y Define the y component value of the vec2
  88961. */
  88962. addFloat2(name: string, x: number, y: number): void;
  88963. /**
  88964. * Adds a vec3 to the uniform buffer.
  88965. * @param name Name of the uniform, as used in the uniform block in the shader.
  88966. * @param x Define the x component value of the vec3
  88967. * @param y Define the y component value of the vec3
  88968. * @param z Define the z component value of the vec3
  88969. */
  88970. addFloat3(name: string, x: number, y: number, z: number): void;
  88971. /**
  88972. * Adds a vec3 to the uniform buffer.
  88973. * @param name Name of the uniform, as used in the uniform block in the shader.
  88974. * @param color Define the vec3 from a Color
  88975. */
  88976. addColor3(name: string, color: Color3): void;
  88977. /**
  88978. * Adds a vec4 to the uniform buffer.
  88979. * @param name Name of the uniform, as used in the uniform block in the shader.
  88980. * @param color Define the rgb components from a Color
  88981. * @param alpha Define the a component of the vec4
  88982. */
  88983. addColor4(name: string, color: Color3, alpha: number): void;
  88984. /**
  88985. * Adds a vec3 to the uniform buffer.
  88986. * @param name Name of the uniform, as used in the uniform block in the shader.
  88987. * @param vector Define the vec3 components from a Vector
  88988. */
  88989. addVector3(name: string, vector: Vector3): void;
  88990. /**
  88991. * Adds a Matrix 3x3 to the uniform buffer.
  88992. * @param name Name of the uniform, as used in the uniform block in the shader.
  88993. */
  88994. addMatrix3x3(name: string): void;
  88995. /**
  88996. * Adds a Matrix 2x2 to the uniform buffer.
  88997. * @param name Name of the uniform, as used in the uniform block in the shader.
  88998. */
  88999. addMatrix2x2(name: string): void;
  89000. /**
  89001. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  89002. */
  89003. create(): void;
  89004. /** @hidden */
  89005. _rebuild(): void;
  89006. /**
  89007. * Updates the WebGL Uniform Buffer on the GPU.
  89008. * If the `dynamic` flag is set to true, no cache comparison is done.
  89009. * Otherwise, the buffer will be updated only if the cache differs.
  89010. */
  89011. update(): void;
  89012. /**
  89013. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  89014. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89015. * @param data Define the flattened data
  89016. * @param size Define the size of the data.
  89017. */
  89018. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  89019. private _updateMatrix3x3ForUniform;
  89020. private _updateMatrix3x3ForEffect;
  89021. private _updateMatrix2x2ForEffect;
  89022. private _updateMatrix2x2ForUniform;
  89023. private _updateFloatForEffect;
  89024. private _updateFloatForUniform;
  89025. private _updateFloat2ForEffect;
  89026. private _updateFloat2ForUniform;
  89027. private _updateFloat3ForEffect;
  89028. private _updateFloat3ForUniform;
  89029. private _updateFloat4ForEffect;
  89030. private _updateFloat4ForUniform;
  89031. private _updateMatrixForEffect;
  89032. private _updateMatrixForUniform;
  89033. private _updateVector3ForEffect;
  89034. private _updateVector3ForUniform;
  89035. private _updateVector4ForEffect;
  89036. private _updateVector4ForUniform;
  89037. private _updateColor3ForEffect;
  89038. private _updateColor3ForUniform;
  89039. private _updateColor4ForEffect;
  89040. private _updateColor4ForUniform;
  89041. /**
  89042. * Sets a sampler uniform on the effect.
  89043. * @param name Define the name of the sampler.
  89044. * @param texture Define the texture to set in the sampler
  89045. */
  89046. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  89047. /**
  89048. * Directly updates the value of the uniform in the cache AND on the GPU.
  89049. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89050. * @param data Define the flattened data
  89051. */
  89052. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  89053. /**
  89054. * Binds this uniform buffer to an effect.
  89055. * @param effect Define the effect to bind the buffer to
  89056. * @param name Name of the uniform block in the shader.
  89057. */
  89058. bindToEffect(effect: Effect, name: string): void;
  89059. /**
  89060. * Disposes the uniform buffer.
  89061. */
  89062. dispose(): void;
  89063. }
  89064. }
  89065. declare module BABYLON {
  89066. /**
  89067. * Class used to work with sound analyzer using fast fourier transform (FFT)
  89068. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89069. */
  89070. export class Analyser {
  89071. /**
  89072. * Gets or sets the smoothing
  89073. * @ignorenaming
  89074. */
  89075. SMOOTHING: number;
  89076. /**
  89077. * Gets or sets the FFT table size
  89078. * @ignorenaming
  89079. */
  89080. FFT_SIZE: number;
  89081. /**
  89082. * Gets or sets the bar graph amplitude
  89083. * @ignorenaming
  89084. */
  89085. BARGRAPHAMPLITUDE: number;
  89086. /**
  89087. * Gets or sets the position of the debug canvas
  89088. * @ignorenaming
  89089. */
  89090. DEBUGCANVASPOS: {
  89091. x: number;
  89092. y: number;
  89093. };
  89094. /**
  89095. * Gets or sets the debug canvas size
  89096. * @ignorenaming
  89097. */
  89098. DEBUGCANVASSIZE: {
  89099. width: number;
  89100. height: number;
  89101. };
  89102. private _byteFreqs;
  89103. private _byteTime;
  89104. private _floatFreqs;
  89105. private _webAudioAnalyser;
  89106. private _debugCanvas;
  89107. private _debugCanvasContext;
  89108. private _scene;
  89109. private _registerFunc;
  89110. private _audioEngine;
  89111. /**
  89112. * Creates a new analyser
  89113. * @param scene defines hosting scene
  89114. */
  89115. constructor(scene: Scene);
  89116. /**
  89117. * Get the number of data values you will have to play with for the visualization
  89118. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  89119. * @returns a number
  89120. */
  89121. getFrequencyBinCount(): number;
  89122. /**
  89123. * Gets the current frequency data as a byte array
  89124. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  89125. * @returns a Uint8Array
  89126. */
  89127. getByteFrequencyData(): Uint8Array;
  89128. /**
  89129. * Gets the current waveform as a byte array
  89130. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  89131. * @returns a Uint8Array
  89132. */
  89133. getByteTimeDomainData(): Uint8Array;
  89134. /**
  89135. * Gets the current frequency data as a float array
  89136. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  89137. * @returns a Float32Array
  89138. */
  89139. getFloatFrequencyData(): Float32Array;
  89140. /**
  89141. * Renders the debug canvas
  89142. */
  89143. drawDebugCanvas(): void;
  89144. /**
  89145. * Stops rendering the debug canvas and removes it
  89146. */
  89147. stopDebugCanvas(): void;
  89148. /**
  89149. * Connects two audio nodes
  89150. * @param inputAudioNode defines first node to connect
  89151. * @param outputAudioNode defines second node to connect
  89152. */
  89153. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  89154. /**
  89155. * Releases all associated resources
  89156. */
  89157. dispose(): void;
  89158. }
  89159. }
  89160. declare module BABYLON {
  89161. /**
  89162. * This represents an audio engine and it is responsible
  89163. * to play, synchronize and analyse sounds throughout the application.
  89164. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89165. */
  89166. export interface IAudioEngine extends IDisposable {
  89167. /**
  89168. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  89169. */
  89170. readonly canUseWebAudio: boolean;
  89171. /**
  89172. * Gets the current AudioContext if available.
  89173. */
  89174. readonly audioContext: Nullable<AudioContext>;
  89175. /**
  89176. * The master gain node defines the global audio volume of your audio engine.
  89177. */
  89178. readonly masterGain: GainNode;
  89179. /**
  89180. * Gets whether or not mp3 are supported by your browser.
  89181. */
  89182. readonly isMP3supported: boolean;
  89183. /**
  89184. * Gets whether or not ogg are supported by your browser.
  89185. */
  89186. readonly isOGGsupported: boolean;
  89187. /**
  89188. * Defines if Babylon should emit a warning if WebAudio is not supported.
  89189. * @ignoreNaming
  89190. */
  89191. WarnedWebAudioUnsupported: boolean;
  89192. /**
  89193. * Defines if the audio engine relies on a custom unlocked button.
  89194. * In this case, the embedded button will not be displayed.
  89195. */
  89196. useCustomUnlockedButton: boolean;
  89197. /**
  89198. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  89199. */
  89200. readonly unlocked: boolean;
  89201. /**
  89202. * Event raised when audio has been unlocked on the browser.
  89203. */
  89204. onAudioUnlockedObservable: Observable<AudioEngine>;
  89205. /**
  89206. * Event raised when audio has been locked on the browser.
  89207. */
  89208. onAudioLockedObservable: Observable<AudioEngine>;
  89209. /**
  89210. * Flags the audio engine in Locked state.
  89211. * This happens due to new browser policies preventing audio to autoplay.
  89212. */
  89213. lock(): void;
  89214. /**
  89215. * Unlocks the audio engine once a user action has been done on the dom.
  89216. * This is helpful to resume play once browser policies have been satisfied.
  89217. */
  89218. unlock(): void;
  89219. }
  89220. /**
  89221. * This represents the default audio engine used in babylon.
  89222. * It is responsible to play, synchronize and analyse sounds throughout the application.
  89223. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89224. */
  89225. export class AudioEngine implements IAudioEngine {
  89226. private _audioContext;
  89227. private _audioContextInitialized;
  89228. private _muteButton;
  89229. private _hostElement;
  89230. /**
  89231. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  89232. */
  89233. canUseWebAudio: boolean;
  89234. /**
  89235. * The master gain node defines the global audio volume of your audio engine.
  89236. */
  89237. masterGain: GainNode;
  89238. /**
  89239. * Defines if Babylon should emit a warning if WebAudio is not supported.
  89240. * @ignoreNaming
  89241. */
  89242. WarnedWebAudioUnsupported: boolean;
  89243. /**
  89244. * Gets whether or not mp3 are supported by your browser.
  89245. */
  89246. isMP3supported: boolean;
  89247. /**
  89248. * Gets whether or not ogg are supported by your browser.
  89249. */
  89250. isOGGsupported: boolean;
  89251. /**
  89252. * Gets whether audio has been unlocked on the device.
  89253. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  89254. * a user interaction has happened.
  89255. */
  89256. unlocked: boolean;
  89257. /**
  89258. * Defines if the audio engine relies on a custom unlocked button.
  89259. * In this case, the embedded button will not be displayed.
  89260. */
  89261. useCustomUnlockedButton: boolean;
  89262. /**
  89263. * Event raised when audio has been unlocked on the browser.
  89264. */
  89265. onAudioUnlockedObservable: Observable<AudioEngine>;
  89266. /**
  89267. * Event raised when audio has been locked on the browser.
  89268. */
  89269. onAudioLockedObservable: Observable<AudioEngine>;
  89270. /**
  89271. * Gets the current AudioContext if available.
  89272. */
  89273. readonly audioContext: Nullable<AudioContext>;
  89274. private _connectedAnalyser;
  89275. /**
  89276. * Instantiates a new audio engine.
  89277. *
  89278. * There should be only one per page as some browsers restrict the number
  89279. * of audio contexts you can create.
  89280. * @param hostElement defines the host element where to display the mute icon if necessary
  89281. */
  89282. constructor(hostElement?: Nullable<HTMLElement>);
  89283. /**
  89284. * Flags the audio engine in Locked state.
  89285. * This happens due to new browser policies preventing audio to autoplay.
  89286. */
  89287. lock(): void;
  89288. /**
  89289. * Unlocks the audio engine once a user action has been done on the dom.
  89290. * This is helpful to resume play once browser policies have been satisfied.
  89291. */
  89292. unlock(): void;
  89293. private _resumeAudioContext;
  89294. private _initializeAudioContext;
  89295. private _tryToRun;
  89296. private _triggerRunningState;
  89297. private _triggerSuspendedState;
  89298. private _displayMuteButton;
  89299. private _moveButtonToTopLeft;
  89300. private _onResize;
  89301. private _hideMuteButton;
  89302. /**
  89303. * Destroy and release the resources associated with the audio ccontext.
  89304. */
  89305. dispose(): void;
  89306. /**
  89307. * Gets the global volume sets on the master gain.
  89308. * @returns the global volume if set or -1 otherwise
  89309. */
  89310. getGlobalVolume(): number;
  89311. /**
  89312. * Sets the global volume of your experience (sets on the master gain).
  89313. * @param newVolume Defines the new global volume of the application
  89314. */
  89315. setGlobalVolume(newVolume: number): void;
  89316. /**
  89317. * Connect the audio engine to an audio analyser allowing some amazing
  89318. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  89319. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  89320. * @param analyser The analyser to connect to the engine
  89321. */
  89322. connectToAnalyser(analyser: Analyser): void;
  89323. }
  89324. }
  89325. declare module BABYLON {
  89326. /**
  89327. * Interface used to present a loading screen while loading a scene
  89328. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  89329. */
  89330. export interface ILoadingScreen {
  89331. /**
  89332. * Function called to display the loading screen
  89333. */
  89334. displayLoadingUI: () => void;
  89335. /**
  89336. * Function called to hide the loading screen
  89337. */
  89338. hideLoadingUI: () => void;
  89339. /**
  89340. * Gets or sets the color to use for the background
  89341. */
  89342. loadingUIBackgroundColor: string;
  89343. /**
  89344. * Gets or sets the text to display while loading
  89345. */
  89346. loadingUIText: string;
  89347. }
  89348. /**
  89349. * Class used for the default loading screen
  89350. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  89351. */
  89352. export class DefaultLoadingScreen implements ILoadingScreen {
  89353. private _renderingCanvas;
  89354. private _loadingText;
  89355. private _loadingDivBackgroundColor;
  89356. private _loadingDiv;
  89357. private _loadingTextDiv;
  89358. /** Gets or sets the logo url to use for the default loading screen */
  89359. static DefaultLogoUrl: string;
  89360. /** Gets or sets the spinner url to use for the default loading screen */
  89361. static DefaultSpinnerUrl: string;
  89362. /**
  89363. * Creates a new default loading screen
  89364. * @param _renderingCanvas defines the canvas used to render the scene
  89365. * @param _loadingText defines the default text to display
  89366. * @param _loadingDivBackgroundColor defines the default background color
  89367. */
  89368. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  89369. /**
  89370. * Function called to display the loading screen
  89371. */
  89372. displayLoadingUI(): void;
  89373. /**
  89374. * Function called to hide the loading screen
  89375. */
  89376. hideLoadingUI(): void;
  89377. /**
  89378. * Gets or sets the text to display while loading
  89379. */
  89380. loadingUIText: string;
  89381. /**
  89382. * Gets or sets the color to use for the background
  89383. */
  89384. loadingUIBackgroundColor: string;
  89385. private _resizeLoadingUI;
  89386. }
  89387. }
  89388. declare module BABYLON {
  89389. /** @hidden */
  89390. export class WebGLPipelineContext implements IPipelineContext {
  89391. engine: Engine;
  89392. program: Nullable<WebGLProgram>;
  89393. context?: WebGLRenderingContext;
  89394. vertexShader?: WebGLShader;
  89395. fragmentShader?: WebGLShader;
  89396. isParallelCompiled: boolean;
  89397. onCompiled?: () => void;
  89398. transformFeedback?: WebGLTransformFeedback | null;
  89399. readonly isAsync: boolean;
  89400. readonly isReady: boolean;
  89401. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  89402. }
  89403. }
  89404. declare module BABYLON {
  89405. /** @hidden */
  89406. export class WebGLDataBuffer extends DataBuffer {
  89407. private _buffer;
  89408. constructor(resource: WebGLBuffer);
  89409. readonly underlyingResource: any;
  89410. }
  89411. }
  89412. declare module BABYLON {
  89413. /** @hidden */
  89414. export class WebGL2ShaderProcessor implements IShaderProcessor {
  89415. attributeProcessor(attribute: string): string;
  89416. varyingProcessor(varying: string, isFragment: boolean): string;
  89417. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  89418. }
  89419. }
  89420. declare module BABYLON {
  89421. /**
  89422. * Settings for finer control over video usage
  89423. */
  89424. export interface VideoTextureSettings {
  89425. /**
  89426. * Applies `autoplay` to video, if specified
  89427. */
  89428. autoPlay?: boolean;
  89429. /**
  89430. * Applies `loop` to video, if specified
  89431. */
  89432. loop?: boolean;
  89433. /**
  89434. * Automatically updates internal texture from video at every frame in the render loop
  89435. */
  89436. autoUpdateTexture: boolean;
  89437. /**
  89438. * Image src displayed during the video loading or until the user interacts with the video.
  89439. */
  89440. poster?: string;
  89441. }
  89442. /**
  89443. * If you want to display a video in your scene, this is the special texture for that.
  89444. * This special texture works similar to other textures, with the exception of a few parameters.
  89445. * @see https://doc.babylonjs.com/how_to/video_texture
  89446. */
  89447. export class VideoTexture extends Texture {
  89448. /**
  89449. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  89450. */
  89451. readonly autoUpdateTexture: boolean;
  89452. /**
  89453. * The video instance used by the texture internally
  89454. */
  89455. readonly video: HTMLVideoElement;
  89456. private _onUserActionRequestedObservable;
  89457. /**
  89458. * Event triggerd when a dom action is required by the user to play the video.
  89459. * This happens due to recent changes in browser policies preventing video to auto start.
  89460. */
  89461. readonly onUserActionRequestedObservable: Observable<Texture>;
  89462. private _generateMipMaps;
  89463. private _engine;
  89464. private _stillImageCaptured;
  89465. private _displayingPosterTexture;
  89466. private _settings;
  89467. private _createInternalTextureOnEvent;
  89468. /**
  89469. * Creates a video texture.
  89470. * If you want to display a video in your scene, this is the special texture for that.
  89471. * This special texture works similar to other textures, with the exception of a few parameters.
  89472. * @see https://doc.babylonjs.com/how_to/video_texture
  89473. * @param name optional name, will detect from video source, if not defined
  89474. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  89475. * @param scene is obviously the current scene.
  89476. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  89477. * @param invertY is false by default but can be used to invert video on Y axis
  89478. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  89479. * @param settings allows finer control over video usage
  89480. */
  89481. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  89482. private _getName;
  89483. private _getVideo;
  89484. private _createInternalTexture;
  89485. private reset;
  89486. /**
  89487. * @hidden Internal method to initiate `update`.
  89488. */
  89489. _rebuild(): void;
  89490. /**
  89491. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  89492. */
  89493. update(): void;
  89494. /**
  89495. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  89496. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  89497. */
  89498. updateTexture(isVisible: boolean): void;
  89499. protected _updateInternalTexture: () => void;
  89500. /**
  89501. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  89502. * @param url New url.
  89503. */
  89504. updateURL(url: string): void;
  89505. /**
  89506. * Dispose the texture and release its associated resources.
  89507. */
  89508. dispose(): void;
  89509. /**
  89510. * Creates a video texture straight from a stream.
  89511. * @param scene Define the scene the texture should be created in
  89512. * @param stream Define the stream the texture should be created from
  89513. * @returns The created video texture as a promise
  89514. */
  89515. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  89516. /**
  89517. * Creates a video texture straight from your WebCam video feed.
  89518. * @param scene Define the scene the texture should be created in
  89519. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  89520. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  89521. * @returns The created video texture as a promise
  89522. */
  89523. static CreateFromWebCamAsync(scene: Scene, constraints: {
  89524. minWidth: number;
  89525. maxWidth: number;
  89526. minHeight: number;
  89527. maxHeight: number;
  89528. deviceId: string;
  89529. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  89530. /**
  89531. * Creates a video texture straight from your WebCam video feed.
  89532. * @param scene Define the scene the texture should be created in
  89533. * @param onReady Define a callback to triggered once the texture will be ready
  89534. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  89535. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  89536. */
  89537. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  89538. minWidth: number;
  89539. maxWidth: number;
  89540. minHeight: number;
  89541. maxHeight: number;
  89542. deviceId: string;
  89543. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  89544. }
  89545. }
  89546. declare module BABYLON {
  89547. /**
  89548. * Interface for attribute information associated with buffer instanciation
  89549. */
  89550. export class InstancingAttributeInfo {
  89551. /**
  89552. * Index/offset of the attribute in the vertex shader
  89553. */
  89554. index: number;
  89555. /**
  89556. * size of the attribute, 1, 2, 3 or 4
  89557. */
  89558. attributeSize: number;
  89559. /**
  89560. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  89561. * default is FLOAT
  89562. */
  89563. attribyteType: number;
  89564. /**
  89565. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  89566. */
  89567. normalized: boolean;
  89568. /**
  89569. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  89570. */
  89571. offset: number;
  89572. /**
  89573. * Name of the GLSL attribute, for debugging purpose only
  89574. */
  89575. attributeName: string;
  89576. }
  89577. /**
  89578. * Define options used to create a depth texture
  89579. */
  89580. export class DepthTextureCreationOptions {
  89581. /** Specifies whether or not a stencil should be allocated in the texture */
  89582. generateStencil?: boolean;
  89583. /** Specifies whether or not bilinear filtering is enable on the texture */
  89584. bilinearFiltering?: boolean;
  89585. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  89586. comparisonFunction?: number;
  89587. /** Specifies if the created texture is a cube texture */
  89588. isCube?: boolean;
  89589. }
  89590. /**
  89591. * Class used to describe the capabilities of the engine relatively to the current browser
  89592. */
  89593. export class EngineCapabilities {
  89594. /** Maximum textures units per fragment shader */
  89595. maxTexturesImageUnits: number;
  89596. /** Maximum texture units per vertex shader */
  89597. maxVertexTextureImageUnits: number;
  89598. /** Maximum textures units in the entire pipeline */
  89599. maxCombinedTexturesImageUnits: number;
  89600. /** Maximum texture size */
  89601. maxTextureSize: number;
  89602. /** Maximum cube texture size */
  89603. maxCubemapTextureSize: number;
  89604. /** Maximum render texture size */
  89605. maxRenderTextureSize: number;
  89606. /** Maximum number of vertex attributes */
  89607. maxVertexAttribs: number;
  89608. /** Maximum number of varyings */
  89609. maxVaryingVectors: number;
  89610. /** Maximum number of uniforms per vertex shader */
  89611. maxVertexUniformVectors: number;
  89612. /** Maximum number of uniforms per fragment shader */
  89613. maxFragmentUniformVectors: number;
  89614. /** Defines if standard derivates (dx/dy) are supported */
  89615. standardDerivatives: boolean;
  89616. /** Defines if s3tc texture compression is supported */
  89617. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  89618. /** Defines if pvrtc texture compression is supported */
  89619. pvrtc: any;
  89620. /** Defines if etc1 texture compression is supported */
  89621. etc1: any;
  89622. /** Defines if etc2 texture compression is supported */
  89623. etc2: any;
  89624. /** Defines if astc texture compression is supported */
  89625. astc: any;
  89626. /** Defines if float textures are supported */
  89627. textureFloat: boolean;
  89628. /** Defines if vertex array objects are supported */
  89629. vertexArrayObject: boolean;
  89630. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  89631. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  89632. /** Gets the maximum level of anisotropy supported */
  89633. maxAnisotropy: number;
  89634. /** Defines if instancing is supported */
  89635. instancedArrays: boolean;
  89636. /** Defines if 32 bits indices are supported */
  89637. uintIndices: boolean;
  89638. /** Defines if high precision shaders are supported */
  89639. highPrecisionShaderSupported: boolean;
  89640. /** Defines if depth reading in the fragment shader is supported */
  89641. fragmentDepthSupported: boolean;
  89642. /** Defines if float texture linear filtering is supported*/
  89643. textureFloatLinearFiltering: boolean;
  89644. /** Defines if rendering to float textures is supported */
  89645. textureFloatRender: boolean;
  89646. /** Defines if half float textures are supported*/
  89647. textureHalfFloat: boolean;
  89648. /** Defines if half float texture linear filtering is supported*/
  89649. textureHalfFloatLinearFiltering: boolean;
  89650. /** Defines if rendering to half float textures is supported */
  89651. textureHalfFloatRender: boolean;
  89652. /** Defines if textureLOD shader command is supported */
  89653. textureLOD: boolean;
  89654. /** Defines if draw buffers extension is supported */
  89655. drawBuffersExtension: boolean;
  89656. /** Defines if depth textures are supported */
  89657. depthTextureExtension: boolean;
  89658. /** Defines if float color buffer are supported */
  89659. colorBufferFloat: boolean;
  89660. /** Gets disjoint timer query extension (null if not supported) */
  89661. timerQuery: EXT_disjoint_timer_query;
  89662. /** Defines if timestamp can be used with timer query */
  89663. canUseTimestampForTimerQuery: boolean;
  89664. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  89665. multiview: any;
  89666. /** Function used to let the system compiles shaders in background */
  89667. parallelShaderCompile: {
  89668. COMPLETION_STATUS_KHR: number;
  89669. };
  89670. }
  89671. /** Interface defining initialization parameters for Engine class */
  89672. export interface EngineOptions extends WebGLContextAttributes {
  89673. /**
  89674. * Defines if the engine should no exceed a specified device ratio
  89675. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  89676. */
  89677. limitDeviceRatio?: number;
  89678. /**
  89679. * Defines if webvr should be enabled automatically
  89680. * @see http://doc.babylonjs.com/how_to/webvr_camera
  89681. */
  89682. autoEnableWebVR?: boolean;
  89683. /**
  89684. * Defines if webgl2 should be turned off even if supported
  89685. * @see http://doc.babylonjs.com/features/webgl2
  89686. */
  89687. disableWebGL2Support?: boolean;
  89688. /**
  89689. * Defines if webaudio should be initialized as well
  89690. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89691. */
  89692. audioEngine?: boolean;
  89693. /**
  89694. * Defines if animations should run using a deterministic lock step
  89695. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89696. */
  89697. deterministicLockstep?: boolean;
  89698. /** Defines the maximum steps to use with deterministic lock step mode */
  89699. lockstepMaxSteps?: number;
  89700. /**
  89701. * Defines that engine should ignore context lost events
  89702. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  89703. */
  89704. doNotHandleContextLost?: boolean;
  89705. /**
  89706. * Defines that engine should ignore modifying touch action attribute and style
  89707. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  89708. */
  89709. doNotHandleTouchAction?: boolean;
  89710. /**
  89711. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  89712. */
  89713. useHighPrecisionFloats?: boolean;
  89714. }
  89715. /**
  89716. * Defines the interface used by display changed events
  89717. */
  89718. export interface IDisplayChangedEventArgs {
  89719. /** Gets the vrDisplay object (if any) */
  89720. vrDisplay: Nullable<any>;
  89721. /** Gets a boolean indicating if webVR is supported */
  89722. vrSupported: boolean;
  89723. }
  89724. /**
  89725. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  89726. */
  89727. export class Engine {
  89728. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  89729. static ExceptionList: ({
  89730. key: string;
  89731. capture: string;
  89732. captureConstraint: number;
  89733. targets: string[];
  89734. } | {
  89735. key: string;
  89736. capture: null;
  89737. captureConstraint: null;
  89738. targets: string[];
  89739. })[];
  89740. /** Gets the list of created engines */
  89741. static readonly Instances: Engine[];
  89742. /**
  89743. * Gets the latest created engine
  89744. */
  89745. static readonly LastCreatedEngine: Nullable<Engine>;
  89746. /**
  89747. * Gets the latest created scene
  89748. */
  89749. static readonly LastCreatedScene: Nullable<Scene>;
  89750. /**
  89751. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  89752. * @param flag defines which part of the materials must be marked as dirty
  89753. * @param predicate defines a predicate used to filter which materials should be affected
  89754. */
  89755. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  89756. /** @hidden */
  89757. static _TextureLoaders: IInternalTextureLoader[];
  89758. /** Defines that alpha blending is disabled */
  89759. static readonly ALPHA_DISABLE: number;
  89760. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  89761. static readonly ALPHA_ADD: number;
  89762. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  89763. static readonly ALPHA_COMBINE: number;
  89764. /** Defines that alpha blending to DEST - SRC * DEST */
  89765. static readonly ALPHA_SUBTRACT: number;
  89766. /** Defines that alpha blending to SRC * DEST */
  89767. static readonly ALPHA_MULTIPLY: number;
  89768. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  89769. static readonly ALPHA_MAXIMIZED: number;
  89770. /** Defines that alpha blending to SRC + DEST */
  89771. static readonly ALPHA_ONEONE: number;
  89772. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  89773. static readonly ALPHA_PREMULTIPLIED: number;
  89774. /**
  89775. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  89776. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  89777. */
  89778. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  89779. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  89780. static readonly ALPHA_INTERPOLATE: number;
  89781. /**
  89782. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  89783. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  89784. */
  89785. static readonly ALPHA_SCREENMODE: number;
  89786. /** Defines that the ressource is not delayed*/
  89787. static readonly DELAYLOADSTATE_NONE: number;
  89788. /** Defines that the ressource was successfully delay loaded */
  89789. static readonly DELAYLOADSTATE_LOADED: number;
  89790. /** Defines that the ressource is currently delay loading */
  89791. static readonly DELAYLOADSTATE_LOADING: number;
  89792. /** Defines that the ressource is delayed and has not started loading */
  89793. static readonly DELAYLOADSTATE_NOTLOADED: number;
  89794. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  89795. static readonly NEVER: number;
  89796. /** 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 */
  89797. static readonly ALWAYS: number;
  89798. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  89799. static readonly LESS: number;
  89800. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  89801. static readonly EQUAL: number;
  89802. /** 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 */
  89803. static readonly LEQUAL: number;
  89804. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  89805. static readonly GREATER: number;
  89806. /** 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 */
  89807. static readonly GEQUAL: number;
  89808. /** 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 */
  89809. static readonly NOTEQUAL: number;
  89810. /** Passed to stencilOperation to specify that stencil value must be kept */
  89811. static readonly KEEP: number;
  89812. /** Passed to stencilOperation to specify that stencil value must be replaced */
  89813. static readonly REPLACE: number;
  89814. /** Passed to stencilOperation to specify that stencil value must be incremented */
  89815. static readonly INCR: number;
  89816. /** Passed to stencilOperation to specify that stencil value must be decremented */
  89817. static readonly DECR: number;
  89818. /** Passed to stencilOperation to specify that stencil value must be inverted */
  89819. static readonly INVERT: number;
  89820. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  89821. static readonly INCR_WRAP: number;
  89822. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  89823. static readonly DECR_WRAP: number;
  89824. /** Texture is not repeating outside of 0..1 UVs */
  89825. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  89826. /** Texture is repeating outside of 0..1 UVs */
  89827. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  89828. /** Texture is repeating and mirrored */
  89829. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  89830. /** ALPHA */
  89831. static readonly TEXTUREFORMAT_ALPHA: number;
  89832. /** LUMINANCE */
  89833. static readonly TEXTUREFORMAT_LUMINANCE: number;
  89834. /** LUMINANCE_ALPHA */
  89835. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  89836. /** RGB */
  89837. static readonly TEXTUREFORMAT_RGB: number;
  89838. /** RGBA */
  89839. static readonly TEXTUREFORMAT_RGBA: number;
  89840. /** RED */
  89841. static readonly TEXTUREFORMAT_RED: number;
  89842. /** RED (2nd reference) */
  89843. static readonly TEXTUREFORMAT_R: number;
  89844. /** RG */
  89845. static readonly TEXTUREFORMAT_RG: number;
  89846. /** RED_INTEGER */
  89847. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  89848. /** RED_INTEGER (2nd reference) */
  89849. static readonly TEXTUREFORMAT_R_INTEGER: number;
  89850. /** RG_INTEGER */
  89851. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  89852. /** RGB_INTEGER */
  89853. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  89854. /** RGBA_INTEGER */
  89855. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  89856. /** UNSIGNED_BYTE */
  89857. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  89858. /** UNSIGNED_BYTE (2nd reference) */
  89859. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  89860. /** FLOAT */
  89861. static readonly TEXTURETYPE_FLOAT: number;
  89862. /** HALF_FLOAT */
  89863. static readonly TEXTURETYPE_HALF_FLOAT: number;
  89864. /** BYTE */
  89865. static readonly TEXTURETYPE_BYTE: number;
  89866. /** SHORT */
  89867. static readonly TEXTURETYPE_SHORT: number;
  89868. /** UNSIGNED_SHORT */
  89869. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  89870. /** INT */
  89871. static readonly TEXTURETYPE_INT: number;
  89872. /** UNSIGNED_INT */
  89873. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  89874. /** UNSIGNED_SHORT_4_4_4_4 */
  89875. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  89876. /** UNSIGNED_SHORT_5_5_5_1 */
  89877. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  89878. /** UNSIGNED_SHORT_5_6_5 */
  89879. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  89880. /** UNSIGNED_INT_2_10_10_10_REV */
  89881. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  89882. /** UNSIGNED_INT_24_8 */
  89883. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  89884. /** UNSIGNED_INT_10F_11F_11F_REV */
  89885. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  89886. /** UNSIGNED_INT_5_9_9_9_REV */
  89887. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  89888. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  89889. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  89890. /** nearest is mag = nearest and min = nearest and mip = linear */
  89891. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  89892. /** Bilinear is mag = linear and min = linear and mip = nearest */
  89893. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  89894. /** Trilinear is mag = linear and min = linear and mip = linear */
  89895. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  89896. /** nearest is mag = nearest and min = nearest and mip = linear */
  89897. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  89898. /** Bilinear is mag = linear and min = linear and mip = nearest */
  89899. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  89900. /** Trilinear is mag = linear and min = linear and mip = linear */
  89901. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  89902. /** mag = nearest and min = nearest and mip = nearest */
  89903. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  89904. /** mag = nearest and min = linear and mip = nearest */
  89905. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  89906. /** mag = nearest and min = linear and mip = linear */
  89907. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  89908. /** mag = nearest and min = linear and mip = none */
  89909. static readonly TEXTURE_NEAREST_LINEAR: number;
  89910. /** mag = nearest and min = nearest and mip = none */
  89911. static readonly TEXTURE_NEAREST_NEAREST: number;
  89912. /** mag = linear and min = nearest and mip = nearest */
  89913. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  89914. /** mag = linear and min = nearest and mip = linear */
  89915. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  89916. /** mag = linear and min = linear and mip = none */
  89917. static readonly TEXTURE_LINEAR_LINEAR: number;
  89918. /** mag = linear and min = nearest and mip = none */
  89919. static readonly TEXTURE_LINEAR_NEAREST: number;
  89920. /** Explicit coordinates mode */
  89921. static readonly TEXTURE_EXPLICIT_MODE: number;
  89922. /** Spherical coordinates mode */
  89923. static readonly TEXTURE_SPHERICAL_MODE: number;
  89924. /** Planar coordinates mode */
  89925. static readonly TEXTURE_PLANAR_MODE: number;
  89926. /** Cubic coordinates mode */
  89927. static readonly TEXTURE_CUBIC_MODE: number;
  89928. /** Projection coordinates mode */
  89929. static readonly TEXTURE_PROJECTION_MODE: number;
  89930. /** Skybox coordinates mode */
  89931. static readonly TEXTURE_SKYBOX_MODE: number;
  89932. /** Inverse Cubic coordinates mode */
  89933. static readonly TEXTURE_INVCUBIC_MODE: number;
  89934. /** Equirectangular coordinates mode */
  89935. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  89936. /** Equirectangular Fixed coordinates mode */
  89937. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  89938. /** Equirectangular Fixed Mirrored coordinates mode */
  89939. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  89940. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  89941. static readonly SCALEMODE_FLOOR: number;
  89942. /** Defines that texture rescaling will look for the nearest power of 2 size */
  89943. static readonly SCALEMODE_NEAREST: number;
  89944. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  89945. static readonly SCALEMODE_CEILING: number;
  89946. /**
  89947. * Returns the current npm package of the sdk
  89948. */
  89949. static readonly NpmPackage: string;
  89950. /**
  89951. * Returns the current version of the framework
  89952. */
  89953. static readonly Version: string;
  89954. /**
  89955. * Returns a string describing the current engine
  89956. */
  89957. readonly description: string;
  89958. /**
  89959. * Gets or sets the epsilon value used by collision engine
  89960. */
  89961. static CollisionsEpsilon: number;
  89962. /**
  89963. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  89964. */
  89965. static ShadersRepository: string;
  89966. /**
  89967. * Method called to create the default loading screen.
  89968. * This can be overriden in your own app.
  89969. * @param canvas The rendering canvas element
  89970. * @returns The loading screen
  89971. */
  89972. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  89973. /**
  89974. * Method called to create the default rescale post process on each engine.
  89975. */
  89976. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  89977. /** @hidden */
  89978. _shaderProcessor: IShaderProcessor;
  89979. /**
  89980. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  89981. */
  89982. forcePOTTextures: boolean;
  89983. /**
  89984. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  89985. */
  89986. isFullscreen: boolean;
  89987. /**
  89988. * Gets a boolean indicating if the pointer is currently locked
  89989. */
  89990. isPointerLock: boolean;
  89991. /**
  89992. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  89993. */
  89994. cullBackFaces: boolean;
  89995. /**
  89996. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  89997. */
  89998. renderEvenInBackground: boolean;
  89999. /**
  90000. * Gets or sets a boolean indicating that cache can be kept between frames
  90001. */
  90002. preventCacheWipeBetweenFrames: boolean;
  90003. /**
  90004. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  90005. **/
  90006. enableOfflineSupport: boolean;
  90007. /**
  90008. * 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)
  90009. **/
  90010. disableManifestCheck: boolean;
  90011. /**
  90012. * Gets the list of created scenes
  90013. */
  90014. scenes: Scene[];
  90015. /**
  90016. * Event raised when a new scene is created
  90017. */
  90018. onNewSceneAddedObservable: Observable<Scene>;
  90019. /**
  90020. * Gets the list of created postprocesses
  90021. */
  90022. postProcesses: PostProcess[];
  90023. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  90024. validateShaderPrograms: boolean;
  90025. /**
  90026. * Observable event triggered each time the rendering canvas is resized
  90027. */
  90028. onResizeObservable: Observable<Engine>;
  90029. /**
  90030. * Observable event triggered each time the canvas loses focus
  90031. */
  90032. onCanvasBlurObservable: Observable<Engine>;
  90033. /**
  90034. * Observable event triggered each time the canvas gains focus
  90035. */
  90036. onCanvasFocusObservable: Observable<Engine>;
  90037. /**
  90038. * Observable event triggered each time the canvas receives pointerout event
  90039. */
  90040. onCanvasPointerOutObservable: Observable<PointerEvent>;
  90041. /**
  90042. * Observable event triggered before each texture is initialized
  90043. */
  90044. onBeforeTextureInitObservable: Observable<Texture>;
  90045. /**
  90046. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  90047. */
  90048. disableUniformBuffers: boolean;
  90049. /** @hidden */
  90050. _uniformBuffers: UniformBuffer[];
  90051. /**
  90052. * Gets a boolean indicating that the engine supports uniform buffers
  90053. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90054. */
  90055. readonly supportsUniformBuffers: boolean;
  90056. /**
  90057. * Observable raised when the engine begins a new frame
  90058. */
  90059. onBeginFrameObservable: Observable<Engine>;
  90060. /**
  90061. * If set, will be used to request the next animation frame for the render loop
  90062. */
  90063. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  90064. /**
  90065. * Observable raised when the engine ends the current frame
  90066. */
  90067. onEndFrameObservable: Observable<Engine>;
  90068. /**
  90069. * Observable raised when the engine is about to compile a shader
  90070. */
  90071. onBeforeShaderCompilationObservable: Observable<Engine>;
  90072. /**
  90073. * Observable raised when the engine has jsut compiled a shader
  90074. */
  90075. onAfterShaderCompilationObservable: Observable<Engine>;
  90076. /** @hidden */
  90077. _gl: WebGLRenderingContext;
  90078. private _renderingCanvas;
  90079. private _windowIsBackground;
  90080. private _webGLVersion;
  90081. protected _highPrecisionShadersAllowed: boolean;
  90082. /** @hidden */
  90083. readonly _shouldUseHighPrecisionShader: boolean;
  90084. /**
  90085. * Gets a boolean indicating that only power of 2 textures are supported
  90086. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  90087. */
  90088. readonly needPOTTextures: boolean;
  90089. /** @hidden */
  90090. _badOS: boolean;
  90091. /** @hidden */
  90092. _badDesktopOS: boolean;
  90093. /**
  90094. * Gets the audio engine
  90095. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90096. * @ignorenaming
  90097. */
  90098. static audioEngine: IAudioEngine;
  90099. /**
  90100. * Default AudioEngine factory responsible of creating the Audio Engine.
  90101. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  90102. */
  90103. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  90104. /**
  90105. * Default offline support factory responsible of creating a tool used to store data locally.
  90106. * By default, this will create a Database object if the workload has been embedded.
  90107. */
  90108. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  90109. private _onFocus;
  90110. private _onBlur;
  90111. private _onCanvasPointerOut;
  90112. private _onCanvasBlur;
  90113. private _onCanvasFocus;
  90114. private _onFullscreenChange;
  90115. private _onPointerLockChange;
  90116. private _hardwareScalingLevel;
  90117. /** @hidden */
  90118. _caps: EngineCapabilities;
  90119. private _pointerLockRequested;
  90120. private _isStencilEnable;
  90121. private _colorWrite;
  90122. private _loadingScreen;
  90123. /** @hidden */
  90124. _drawCalls: PerfCounter;
  90125. private _glVersion;
  90126. private _glRenderer;
  90127. private _glVendor;
  90128. private _videoTextureSupported;
  90129. private _renderingQueueLaunched;
  90130. private _activeRenderLoops;
  90131. private _deterministicLockstep;
  90132. private _lockstepMaxSteps;
  90133. /**
  90134. * Observable signaled when a context lost event is raised
  90135. */
  90136. onContextLostObservable: Observable<Engine>;
  90137. /**
  90138. * Observable signaled when a context restored event is raised
  90139. */
  90140. onContextRestoredObservable: Observable<Engine>;
  90141. private _onContextLost;
  90142. private _onContextRestored;
  90143. private _contextWasLost;
  90144. /** @hidden */
  90145. _doNotHandleContextLost: boolean;
  90146. /**
  90147. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  90148. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  90149. */
  90150. doNotHandleContextLost: boolean;
  90151. private _performanceMonitor;
  90152. private _fps;
  90153. private _deltaTime;
  90154. /**
  90155. * Turn this value on if you want to pause FPS computation when in background
  90156. */
  90157. disablePerformanceMonitorInBackground: boolean;
  90158. /**
  90159. * Gets the performance monitor attached to this engine
  90160. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  90161. */
  90162. readonly performanceMonitor: PerformanceMonitor;
  90163. /**
  90164. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  90165. */
  90166. disableVertexArrayObjects: boolean;
  90167. /** @hidden */
  90168. protected _depthCullingState: _DepthCullingState;
  90169. /** @hidden */
  90170. protected _stencilState: _StencilState;
  90171. /** @hidden */
  90172. protected _alphaState: _AlphaState;
  90173. /** @hidden */
  90174. protected _alphaMode: number;
  90175. /** @hidden */
  90176. _internalTexturesCache: InternalTexture[];
  90177. /** @hidden */
  90178. protected _activeChannel: number;
  90179. private _currentTextureChannel;
  90180. /** @hidden */
  90181. protected _boundTexturesCache: {
  90182. [key: string]: Nullable<InternalTexture>;
  90183. };
  90184. /** @hidden */
  90185. protected _currentEffect: Nullable<Effect>;
  90186. /** @hidden */
  90187. protected _currentProgram: Nullable<WebGLProgram>;
  90188. private _compiledEffects;
  90189. private _vertexAttribArraysEnabled;
  90190. /** @hidden */
  90191. protected _cachedViewport: Nullable<Viewport>;
  90192. private _cachedVertexArrayObject;
  90193. /** @hidden */
  90194. protected _cachedVertexBuffers: any;
  90195. /** @hidden */
  90196. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  90197. /** @hidden */
  90198. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  90199. /** @hidden */
  90200. _currentRenderTarget: Nullable<InternalTexture>;
  90201. private _uintIndicesCurrentlySet;
  90202. private _currentBoundBuffer;
  90203. /** @hidden */
  90204. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  90205. private _currentBufferPointers;
  90206. private _currentInstanceLocations;
  90207. private _currentInstanceBuffers;
  90208. private _textureUnits;
  90209. /** @hidden */
  90210. _workingCanvas: Nullable<HTMLCanvasElement>;
  90211. /** @hidden */
  90212. _workingContext: Nullable<CanvasRenderingContext2D>;
  90213. private _rescalePostProcess;
  90214. private _dummyFramebuffer;
  90215. private _externalData;
  90216. /** @hidden */
  90217. _bindedRenderFunction: any;
  90218. private _vaoRecordInProgress;
  90219. private _mustWipeVertexAttributes;
  90220. private _emptyTexture;
  90221. private _emptyCubeTexture;
  90222. private _emptyTexture3D;
  90223. /** @hidden */
  90224. _frameHandler: number;
  90225. private _nextFreeTextureSlots;
  90226. private _maxSimultaneousTextures;
  90227. private _activeRequests;
  90228. private _texturesSupported;
  90229. /** @hidden */
  90230. _textureFormatInUse: Nullable<string>;
  90231. /**
  90232. * Gets the list of texture formats supported
  90233. */
  90234. readonly texturesSupported: Array<string>;
  90235. /**
  90236. * Gets the list of texture formats in use
  90237. */
  90238. readonly textureFormatInUse: Nullable<string>;
  90239. /**
  90240. * Gets the current viewport
  90241. */
  90242. readonly currentViewport: Nullable<Viewport>;
  90243. /**
  90244. * Gets the default empty texture
  90245. */
  90246. readonly emptyTexture: InternalTexture;
  90247. /**
  90248. * Gets the default empty 3D texture
  90249. */
  90250. readonly emptyTexture3D: InternalTexture;
  90251. /**
  90252. * Gets the default empty cube texture
  90253. */
  90254. readonly emptyCubeTexture: InternalTexture;
  90255. /**
  90256. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  90257. */
  90258. readonly premultipliedAlpha: boolean;
  90259. /**
  90260. * Creates a new engine
  90261. * @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
  90262. * @param antialias defines enable antialiasing (default: false)
  90263. * @param options defines further options to be sent to the getContext() function
  90264. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  90265. */
  90266. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  90267. /**
  90268. * Initializes a webVR display and starts listening to display change events
  90269. * The onVRDisplayChangedObservable will be notified upon these changes
  90270. * @returns The onVRDisplayChangedObservable
  90271. */
  90272. initWebVR(): Observable<IDisplayChangedEventArgs>;
  90273. /** @hidden */
  90274. _prepareVRComponent(): void;
  90275. /** @hidden */
  90276. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  90277. /** @hidden */
  90278. _submitVRFrame(): void;
  90279. /**
  90280. * Call this function to leave webVR mode
  90281. * Will do nothing if webVR is not supported or if there is no webVR device
  90282. * @see http://doc.babylonjs.com/how_to/webvr_camera
  90283. */
  90284. disableVR(): void;
  90285. /**
  90286. * Gets a boolean indicating that the system is in VR mode and is presenting
  90287. * @returns true if VR mode is engaged
  90288. */
  90289. isVRPresenting(): boolean;
  90290. /** @hidden */
  90291. _requestVRFrame(): void;
  90292. private _disableTouchAction;
  90293. private _rebuildInternalTextures;
  90294. private _rebuildEffects;
  90295. /**
  90296. * Gets a boolean indicating if all created effects are ready
  90297. * @returns true if all effects are ready
  90298. */
  90299. areAllEffectsReady(): boolean;
  90300. private _rebuildBuffers;
  90301. private _initGLContext;
  90302. /**
  90303. * Gets version of the current webGL context
  90304. */
  90305. readonly webGLVersion: number;
  90306. /**
  90307. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  90308. */
  90309. readonly isStencilEnable: boolean;
  90310. /** @hidden */
  90311. _prepareWorkingCanvas(): void;
  90312. /**
  90313. * Reset the texture cache to empty state
  90314. */
  90315. resetTextureCache(): void;
  90316. /**
  90317. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  90318. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90319. * @returns true if engine is in deterministic lock step mode
  90320. */
  90321. isDeterministicLockStep(): boolean;
  90322. /**
  90323. * Gets the max steps when engine is running in deterministic lock step
  90324. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90325. * @returns the max steps
  90326. */
  90327. getLockstepMaxSteps(): number;
  90328. /**
  90329. * Gets an object containing information about the current webGL context
  90330. * @returns an object containing the vender, the renderer and the version of the current webGL context
  90331. */
  90332. getGlInfo(): {
  90333. vendor: string;
  90334. renderer: string;
  90335. version: string;
  90336. };
  90337. /**
  90338. * Gets current aspect ratio
  90339. * @param camera defines the camera to use to get the aspect ratio
  90340. * @param useScreen defines if screen size must be used (or the current render target if any)
  90341. * @returns a number defining the aspect ratio
  90342. */
  90343. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  90344. /**
  90345. * Gets current screen aspect ratio
  90346. * @returns a number defining the aspect ratio
  90347. */
  90348. getScreenAspectRatio(): number;
  90349. /**
  90350. * Gets the current render width
  90351. * @param useScreen defines if screen size must be used (or the current render target if any)
  90352. * @returns a number defining the current render width
  90353. */
  90354. getRenderWidth(useScreen?: boolean): number;
  90355. /**
  90356. * Gets the current render height
  90357. * @param useScreen defines if screen size must be used (or the current render target if any)
  90358. * @returns a number defining the current render height
  90359. */
  90360. getRenderHeight(useScreen?: boolean): number;
  90361. /**
  90362. * Gets the HTML canvas attached with the current webGL context
  90363. * @returns a HTML canvas
  90364. */
  90365. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  90366. /**
  90367. * Gets the client rect of the HTML canvas attached with the current webGL context
  90368. * @returns a client rectanglee
  90369. */
  90370. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  90371. /**
  90372. * Defines the hardware scaling level.
  90373. * By default the hardware scaling level is computed from the window device ratio.
  90374. * 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.
  90375. * @param level defines the level to use
  90376. */
  90377. setHardwareScalingLevel(level: number): void;
  90378. /**
  90379. * Gets the current hardware scaling level.
  90380. * By default the hardware scaling level is computed from the window device ratio.
  90381. * 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.
  90382. * @returns a number indicating the current hardware scaling level
  90383. */
  90384. getHardwareScalingLevel(): number;
  90385. /**
  90386. * Gets the list of loaded textures
  90387. * @returns an array containing all loaded textures
  90388. */
  90389. getLoadedTexturesCache(): InternalTexture[];
  90390. /**
  90391. * Gets the object containing all engine capabilities
  90392. * @returns the EngineCapabilities object
  90393. */
  90394. getCaps(): EngineCapabilities;
  90395. /**
  90396. * Gets the current depth function
  90397. * @returns a number defining the depth function
  90398. */
  90399. getDepthFunction(): Nullable<number>;
  90400. /**
  90401. * Sets the current depth function
  90402. * @param depthFunc defines the function to use
  90403. */
  90404. setDepthFunction(depthFunc: number): void;
  90405. /**
  90406. * Sets the current depth function to GREATER
  90407. */
  90408. setDepthFunctionToGreater(): void;
  90409. /**
  90410. * Sets the current depth function to GEQUAL
  90411. */
  90412. setDepthFunctionToGreaterOrEqual(): void;
  90413. /**
  90414. * Sets the current depth function to LESS
  90415. */
  90416. setDepthFunctionToLess(): void;
  90417. private _cachedStencilBuffer;
  90418. private _cachedStencilFunction;
  90419. private _cachedStencilMask;
  90420. private _cachedStencilOperationPass;
  90421. private _cachedStencilOperationFail;
  90422. private _cachedStencilOperationDepthFail;
  90423. private _cachedStencilReference;
  90424. /**
  90425. * Caches the the state of the stencil buffer
  90426. */
  90427. cacheStencilState(): void;
  90428. /**
  90429. * Restores the state of the stencil buffer
  90430. */
  90431. restoreStencilState(): void;
  90432. /**
  90433. * Sets the current depth function to LEQUAL
  90434. */
  90435. setDepthFunctionToLessOrEqual(): void;
  90436. /**
  90437. * Gets a boolean indicating if stencil buffer is enabled
  90438. * @returns the current stencil buffer state
  90439. */
  90440. getStencilBuffer(): boolean;
  90441. /**
  90442. * Enable or disable the stencil buffer
  90443. * @param enable defines if the stencil buffer must be enabled or disabled
  90444. */
  90445. setStencilBuffer(enable: boolean): void;
  90446. /**
  90447. * Gets the current stencil mask
  90448. * @returns a number defining the new stencil mask to use
  90449. */
  90450. getStencilMask(): number;
  90451. /**
  90452. * Sets the current stencil mask
  90453. * @param mask defines the new stencil mask to use
  90454. */
  90455. setStencilMask(mask: number): void;
  90456. /**
  90457. * Gets the current stencil function
  90458. * @returns a number defining the stencil function to use
  90459. */
  90460. getStencilFunction(): number;
  90461. /**
  90462. * Gets the current stencil reference value
  90463. * @returns a number defining the stencil reference value to use
  90464. */
  90465. getStencilFunctionReference(): number;
  90466. /**
  90467. * Gets the current stencil mask
  90468. * @returns a number defining the stencil mask to use
  90469. */
  90470. getStencilFunctionMask(): number;
  90471. /**
  90472. * Sets the current stencil function
  90473. * @param stencilFunc defines the new stencil function to use
  90474. */
  90475. setStencilFunction(stencilFunc: number): void;
  90476. /**
  90477. * Sets the current stencil reference
  90478. * @param reference defines the new stencil reference to use
  90479. */
  90480. setStencilFunctionReference(reference: number): void;
  90481. /**
  90482. * Sets the current stencil mask
  90483. * @param mask defines the new stencil mask to use
  90484. */
  90485. setStencilFunctionMask(mask: number): void;
  90486. /**
  90487. * Gets the current stencil operation when stencil fails
  90488. * @returns a number defining stencil operation to use when stencil fails
  90489. */
  90490. getStencilOperationFail(): number;
  90491. /**
  90492. * Gets the current stencil operation when depth fails
  90493. * @returns a number defining stencil operation to use when depth fails
  90494. */
  90495. getStencilOperationDepthFail(): number;
  90496. /**
  90497. * Gets the current stencil operation when stencil passes
  90498. * @returns a number defining stencil operation to use when stencil passes
  90499. */
  90500. getStencilOperationPass(): number;
  90501. /**
  90502. * Sets the stencil operation to use when stencil fails
  90503. * @param operation defines the stencil operation to use when stencil fails
  90504. */
  90505. setStencilOperationFail(operation: number): void;
  90506. /**
  90507. * Sets the stencil operation to use when depth fails
  90508. * @param operation defines the stencil operation to use when depth fails
  90509. */
  90510. setStencilOperationDepthFail(operation: number): void;
  90511. /**
  90512. * Sets the stencil operation to use when stencil passes
  90513. * @param operation defines the stencil operation to use when stencil passes
  90514. */
  90515. setStencilOperationPass(operation: number): void;
  90516. /**
  90517. * Sets a boolean indicating if the dithering state is enabled or disabled
  90518. * @param value defines the dithering state
  90519. */
  90520. setDitheringState(value: boolean): void;
  90521. /**
  90522. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  90523. * @param value defines the rasterizer state
  90524. */
  90525. setRasterizerState(value: boolean): void;
  90526. /**
  90527. * stop executing a render loop function and remove it from the execution array
  90528. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  90529. */
  90530. stopRenderLoop(renderFunction?: () => void): void;
  90531. /** @hidden */
  90532. _renderLoop(): void;
  90533. /**
  90534. * Register and execute a render loop. The engine can have more than one render function
  90535. * @param renderFunction defines the function to continuously execute
  90536. */
  90537. runRenderLoop(renderFunction: () => void): void;
  90538. /**
  90539. * Toggle full screen mode
  90540. * @param requestPointerLock defines if a pointer lock should be requested from the user
  90541. */
  90542. switchFullscreen(requestPointerLock: boolean): void;
  90543. /**
  90544. * Enters full screen mode
  90545. * @param requestPointerLock defines if a pointer lock should be requested from the user
  90546. */
  90547. enterFullscreen(requestPointerLock: boolean): void;
  90548. /**
  90549. * Exits full screen mode
  90550. */
  90551. exitFullscreen(): void;
  90552. /**
  90553. * Clear the current render buffer or the current render target (if any is set up)
  90554. * @param color defines the color to use
  90555. * @param backBuffer defines if the back buffer must be cleared
  90556. * @param depth defines if the depth buffer must be cleared
  90557. * @param stencil defines if the stencil buffer must be cleared
  90558. */
  90559. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  90560. /**
  90561. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  90562. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  90563. * @param y defines the y-coordinate of the corner of the clear rectangle
  90564. * @param width defines the width of the clear rectangle
  90565. * @param height defines the height of the clear rectangle
  90566. * @param clearColor defines the clear color
  90567. */
  90568. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  90569. /**
  90570. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  90571. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  90572. * @param y defines the y-coordinate of the corner of the clear rectangle
  90573. * @param width defines the width of the clear rectangle
  90574. * @param height defines the height of the clear rectangle
  90575. */
  90576. enableScissor(x: number, y: number, width: number, height: number): void;
  90577. /**
  90578. * Disable previously set scissor test rectangle
  90579. */
  90580. disableScissor(): void;
  90581. private _viewportCached;
  90582. /** @hidden */
  90583. _viewport(x: number, y: number, width: number, height: number): void;
  90584. /**
  90585. * Set the WebGL's viewport
  90586. * @param viewport defines the viewport element to be used
  90587. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  90588. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  90589. */
  90590. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  90591. /**
  90592. * Directly set the WebGL Viewport
  90593. * @param x defines the x coordinate of the viewport (in screen space)
  90594. * @param y defines the y coordinate of the viewport (in screen space)
  90595. * @param width defines the width of the viewport (in screen space)
  90596. * @param height defines the height of the viewport (in screen space)
  90597. * @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
  90598. */
  90599. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  90600. /**
  90601. * Begin a new frame
  90602. */
  90603. beginFrame(): void;
  90604. /**
  90605. * Enf the current frame
  90606. */
  90607. endFrame(): void;
  90608. /**
  90609. * Resize the view according to the canvas' size
  90610. */
  90611. resize(): void;
  90612. /**
  90613. * Force a specific size of the canvas
  90614. * @param width defines the new canvas' width
  90615. * @param height defines the new canvas' height
  90616. */
  90617. setSize(width: number, height: number): void;
  90618. /**
  90619. * Binds the frame buffer to the specified texture.
  90620. * @param texture The texture to render to or null for the default canvas
  90621. * @param faceIndex The face of the texture to render to in case of cube texture
  90622. * @param requiredWidth The width of the target to render to
  90623. * @param requiredHeight The height of the target to render to
  90624. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  90625. * @param depthStencilTexture The depth stencil texture to use to render
  90626. * @param lodLevel defines le lod level to bind to the frame buffer
  90627. */
  90628. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  90629. /** @hidden */
  90630. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  90631. /**
  90632. * Unbind the current render target texture from the webGL context
  90633. * @param texture defines the render target texture to unbind
  90634. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  90635. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  90636. */
  90637. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  90638. /**
  90639. * Force the mipmap generation for the given render target texture
  90640. * @param texture defines the render target texture to use
  90641. */
  90642. generateMipMapsForCubemap(texture: InternalTexture): void;
  90643. /**
  90644. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  90645. */
  90646. flushFramebuffer(): void;
  90647. /**
  90648. * Unbind the current render target and bind the default framebuffer
  90649. */
  90650. restoreDefaultFramebuffer(): void;
  90651. /**
  90652. * Create an uniform buffer
  90653. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90654. * @param elements defines the content of the uniform buffer
  90655. * @returns the webGL uniform buffer
  90656. */
  90657. createUniformBuffer(elements: FloatArray): DataBuffer;
  90658. /**
  90659. * Create a dynamic uniform buffer
  90660. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90661. * @param elements defines the content of the uniform buffer
  90662. * @returns the webGL uniform buffer
  90663. */
  90664. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  90665. /**
  90666. * Update an existing uniform buffer
  90667. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90668. * @param uniformBuffer defines the target uniform buffer
  90669. * @param elements defines the content to update
  90670. * @param offset defines the offset in the uniform buffer where update should start
  90671. * @param count defines the size of the data to update
  90672. */
  90673. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  90674. private _resetVertexBufferBinding;
  90675. /**
  90676. * Creates a vertex buffer
  90677. * @param data the data for the vertex buffer
  90678. * @returns the new WebGL static buffer
  90679. */
  90680. createVertexBuffer(data: DataArray): DataBuffer;
  90681. /**
  90682. * Creates a dynamic vertex buffer
  90683. * @param data the data for the dynamic vertex buffer
  90684. * @returns the new WebGL dynamic buffer
  90685. */
  90686. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  90687. /**
  90688. * Update a dynamic index buffer
  90689. * @param indexBuffer defines the target index buffer
  90690. * @param indices defines the data to update
  90691. * @param offset defines the offset in the target index buffer where update should start
  90692. */
  90693. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  90694. /**
  90695. * Updates a dynamic vertex buffer.
  90696. * @param vertexBuffer the vertex buffer to update
  90697. * @param data the data used to update the vertex buffer
  90698. * @param byteOffset the byte offset of the data
  90699. * @param byteLength the byte length of the data
  90700. */
  90701. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  90702. private _resetIndexBufferBinding;
  90703. /**
  90704. * Creates a new index buffer
  90705. * @param indices defines the content of the index buffer
  90706. * @param updatable defines if the index buffer must be updatable
  90707. * @returns a new webGL buffer
  90708. */
  90709. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  90710. /**
  90711. * Bind a webGL buffer to the webGL context
  90712. * @param buffer defines the buffer to bind
  90713. */
  90714. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  90715. /**
  90716. * Bind an uniform buffer to the current webGL context
  90717. * @param buffer defines the buffer to bind
  90718. */
  90719. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  90720. /**
  90721. * Bind a buffer to the current webGL context at a given location
  90722. * @param buffer defines the buffer to bind
  90723. * @param location defines the index where to bind the buffer
  90724. */
  90725. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  90726. /**
  90727. * Bind a specific block at a given index in a specific shader program
  90728. * @param pipelineContext defines the pipeline context to use
  90729. * @param blockName defines the block name
  90730. * @param index defines the index where to bind the block
  90731. */
  90732. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  90733. private bindIndexBuffer;
  90734. private bindBuffer;
  90735. /**
  90736. * update the bound buffer with the given data
  90737. * @param data defines the data to update
  90738. */
  90739. updateArrayBuffer(data: Float32Array): void;
  90740. private _vertexAttribPointer;
  90741. private _bindIndexBufferWithCache;
  90742. private _bindVertexBuffersAttributes;
  90743. /**
  90744. * Records a vertex array object
  90745. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  90746. * @param vertexBuffers defines the list of vertex buffers to store
  90747. * @param indexBuffer defines the index buffer to store
  90748. * @param effect defines the effect to store
  90749. * @returns the new vertex array object
  90750. */
  90751. recordVertexArrayObject(vertexBuffers: {
  90752. [key: string]: VertexBuffer;
  90753. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  90754. /**
  90755. * Bind a specific vertex array object
  90756. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  90757. * @param vertexArrayObject defines the vertex array object to bind
  90758. * @param indexBuffer defines the index buffer to bind
  90759. */
  90760. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  90761. /**
  90762. * Bind webGl buffers directly to the webGL context
  90763. * @param vertexBuffer defines the vertex buffer to bind
  90764. * @param indexBuffer defines the index buffer to bind
  90765. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  90766. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  90767. * @param effect defines the effect associated with the vertex buffer
  90768. */
  90769. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  90770. private _unbindVertexArrayObject;
  90771. /**
  90772. * Bind a list of vertex buffers to the webGL context
  90773. * @param vertexBuffers defines the list of vertex buffers to bind
  90774. * @param indexBuffer defines the index buffer to bind
  90775. * @param effect defines the effect associated with the vertex buffers
  90776. */
  90777. bindBuffers(vertexBuffers: {
  90778. [key: string]: Nullable<VertexBuffer>;
  90779. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  90780. /**
  90781. * Unbind all instance attributes
  90782. */
  90783. unbindInstanceAttributes(): void;
  90784. /**
  90785. * Release and free the memory of a vertex array object
  90786. * @param vao defines the vertex array object to delete
  90787. */
  90788. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  90789. /** @hidden */
  90790. _releaseBuffer(buffer: DataBuffer): boolean;
  90791. /**
  90792. * Creates a webGL buffer to use with instanciation
  90793. * @param capacity defines the size of the buffer
  90794. * @returns the webGL buffer
  90795. */
  90796. createInstancesBuffer(capacity: number): DataBuffer;
  90797. /**
  90798. * Delete a webGL buffer used with instanciation
  90799. * @param buffer defines the webGL buffer to delete
  90800. */
  90801. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  90802. /**
  90803. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  90804. * @param instancesBuffer defines the webGL buffer to update and bind
  90805. * @param data defines the data to store in the buffer
  90806. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  90807. */
  90808. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  90809. /**
  90810. * Apply all cached states (depth, culling, stencil and alpha)
  90811. */
  90812. applyStates(): void;
  90813. /**
  90814. * Send a draw order
  90815. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  90816. * @param indexStart defines the starting index
  90817. * @param indexCount defines the number of index to draw
  90818. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  90819. */
  90820. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  90821. /**
  90822. * Draw a list of points
  90823. * @param verticesStart defines the index of first vertex to draw
  90824. * @param verticesCount defines the count of vertices to draw
  90825. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  90826. */
  90827. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  90828. /**
  90829. * Draw a list of unindexed primitives
  90830. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  90831. * @param verticesStart defines the index of first vertex to draw
  90832. * @param verticesCount defines the count of vertices to draw
  90833. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  90834. */
  90835. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  90836. /**
  90837. * Draw a list of indexed primitives
  90838. * @param fillMode defines the primitive to use
  90839. * @param indexStart defines the starting index
  90840. * @param indexCount defines the number of index to draw
  90841. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  90842. */
  90843. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  90844. /**
  90845. * Draw a list of unindexed primitives
  90846. * @param fillMode defines the primitive to use
  90847. * @param verticesStart defines the index of first vertex to draw
  90848. * @param verticesCount defines the count of vertices to draw
  90849. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  90850. */
  90851. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  90852. private _drawMode;
  90853. /** @hidden */
  90854. _releaseEffect(effect: Effect): void;
  90855. /** @hidden */
  90856. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  90857. /**
  90858. * Create a new effect (used to store vertex/fragment shaders)
  90859. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  90860. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  90861. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  90862. * @param samplers defines an array of string used to represent textures
  90863. * @param defines defines the string containing the defines to use to compile the shaders
  90864. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  90865. * @param onCompiled defines a function to call when the effect creation is successful
  90866. * @param onError defines a function to call when the effect creation has failed
  90867. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  90868. * @returns the new Effect
  90869. */
  90870. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  90871. private _compileShader;
  90872. private _compileRawShader;
  90873. /**
  90874. * Directly creates a webGL program
  90875. * @param pipelineContext defines the pipeline context to attach to
  90876. * @param vertexCode defines the vertex shader code to use
  90877. * @param fragmentCode defines the fragment shader code to use
  90878. * @param context defines the webGL context to use (if not set, the current one will be used)
  90879. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  90880. * @returns the new webGL program
  90881. */
  90882. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  90883. /**
  90884. * Creates a webGL program
  90885. * @param pipelineContext defines the pipeline context to attach to
  90886. * @param vertexCode defines the vertex shader code to use
  90887. * @param fragmentCode defines the fragment shader code to use
  90888. * @param defines defines the string containing the defines to use to compile the shaders
  90889. * @param context defines the webGL context to use (if not set, the current one will be used)
  90890. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  90891. * @returns the new webGL program
  90892. */
  90893. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  90894. /**
  90895. * Creates a new pipeline context
  90896. * @returns the new pipeline
  90897. */
  90898. createPipelineContext(): WebGLPipelineContext;
  90899. private _createShaderProgram;
  90900. private _finalizePipelineContext;
  90901. /** @hidden */
  90902. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  90903. /** @hidden */
  90904. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  90905. /** @hidden */
  90906. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  90907. /**
  90908. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  90909. * @param pipelineContext defines the pipeline context to use
  90910. * @param uniformsNames defines the list of uniform names
  90911. * @returns an array of webGL uniform locations
  90912. */
  90913. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  90914. /**
  90915. * Gets the lsit of active attributes for a given webGL program
  90916. * @param pipelineContext defines the pipeline context to use
  90917. * @param attributesNames defines the list of attribute names to get
  90918. * @returns an array of indices indicating the offset of each attribute
  90919. */
  90920. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  90921. /**
  90922. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  90923. * @param effect defines the effect to activate
  90924. */
  90925. enableEffect(effect: Nullable<Effect>): void;
  90926. /**
  90927. * Set the value of an uniform to an array of int32
  90928. * @param uniform defines the webGL uniform location where to store the value
  90929. * @param array defines the array of int32 to store
  90930. */
  90931. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  90932. /**
  90933. * Set the value of an uniform to an array of int32 (stored as vec2)
  90934. * @param uniform defines the webGL uniform location where to store the value
  90935. * @param array defines the array of int32 to store
  90936. */
  90937. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  90938. /**
  90939. * Set the value of an uniform to an array of int32 (stored as vec3)
  90940. * @param uniform defines the webGL uniform location where to store the value
  90941. * @param array defines the array of int32 to store
  90942. */
  90943. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  90944. /**
  90945. * Set the value of an uniform to an array of int32 (stored as vec4)
  90946. * @param uniform defines the webGL uniform location where to store the value
  90947. * @param array defines the array of int32 to store
  90948. */
  90949. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  90950. /**
  90951. * Set the value of an uniform to an array of float32
  90952. * @param uniform defines the webGL uniform location where to store the value
  90953. * @param array defines the array of float32 to store
  90954. */
  90955. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  90956. /**
  90957. * Set the value of an uniform to an array of float32 (stored as vec2)
  90958. * @param uniform defines the webGL uniform location where to store the value
  90959. * @param array defines the array of float32 to store
  90960. */
  90961. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  90962. /**
  90963. * Set the value of an uniform to an array of float32 (stored as vec3)
  90964. * @param uniform defines the webGL uniform location where to store the value
  90965. * @param array defines the array of float32 to store
  90966. */
  90967. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  90968. /**
  90969. * Set the value of an uniform to an array of float32 (stored as vec4)
  90970. * @param uniform defines the webGL uniform location where to store the value
  90971. * @param array defines the array of float32 to store
  90972. */
  90973. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  90974. /**
  90975. * Set the value of an uniform to an array of number
  90976. * @param uniform defines the webGL uniform location where to store the value
  90977. * @param array defines the array of number to store
  90978. */
  90979. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  90980. /**
  90981. * Set the value of an uniform to an array of number (stored as vec2)
  90982. * @param uniform defines the webGL uniform location where to store the value
  90983. * @param array defines the array of number to store
  90984. */
  90985. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  90986. /**
  90987. * Set the value of an uniform to an array of number (stored as vec3)
  90988. * @param uniform defines the webGL uniform location where to store the value
  90989. * @param array defines the array of number to store
  90990. */
  90991. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  90992. /**
  90993. * Set the value of an uniform to an array of number (stored as vec4)
  90994. * @param uniform defines the webGL uniform location where to store the value
  90995. * @param array defines the array of number to store
  90996. */
  90997. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  90998. /**
  90999. * Set the value of an uniform to an array of float32 (stored as matrices)
  91000. * @param uniform defines the webGL uniform location where to store the value
  91001. * @param matrices defines the array of float32 to store
  91002. */
  91003. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  91004. /**
  91005. * Set the value of an uniform to a matrix
  91006. * @param uniform defines the webGL uniform location where to store the value
  91007. * @param matrix defines the matrix to store
  91008. */
  91009. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  91010. /**
  91011. * Set the value of an uniform to a matrix (3x3)
  91012. * @param uniform defines the webGL uniform location where to store the value
  91013. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  91014. */
  91015. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  91016. /**
  91017. * Set the value of an uniform to a matrix (2x2)
  91018. * @param uniform defines the webGL uniform location where to store the value
  91019. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  91020. */
  91021. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  91022. /**
  91023. * Set the value of an uniform to a number (int)
  91024. * @param uniform defines the webGL uniform location where to store the value
  91025. * @param value defines the int number to store
  91026. */
  91027. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  91028. /**
  91029. * Set the value of an uniform to a number (float)
  91030. * @param uniform defines the webGL uniform location where to store the value
  91031. * @param value defines the float number to store
  91032. */
  91033. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  91034. /**
  91035. * Set the value of an uniform to a vec2
  91036. * @param uniform defines the webGL uniform location where to store the value
  91037. * @param x defines the 1st component of the value
  91038. * @param y defines the 2nd component of the value
  91039. */
  91040. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  91041. /**
  91042. * Set the value of an uniform to a vec3
  91043. * @param uniform defines the webGL uniform location where to store the value
  91044. * @param x defines the 1st component of the value
  91045. * @param y defines the 2nd component of the value
  91046. * @param z defines the 3rd component of the value
  91047. */
  91048. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  91049. /**
  91050. * Set the value of an uniform to a boolean
  91051. * @param uniform defines the webGL uniform location where to store the value
  91052. * @param bool defines the boolean to store
  91053. */
  91054. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  91055. /**
  91056. * Set the value of an uniform to a vec4
  91057. * @param uniform defines the webGL uniform location where to store the value
  91058. * @param x defines the 1st component of the value
  91059. * @param y defines the 2nd component of the value
  91060. * @param z defines the 3rd component of the value
  91061. * @param w defines the 4th component of the value
  91062. */
  91063. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  91064. /**
  91065. * Set the value of an uniform to a Color3
  91066. * @param uniform defines the webGL uniform location where to store the value
  91067. * @param color3 defines the color to store
  91068. */
  91069. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  91070. /**
  91071. * Set the value of an uniform to a Color3 and an alpha value
  91072. * @param uniform defines the webGL uniform location where to store the value
  91073. * @param color3 defines the color to store
  91074. * @param alpha defines the alpha component to store
  91075. */
  91076. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  91077. /**
  91078. * Sets a Color4 on a uniform variable
  91079. * @param uniform defines the uniform location
  91080. * @param color4 defines the value to be set
  91081. */
  91082. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  91083. /**
  91084. * Set various states to the webGL context
  91085. * @param culling defines backface culling state
  91086. * @param zOffset defines the value to apply to zOffset (0 by default)
  91087. * @param force defines if states must be applied even if cache is up to date
  91088. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  91089. */
  91090. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  91091. /**
  91092. * Set the z offset to apply to current rendering
  91093. * @param value defines the offset to apply
  91094. */
  91095. setZOffset(value: number): void;
  91096. /**
  91097. * Gets the current value of the zOffset
  91098. * @returns the current zOffset state
  91099. */
  91100. getZOffset(): number;
  91101. /**
  91102. * Enable or disable depth buffering
  91103. * @param enable defines the state to set
  91104. */
  91105. setDepthBuffer(enable: boolean): void;
  91106. /**
  91107. * Gets a boolean indicating if depth writing is enabled
  91108. * @returns the current depth writing state
  91109. */
  91110. getDepthWrite(): boolean;
  91111. /**
  91112. * Enable or disable depth writing
  91113. * @param enable defines the state to set
  91114. */
  91115. setDepthWrite(enable: boolean): void;
  91116. /**
  91117. * Enable or disable color writing
  91118. * @param enable defines the state to set
  91119. */
  91120. setColorWrite(enable: boolean): void;
  91121. /**
  91122. * Gets a boolean indicating if color writing is enabled
  91123. * @returns the current color writing state
  91124. */
  91125. getColorWrite(): boolean;
  91126. /**
  91127. * Sets alpha constants used by some alpha blending modes
  91128. * @param r defines the red component
  91129. * @param g defines the green component
  91130. * @param b defines the blue component
  91131. * @param a defines the alpha component
  91132. */
  91133. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  91134. /**
  91135. * Sets the current alpha mode
  91136. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  91137. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  91138. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  91139. */
  91140. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  91141. /**
  91142. * Gets the current alpha mode
  91143. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  91144. * @returns the current alpha mode
  91145. */
  91146. getAlphaMode(): number;
  91147. /**
  91148. * Clears the list of texture accessible through engine.
  91149. * This can help preventing texture load conflict due to name collision.
  91150. */
  91151. clearInternalTexturesCache(): void;
  91152. /**
  91153. * Force the entire cache to be cleared
  91154. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  91155. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  91156. */
  91157. wipeCaches(bruteForce?: boolean): void;
  91158. /**
  91159. * Set the compressed texture format to use, based on the formats you have, and the formats
  91160. * supported by the hardware / browser.
  91161. *
  91162. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  91163. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  91164. * to API arguments needed to compressed textures. This puts the burden on the container
  91165. * generator to house the arcane code for determining these for current & future formats.
  91166. *
  91167. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  91168. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  91169. *
  91170. * Note: The result of this call is not taken into account when a texture is base64.
  91171. *
  91172. * @param formatsAvailable defines the list of those format families you have created
  91173. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  91174. *
  91175. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  91176. * @returns The extension selected.
  91177. */
  91178. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  91179. /** @hidden */
  91180. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  91181. min: number;
  91182. mag: number;
  91183. };
  91184. /** @hidden */
  91185. _createTexture(): WebGLTexture;
  91186. /**
  91187. * Usually called from Texture.ts.
  91188. * Passed information to create a WebGLTexture
  91189. * @param urlArg defines a value which contains one of the following:
  91190. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  91191. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  91192. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  91193. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  91194. * @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)
  91195. * @param scene needed for loading to the correct scene
  91196. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  91197. * @param onLoad optional callback to be called upon successful completion
  91198. * @param onError optional callback to be called upon failure
  91199. * @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
  91200. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  91201. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  91202. * @param forcedExtension defines the extension to use to pick the right loader
  91203. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  91204. * @returns a InternalTexture for assignment back into BABYLON.Texture
  91205. */
  91206. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  91207. private _rescaleTexture;
  91208. private _unpackFlipYCached;
  91209. /**
  91210. * In case you are sharing the context with other applications, it might
  91211. * be interested to not cache the unpack flip y state to ensure a consistent
  91212. * value would be set.
  91213. */
  91214. enableUnpackFlipYCached: boolean;
  91215. /** @hidden */
  91216. _unpackFlipY(value: boolean): void;
  91217. /** @hidden */
  91218. _getUnpackAlignement(): number;
  91219. /**
  91220. * Creates a dynamic texture
  91221. * @param width defines the width of the texture
  91222. * @param height defines the height of the texture
  91223. * @param generateMipMaps defines if the engine should generate the mip levels
  91224. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  91225. * @returns the dynamic texture inside an InternalTexture
  91226. */
  91227. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  91228. /**
  91229. * Update the sampling mode of a given texture
  91230. * @param samplingMode defines the required sampling mode
  91231. * @param texture defines the texture to update
  91232. */
  91233. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  91234. /**
  91235. * Update the content of a dynamic texture
  91236. * @param texture defines the texture to update
  91237. * @param canvas defines the canvas containing the source
  91238. * @param invertY defines if data must be stored with Y axis inverted
  91239. * @param premulAlpha defines if alpha is stored as premultiplied
  91240. * @param format defines the format of the data
  91241. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  91242. */
  91243. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  91244. /**
  91245. * Update a video texture
  91246. * @param texture defines the texture to update
  91247. * @param video defines the video element to use
  91248. * @param invertY defines if data must be stored with Y axis inverted
  91249. */
  91250. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  91251. /**
  91252. * Updates a depth texture Comparison Mode and Function.
  91253. * If the comparison Function is equal to 0, the mode will be set to none.
  91254. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  91255. * @param texture The texture to set the comparison function for
  91256. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  91257. */
  91258. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  91259. /** @hidden */
  91260. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  91261. width: number;
  91262. height: number;
  91263. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  91264. /**
  91265. * Creates a depth stencil texture.
  91266. * This is only available in WebGL 2 or with the depth texture extension available.
  91267. * @param size The size of face edge in the texture.
  91268. * @param options The options defining the texture.
  91269. * @returns The texture
  91270. */
  91271. createDepthStencilTexture(size: number | {
  91272. width: number;
  91273. height: number;
  91274. }, options: DepthTextureCreationOptions): InternalTexture;
  91275. /**
  91276. * Creates a depth stencil texture.
  91277. * This is only available in WebGL 2 or with the depth texture extension available.
  91278. * @param size The size of face edge in the texture.
  91279. * @param options The options defining the texture.
  91280. * @returns The texture
  91281. */
  91282. private _createDepthStencilTexture;
  91283. /**
  91284. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  91285. * @param renderTarget The render target to set the frame buffer for
  91286. */
  91287. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  91288. /**
  91289. * Creates a new render target texture
  91290. * @param size defines the size of the texture
  91291. * @param options defines the options used to create the texture
  91292. * @returns a new render target texture stored in an InternalTexture
  91293. */
  91294. createRenderTargetTexture(size: number | {
  91295. width: number;
  91296. height: number;
  91297. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  91298. /** @hidden */
  91299. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  91300. /**
  91301. * Updates the sample count of a render target texture
  91302. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  91303. * @param texture defines the texture to update
  91304. * @param samples defines the sample count to set
  91305. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  91306. */
  91307. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  91308. /** @hidden */
  91309. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  91310. /** @hidden */
  91311. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  91312. /** @hidden */
  91313. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  91314. /** @hidden */
  91315. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  91316. /**
  91317. * @hidden
  91318. */
  91319. _setCubeMapTextureParams(loadMipmap: boolean): void;
  91320. private _prepareWebGLTextureContinuation;
  91321. private _prepareWebGLTexture;
  91322. /** @hidden */
  91323. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  91324. /** @hidden */
  91325. _releaseFramebufferObjects(texture: InternalTexture): void;
  91326. /** @hidden */
  91327. _releaseTexture(texture: InternalTexture): void;
  91328. private setProgram;
  91329. private _boundUniforms;
  91330. /**
  91331. * Binds an effect to the webGL context
  91332. * @param effect defines the effect to bind
  91333. */
  91334. bindSamplers(effect: Effect): void;
  91335. private _activateCurrentTexture;
  91336. /** @hidden */
  91337. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  91338. /** @hidden */
  91339. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  91340. /**
  91341. * Sets a texture to the webGL context from a postprocess
  91342. * @param channel defines the channel to use
  91343. * @param postProcess defines the source postprocess
  91344. */
  91345. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  91346. /**
  91347. * Binds the output of the passed in post process to the texture channel specified
  91348. * @param channel The channel the texture should be bound to
  91349. * @param postProcess The post process which's output should be bound
  91350. */
  91351. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  91352. /**
  91353. * Unbind all textures from the webGL context
  91354. */
  91355. unbindAllTextures(): void;
  91356. /**
  91357. * Sets a texture to the according uniform.
  91358. * @param channel The texture channel
  91359. * @param uniform The uniform to set
  91360. * @param texture The texture to apply
  91361. */
  91362. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  91363. /**
  91364. * Sets a depth stencil texture from a render target to the according uniform.
  91365. * @param channel The texture channel
  91366. * @param uniform The uniform to set
  91367. * @param texture The render target texture containing the depth stencil texture to apply
  91368. */
  91369. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  91370. private _bindSamplerUniformToChannel;
  91371. private _getTextureWrapMode;
  91372. private _setTexture;
  91373. /**
  91374. * Sets an array of texture to the webGL context
  91375. * @param channel defines the channel where the texture array must be set
  91376. * @param uniform defines the associated uniform location
  91377. * @param textures defines the array of textures to bind
  91378. */
  91379. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  91380. /** @hidden */
  91381. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  91382. private _setTextureParameterFloat;
  91383. private _setTextureParameterInteger;
  91384. /**
  91385. * Reads pixels from the current frame buffer. Please note that this function can be slow
  91386. * @param x defines the x coordinate of the rectangle where pixels must be read
  91387. * @param y defines the y coordinate of the rectangle where pixels must be read
  91388. * @param width defines the width of the rectangle where pixels must be read
  91389. * @param height defines the height of the rectangle where pixels must be read
  91390. * @returns a Uint8Array containing RGBA colors
  91391. */
  91392. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  91393. /**
  91394. * Add an externaly attached data from its key.
  91395. * This method call will fail and return false, if such key already exists.
  91396. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  91397. * @param key the unique key that identifies the data
  91398. * @param data the data object to associate to the key for this Engine instance
  91399. * @return true if no such key were already present and the data was added successfully, false otherwise
  91400. */
  91401. addExternalData<T>(key: string, data: T): boolean;
  91402. /**
  91403. * Get an externaly attached data from its key
  91404. * @param key the unique key that identifies the data
  91405. * @return the associated data, if present (can be null), or undefined if not present
  91406. */
  91407. getExternalData<T>(key: string): T;
  91408. /**
  91409. * Get an externaly attached data from its key, create it using a factory if it's not already present
  91410. * @param key the unique key that identifies the data
  91411. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  91412. * @return the associated data, can be null if the factory returned null.
  91413. */
  91414. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  91415. /**
  91416. * Remove an externaly attached data from the Engine instance
  91417. * @param key the unique key that identifies the data
  91418. * @return true if the data was successfully removed, false if it doesn't exist
  91419. */
  91420. removeExternalData(key: string): boolean;
  91421. /**
  91422. * Unbind all vertex attributes from the webGL context
  91423. */
  91424. unbindAllAttributes(): void;
  91425. /**
  91426. * 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
  91427. */
  91428. releaseEffects(): void;
  91429. /**
  91430. * Dispose and release all associated resources
  91431. */
  91432. dispose(): void;
  91433. /**
  91434. * Display the loading screen
  91435. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91436. */
  91437. displayLoadingUI(): void;
  91438. /**
  91439. * Hide the loading screen
  91440. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91441. */
  91442. hideLoadingUI(): void;
  91443. /**
  91444. * Gets the current loading screen object
  91445. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91446. */
  91447. /**
  91448. * Sets the current loading screen object
  91449. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91450. */
  91451. loadingScreen: ILoadingScreen;
  91452. /**
  91453. * Sets the current loading screen text
  91454. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91455. */
  91456. loadingUIText: string;
  91457. /**
  91458. * Sets the current loading screen background color
  91459. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91460. */
  91461. loadingUIBackgroundColor: string;
  91462. /**
  91463. * Attach a new callback raised when context lost event is fired
  91464. * @param callback defines the callback to call
  91465. */
  91466. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  91467. /**
  91468. * Attach a new callback raised when context restored event is fired
  91469. * @param callback defines the callback to call
  91470. */
  91471. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  91472. /**
  91473. * Gets the source code of the vertex shader associated with a specific webGL program
  91474. * @param program defines the program to use
  91475. * @returns a string containing the source code of the vertex shader associated with the program
  91476. */
  91477. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  91478. /**
  91479. * Gets the source code of the fragment shader associated with a specific webGL program
  91480. * @param program defines the program to use
  91481. * @returns a string containing the source code of the fragment shader associated with the program
  91482. */
  91483. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  91484. /**
  91485. * Get the current error code of the webGL context
  91486. * @returns the error code
  91487. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  91488. */
  91489. getError(): number;
  91490. /**
  91491. * Gets the current framerate
  91492. * @returns a number representing the framerate
  91493. */
  91494. getFps(): number;
  91495. /**
  91496. * Gets the time spent between current and previous frame
  91497. * @returns a number representing the delta time in ms
  91498. */
  91499. getDeltaTime(): number;
  91500. private _measureFps;
  91501. /** @hidden */
  91502. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  91503. private _canRenderToFloatFramebuffer;
  91504. private _canRenderToHalfFloatFramebuffer;
  91505. private _canRenderToFramebuffer;
  91506. /** @hidden */
  91507. _getWebGLTextureType(type: number): number;
  91508. /** @hidden */
  91509. _getInternalFormat(format: number): number;
  91510. /** @hidden */
  91511. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  91512. /** @hidden */
  91513. _getRGBAMultiSampleBufferFormat(type: number): number;
  91514. /** @hidden */
  91515. _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;
  91516. /** @hidden */
  91517. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  91518. /**
  91519. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  91520. * @returns true if the engine can be created
  91521. * @ignorenaming
  91522. */
  91523. static isSupported(): boolean;
  91524. }
  91525. }
  91526. declare module BABYLON {
  91527. /**
  91528. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  91529. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  91530. */
  91531. export class EffectFallbacks {
  91532. private _defines;
  91533. private _currentRank;
  91534. private _maxRank;
  91535. private _mesh;
  91536. /**
  91537. * Removes the fallback from the bound mesh.
  91538. */
  91539. unBindMesh(): void;
  91540. /**
  91541. * Adds a fallback on the specified property.
  91542. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  91543. * @param define The name of the define in the shader
  91544. */
  91545. addFallback(rank: number, define: string): void;
  91546. /**
  91547. * Sets the mesh to use CPU skinning when needing to fallback.
  91548. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  91549. * @param mesh The mesh to use the fallbacks.
  91550. */
  91551. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  91552. /**
  91553. * Checks to see if more fallbacks are still availible.
  91554. */
  91555. readonly isMoreFallbacks: boolean;
  91556. /**
  91557. * Removes the defines that should be removed when falling back.
  91558. * @param currentDefines defines the current define statements for the shader.
  91559. * @param effect defines the current effect we try to compile
  91560. * @returns The resulting defines with defines of the current rank removed.
  91561. */
  91562. reduce(currentDefines: string, effect: Effect): string;
  91563. }
  91564. /**
  91565. * Options to be used when creating an effect.
  91566. */
  91567. export class EffectCreationOptions {
  91568. /**
  91569. * Atrributes that will be used in the shader.
  91570. */
  91571. attributes: string[];
  91572. /**
  91573. * Uniform varible names that will be set in the shader.
  91574. */
  91575. uniformsNames: string[];
  91576. /**
  91577. * Uniform buffer varible names that will be set in the shader.
  91578. */
  91579. uniformBuffersNames: string[];
  91580. /**
  91581. * Sampler texture variable names that will be set in the shader.
  91582. */
  91583. samplers: string[];
  91584. /**
  91585. * Define statements that will be set in the shader.
  91586. */
  91587. defines: any;
  91588. /**
  91589. * Possible fallbacks for this effect to improve performance when needed.
  91590. */
  91591. fallbacks: Nullable<EffectFallbacks>;
  91592. /**
  91593. * Callback that will be called when the shader is compiled.
  91594. */
  91595. onCompiled: Nullable<(effect: Effect) => void>;
  91596. /**
  91597. * Callback that will be called if an error occurs during shader compilation.
  91598. */
  91599. onError: Nullable<(effect: Effect, errors: string) => void>;
  91600. /**
  91601. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  91602. */
  91603. indexParameters: any;
  91604. /**
  91605. * Max number of lights that can be used in the shader.
  91606. */
  91607. maxSimultaneousLights: number;
  91608. /**
  91609. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  91610. */
  91611. transformFeedbackVaryings: Nullable<string[]>;
  91612. }
  91613. /**
  91614. * Effect containing vertex and fragment shader that can be executed on an object.
  91615. */
  91616. export class Effect implements IDisposable {
  91617. /**
  91618. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  91619. */
  91620. static ShadersRepository: string;
  91621. /**
  91622. * Name of the effect.
  91623. */
  91624. name: any;
  91625. /**
  91626. * String container all the define statements that should be set on the shader.
  91627. */
  91628. defines: string;
  91629. /**
  91630. * Callback that will be called when the shader is compiled.
  91631. */
  91632. onCompiled: Nullable<(effect: Effect) => void>;
  91633. /**
  91634. * Callback that will be called if an error occurs during shader compilation.
  91635. */
  91636. onError: Nullable<(effect: Effect, errors: string) => void>;
  91637. /**
  91638. * Callback that will be called when effect is bound.
  91639. */
  91640. onBind: Nullable<(effect: Effect) => void>;
  91641. /**
  91642. * Unique ID of the effect.
  91643. */
  91644. uniqueId: number;
  91645. /**
  91646. * Observable that will be called when the shader is compiled.
  91647. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  91648. */
  91649. onCompileObservable: Observable<Effect>;
  91650. /**
  91651. * Observable that will be called if an error occurs during shader compilation.
  91652. */
  91653. onErrorObservable: Observable<Effect>;
  91654. /** @hidden */
  91655. _onBindObservable: Nullable<Observable<Effect>>;
  91656. /**
  91657. * Observable that will be called when effect is bound.
  91658. */
  91659. readonly onBindObservable: Observable<Effect>;
  91660. /** @hidden */
  91661. _bonesComputationForcedToCPU: boolean;
  91662. private static _uniqueIdSeed;
  91663. private _engine;
  91664. private _uniformBuffersNames;
  91665. private _uniformsNames;
  91666. private _samplerList;
  91667. private _samplers;
  91668. private _isReady;
  91669. private _compilationError;
  91670. private _attributesNames;
  91671. private _attributes;
  91672. private _uniforms;
  91673. /**
  91674. * Key for the effect.
  91675. * @hidden
  91676. */
  91677. _key: string;
  91678. private _indexParameters;
  91679. private _fallbacks;
  91680. private _vertexSourceCode;
  91681. private _fragmentSourceCode;
  91682. private _vertexSourceCodeOverride;
  91683. private _fragmentSourceCodeOverride;
  91684. private _transformFeedbackVaryings;
  91685. /**
  91686. * Compiled shader to webGL program.
  91687. * @hidden
  91688. */
  91689. _pipelineContext: Nullable<IPipelineContext>;
  91690. private _valueCache;
  91691. private static _baseCache;
  91692. /**
  91693. * Instantiates an effect.
  91694. * An effect can be used to create/manage/execute vertex and fragment shaders.
  91695. * @param baseName Name of the effect.
  91696. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  91697. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  91698. * @param samplers List of sampler variables that will be passed to the shader.
  91699. * @param engine Engine to be used to render the effect
  91700. * @param defines Define statements to be added to the shader.
  91701. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  91702. * @param onCompiled Callback that will be called when the shader is compiled.
  91703. * @param onError Callback that will be called if an error occurs during shader compilation.
  91704. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  91705. */
  91706. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  91707. private _useFinalCode;
  91708. /**
  91709. * Unique key for this effect
  91710. */
  91711. readonly key: string;
  91712. /**
  91713. * If the effect has been compiled and prepared.
  91714. * @returns if the effect is compiled and prepared.
  91715. */
  91716. isReady(): boolean;
  91717. /**
  91718. * The engine the effect was initialized with.
  91719. * @returns the engine.
  91720. */
  91721. getEngine(): Engine;
  91722. /**
  91723. * The pipeline context for this effect
  91724. * @returns the associated pipeline context
  91725. */
  91726. getPipelineContext(): Nullable<IPipelineContext>;
  91727. /**
  91728. * The set of names of attribute variables for the shader.
  91729. * @returns An array of attribute names.
  91730. */
  91731. getAttributesNames(): string[];
  91732. /**
  91733. * Returns the attribute at the given index.
  91734. * @param index The index of the attribute.
  91735. * @returns The location of the attribute.
  91736. */
  91737. getAttributeLocation(index: number): number;
  91738. /**
  91739. * Returns the attribute based on the name of the variable.
  91740. * @param name of the attribute to look up.
  91741. * @returns the attribute location.
  91742. */
  91743. getAttributeLocationByName(name: string): number;
  91744. /**
  91745. * The number of attributes.
  91746. * @returns the numnber of attributes.
  91747. */
  91748. getAttributesCount(): number;
  91749. /**
  91750. * Gets the index of a uniform variable.
  91751. * @param uniformName of the uniform to look up.
  91752. * @returns the index.
  91753. */
  91754. getUniformIndex(uniformName: string): number;
  91755. /**
  91756. * Returns the attribute based on the name of the variable.
  91757. * @param uniformName of the uniform to look up.
  91758. * @returns the location of the uniform.
  91759. */
  91760. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  91761. /**
  91762. * Returns an array of sampler variable names
  91763. * @returns The array of sampler variable neames.
  91764. */
  91765. getSamplers(): string[];
  91766. /**
  91767. * The error from the last compilation.
  91768. * @returns the error string.
  91769. */
  91770. getCompilationError(): string;
  91771. /**
  91772. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  91773. * @param func The callback to be used.
  91774. */
  91775. executeWhenCompiled(func: (effect: Effect) => void): void;
  91776. private _checkIsReady;
  91777. /** @hidden */
  91778. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  91779. /** @hidden */
  91780. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  91781. /** @hidden */
  91782. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  91783. /**
  91784. * Recompiles the webGL program
  91785. * @param vertexSourceCode The source code for the vertex shader.
  91786. * @param fragmentSourceCode The source code for the fragment shader.
  91787. * @param onCompiled Callback called when completed.
  91788. * @param onError Callback called on error.
  91789. * @hidden
  91790. */
  91791. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  91792. /**
  91793. * Prepares the effect
  91794. * @hidden
  91795. */
  91796. _prepareEffect(): void;
  91797. /**
  91798. * Checks if the effect is supported. (Must be called after compilation)
  91799. */
  91800. readonly isSupported: boolean;
  91801. /**
  91802. * Binds a texture to the engine to be used as output of the shader.
  91803. * @param channel Name of the output variable.
  91804. * @param texture Texture to bind.
  91805. * @hidden
  91806. */
  91807. _bindTexture(channel: string, texture: InternalTexture): void;
  91808. /**
  91809. * Sets a texture on the engine to be used in the shader.
  91810. * @param channel Name of the sampler variable.
  91811. * @param texture Texture to set.
  91812. */
  91813. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  91814. /**
  91815. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  91816. * @param channel Name of the sampler variable.
  91817. * @param texture Texture to set.
  91818. */
  91819. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  91820. /**
  91821. * Sets an array of textures on the engine to be used in the shader.
  91822. * @param channel Name of the variable.
  91823. * @param textures Textures to set.
  91824. */
  91825. setTextureArray(channel: string, textures: BaseTexture[]): void;
  91826. /**
  91827. * 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)
  91828. * @param channel Name of the sampler variable.
  91829. * @param postProcess Post process to get the input texture from.
  91830. */
  91831. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  91832. /**
  91833. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  91834. * 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)
  91835. * @param channel Name of the sampler variable.
  91836. * @param postProcess Post process to get the output texture from.
  91837. */
  91838. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  91839. /** @hidden */
  91840. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  91841. /** @hidden */
  91842. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  91843. /** @hidden */
  91844. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  91845. /** @hidden */
  91846. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  91847. /**
  91848. * Binds a buffer to a uniform.
  91849. * @param buffer Buffer to bind.
  91850. * @param name Name of the uniform variable to bind to.
  91851. */
  91852. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  91853. /**
  91854. * Binds block to a uniform.
  91855. * @param blockName Name of the block to bind.
  91856. * @param index Index to bind.
  91857. */
  91858. bindUniformBlock(blockName: string, index: number): void;
  91859. /**
  91860. * Sets an interger value on a uniform variable.
  91861. * @param uniformName Name of the variable.
  91862. * @param value Value to be set.
  91863. * @returns this effect.
  91864. */
  91865. setInt(uniformName: string, value: number): Effect;
  91866. /**
  91867. * Sets an int array on a uniform variable.
  91868. * @param uniformName Name of the variable.
  91869. * @param array array to be set.
  91870. * @returns this effect.
  91871. */
  91872. setIntArray(uniformName: string, array: Int32Array): Effect;
  91873. /**
  91874. * 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)
  91875. * @param uniformName Name of the variable.
  91876. * @param array array to be set.
  91877. * @returns this effect.
  91878. */
  91879. setIntArray2(uniformName: string, array: Int32Array): Effect;
  91880. /**
  91881. * 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)
  91882. * @param uniformName Name of the variable.
  91883. * @param array array to be set.
  91884. * @returns this effect.
  91885. */
  91886. setIntArray3(uniformName: string, array: Int32Array): Effect;
  91887. /**
  91888. * 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)
  91889. * @param uniformName Name of the variable.
  91890. * @param array array to be set.
  91891. * @returns this effect.
  91892. */
  91893. setIntArray4(uniformName: string, array: Int32Array): Effect;
  91894. /**
  91895. * Sets an float array on a uniform variable.
  91896. * @param uniformName Name of the variable.
  91897. * @param array array to be set.
  91898. * @returns this effect.
  91899. */
  91900. setFloatArray(uniformName: string, array: Float32Array): Effect;
  91901. /**
  91902. * 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)
  91903. * @param uniformName Name of the variable.
  91904. * @param array array to be set.
  91905. * @returns this effect.
  91906. */
  91907. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  91908. /**
  91909. * 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)
  91910. * @param uniformName Name of the variable.
  91911. * @param array array to be set.
  91912. * @returns this effect.
  91913. */
  91914. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  91915. /**
  91916. * 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)
  91917. * @param uniformName Name of the variable.
  91918. * @param array array to be set.
  91919. * @returns this effect.
  91920. */
  91921. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  91922. /**
  91923. * Sets an array on a uniform variable.
  91924. * @param uniformName Name of the variable.
  91925. * @param array array to be set.
  91926. * @returns this effect.
  91927. */
  91928. setArray(uniformName: string, array: number[]): Effect;
  91929. /**
  91930. * 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)
  91931. * @param uniformName Name of the variable.
  91932. * @param array array to be set.
  91933. * @returns this effect.
  91934. */
  91935. setArray2(uniformName: string, array: number[]): Effect;
  91936. /**
  91937. * 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)
  91938. * @param uniformName Name of the variable.
  91939. * @param array array to be set.
  91940. * @returns this effect.
  91941. */
  91942. setArray3(uniformName: string, array: number[]): Effect;
  91943. /**
  91944. * 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)
  91945. * @param uniformName Name of the variable.
  91946. * @param array array to be set.
  91947. * @returns this effect.
  91948. */
  91949. setArray4(uniformName: string, array: number[]): Effect;
  91950. /**
  91951. * Sets matrices on a uniform variable.
  91952. * @param uniformName Name of the variable.
  91953. * @param matrices matrices to be set.
  91954. * @returns this effect.
  91955. */
  91956. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  91957. /**
  91958. * Sets matrix on a uniform variable.
  91959. * @param uniformName Name of the variable.
  91960. * @param matrix matrix to be set.
  91961. * @returns this effect.
  91962. */
  91963. setMatrix(uniformName: string, matrix: Matrix): Effect;
  91964. /**
  91965. * 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)
  91966. * @param uniformName Name of the variable.
  91967. * @param matrix matrix to be set.
  91968. * @returns this effect.
  91969. */
  91970. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  91971. /**
  91972. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  91973. * @param uniformName Name of the variable.
  91974. * @param matrix matrix to be set.
  91975. * @returns this effect.
  91976. */
  91977. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  91978. /**
  91979. * Sets a float on a uniform variable.
  91980. * @param uniformName Name of the variable.
  91981. * @param value value to be set.
  91982. * @returns this effect.
  91983. */
  91984. setFloat(uniformName: string, value: number): Effect;
  91985. /**
  91986. * Sets a boolean on a uniform variable.
  91987. * @param uniformName Name of the variable.
  91988. * @param bool value to be set.
  91989. * @returns this effect.
  91990. */
  91991. setBool(uniformName: string, bool: boolean): Effect;
  91992. /**
  91993. * Sets a Vector2 on a uniform variable.
  91994. * @param uniformName Name of the variable.
  91995. * @param vector2 vector2 to be set.
  91996. * @returns this effect.
  91997. */
  91998. setVector2(uniformName: string, vector2: Vector2): Effect;
  91999. /**
  92000. * Sets a float2 on a uniform variable.
  92001. * @param uniformName Name of the variable.
  92002. * @param x First float in float2.
  92003. * @param y Second float in float2.
  92004. * @returns this effect.
  92005. */
  92006. setFloat2(uniformName: string, x: number, y: number): Effect;
  92007. /**
  92008. * Sets a Vector3 on a uniform variable.
  92009. * @param uniformName Name of the variable.
  92010. * @param vector3 Value to be set.
  92011. * @returns this effect.
  92012. */
  92013. setVector3(uniformName: string, vector3: Vector3): Effect;
  92014. /**
  92015. * Sets a float3 on a uniform variable.
  92016. * @param uniformName Name of the variable.
  92017. * @param x First float in float3.
  92018. * @param y Second float in float3.
  92019. * @param z Third float in float3.
  92020. * @returns this effect.
  92021. */
  92022. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  92023. /**
  92024. * Sets a Vector4 on a uniform variable.
  92025. * @param uniformName Name of the variable.
  92026. * @param vector4 Value to be set.
  92027. * @returns this effect.
  92028. */
  92029. setVector4(uniformName: string, vector4: Vector4): Effect;
  92030. /**
  92031. * Sets a float4 on a uniform variable.
  92032. * @param uniformName Name of the variable.
  92033. * @param x First float in float4.
  92034. * @param y Second float in float4.
  92035. * @param z Third float in float4.
  92036. * @param w Fourth float in float4.
  92037. * @returns this effect.
  92038. */
  92039. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  92040. /**
  92041. * Sets a Color3 on a uniform variable.
  92042. * @param uniformName Name of the variable.
  92043. * @param color3 Value to be set.
  92044. * @returns this effect.
  92045. */
  92046. setColor3(uniformName: string, color3: Color3): Effect;
  92047. /**
  92048. * Sets a Color4 on a uniform variable.
  92049. * @param uniformName Name of the variable.
  92050. * @param color3 Value to be set.
  92051. * @param alpha Alpha value to be set.
  92052. * @returns this effect.
  92053. */
  92054. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  92055. /**
  92056. * Sets a Color4 on a uniform variable
  92057. * @param uniformName defines the name of the variable
  92058. * @param color4 defines the value to be set
  92059. * @returns this effect.
  92060. */
  92061. setDirectColor4(uniformName: string, color4: Color4): Effect;
  92062. /** Release all associated resources */
  92063. dispose(): void;
  92064. /**
  92065. * This function will add a new shader to the shader store
  92066. * @param name the name of the shader
  92067. * @param pixelShader optional pixel shader content
  92068. * @param vertexShader optional vertex shader content
  92069. */
  92070. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  92071. /**
  92072. * Store of each shader (The can be looked up using effect.key)
  92073. */
  92074. static ShadersStore: {
  92075. [key: string]: string;
  92076. };
  92077. /**
  92078. * Store of each included file for a shader (The can be looked up using effect.key)
  92079. */
  92080. static IncludesShadersStore: {
  92081. [key: string]: string;
  92082. };
  92083. /**
  92084. * Resets the cache of effects.
  92085. */
  92086. static ResetCache(): void;
  92087. }
  92088. }
  92089. declare module BABYLON {
  92090. /**
  92091. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  92092. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  92093. * 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;
  92094. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  92095. */
  92096. export class ColorCurves {
  92097. private _dirty;
  92098. private _tempColor;
  92099. private _globalCurve;
  92100. private _highlightsCurve;
  92101. private _midtonesCurve;
  92102. private _shadowsCurve;
  92103. private _positiveCurve;
  92104. private _negativeCurve;
  92105. private _globalHue;
  92106. private _globalDensity;
  92107. private _globalSaturation;
  92108. private _globalExposure;
  92109. /**
  92110. * Gets the global Hue value.
  92111. * 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).
  92112. */
  92113. /**
  92114. * Sets the global Hue value.
  92115. * 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).
  92116. */
  92117. globalHue: number;
  92118. /**
  92119. * Gets the global Density value.
  92120. * 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.
  92121. * Values less than zero provide a filter of opposite hue.
  92122. */
  92123. /**
  92124. * Sets the global Density value.
  92125. * 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.
  92126. * Values less than zero provide a filter of opposite hue.
  92127. */
  92128. globalDensity: number;
  92129. /**
  92130. * Gets the global Saturation value.
  92131. * 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.
  92132. */
  92133. /**
  92134. * Sets the global Saturation value.
  92135. * 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.
  92136. */
  92137. globalSaturation: number;
  92138. /**
  92139. * Gets the global Exposure value.
  92140. * 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.
  92141. */
  92142. /**
  92143. * Sets the global Exposure value.
  92144. * 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.
  92145. */
  92146. globalExposure: number;
  92147. private _highlightsHue;
  92148. private _highlightsDensity;
  92149. private _highlightsSaturation;
  92150. private _highlightsExposure;
  92151. /**
  92152. * Gets the highlights Hue value.
  92153. * 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).
  92154. */
  92155. /**
  92156. * Sets the highlights Hue value.
  92157. * 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).
  92158. */
  92159. highlightsHue: number;
  92160. /**
  92161. * Gets the highlights Density value.
  92162. * 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.
  92163. * Values less than zero provide a filter of opposite hue.
  92164. */
  92165. /**
  92166. * Sets the highlights Density value.
  92167. * 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.
  92168. * Values less than zero provide a filter of opposite hue.
  92169. */
  92170. highlightsDensity: number;
  92171. /**
  92172. * Gets the highlights Saturation value.
  92173. * 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.
  92174. */
  92175. /**
  92176. * Sets the highlights Saturation value.
  92177. * 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.
  92178. */
  92179. highlightsSaturation: number;
  92180. /**
  92181. * Gets the highlights Exposure value.
  92182. * 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.
  92183. */
  92184. /**
  92185. * Sets the highlights Exposure value.
  92186. * 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.
  92187. */
  92188. highlightsExposure: number;
  92189. private _midtonesHue;
  92190. private _midtonesDensity;
  92191. private _midtonesSaturation;
  92192. private _midtonesExposure;
  92193. /**
  92194. * Gets the midtones Hue value.
  92195. * 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).
  92196. */
  92197. /**
  92198. * Sets the midtones Hue value.
  92199. * 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).
  92200. */
  92201. midtonesHue: number;
  92202. /**
  92203. * Gets the midtones Density value.
  92204. * 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.
  92205. * Values less than zero provide a filter of opposite hue.
  92206. */
  92207. /**
  92208. * Sets the midtones Density value.
  92209. * 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.
  92210. * Values less than zero provide a filter of opposite hue.
  92211. */
  92212. midtonesDensity: number;
  92213. /**
  92214. * Gets the midtones Saturation value.
  92215. * 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.
  92216. */
  92217. /**
  92218. * Sets the midtones Saturation value.
  92219. * 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.
  92220. */
  92221. midtonesSaturation: number;
  92222. /**
  92223. * Gets the midtones Exposure value.
  92224. * 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.
  92225. */
  92226. /**
  92227. * Sets the midtones Exposure value.
  92228. * 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.
  92229. */
  92230. midtonesExposure: number;
  92231. private _shadowsHue;
  92232. private _shadowsDensity;
  92233. private _shadowsSaturation;
  92234. private _shadowsExposure;
  92235. /**
  92236. * Gets the shadows Hue value.
  92237. * 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).
  92238. */
  92239. /**
  92240. * Sets the shadows Hue value.
  92241. * 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).
  92242. */
  92243. shadowsHue: number;
  92244. /**
  92245. * Gets the shadows Density value.
  92246. * 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.
  92247. * Values less than zero provide a filter of opposite hue.
  92248. */
  92249. /**
  92250. * Sets the shadows Density value.
  92251. * 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.
  92252. * Values less than zero provide a filter of opposite hue.
  92253. */
  92254. shadowsDensity: number;
  92255. /**
  92256. * Gets the shadows Saturation value.
  92257. * 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.
  92258. */
  92259. /**
  92260. * Sets the shadows Saturation value.
  92261. * 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.
  92262. */
  92263. shadowsSaturation: number;
  92264. /**
  92265. * Gets the shadows Exposure value.
  92266. * 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.
  92267. */
  92268. /**
  92269. * Sets the shadows Exposure value.
  92270. * 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.
  92271. */
  92272. shadowsExposure: number;
  92273. /**
  92274. * Returns the class name
  92275. * @returns The class name
  92276. */
  92277. getClassName(): string;
  92278. /**
  92279. * Binds the color curves to the shader.
  92280. * @param colorCurves The color curve to bind
  92281. * @param effect The effect to bind to
  92282. * @param positiveUniform The positive uniform shader parameter
  92283. * @param neutralUniform The neutral uniform shader parameter
  92284. * @param negativeUniform The negative uniform shader parameter
  92285. */
  92286. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  92287. /**
  92288. * Prepare the list of uniforms associated with the ColorCurves effects.
  92289. * @param uniformsList The list of uniforms used in the effect
  92290. */
  92291. static PrepareUniforms(uniformsList: string[]): void;
  92292. /**
  92293. * Returns color grading data based on a hue, density, saturation and exposure value.
  92294. * @param filterHue The hue of the color filter.
  92295. * @param filterDensity The density of the color filter.
  92296. * @param saturation The saturation.
  92297. * @param exposure The exposure.
  92298. * @param result The result data container.
  92299. */
  92300. private getColorGradingDataToRef;
  92301. /**
  92302. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  92303. * @param value The input slider value in range [-100,100].
  92304. * @returns Adjusted value.
  92305. */
  92306. private static applyColorGradingSliderNonlinear;
  92307. /**
  92308. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  92309. * @param hue The hue (H) input.
  92310. * @param saturation The saturation (S) input.
  92311. * @param brightness The brightness (B) input.
  92312. * @result An RGBA color represented as Vector4.
  92313. */
  92314. private static fromHSBToRef;
  92315. /**
  92316. * Returns a value clamped between min and max
  92317. * @param value The value to clamp
  92318. * @param min The minimum of value
  92319. * @param max The maximum of value
  92320. * @returns The clamped value.
  92321. */
  92322. private static clamp;
  92323. /**
  92324. * Clones the current color curve instance.
  92325. * @return The cloned curves
  92326. */
  92327. clone(): ColorCurves;
  92328. /**
  92329. * Serializes the current color curve instance to a json representation.
  92330. * @return a JSON representation
  92331. */
  92332. serialize(): any;
  92333. /**
  92334. * Parses the color curve from a json representation.
  92335. * @param source the JSON source to parse
  92336. * @return The parsed curves
  92337. */
  92338. static Parse(source: any): ColorCurves;
  92339. }
  92340. }
  92341. declare module BABYLON {
  92342. /**
  92343. * Interface to follow in your material defines to integrate easily the
  92344. * Image proccessing functions.
  92345. * @hidden
  92346. */
  92347. export interface IImageProcessingConfigurationDefines {
  92348. IMAGEPROCESSING: boolean;
  92349. VIGNETTE: boolean;
  92350. VIGNETTEBLENDMODEMULTIPLY: boolean;
  92351. VIGNETTEBLENDMODEOPAQUE: boolean;
  92352. TONEMAPPING: boolean;
  92353. TONEMAPPING_ACES: boolean;
  92354. CONTRAST: boolean;
  92355. EXPOSURE: boolean;
  92356. COLORCURVES: boolean;
  92357. COLORGRADING: boolean;
  92358. COLORGRADING3D: boolean;
  92359. SAMPLER3DGREENDEPTH: boolean;
  92360. SAMPLER3DBGRMAP: boolean;
  92361. IMAGEPROCESSINGPOSTPROCESS: boolean;
  92362. }
  92363. /**
  92364. * @hidden
  92365. */
  92366. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  92367. IMAGEPROCESSING: boolean;
  92368. VIGNETTE: boolean;
  92369. VIGNETTEBLENDMODEMULTIPLY: boolean;
  92370. VIGNETTEBLENDMODEOPAQUE: boolean;
  92371. TONEMAPPING: boolean;
  92372. TONEMAPPING_ACES: boolean;
  92373. CONTRAST: boolean;
  92374. COLORCURVES: boolean;
  92375. COLORGRADING: boolean;
  92376. COLORGRADING3D: boolean;
  92377. SAMPLER3DGREENDEPTH: boolean;
  92378. SAMPLER3DBGRMAP: boolean;
  92379. IMAGEPROCESSINGPOSTPROCESS: boolean;
  92380. EXPOSURE: boolean;
  92381. constructor();
  92382. }
  92383. /**
  92384. * This groups together the common properties used for image processing either in direct forward pass
  92385. * or through post processing effect depending on the use of the image processing pipeline in your scene
  92386. * or not.
  92387. */
  92388. export class ImageProcessingConfiguration {
  92389. /**
  92390. * Default tone mapping applied in BabylonJS.
  92391. */
  92392. static readonly TONEMAPPING_STANDARD: number;
  92393. /**
  92394. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  92395. * to other engines rendering to increase portability.
  92396. */
  92397. static readonly TONEMAPPING_ACES: number;
  92398. /**
  92399. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  92400. */
  92401. colorCurves: Nullable<ColorCurves>;
  92402. private _colorCurvesEnabled;
  92403. /**
  92404. * Gets wether the color curves effect is enabled.
  92405. */
  92406. /**
  92407. * Sets wether the color curves effect is enabled.
  92408. */
  92409. colorCurvesEnabled: boolean;
  92410. private _colorGradingTexture;
  92411. /**
  92412. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  92413. */
  92414. /**
  92415. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  92416. */
  92417. colorGradingTexture: Nullable<BaseTexture>;
  92418. private _colorGradingEnabled;
  92419. /**
  92420. * Gets wether the color grading effect is enabled.
  92421. */
  92422. /**
  92423. * Sets wether the color grading effect is enabled.
  92424. */
  92425. colorGradingEnabled: boolean;
  92426. private _colorGradingWithGreenDepth;
  92427. /**
  92428. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  92429. */
  92430. /**
  92431. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  92432. */
  92433. colorGradingWithGreenDepth: boolean;
  92434. private _colorGradingBGR;
  92435. /**
  92436. * Gets wether the color grading texture contains BGR values.
  92437. */
  92438. /**
  92439. * Sets wether the color grading texture contains BGR values.
  92440. */
  92441. colorGradingBGR: boolean;
  92442. /** @hidden */
  92443. _exposure: number;
  92444. /**
  92445. * Gets the Exposure used in the effect.
  92446. */
  92447. /**
  92448. * Sets the Exposure used in the effect.
  92449. */
  92450. exposure: number;
  92451. private _toneMappingEnabled;
  92452. /**
  92453. * Gets wether the tone mapping effect is enabled.
  92454. */
  92455. /**
  92456. * Sets wether the tone mapping effect is enabled.
  92457. */
  92458. toneMappingEnabled: boolean;
  92459. private _toneMappingType;
  92460. /**
  92461. * Gets the type of tone mapping effect.
  92462. */
  92463. /**
  92464. * Sets the type of tone mapping effect used in BabylonJS.
  92465. */
  92466. toneMappingType: number;
  92467. protected _contrast: number;
  92468. /**
  92469. * Gets the contrast used in the effect.
  92470. */
  92471. /**
  92472. * Sets the contrast used in the effect.
  92473. */
  92474. contrast: number;
  92475. /**
  92476. * Vignette stretch size.
  92477. */
  92478. vignetteStretch: number;
  92479. /**
  92480. * Vignette centre X Offset.
  92481. */
  92482. vignetteCentreX: number;
  92483. /**
  92484. * Vignette centre Y Offset.
  92485. */
  92486. vignetteCentreY: number;
  92487. /**
  92488. * Vignette weight or intensity of the vignette effect.
  92489. */
  92490. vignetteWeight: number;
  92491. /**
  92492. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  92493. * if vignetteEnabled is set to true.
  92494. */
  92495. vignetteColor: Color4;
  92496. /**
  92497. * Camera field of view used by the Vignette effect.
  92498. */
  92499. vignetteCameraFov: number;
  92500. private _vignetteBlendMode;
  92501. /**
  92502. * Gets the vignette blend mode allowing different kind of effect.
  92503. */
  92504. /**
  92505. * Sets the vignette blend mode allowing different kind of effect.
  92506. */
  92507. vignetteBlendMode: number;
  92508. private _vignetteEnabled;
  92509. /**
  92510. * Gets wether the vignette effect is enabled.
  92511. */
  92512. /**
  92513. * Sets wether the vignette effect is enabled.
  92514. */
  92515. vignetteEnabled: boolean;
  92516. private _applyByPostProcess;
  92517. /**
  92518. * Gets wether the image processing is applied through a post process or not.
  92519. */
  92520. /**
  92521. * Sets wether the image processing is applied through a post process or not.
  92522. */
  92523. applyByPostProcess: boolean;
  92524. private _isEnabled;
  92525. /**
  92526. * Gets wether the image processing is enabled or not.
  92527. */
  92528. /**
  92529. * Sets wether the image processing is enabled or not.
  92530. */
  92531. isEnabled: boolean;
  92532. /**
  92533. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  92534. */
  92535. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  92536. /**
  92537. * Method called each time the image processing information changes requires to recompile the effect.
  92538. */
  92539. protected _updateParameters(): void;
  92540. /**
  92541. * Gets the current class name.
  92542. * @return "ImageProcessingConfiguration"
  92543. */
  92544. getClassName(): string;
  92545. /**
  92546. * Prepare the list of uniforms associated with the Image Processing effects.
  92547. * @param uniforms The list of uniforms used in the effect
  92548. * @param defines the list of defines currently in use
  92549. */
  92550. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  92551. /**
  92552. * Prepare the list of samplers associated with the Image Processing effects.
  92553. * @param samplersList The list of uniforms used in the effect
  92554. * @param defines the list of defines currently in use
  92555. */
  92556. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  92557. /**
  92558. * Prepare the list of defines associated to the shader.
  92559. * @param defines the list of defines to complete
  92560. * @param forPostProcess Define if we are currently in post process mode or not
  92561. */
  92562. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  92563. /**
  92564. * Returns true if all the image processing information are ready.
  92565. * @returns True if ready, otherwise, false
  92566. */
  92567. isReady(): boolean;
  92568. /**
  92569. * Binds the image processing to the shader.
  92570. * @param effect The effect to bind to
  92571. * @param aspectRatio Define the current aspect ratio of the effect
  92572. */
  92573. bind(effect: Effect, aspectRatio?: number): void;
  92574. /**
  92575. * Clones the current image processing instance.
  92576. * @return The cloned image processing
  92577. */
  92578. clone(): ImageProcessingConfiguration;
  92579. /**
  92580. * Serializes the current image processing instance to a json representation.
  92581. * @return a JSON representation
  92582. */
  92583. serialize(): any;
  92584. /**
  92585. * Parses the image processing from a json representation.
  92586. * @param source the JSON source to parse
  92587. * @return The parsed image processing
  92588. */
  92589. static Parse(source: any): ImageProcessingConfiguration;
  92590. private static _VIGNETTEMODE_MULTIPLY;
  92591. private static _VIGNETTEMODE_OPAQUE;
  92592. /**
  92593. * Used to apply the vignette as a mix with the pixel color.
  92594. */
  92595. static readonly VIGNETTEMODE_MULTIPLY: number;
  92596. /**
  92597. * Used to apply the vignette as a replacement of the pixel color.
  92598. */
  92599. static readonly VIGNETTEMODE_OPAQUE: number;
  92600. }
  92601. }
  92602. declare module BABYLON {
  92603. /**
  92604. * This represents all the required information to add a fresnel effect on a material:
  92605. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  92606. */
  92607. export class FresnelParameters {
  92608. private _isEnabled;
  92609. /**
  92610. * Define if the fresnel effect is enable or not.
  92611. */
  92612. isEnabled: boolean;
  92613. /**
  92614. * Define the color used on edges (grazing angle)
  92615. */
  92616. leftColor: Color3;
  92617. /**
  92618. * Define the color used on center
  92619. */
  92620. rightColor: Color3;
  92621. /**
  92622. * Define bias applied to computed fresnel term
  92623. */
  92624. bias: number;
  92625. /**
  92626. * Defined the power exponent applied to fresnel term
  92627. */
  92628. power: number;
  92629. /**
  92630. * Clones the current fresnel and its valuues
  92631. * @returns a clone fresnel configuration
  92632. */
  92633. clone(): FresnelParameters;
  92634. /**
  92635. * Serializes the current fresnel parameters to a JSON representation.
  92636. * @return the JSON serialization
  92637. */
  92638. serialize(): any;
  92639. /**
  92640. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  92641. * @param parsedFresnelParameters Define the JSON representation
  92642. * @returns the parsed parameters
  92643. */
  92644. static Parse(parsedFresnelParameters: any): FresnelParameters;
  92645. }
  92646. }
  92647. declare module BABYLON {
  92648. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  92649. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92650. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92651. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92652. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92653. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92654. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92655. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92656. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92657. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92658. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92659. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92660. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92661. /**
  92662. * Decorator used to define property that can be serialized as reference to a camera
  92663. * @param sourceName defines the name of the property to decorate
  92664. */
  92665. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92666. /**
  92667. * Class used to help serialization objects
  92668. */
  92669. export class SerializationHelper {
  92670. /** @hidden */
  92671. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  92672. /** @hidden */
  92673. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  92674. /** @hidden */
  92675. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  92676. /** @hidden */
  92677. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  92678. /**
  92679. * Appends the serialized animations from the source animations
  92680. * @param source Source containing the animations
  92681. * @param destination Target to store the animations
  92682. */
  92683. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  92684. /**
  92685. * Static function used to serialized a specific entity
  92686. * @param entity defines the entity to serialize
  92687. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  92688. * @returns a JSON compatible object representing the serialization of the entity
  92689. */
  92690. static Serialize<T>(entity: T, serializationObject?: any): any;
  92691. /**
  92692. * Creates a new entity from a serialization data object
  92693. * @param creationFunction defines a function used to instanciated the new entity
  92694. * @param source defines the source serialization data
  92695. * @param scene defines the hosting scene
  92696. * @param rootUrl defines the root url for resources
  92697. * @returns a new entity
  92698. */
  92699. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  92700. /**
  92701. * Clones an object
  92702. * @param creationFunction defines the function used to instanciate the new object
  92703. * @param source defines the source object
  92704. * @returns the cloned object
  92705. */
  92706. static Clone<T>(creationFunction: () => T, source: T): T;
  92707. /**
  92708. * Instanciates a new object based on a source one (some data will be shared between both object)
  92709. * @param creationFunction defines the function used to instanciate the new object
  92710. * @param source defines the source object
  92711. * @returns the new object
  92712. */
  92713. static Instanciate<T>(creationFunction: () => T, source: T): T;
  92714. }
  92715. }
  92716. declare module BABYLON {
  92717. /**
  92718. * This is the base class of all the camera used in the application.
  92719. * @see http://doc.babylonjs.com/features/cameras
  92720. */
  92721. export class Camera extends Node {
  92722. /** @hidden */
  92723. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  92724. /**
  92725. * This is the default projection mode used by the cameras.
  92726. * It helps recreating a feeling of perspective and better appreciate depth.
  92727. * This is the best way to simulate real life cameras.
  92728. */
  92729. static readonly PERSPECTIVE_CAMERA: number;
  92730. /**
  92731. * This helps creating camera with an orthographic mode.
  92732. * 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.
  92733. */
  92734. static readonly ORTHOGRAPHIC_CAMERA: number;
  92735. /**
  92736. * This is the default FOV mode for perspective cameras.
  92737. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  92738. */
  92739. static readonly FOVMODE_VERTICAL_FIXED: number;
  92740. /**
  92741. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  92742. */
  92743. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  92744. /**
  92745. * This specifies ther is no need for a camera rig.
  92746. * Basically only one eye is rendered corresponding to the camera.
  92747. */
  92748. static readonly RIG_MODE_NONE: number;
  92749. /**
  92750. * Simulates a camera Rig with one blue eye and one red eye.
  92751. * This can be use with 3d blue and red glasses.
  92752. */
  92753. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  92754. /**
  92755. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  92756. */
  92757. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  92758. /**
  92759. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  92760. */
  92761. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  92762. /**
  92763. * Defines that both eyes of the camera will be rendered over under each other.
  92764. */
  92765. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  92766. /**
  92767. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  92768. */
  92769. static readonly RIG_MODE_VR: number;
  92770. /**
  92771. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  92772. */
  92773. static readonly RIG_MODE_WEBVR: number;
  92774. /**
  92775. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  92776. */
  92777. static readonly RIG_MODE_CUSTOM: number;
  92778. /**
  92779. * Defines if by default attaching controls should prevent the default javascript event to continue.
  92780. */
  92781. static ForceAttachControlToAlwaysPreventDefault: boolean;
  92782. /**
  92783. * Define the input manager associated with the camera.
  92784. */
  92785. inputs: CameraInputsManager<Camera>;
  92786. /** @hidden */
  92787. _position: Vector3;
  92788. /**
  92789. * Define the current local position of the camera in the scene
  92790. */
  92791. position: Vector3;
  92792. /**
  92793. * The vector the camera should consider as up.
  92794. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  92795. */
  92796. upVector: Vector3;
  92797. /**
  92798. * Define the current limit on the left side for an orthographic camera
  92799. * In scene unit
  92800. */
  92801. orthoLeft: Nullable<number>;
  92802. /**
  92803. * Define the current limit on the right side for an orthographic camera
  92804. * In scene unit
  92805. */
  92806. orthoRight: Nullable<number>;
  92807. /**
  92808. * Define the current limit on the bottom side for an orthographic camera
  92809. * In scene unit
  92810. */
  92811. orthoBottom: Nullable<number>;
  92812. /**
  92813. * Define the current limit on the top side for an orthographic camera
  92814. * In scene unit
  92815. */
  92816. orthoTop: Nullable<number>;
  92817. /**
  92818. * Field Of View is set in Radians. (default is 0.8)
  92819. */
  92820. fov: number;
  92821. /**
  92822. * Define the minimum distance the camera can see from.
  92823. * This is important to note that the depth buffer are not infinite and the closer it starts
  92824. * the more your scene might encounter depth fighting issue.
  92825. */
  92826. minZ: number;
  92827. /**
  92828. * Define the maximum distance the camera can see to.
  92829. * This is important to note that the depth buffer are not infinite and the further it end
  92830. * the more your scene might encounter depth fighting issue.
  92831. */
  92832. maxZ: number;
  92833. /**
  92834. * Define the default inertia of the camera.
  92835. * This helps giving a smooth feeling to the camera movement.
  92836. */
  92837. inertia: number;
  92838. /**
  92839. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  92840. */
  92841. mode: number;
  92842. /**
  92843. * Define wether the camera is intermediate.
  92844. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  92845. */
  92846. isIntermediate: boolean;
  92847. /**
  92848. * Define the viewport of the camera.
  92849. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  92850. */
  92851. viewport: Viewport;
  92852. /**
  92853. * Restricts the camera to viewing objects with the same layerMask.
  92854. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  92855. */
  92856. layerMask: number;
  92857. /**
  92858. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  92859. */
  92860. fovMode: number;
  92861. /**
  92862. * Rig mode of the camera.
  92863. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  92864. * This is normally controlled byt the camera themselves as internal use.
  92865. */
  92866. cameraRigMode: number;
  92867. /**
  92868. * Defines the distance between both "eyes" in case of a RIG
  92869. */
  92870. interaxialDistance: number;
  92871. /**
  92872. * Defines if stereoscopic rendering is done side by side or over under.
  92873. */
  92874. isStereoscopicSideBySide: boolean;
  92875. /**
  92876. * 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
  92877. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  92878. * else in the scene.
  92879. */
  92880. customRenderTargets: RenderTargetTexture[];
  92881. /**
  92882. * When set, the camera will render to this render target instead of the default canvas
  92883. */
  92884. outputRenderTarget: Nullable<RenderTargetTexture>;
  92885. /**
  92886. * Observable triggered when the camera view matrix has changed.
  92887. */
  92888. onViewMatrixChangedObservable: Observable<Camera>;
  92889. /**
  92890. * Observable triggered when the camera Projection matrix has changed.
  92891. */
  92892. onProjectionMatrixChangedObservable: Observable<Camera>;
  92893. /**
  92894. * Observable triggered when the inputs have been processed.
  92895. */
  92896. onAfterCheckInputsObservable: Observable<Camera>;
  92897. /**
  92898. * Observable triggered when reset has been called and applied to the camera.
  92899. */
  92900. onRestoreStateObservable: Observable<Camera>;
  92901. /** @hidden */
  92902. _cameraRigParams: any;
  92903. /** @hidden */
  92904. _rigCameras: Camera[];
  92905. /** @hidden */
  92906. _rigPostProcess: Nullable<PostProcess>;
  92907. protected _webvrViewMatrix: Matrix;
  92908. /** @hidden */
  92909. _skipRendering: boolean;
  92910. /** @hidden */
  92911. _projectionMatrix: Matrix;
  92912. /** @hidden */
  92913. _postProcesses: Nullable<PostProcess>[];
  92914. /** @hidden */
  92915. _activeMeshes: SmartArray<AbstractMesh>;
  92916. protected _globalPosition: Vector3;
  92917. /** @hidden */
  92918. _computedViewMatrix: Matrix;
  92919. private _doNotComputeProjectionMatrix;
  92920. private _transformMatrix;
  92921. private _frustumPlanes;
  92922. private _refreshFrustumPlanes;
  92923. private _storedFov;
  92924. private _stateStored;
  92925. /**
  92926. * Instantiates a new camera object.
  92927. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  92928. * @see http://doc.babylonjs.com/features/cameras
  92929. * @param name Defines the name of the camera in the scene
  92930. * @param position Defines the position of the camera
  92931. * @param scene Defines the scene the camera belongs too
  92932. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  92933. */
  92934. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  92935. /**
  92936. * Store current camera state (fov, position, etc..)
  92937. * @returns the camera
  92938. */
  92939. storeState(): Camera;
  92940. /**
  92941. * Restores the camera state values if it has been stored. You must call storeState() first
  92942. */
  92943. protected _restoreStateValues(): boolean;
  92944. /**
  92945. * Restored camera state. You must call storeState() first.
  92946. * @returns true if restored and false otherwise
  92947. */
  92948. restoreState(): boolean;
  92949. /**
  92950. * Gets the class name of the camera.
  92951. * @returns the class name
  92952. */
  92953. getClassName(): string;
  92954. /** @hidden */
  92955. readonly _isCamera: boolean;
  92956. /**
  92957. * Gets a string representation of the camera useful for debug purpose.
  92958. * @param fullDetails Defines that a more verboe level of logging is required
  92959. * @returns the string representation
  92960. */
  92961. toString(fullDetails?: boolean): string;
  92962. /**
  92963. * Gets the current world space position of the camera.
  92964. */
  92965. readonly globalPosition: Vector3;
  92966. /**
  92967. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  92968. * @returns the active meshe list
  92969. */
  92970. getActiveMeshes(): SmartArray<AbstractMesh>;
  92971. /**
  92972. * Check wether a mesh is part of the current active mesh list of the camera
  92973. * @param mesh Defines the mesh to check
  92974. * @returns true if active, false otherwise
  92975. */
  92976. isActiveMesh(mesh: Mesh): boolean;
  92977. /**
  92978. * Is this camera ready to be used/rendered
  92979. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  92980. * @return true if the camera is ready
  92981. */
  92982. isReady(completeCheck?: boolean): boolean;
  92983. /** @hidden */
  92984. _initCache(): void;
  92985. /** @hidden */
  92986. _updateCache(ignoreParentClass?: boolean): void;
  92987. /** @hidden */
  92988. _isSynchronized(): boolean;
  92989. /** @hidden */
  92990. _isSynchronizedViewMatrix(): boolean;
  92991. /** @hidden */
  92992. _isSynchronizedProjectionMatrix(): boolean;
  92993. /**
  92994. * Attach the input controls to a specific dom element to get the input from.
  92995. * @param element Defines the element the controls should be listened from
  92996. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92997. */
  92998. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92999. /**
  93000. * Detach the current controls from the specified dom element.
  93001. * @param element Defines the element to stop listening the inputs from
  93002. */
  93003. detachControl(element: HTMLElement): void;
  93004. /**
  93005. * Update the camera state according to the different inputs gathered during the frame.
  93006. */
  93007. update(): void;
  93008. /** @hidden */
  93009. _checkInputs(): void;
  93010. /** @hidden */
  93011. readonly rigCameras: Camera[];
  93012. /**
  93013. * Gets the post process used by the rig cameras
  93014. */
  93015. readonly rigPostProcess: Nullable<PostProcess>;
  93016. /**
  93017. * Internal, gets the first post proces.
  93018. * @returns the first post process to be run on this camera.
  93019. */
  93020. _getFirstPostProcess(): Nullable<PostProcess>;
  93021. private _cascadePostProcessesToRigCams;
  93022. /**
  93023. * Attach a post process to the camera.
  93024. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93025. * @param postProcess The post process to attach to the camera
  93026. * @param insertAt The position of the post process in case several of them are in use in the scene
  93027. * @returns the position the post process has been inserted at
  93028. */
  93029. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  93030. /**
  93031. * Detach a post process to the camera.
  93032. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93033. * @param postProcess The post process to detach from the camera
  93034. */
  93035. detachPostProcess(postProcess: PostProcess): void;
  93036. /**
  93037. * Gets the current world matrix of the camera
  93038. */
  93039. getWorldMatrix(): Matrix;
  93040. /** @hidden */
  93041. _getViewMatrix(): Matrix;
  93042. /**
  93043. * Gets the current view matrix of the camera.
  93044. * @param force forces the camera to recompute the matrix without looking at the cached state
  93045. * @returns the view matrix
  93046. */
  93047. getViewMatrix(force?: boolean): Matrix;
  93048. /**
  93049. * Freeze the projection matrix.
  93050. * It will prevent the cache check of the camera projection compute and can speed up perf
  93051. * if no parameter of the camera are meant to change
  93052. * @param projection Defines manually a projection if necessary
  93053. */
  93054. freezeProjectionMatrix(projection?: Matrix): void;
  93055. /**
  93056. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  93057. */
  93058. unfreezeProjectionMatrix(): void;
  93059. /**
  93060. * Gets the current projection matrix of the camera.
  93061. * @param force forces the camera to recompute the matrix without looking at the cached state
  93062. * @returns the projection matrix
  93063. */
  93064. getProjectionMatrix(force?: boolean): Matrix;
  93065. /**
  93066. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  93067. * @returns a Matrix
  93068. */
  93069. getTransformationMatrix(): Matrix;
  93070. private _updateFrustumPlanes;
  93071. /**
  93072. * Checks if a cullable object (mesh...) is in the camera frustum
  93073. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  93074. * @param target The object to check
  93075. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  93076. * @returns true if the object is in frustum otherwise false
  93077. */
  93078. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  93079. /**
  93080. * Checks if a cullable object (mesh...) is in the camera frustum
  93081. * Unlike isInFrustum this cheks the full bounding box
  93082. * @param target The object to check
  93083. * @returns true if the object is in frustum otherwise false
  93084. */
  93085. isCompletelyInFrustum(target: ICullable): boolean;
  93086. /**
  93087. * Gets a ray in the forward direction from the camera.
  93088. * @param length Defines the length of the ray to create
  93089. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  93090. * @param origin Defines the start point of the ray which defaults to the camera position
  93091. * @returns the forward ray
  93092. */
  93093. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  93094. /**
  93095. * Releases resources associated with this node.
  93096. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93097. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93098. */
  93099. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93100. /** @hidden */
  93101. _isLeftCamera: boolean;
  93102. /**
  93103. * Gets the left camera of a rig setup in case of Rigged Camera
  93104. */
  93105. readonly isLeftCamera: boolean;
  93106. /** @hidden */
  93107. _isRightCamera: boolean;
  93108. /**
  93109. * Gets the right camera of a rig setup in case of Rigged Camera
  93110. */
  93111. readonly isRightCamera: boolean;
  93112. /**
  93113. * Gets the left camera of a rig setup in case of Rigged Camera
  93114. */
  93115. readonly leftCamera: Nullable<FreeCamera>;
  93116. /**
  93117. * Gets the right camera of a rig setup in case of Rigged Camera
  93118. */
  93119. readonly rightCamera: Nullable<FreeCamera>;
  93120. /**
  93121. * Gets the left camera target of a rig setup in case of Rigged Camera
  93122. * @returns the target position
  93123. */
  93124. getLeftTarget(): Nullable<Vector3>;
  93125. /**
  93126. * Gets the right camera target of a rig setup in case of Rigged Camera
  93127. * @returns the target position
  93128. */
  93129. getRightTarget(): Nullable<Vector3>;
  93130. /**
  93131. * @hidden
  93132. */
  93133. setCameraRigMode(mode: number, rigParams: any): void;
  93134. /** @hidden */
  93135. static _setStereoscopicRigMode(camera: Camera): void;
  93136. /** @hidden */
  93137. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  93138. /** @hidden */
  93139. static _setVRRigMode(camera: Camera, rigParams: any): void;
  93140. /** @hidden */
  93141. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  93142. /** @hidden */
  93143. _getVRProjectionMatrix(): Matrix;
  93144. protected _updateCameraRotationMatrix(): void;
  93145. protected _updateWebVRCameraRotationMatrix(): void;
  93146. /**
  93147. * This function MUST be overwritten by the different WebVR cameras available.
  93148. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93149. * @hidden
  93150. */
  93151. _getWebVRProjectionMatrix(): Matrix;
  93152. /**
  93153. * This function MUST be overwritten by the different WebVR cameras available.
  93154. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93155. * @hidden
  93156. */
  93157. _getWebVRViewMatrix(): Matrix;
  93158. /** @hidden */
  93159. setCameraRigParameter(name: string, value: any): void;
  93160. /**
  93161. * needs to be overridden by children so sub has required properties to be copied
  93162. * @hidden
  93163. */
  93164. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  93165. /**
  93166. * May need to be overridden by children
  93167. * @hidden
  93168. */
  93169. _updateRigCameras(): void;
  93170. /** @hidden */
  93171. _setupInputs(): void;
  93172. /**
  93173. * Serialiaze the camera setup to a json represention
  93174. * @returns the JSON representation
  93175. */
  93176. serialize(): any;
  93177. /**
  93178. * Clones the current camera.
  93179. * @param name The cloned camera name
  93180. * @returns the cloned camera
  93181. */
  93182. clone(name: string): Camera;
  93183. /**
  93184. * Gets the direction of the camera relative to a given local axis.
  93185. * @param localAxis Defines the reference axis to provide a relative direction.
  93186. * @return the direction
  93187. */
  93188. getDirection(localAxis: Vector3): Vector3;
  93189. /**
  93190. * Gets the direction of the camera relative to a given local axis into a passed vector.
  93191. * @param localAxis Defines the reference axis to provide a relative direction.
  93192. * @param result Defines the vector to store the result in
  93193. */
  93194. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  93195. /**
  93196. * Gets a camera constructor for a given camera type
  93197. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  93198. * @param name The name of the camera the result will be able to instantiate
  93199. * @param scene The scene the result will construct the camera in
  93200. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  93201. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  93202. * @returns a factory method to construc the camera
  93203. */
  93204. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  93205. /**
  93206. * Compute the world matrix of the camera.
  93207. * @returns the camera workd matrix
  93208. */
  93209. computeWorldMatrix(): Matrix;
  93210. /**
  93211. * Parse a JSON and creates the camera from the parsed information
  93212. * @param parsedCamera The JSON to parse
  93213. * @param scene The scene to instantiate the camera in
  93214. * @returns the newly constructed camera
  93215. */
  93216. static Parse(parsedCamera: any, scene: Scene): Camera;
  93217. }
  93218. }
  93219. declare module BABYLON {
  93220. /**
  93221. * Interface for any object that can request an animation frame
  93222. */
  93223. export interface ICustomAnimationFrameRequester {
  93224. /**
  93225. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  93226. */
  93227. renderFunction?: Function;
  93228. /**
  93229. * Called to request the next frame to render to
  93230. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  93231. */
  93232. requestAnimationFrame: Function;
  93233. /**
  93234. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  93235. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  93236. */
  93237. requestID?: number;
  93238. }
  93239. /**
  93240. * Interface containing an array of animations
  93241. */
  93242. export interface IAnimatable {
  93243. /**
  93244. * Array of animations
  93245. */
  93246. animations: Nullable<Array<Animation>>;
  93247. }
  93248. /** Interface used by value gradients (color, factor, ...) */
  93249. export interface IValueGradient {
  93250. /**
  93251. * Gets or sets the gradient value (between 0 and 1)
  93252. */
  93253. gradient: number;
  93254. }
  93255. /** Class used to store color4 gradient */
  93256. export class ColorGradient implements IValueGradient {
  93257. /**
  93258. * Gets or sets the gradient value (between 0 and 1)
  93259. */
  93260. gradient: number;
  93261. /**
  93262. * Gets or sets first associated color
  93263. */
  93264. color1: Color4;
  93265. /**
  93266. * Gets or sets second associated color
  93267. */
  93268. color2?: Color4;
  93269. /**
  93270. * Will get a color picked randomly between color1 and color2.
  93271. * If color2 is undefined then color1 will be used
  93272. * @param result defines the target Color4 to store the result in
  93273. */
  93274. getColorToRef(result: Color4): void;
  93275. }
  93276. /** Class used to store color 3 gradient */
  93277. export class Color3Gradient implements IValueGradient {
  93278. /**
  93279. * Gets or sets the gradient value (between 0 and 1)
  93280. */
  93281. gradient: number;
  93282. /**
  93283. * Gets or sets the associated color
  93284. */
  93285. color: Color3;
  93286. }
  93287. /** Class used to store factor gradient */
  93288. export class FactorGradient implements IValueGradient {
  93289. /**
  93290. * Gets or sets the gradient value (between 0 and 1)
  93291. */
  93292. gradient: number;
  93293. /**
  93294. * Gets or sets first associated factor
  93295. */
  93296. factor1: number;
  93297. /**
  93298. * Gets or sets second associated factor
  93299. */
  93300. factor2?: number;
  93301. /**
  93302. * Will get a number picked randomly between factor1 and factor2.
  93303. * If factor2 is undefined then factor1 will be used
  93304. * @returns the picked number
  93305. */
  93306. getFactor(): number;
  93307. }
  93308. /**
  93309. * @ignore
  93310. * Application error to support additional information when loading a file
  93311. */
  93312. export class LoadFileError extends Error {
  93313. /** defines the optional web request */
  93314. request?: WebRequest | undefined;
  93315. private static _setPrototypeOf;
  93316. /**
  93317. * Creates a new LoadFileError
  93318. * @param message defines the message of the error
  93319. * @param request defines the optional web request
  93320. */
  93321. constructor(message: string,
  93322. /** defines the optional web request */
  93323. request?: WebRequest | undefined);
  93324. }
  93325. /**
  93326. * Class used to define a retry strategy when error happens while loading assets
  93327. */
  93328. export class RetryStrategy {
  93329. /**
  93330. * Function used to defines an exponential back off strategy
  93331. * @param maxRetries defines the maximum number of retries (3 by default)
  93332. * @param baseInterval defines the interval between retries
  93333. * @returns the strategy function to use
  93334. */
  93335. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  93336. }
  93337. /**
  93338. * File request interface
  93339. */
  93340. export interface IFileRequest {
  93341. /**
  93342. * Raised when the request is complete (success or error).
  93343. */
  93344. onCompleteObservable: Observable<IFileRequest>;
  93345. /**
  93346. * Aborts the request for a file.
  93347. */
  93348. abort: () => void;
  93349. }
  93350. /**
  93351. * Class containing a set of static utilities functions
  93352. */
  93353. export class Tools {
  93354. /**
  93355. * Gets or sets the base URL to use to load assets
  93356. */
  93357. static BaseUrl: string;
  93358. /**
  93359. * Enable/Disable Custom HTTP Request Headers globally.
  93360. * default = false
  93361. * @see CustomRequestHeaders
  93362. */
  93363. static UseCustomRequestHeaders: boolean;
  93364. /**
  93365. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  93366. * i.e. when loading files, where the server/service expects an Authorization header
  93367. */
  93368. static CustomRequestHeaders: {
  93369. [key: string]: string;
  93370. };
  93371. /**
  93372. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  93373. */
  93374. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  93375. /**
  93376. * Default behaviour for cors in the application.
  93377. * It can be a string if the expected behavior is identical in the entire app.
  93378. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  93379. */
  93380. static CorsBehavior: string | ((url: string | string[]) => string);
  93381. /**
  93382. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  93383. * @ignorenaming
  93384. */
  93385. static UseFallbackTexture: boolean;
  93386. /**
  93387. * Use this object to register external classes like custom textures or material
  93388. * to allow the laoders to instantiate them
  93389. */
  93390. static RegisteredExternalClasses: {
  93391. [key: string]: Object;
  93392. };
  93393. /**
  93394. * Texture content used if a texture cannot loaded
  93395. * @ignorenaming
  93396. */
  93397. static fallbackTexture: string;
  93398. /**
  93399. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  93400. * @param u defines the coordinate on X axis
  93401. * @param v defines the coordinate on Y axis
  93402. * @param width defines the width of the source data
  93403. * @param height defines the height of the source data
  93404. * @param pixels defines the source byte array
  93405. * @param color defines the output color
  93406. */
  93407. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  93408. /**
  93409. * Interpolates between a and b via alpha
  93410. * @param a The lower value (returned when alpha = 0)
  93411. * @param b The upper value (returned when alpha = 1)
  93412. * @param alpha The interpolation-factor
  93413. * @return The mixed value
  93414. */
  93415. static Mix(a: number, b: number, alpha: number): number;
  93416. /**
  93417. * Tries to instantiate a new object from a given class name
  93418. * @param className defines the class name to instantiate
  93419. * @returns the new object or null if the system was not able to do the instantiation
  93420. */
  93421. static Instantiate(className: string): any;
  93422. /**
  93423. * Provides a slice function that will work even on IE
  93424. * @param data defines the array to slice
  93425. * @param start defines the start of the data (optional)
  93426. * @param end defines the end of the data (optional)
  93427. * @returns the new sliced array
  93428. */
  93429. static Slice<T>(data: T, start?: number, end?: number): T;
  93430. /**
  93431. * Polyfill for setImmediate
  93432. * @param action defines the action to execute after the current execution block
  93433. */
  93434. static SetImmediate(action: () => void): void;
  93435. /**
  93436. * Function indicating if a number is an exponent of 2
  93437. * @param value defines the value to test
  93438. * @returns true if the value is an exponent of 2
  93439. */
  93440. static IsExponentOfTwo(value: number): boolean;
  93441. private static _tmpFloatArray;
  93442. /**
  93443. * Returns the nearest 32-bit single precision float representation of a Number
  93444. * @param value A Number. If the parameter is of a different type, it will get converted
  93445. * to a number or to NaN if it cannot be converted
  93446. * @returns number
  93447. */
  93448. static FloatRound(value: number): number;
  93449. /**
  93450. * Find the next highest power of two.
  93451. * @param x Number to start search from.
  93452. * @return Next highest power of two.
  93453. */
  93454. static CeilingPOT(x: number): number;
  93455. /**
  93456. * Find the next lowest power of two.
  93457. * @param x Number to start search from.
  93458. * @return Next lowest power of two.
  93459. */
  93460. static FloorPOT(x: number): number;
  93461. /**
  93462. * Find the nearest power of two.
  93463. * @param x Number to start search from.
  93464. * @return Next nearest power of two.
  93465. */
  93466. static NearestPOT(x: number): number;
  93467. /**
  93468. * Get the closest exponent of two
  93469. * @param value defines the value to approximate
  93470. * @param max defines the maximum value to return
  93471. * @param mode defines how to define the closest value
  93472. * @returns closest exponent of two of the given value
  93473. */
  93474. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  93475. /**
  93476. * Extracts the filename from a path
  93477. * @param path defines the path to use
  93478. * @returns the filename
  93479. */
  93480. static GetFilename(path: string): string;
  93481. /**
  93482. * Extracts the "folder" part of a path (everything before the filename).
  93483. * @param uri The URI to extract the info from
  93484. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  93485. * @returns The "folder" part of the path
  93486. */
  93487. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  93488. /**
  93489. * Extracts text content from a DOM element hierarchy
  93490. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  93491. */
  93492. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  93493. /**
  93494. * Convert an angle in radians to degrees
  93495. * @param angle defines the angle to convert
  93496. * @returns the angle in degrees
  93497. */
  93498. static ToDegrees(angle: number): number;
  93499. /**
  93500. * Convert an angle in degrees to radians
  93501. * @param angle defines the angle to convert
  93502. * @returns the angle in radians
  93503. */
  93504. static ToRadians(angle: number): number;
  93505. /**
  93506. * Encode a buffer to a base64 string
  93507. * @param buffer defines the buffer to encode
  93508. * @returns the encoded string
  93509. */
  93510. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  93511. /**
  93512. * Extracts minimum and maximum values from a list of indexed positions
  93513. * @param positions defines the positions to use
  93514. * @param indices defines the indices to the positions
  93515. * @param indexStart defines the start index
  93516. * @param indexCount defines the end index
  93517. * @param bias defines bias value to add to the result
  93518. * @return minimum and maximum values
  93519. */
  93520. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  93521. minimum: Vector3;
  93522. maximum: Vector3;
  93523. };
  93524. /**
  93525. * Extracts minimum and maximum values from a list of positions
  93526. * @param positions defines the positions to use
  93527. * @param start defines the start index in the positions array
  93528. * @param count defines the number of positions to handle
  93529. * @param bias defines bias value to add to the result
  93530. * @param stride defines the stride size to use (distance between two positions in the positions array)
  93531. * @return minimum and maximum values
  93532. */
  93533. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  93534. minimum: Vector3;
  93535. maximum: Vector3;
  93536. };
  93537. /**
  93538. * Returns an array if obj is not an array
  93539. * @param obj defines the object to evaluate as an array
  93540. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  93541. * @returns either obj directly if obj is an array or a new array containing obj
  93542. */
  93543. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  93544. /**
  93545. * Gets the pointer prefix to use
  93546. * @returns "pointer" if touch is enabled. Else returns "mouse"
  93547. */
  93548. static GetPointerPrefix(): string;
  93549. /**
  93550. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  93551. * @param func - the function to be called
  93552. * @param requester - the object that will request the next frame. Falls back to window.
  93553. * @returns frame number
  93554. */
  93555. static QueueNewFrame(func: () => void, requester?: any): number;
  93556. /**
  93557. * Ask the browser to promote the current element to fullscreen rendering mode
  93558. * @param element defines the DOM element to promote
  93559. */
  93560. static RequestFullscreen(element: HTMLElement): void;
  93561. /**
  93562. * Asks the browser to exit fullscreen mode
  93563. */
  93564. static ExitFullscreen(): void;
  93565. /**
  93566. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  93567. * @param url define the url we are trying
  93568. * @param element define the dom element where to configure the cors policy
  93569. */
  93570. static SetCorsBehavior(url: string | string[], element: {
  93571. crossOrigin: string | null;
  93572. }): void;
  93573. /**
  93574. * Removes unwanted characters from an url
  93575. * @param url defines the url to clean
  93576. * @returns the cleaned url
  93577. */
  93578. static CleanUrl(url: string): string;
  93579. /**
  93580. * Gets or sets a function used to pre-process url before using them to load assets
  93581. */
  93582. static PreprocessUrl: (url: string) => string;
  93583. /**
  93584. * Loads an image as an HTMLImageElement.
  93585. * @param input url string, ArrayBuffer, or Blob to load
  93586. * @param onLoad callback called when the image successfully loads
  93587. * @param onError callback called when the image fails to load
  93588. * @param offlineProvider offline provider for caching
  93589. * @returns the HTMLImageElement of the loaded image
  93590. */
  93591. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  93592. /**
  93593. * Loads a file
  93594. * @param url url string, ArrayBuffer, or Blob to load
  93595. * @param onSuccess callback called when the file successfully loads
  93596. * @param onProgress callback called while file is loading (if the server supports this mode)
  93597. * @param offlineProvider defines the offline provider for caching
  93598. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  93599. * @param onError callback called when the file fails to load
  93600. * @returns a file request object
  93601. */
  93602. 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;
  93603. /**
  93604. * Load a script (identified by an url). When the url returns, the
  93605. * content of this file is added into a new script element, attached to the DOM (body element)
  93606. * @param scriptUrl defines the url of the script to laod
  93607. * @param onSuccess defines the callback called when the script is loaded
  93608. * @param onError defines the callback to call if an error occurs
  93609. * @param scriptId defines the id of the script element
  93610. */
  93611. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  93612. /**
  93613. * Load an asynchronous script (identified by an url). When the url returns, the
  93614. * content of this file is added into a new script element, attached to the DOM (body element)
  93615. * @param scriptUrl defines the url of the script to laod
  93616. * @param scriptId defines the id of the script element
  93617. * @returns a promise request object
  93618. */
  93619. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  93620. /**
  93621. * Loads a file from a blob
  93622. * @param fileToLoad defines the blob to use
  93623. * @param callback defines the callback to call when data is loaded
  93624. * @param progressCallback defines the callback to call during loading process
  93625. * @returns a file request object
  93626. */
  93627. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  93628. /**
  93629. * Loads a file
  93630. * @param fileToLoad defines the file to load
  93631. * @param callback defines the callback to call when data is loaded
  93632. * @param progressCallBack defines the callback to call during loading process
  93633. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  93634. * @returns a file request object
  93635. */
  93636. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  93637. /**
  93638. * Creates a data url from a given string content
  93639. * @param content defines the content to convert
  93640. * @returns the new data url link
  93641. */
  93642. static FileAsURL(content: string): string;
  93643. /**
  93644. * Format the given number to a specific decimal format
  93645. * @param value defines the number to format
  93646. * @param decimals defines the number of decimals to use
  93647. * @returns the formatted string
  93648. */
  93649. static Format(value: number, decimals?: number): string;
  93650. /**
  93651. * Checks if a given vector is inside a specific range
  93652. * @param v defines the vector to test
  93653. * @param min defines the minimum range
  93654. * @param max defines the maximum range
  93655. */
  93656. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  93657. /**
  93658. * Tries to copy an object by duplicating every property
  93659. * @param source defines the source object
  93660. * @param destination defines the target object
  93661. * @param doNotCopyList defines a list of properties to avoid
  93662. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  93663. */
  93664. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  93665. /**
  93666. * Gets a boolean indicating if the given object has no own property
  93667. * @param obj defines the object to test
  93668. * @returns true if object has no own property
  93669. */
  93670. static IsEmpty(obj: any): boolean;
  93671. /**
  93672. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  93673. * @param str Source string
  93674. * @param suffix Suffix to search for in the source string
  93675. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  93676. */
  93677. static EndsWith(str: string, suffix: string): boolean;
  93678. /**
  93679. * Function used to register events at window level
  93680. * @param events defines the events to register
  93681. */
  93682. static RegisterTopRootEvents(events: {
  93683. name: string;
  93684. handler: Nullable<(e: FocusEvent) => any>;
  93685. }[]): void;
  93686. /**
  93687. * Function used to unregister events from window level
  93688. * @param events defines the events to unregister
  93689. */
  93690. static UnregisterTopRootEvents(events: {
  93691. name: string;
  93692. handler: Nullable<(e: FocusEvent) => any>;
  93693. }[]): void;
  93694. /**
  93695. * @ignore
  93696. */
  93697. static _ScreenshotCanvas: HTMLCanvasElement;
  93698. /**
  93699. * Dumps the current bound framebuffer
  93700. * @param width defines the rendering width
  93701. * @param height defines the rendering height
  93702. * @param engine defines the hosting engine
  93703. * @param successCallback defines the callback triggered once the data are available
  93704. * @param mimeType defines the mime type of the result
  93705. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  93706. */
  93707. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  93708. /**
  93709. * Converts the canvas data to blob.
  93710. * This acts as a polyfill for browsers not supporting the to blob function.
  93711. * @param canvas Defines the canvas to extract the data from
  93712. * @param successCallback Defines the callback triggered once the data are available
  93713. * @param mimeType Defines the mime type of the result
  93714. */
  93715. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  93716. /**
  93717. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  93718. * @param successCallback defines the callback triggered once the data are available
  93719. * @param mimeType defines the mime type of the result
  93720. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  93721. */
  93722. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  93723. /**
  93724. * Downloads a blob in the browser
  93725. * @param blob defines the blob to download
  93726. * @param fileName defines the name of the downloaded file
  93727. */
  93728. static Download(blob: Blob, fileName: string): void;
  93729. /**
  93730. * Captures a screenshot of the current rendering
  93731. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  93732. * @param engine defines the rendering engine
  93733. * @param camera defines the source camera
  93734. * @param size This parameter can be set to a single number or to an object with the
  93735. * following (optional) properties: precision, width, height. If a single number is passed,
  93736. * it will be used for both width and height. If an object is passed, the screenshot size
  93737. * will be derived from the parameters. The precision property is a multiplier allowing
  93738. * rendering at a higher or lower resolution
  93739. * @param successCallback defines the callback receives a single parameter which contains the
  93740. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  93741. * src parameter of an <img> to display it
  93742. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  93743. * Check your browser for supported MIME types
  93744. */
  93745. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  93746. /**
  93747. * Generates an image screenshot from the specified camera.
  93748. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  93749. * @param engine The engine to use for rendering
  93750. * @param camera The camera to use for rendering
  93751. * @param size This parameter can be set to a single number or to an object with the
  93752. * following (optional) properties: precision, width, height. If a single number is passed,
  93753. * it will be used for both width and height. If an object is passed, the screenshot size
  93754. * will be derived from the parameters. The precision property is a multiplier allowing
  93755. * rendering at a higher or lower resolution
  93756. * @param successCallback The callback receives a single parameter which contains the
  93757. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  93758. * src parameter of an <img> to display it
  93759. * @param mimeType The MIME type of the screenshot image (default: image/png).
  93760. * Check your browser for supported MIME types
  93761. * @param samples Texture samples (default: 1)
  93762. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  93763. * @param fileName A name for for the downloaded file.
  93764. */
  93765. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  93766. /**
  93767. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  93768. * Be aware Math.random() could cause collisions, but:
  93769. * "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"
  93770. * @returns a pseudo random id
  93771. */
  93772. static RandomId(): string;
  93773. /**
  93774. * Test if the given uri is a base64 string
  93775. * @param uri The uri to test
  93776. * @return True if the uri is a base64 string or false otherwise
  93777. */
  93778. static IsBase64(uri: string): boolean;
  93779. /**
  93780. * Decode the given base64 uri.
  93781. * @param uri The uri to decode
  93782. * @return The decoded base64 data.
  93783. */
  93784. static DecodeBase64(uri: string): ArrayBuffer;
  93785. /**
  93786. * Gets the absolute url.
  93787. * @param url the input url
  93788. * @return the absolute url
  93789. */
  93790. static GetAbsoluteUrl(url: string): string;
  93791. /**
  93792. * No log
  93793. */
  93794. static readonly NoneLogLevel: number;
  93795. /**
  93796. * Only message logs
  93797. */
  93798. static readonly MessageLogLevel: number;
  93799. /**
  93800. * Only warning logs
  93801. */
  93802. static readonly WarningLogLevel: number;
  93803. /**
  93804. * Only error logs
  93805. */
  93806. static readonly ErrorLogLevel: number;
  93807. /**
  93808. * All logs
  93809. */
  93810. static readonly AllLogLevel: number;
  93811. /**
  93812. * Gets a value indicating the number of loading errors
  93813. * @ignorenaming
  93814. */
  93815. static readonly errorsCount: number;
  93816. /**
  93817. * Callback called when a new log is added
  93818. */
  93819. static OnNewCacheEntry: (entry: string) => void;
  93820. /**
  93821. * Log a message to the console
  93822. * @param message defines the message to log
  93823. */
  93824. static Log(message: string): void;
  93825. /**
  93826. * Write a warning message to the console
  93827. * @param message defines the message to log
  93828. */
  93829. static Warn(message: string): void;
  93830. /**
  93831. * Write an error message to the console
  93832. * @param message defines the message to log
  93833. */
  93834. static Error(message: string): void;
  93835. /**
  93836. * Gets current log cache (list of logs)
  93837. */
  93838. static readonly LogCache: string;
  93839. /**
  93840. * Clears the log cache
  93841. */
  93842. static ClearLogCache(): void;
  93843. /**
  93844. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  93845. */
  93846. static LogLevels: number;
  93847. /**
  93848. * Checks if the loaded document was accessed via `file:`-Protocol.
  93849. * @returns boolean
  93850. */
  93851. static IsFileURL(): boolean;
  93852. /**
  93853. * Checks if the window object exists
  93854. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  93855. */
  93856. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  93857. /**
  93858. * No performance log
  93859. */
  93860. static readonly PerformanceNoneLogLevel: number;
  93861. /**
  93862. * Use user marks to log performance
  93863. */
  93864. static readonly PerformanceUserMarkLogLevel: number;
  93865. /**
  93866. * Log performance to the console
  93867. */
  93868. static readonly PerformanceConsoleLogLevel: number;
  93869. private static _performance;
  93870. /**
  93871. * Sets the current performance log level
  93872. */
  93873. static PerformanceLogLevel: number;
  93874. private static _StartPerformanceCounterDisabled;
  93875. private static _EndPerformanceCounterDisabled;
  93876. private static _StartUserMark;
  93877. private static _EndUserMark;
  93878. private static _StartPerformanceConsole;
  93879. private static _EndPerformanceConsole;
  93880. /**
  93881. * Starts a performance counter
  93882. */
  93883. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  93884. /**
  93885. * Ends a specific performance coutner
  93886. */
  93887. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  93888. /**
  93889. * Gets either window.performance.now() if supported or Date.now() else
  93890. */
  93891. static readonly Now: number;
  93892. /**
  93893. * This method will return the name of the class used to create the instance of the given object.
  93894. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  93895. * @param object the object to get the class name from
  93896. * @param isType defines if the object is actually a type
  93897. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  93898. */
  93899. static GetClassName(object: any, isType?: boolean): string;
  93900. /**
  93901. * Gets the first element of an array satisfying a given predicate
  93902. * @param array defines the array to browse
  93903. * @param predicate defines the predicate to use
  93904. * @returns null if not found or the element
  93905. */
  93906. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  93907. /**
  93908. * This method will return the name of the full name of the class, including its owning module (if any).
  93909. * 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).
  93910. * @param object the object to get the class name from
  93911. * @param isType defines if the object is actually a type
  93912. * @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.
  93913. * @ignorenaming
  93914. */
  93915. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  93916. /**
  93917. * Returns a promise that resolves after the given amount of time.
  93918. * @param delay Number of milliseconds to delay
  93919. * @returns Promise that resolves after the given amount of time
  93920. */
  93921. static DelayAsync(delay: number): Promise<void>;
  93922. /**
  93923. * Gets the current gradient from an array of IValueGradient
  93924. * @param ratio defines the current ratio to get
  93925. * @param gradients defines the array of IValueGradient
  93926. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  93927. */
  93928. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  93929. }
  93930. /**
  93931. * This class is used to track a performance counter which is number based.
  93932. * The user has access to many properties which give statistics of different nature.
  93933. *
  93934. * The implementer can track two kinds of Performance Counter: time and count.
  93935. * 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.
  93936. * 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.
  93937. */
  93938. export class PerfCounter {
  93939. /**
  93940. * Gets or sets a global boolean to turn on and off all the counters
  93941. */
  93942. static Enabled: boolean;
  93943. /**
  93944. * Returns the smallest value ever
  93945. */
  93946. readonly min: number;
  93947. /**
  93948. * Returns the biggest value ever
  93949. */
  93950. readonly max: number;
  93951. /**
  93952. * Returns the average value since the performance counter is running
  93953. */
  93954. readonly average: number;
  93955. /**
  93956. * Returns the average value of the last second the counter was monitored
  93957. */
  93958. readonly lastSecAverage: number;
  93959. /**
  93960. * Returns the current value
  93961. */
  93962. readonly current: number;
  93963. /**
  93964. * Gets the accumulated total
  93965. */
  93966. readonly total: number;
  93967. /**
  93968. * Gets the total value count
  93969. */
  93970. readonly count: number;
  93971. /**
  93972. * Creates a new counter
  93973. */
  93974. constructor();
  93975. /**
  93976. * Call this method to start monitoring a new frame.
  93977. * 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.
  93978. */
  93979. fetchNewFrame(): void;
  93980. /**
  93981. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  93982. * @param newCount the count value to add to the monitored count
  93983. * @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.
  93984. */
  93985. addCount(newCount: number, fetchResult: boolean): void;
  93986. /**
  93987. * Start monitoring this performance counter
  93988. */
  93989. beginMonitoring(): void;
  93990. /**
  93991. * Compute the time lapsed since the previous beginMonitoring() call.
  93992. * @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
  93993. */
  93994. endMonitoring(newFrame?: boolean): void;
  93995. private _fetchResult;
  93996. private _startMonitoringTime;
  93997. private _min;
  93998. private _max;
  93999. private _average;
  94000. private _current;
  94001. private _totalValueCount;
  94002. private _totalAccumulated;
  94003. private _lastSecAverage;
  94004. private _lastSecAccumulated;
  94005. private _lastSecTime;
  94006. private _lastSecValueCount;
  94007. }
  94008. /**
  94009. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  94010. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  94011. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  94012. * @param name The name of the class, case should be preserved
  94013. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  94014. */
  94015. export function className(name: string, module?: string): (target: Object) => void;
  94016. /**
  94017. * An implementation of a loop for asynchronous functions.
  94018. */
  94019. export class AsyncLoop {
  94020. /**
  94021. * Defines the number of iterations for the loop
  94022. */
  94023. iterations: number;
  94024. /**
  94025. * Defines the current index of the loop.
  94026. */
  94027. index: number;
  94028. private _done;
  94029. private _fn;
  94030. private _successCallback;
  94031. /**
  94032. * Constructor.
  94033. * @param iterations the number of iterations.
  94034. * @param func the function to run each iteration
  94035. * @param successCallback the callback that will be called upon succesful execution
  94036. * @param offset starting offset.
  94037. */
  94038. constructor(
  94039. /**
  94040. * Defines the number of iterations for the loop
  94041. */
  94042. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  94043. /**
  94044. * Execute the next iteration. Must be called after the last iteration was finished.
  94045. */
  94046. executeNext(): void;
  94047. /**
  94048. * Break the loop and run the success callback.
  94049. */
  94050. breakLoop(): void;
  94051. /**
  94052. * Create and run an async loop.
  94053. * @param iterations the number of iterations.
  94054. * @param fn the function to run each iteration
  94055. * @param successCallback the callback that will be called upon succesful execution
  94056. * @param offset starting offset.
  94057. * @returns the created async loop object
  94058. */
  94059. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  94060. /**
  94061. * A for-loop that will run a given number of iterations synchronous and the rest async.
  94062. * @param iterations total number of iterations
  94063. * @param syncedIterations number of synchronous iterations in each async iteration.
  94064. * @param fn the function to call each iteration.
  94065. * @param callback a success call back that will be called when iterating stops.
  94066. * @param breakFunction a break condition (optional)
  94067. * @param timeout timeout settings for the setTimeout function. default - 0.
  94068. * @returns the created async loop object
  94069. */
  94070. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  94071. }
  94072. }
  94073. declare module BABYLON {
  94074. /** @hidden */
  94075. export interface ICollisionCoordinator {
  94076. createCollider(): Collider;
  94077. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  94078. init(scene: Scene): void;
  94079. }
  94080. /** @hidden */
  94081. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  94082. private _scene;
  94083. private _scaledPosition;
  94084. private _scaledVelocity;
  94085. private _finalPosition;
  94086. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  94087. createCollider(): Collider;
  94088. init(scene: Scene): void;
  94089. private _collideWithWorld;
  94090. }
  94091. }
  94092. declare module BABYLON {
  94093. /**
  94094. * Class used to manage all inputs for the scene.
  94095. */
  94096. export class InputManager {
  94097. /** The distance in pixel that you have to move to prevent some events */
  94098. static DragMovementThreshold: number;
  94099. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  94100. static LongPressDelay: number;
  94101. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  94102. static DoubleClickDelay: number;
  94103. /** If you need to check double click without raising a single click at first click, enable this flag */
  94104. static ExclusiveDoubleClickMode: boolean;
  94105. private _wheelEventName;
  94106. private _onPointerMove;
  94107. private _onPointerDown;
  94108. private _onPointerUp;
  94109. private _initClickEvent;
  94110. private _initActionManager;
  94111. private _delayedSimpleClick;
  94112. private _delayedSimpleClickTimeout;
  94113. private _previousDelayedSimpleClickTimeout;
  94114. private _meshPickProceed;
  94115. private _previousButtonPressed;
  94116. private _currentPickResult;
  94117. private _previousPickResult;
  94118. private _totalPointersPressed;
  94119. private _doubleClickOccured;
  94120. private _pointerOverMesh;
  94121. private _pickedDownMesh;
  94122. private _pickedUpMesh;
  94123. private _pointerX;
  94124. private _pointerY;
  94125. private _unTranslatedPointerX;
  94126. private _unTranslatedPointerY;
  94127. private _startingPointerPosition;
  94128. private _previousStartingPointerPosition;
  94129. private _startingPointerTime;
  94130. private _previousStartingPointerTime;
  94131. private _pointerCaptures;
  94132. private _onKeyDown;
  94133. private _onKeyUp;
  94134. private _onCanvasFocusObserver;
  94135. private _onCanvasBlurObserver;
  94136. private _scene;
  94137. /**
  94138. * Creates a new InputManager
  94139. * @param scene defines the hosting scene
  94140. */
  94141. constructor(scene: Scene);
  94142. /**
  94143. * Gets the mesh that is currently under the pointer
  94144. */
  94145. readonly meshUnderPointer: Nullable<AbstractMesh>;
  94146. /**
  94147. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  94148. */
  94149. readonly unTranslatedPointer: Vector2;
  94150. /**
  94151. * Gets or sets the current on-screen X position of the pointer
  94152. */
  94153. pointerX: number;
  94154. /**
  94155. * Gets or sets the current on-screen Y position of the pointer
  94156. */
  94157. pointerY: number;
  94158. private _updatePointerPosition;
  94159. private _processPointerMove;
  94160. private _setRayOnPointerInfo;
  94161. private _checkPrePointerObservable;
  94162. /**
  94163. * Use this method to simulate a pointer move on a mesh
  94164. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94165. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94166. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94167. */
  94168. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  94169. /**
  94170. * Use this method to simulate a pointer down on a mesh
  94171. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94172. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94173. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94174. */
  94175. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  94176. private _processPointerDown;
  94177. /** @hidden */
  94178. _isPointerSwiping(): boolean;
  94179. /**
  94180. * Use this method to simulate a pointer up on a mesh
  94181. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94182. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94183. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94184. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  94185. */
  94186. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  94187. private _processPointerUp;
  94188. /**
  94189. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  94190. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  94191. * @returns true if the pointer was captured
  94192. */
  94193. isPointerCaptured(pointerId?: number): boolean;
  94194. /**
  94195. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  94196. * @param attachUp defines if you want to attach events to pointerup
  94197. * @param attachDown defines if you want to attach events to pointerdown
  94198. * @param attachMove defines if you want to attach events to pointermove
  94199. */
  94200. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  94201. /**
  94202. * Detaches all event handlers
  94203. */
  94204. detachControl(): void;
  94205. /**
  94206. * Force the value of meshUnderPointer
  94207. * @param mesh defines the mesh to use
  94208. */
  94209. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  94210. /**
  94211. * Gets the mesh under the pointer
  94212. * @returns a Mesh or null if no mesh is under the pointer
  94213. */
  94214. getPointerOverMesh(): Nullable<AbstractMesh>;
  94215. }
  94216. }
  94217. declare module BABYLON {
  94218. /**
  94219. * This class defines the direct association between an animation and a target
  94220. */
  94221. export class TargetedAnimation {
  94222. /**
  94223. * Animation to perform
  94224. */
  94225. animation: Animation;
  94226. /**
  94227. * Target to animate
  94228. */
  94229. target: any;
  94230. /**
  94231. * Serialize the object
  94232. * @returns the JSON object representing the current entity
  94233. */
  94234. serialize(): any;
  94235. }
  94236. /**
  94237. * Use this class to create coordinated animations on multiple targets
  94238. */
  94239. export class AnimationGroup implements IDisposable {
  94240. /** The name of the animation group */
  94241. name: string;
  94242. private _scene;
  94243. private _targetedAnimations;
  94244. private _animatables;
  94245. private _from;
  94246. private _to;
  94247. private _isStarted;
  94248. private _isPaused;
  94249. private _speedRatio;
  94250. private _loopAnimation;
  94251. /**
  94252. * Gets or sets the unique id of the node
  94253. */
  94254. uniqueId: number;
  94255. /**
  94256. * This observable will notify when one animation have ended
  94257. */
  94258. onAnimationEndObservable: Observable<TargetedAnimation>;
  94259. /**
  94260. * Observer raised when one animation loops
  94261. */
  94262. onAnimationLoopObservable: Observable<TargetedAnimation>;
  94263. /**
  94264. * This observable will notify when all animations have ended.
  94265. */
  94266. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  94267. /**
  94268. * This observable will notify when all animations have paused.
  94269. */
  94270. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  94271. /**
  94272. * This observable will notify when all animations are playing.
  94273. */
  94274. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  94275. /**
  94276. * Gets the first frame
  94277. */
  94278. readonly from: number;
  94279. /**
  94280. * Gets the last frame
  94281. */
  94282. readonly to: number;
  94283. /**
  94284. * Define if the animations are started
  94285. */
  94286. readonly isStarted: boolean;
  94287. /**
  94288. * Gets a value indicating that the current group is playing
  94289. */
  94290. readonly isPlaying: boolean;
  94291. /**
  94292. * Gets or sets the speed ratio to use for all animations
  94293. */
  94294. /**
  94295. * Gets or sets the speed ratio to use for all animations
  94296. */
  94297. speedRatio: number;
  94298. /**
  94299. * Gets or sets if all animations should loop or not
  94300. */
  94301. loopAnimation: boolean;
  94302. /**
  94303. * Gets the targeted animations for this animation group
  94304. */
  94305. readonly targetedAnimations: Array<TargetedAnimation>;
  94306. /**
  94307. * returning the list of animatables controlled by this animation group.
  94308. */
  94309. readonly animatables: Array<Animatable>;
  94310. /**
  94311. * Instantiates a new Animation Group.
  94312. * This helps managing several animations at once.
  94313. * @see http://doc.babylonjs.com/how_to/group
  94314. * @param name Defines the name of the group
  94315. * @param scene Defines the scene the group belongs to
  94316. */
  94317. constructor(
  94318. /** The name of the animation group */
  94319. name: string, scene?: Nullable<Scene>);
  94320. /**
  94321. * Add an animation (with its target) in the group
  94322. * @param animation defines the animation we want to add
  94323. * @param target defines the target of the animation
  94324. * @returns the TargetedAnimation object
  94325. */
  94326. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  94327. /**
  94328. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  94329. * It can add constant keys at begin or end
  94330. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  94331. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  94332. * @returns the animation group
  94333. */
  94334. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  94335. /**
  94336. * Start all animations on given targets
  94337. * @param loop defines if animations must loop
  94338. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  94339. * @param from defines the from key (optional)
  94340. * @param to defines the to key (optional)
  94341. * @returns the current animation group
  94342. */
  94343. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  94344. /**
  94345. * Pause all animations
  94346. * @returns the animation group
  94347. */
  94348. pause(): AnimationGroup;
  94349. /**
  94350. * Play all animations to initial state
  94351. * This function will start() the animations if they were not started or will restart() them if they were paused
  94352. * @param loop defines if animations must loop
  94353. * @returns the animation group
  94354. */
  94355. play(loop?: boolean): AnimationGroup;
  94356. /**
  94357. * Reset all animations to initial state
  94358. * @returns the animation group
  94359. */
  94360. reset(): AnimationGroup;
  94361. /**
  94362. * Restart animations from key 0
  94363. * @returns the animation group
  94364. */
  94365. restart(): AnimationGroup;
  94366. /**
  94367. * Stop all animations
  94368. * @returns the animation group
  94369. */
  94370. stop(): AnimationGroup;
  94371. /**
  94372. * Set animation weight for all animatables
  94373. * @param weight defines the weight to use
  94374. * @return the animationGroup
  94375. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  94376. */
  94377. setWeightForAllAnimatables(weight: number): AnimationGroup;
  94378. /**
  94379. * Synchronize and normalize all animatables with a source animatable
  94380. * @param root defines the root animatable to synchronize with
  94381. * @return the animationGroup
  94382. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  94383. */
  94384. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  94385. /**
  94386. * Goes to a specific frame in this animation group
  94387. * @param frame the frame number to go to
  94388. * @return the animationGroup
  94389. */
  94390. goToFrame(frame: number): AnimationGroup;
  94391. /**
  94392. * Dispose all associated resources
  94393. */
  94394. dispose(): void;
  94395. private _checkAnimationGroupEnded;
  94396. /**
  94397. * Clone the current animation group and returns a copy
  94398. * @param newName defines the name of the new group
  94399. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  94400. * @returns the new aniamtion group
  94401. */
  94402. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  94403. /**
  94404. * Serializes the animationGroup to an object
  94405. * @returns Serialized object
  94406. */
  94407. serialize(): any;
  94408. /**
  94409. * Returns a new AnimationGroup object parsed from the source provided.
  94410. * @param parsedAnimationGroup defines the source
  94411. * @param scene defines the scene that will receive the animationGroup
  94412. * @returns a new AnimationGroup
  94413. */
  94414. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  94415. /**
  94416. * Returns the string "AnimationGroup"
  94417. * @returns "AnimationGroup"
  94418. */
  94419. getClassName(): string;
  94420. /**
  94421. * Creates a detailled string about the object
  94422. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  94423. * @returns a string representing the object
  94424. */
  94425. toString(fullDetails?: boolean): string;
  94426. }
  94427. }
  94428. declare module BABYLON {
  94429. /**
  94430. * Define an interface for all classes that will hold resources
  94431. */
  94432. export interface IDisposable {
  94433. /**
  94434. * Releases all held resources
  94435. */
  94436. dispose(): void;
  94437. }
  94438. /** Interface defining initialization parameters for Scene class */
  94439. export interface SceneOptions {
  94440. /**
  94441. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  94442. * It will improve performance when the number of geometries becomes important.
  94443. */
  94444. useGeometryUniqueIdsMap?: boolean;
  94445. /**
  94446. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  94447. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  94448. */
  94449. useMaterialMeshMap?: boolean;
  94450. /**
  94451. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  94452. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  94453. */
  94454. useClonedMeshhMap?: boolean;
  94455. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  94456. virtual?: boolean;
  94457. }
  94458. /**
  94459. * Represents a scene to be rendered by the engine.
  94460. * @see http://doc.babylonjs.com/features/scene
  94461. */
  94462. export class Scene extends AbstractScene implements IAnimatable {
  94463. private static _uniqueIdCounter;
  94464. /** The fog is deactivated */
  94465. static readonly FOGMODE_NONE: number;
  94466. /** The fog density is following an exponential function */
  94467. static readonly FOGMODE_EXP: number;
  94468. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  94469. static readonly FOGMODE_EXP2: number;
  94470. /** The fog density is following a linear function. */
  94471. static readonly FOGMODE_LINEAR: number;
  94472. /**
  94473. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  94474. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94475. */
  94476. static MinDeltaTime: number;
  94477. /**
  94478. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  94479. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94480. */
  94481. static MaxDeltaTime: number;
  94482. /**
  94483. * Factory used to create the default material.
  94484. * @param name The name of the material to create
  94485. * @param scene The scene to create the material for
  94486. * @returns The default material
  94487. */
  94488. static DefaultMaterialFactory(scene: Scene): Material;
  94489. /**
  94490. * Factory used to create the a collision coordinator.
  94491. * @returns The collision coordinator
  94492. */
  94493. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  94494. /** @hidden */
  94495. _inputManager: InputManager;
  94496. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  94497. cameraToUseForPointers: Nullable<Camera>;
  94498. /** @hidden */
  94499. readonly _isScene: boolean;
  94500. /**
  94501. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  94502. */
  94503. autoClear: boolean;
  94504. /**
  94505. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  94506. */
  94507. autoClearDepthAndStencil: boolean;
  94508. /**
  94509. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  94510. */
  94511. clearColor: Color4;
  94512. /**
  94513. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  94514. */
  94515. ambientColor: Color3;
  94516. /**
  94517. * This is use to store the default BRDF lookup for PBR materials in your scene.
  94518. * It should only be one of the following (if not the default embedded one):
  94519. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  94520. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  94521. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  94522. * The material properties need to be setup according to the type of texture in use.
  94523. */
  94524. environmentBRDFTexture: BaseTexture;
  94525. /** @hidden */
  94526. protected _environmentTexture: Nullable<BaseTexture>;
  94527. /**
  94528. * Texture used in all pbr material as the reflection texture.
  94529. * As in the majority of the scene they are the same (exception for multi room and so on),
  94530. * this is easier to reference from here than from all the materials.
  94531. */
  94532. /**
  94533. * Texture used in all pbr material as the reflection texture.
  94534. * As in the majority of the scene they are the same (exception for multi room and so on),
  94535. * this is easier to set here than in all the materials.
  94536. */
  94537. environmentTexture: Nullable<BaseTexture>;
  94538. /** @hidden */
  94539. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  94540. /**
  94541. * Default image processing configuration used either in the rendering
  94542. * Forward main pass or through the imageProcessingPostProcess if present.
  94543. * As in the majority of the scene they are the same (exception for multi camera),
  94544. * this is easier to reference from here than from all the materials and post process.
  94545. *
  94546. * No setter as we it is a shared configuration, you can set the values instead.
  94547. */
  94548. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  94549. private _forceWireframe;
  94550. /**
  94551. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  94552. */
  94553. forceWireframe: boolean;
  94554. private _forcePointsCloud;
  94555. /**
  94556. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  94557. */
  94558. forcePointsCloud: boolean;
  94559. /**
  94560. * Gets or sets the active clipplane 1
  94561. */
  94562. clipPlane: Nullable<Plane>;
  94563. /**
  94564. * Gets or sets the active clipplane 2
  94565. */
  94566. clipPlane2: Nullable<Plane>;
  94567. /**
  94568. * Gets or sets the active clipplane 3
  94569. */
  94570. clipPlane3: Nullable<Plane>;
  94571. /**
  94572. * Gets or sets the active clipplane 4
  94573. */
  94574. clipPlane4: Nullable<Plane>;
  94575. /**
  94576. * Gets or sets a boolean indicating if animations are enabled
  94577. */
  94578. animationsEnabled: boolean;
  94579. private _animationPropertiesOverride;
  94580. /**
  94581. * Gets or sets the animation properties override
  94582. */
  94583. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  94584. /**
  94585. * Gets or sets a boolean indicating if a constant deltatime has to be used
  94586. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  94587. */
  94588. useConstantAnimationDeltaTime: boolean;
  94589. /**
  94590. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  94591. * Please note that it requires to run a ray cast through the scene on every frame
  94592. */
  94593. constantlyUpdateMeshUnderPointer: boolean;
  94594. /**
  94595. * Defines the HTML cursor to use when hovering over interactive elements
  94596. */
  94597. hoverCursor: string;
  94598. /**
  94599. * Defines the HTML default cursor to use (empty by default)
  94600. */
  94601. defaultCursor: string;
  94602. /**
  94603. * This is used to call preventDefault() on pointer down
  94604. * in order to block unwanted artifacts like system double clicks
  94605. */
  94606. preventDefaultOnPointerDown: boolean;
  94607. /**
  94608. * This is used to call preventDefault() on pointer up
  94609. * in order to block unwanted artifacts like system double clicks
  94610. */
  94611. preventDefaultOnPointerUp: boolean;
  94612. /**
  94613. * Gets or sets user defined metadata
  94614. */
  94615. metadata: any;
  94616. /**
  94617. * For internal use only. Please do not use.
  94618. */
  94619. reservedDataStore: any;
  94620. /**
  94621. * Gets the name of the plugin used to load this scene (null by default)
  94622. */
  94623. loadingPluginName: string;
  94624. /**
  94625. * Use this array to add regular expressions used to disable offline support for specific urls
  94626. */
  94627. disableOfflineSupportExceptionRules: RegExp[];
  94628. /**
  94629. * An event triggered when the scene is disposed.
  94630. */
  94631. onDisposeObservable: Observable<Scene>;
  94632. private _onDisposeObserver;
  94633. /** Sets a function to be executed when this scene is disposed. */
  94634. onDispose: () => void;
  94635. /**
  94636. * An event triggered before rendering the scene (right after animations and physics)
  94637. */
  94638. onBeforeRenderObservable: Observable<Scene>;
  94639. private _onBeforeRenderObserver;
  94640. /** Sets a function to be executed before rendering this scene */
  94641. beforeRender: Nullable<() => void>;
  94642. /**
  94643. * An event triggered after rendering the scene
  94644. */
  94645. onAfterRenderObservable: Observable<Scene>;
  94646. private _onAfterRenderObserver;
  94647. /** Sets a function to be executed after rendering this scene */
  94648. afterRender: Nullable<() => void>;
  94649. /**
  94650. * An event triggered before animating the scene
  94651. */
  94652. onBeforeAnimationsObservable: Observable<Scene>;
  94653. /**
  94654. * An event triggered after animations processing
  94655. */
  94656. onAfterAnimationsObservable: Observable<Scene>;
  94657. /**
  94658. * An event triggered before draw calls are ready to be sent
  94659. */
  94660. onBeforeDrawPhaseObservable: Observable<Scene>;
  94661. /**
  94662. * An event triggered after draw calls have been sent
  94663. */
  94664. onAfterDrawPhaseObservable: Observable<Scene>;
  94665. /**
  94666. * An event triggered when the scene is ready
  94667. */
  94668. onReadyObservable: Observable<Scene>;
  94669. /**
  94670. * An event triggered before rendering a camera
  94671. */
  94672. onBeforeCameraRenderObservable: Observable<Camera>;
  94673. private _onBeforeCameraRenderObserver;
  94674. /** Sets a function to be executed before rendering a camera*/
  94675. beforeCameraRender: () => void;
  94676. /**
  94677. * An event triggered after rendering a camera
  94678. */
  94679. onAfterCameraRenderObservable: Observable<Camera>;
  94680. private _onAfterCameraRenderObserver;
  94681. /** Sets a function to be executed after rendering a camera*/
  94682. afterCameraRender: () => void;
  94683. /**
  94684. * An event triggered when active meshes evaluation is about to start
  94685. */
  94686. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  94687. /**
  94688. * An event triggered when active meshes evaluation is done
  94689. */
  94690. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  94691. /**
  94692. * An event triggered when particles rendering is about to start
  94693. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  94694. */
  94695. onBeforeParticlesRenderingObservable: Observable<Scene>;
  94696. /**
  94697. * An event triggered when particles rendering is done
  94698. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  94699. */
  94700. onAfterParticlesRenderingObservable: Observable<Scene>;
  94701. /**
  94702. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  94703. */
  94704. onDataLoadedObservable: Observable<Scene>;
  94705. /**
  94706. * An event triggered when a camera is created
  94707. */
  94708. onNewCameraAddedObservable: Observable<Camera>;
  94709. /**
  94710. * An event triggered when a camera is removed
  94711. */
  94712. onCameraRemovedObservable: Observable<Camera>;
  94713. /**
  94714. * An event triggered when a light is created
  94715. */
  94716. onNewLightAddedObservable: Observable<Light>;
  94717. /**
  94718. * An event triggered when a light is removed
  94719. */
  94720. onLightRemovedObservable: Observable<Light>;
  94721. /**
  94722. * An event triggered when a geometry is created
  94723. */
  94724. onNewGeometryAddedObservable: Observable<Geometry>;
  94725. /**
  94726. * An event triggered when a geometry is removed
  94727. */
  94728. onGeometryRemovedObservable: Observable<Geometry>;
  94729. /**
  94730. * An event triggered when a transform node is created
  94731. */
  94732. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  94733. /**
  94734. * An event triggered when a transform node is removed
  94735. */
  94736. onTransformNodeRemovedObservable: Observable<TransformNode>;
  94737. /**
  94738. * An event triggered when a mesh is created
  94739. */
  94740. onNewMeshAddedObservable: Observable<AbstractMesh>;
  94741. /**
  94742. * An event triggered when a mesh is removed
  94743. */
  94744. onMeshRemovedObservable: Observable<AbstractMesh>;
  94745. /**
  94746. * An event triggered when a skeleton is created
  94747. */
  94748. onNewSkeletonAddedObservable: Observable<Skeleton>;
  94749. /**
  94750. * An event triggered when a skeleton is removed
  94751. */
  94752. onSkeletonRemovedObservable: Observable<Skeleton>;
  94753. /**
  94754. * An event triggered when a material is created
  94755. */
  94756. onNewMaterialAddedObservable: Observable<Material>;
  94757. /**
  94758. * An event triggered when a material is removed
  94759. */
  94760. onMaterialRemovedObservable: Observable<Material>;
  94761. /**
  94762. * An event triggered when a texture is created
  94763. */
  94764. onNewTextureAddedObservable: Observable<BaseTexture>;
  94765. /**
  94766. * An event triggered when a texture is removed
  94767. */
  94768. onTextureRemovedObservable: Observable<BaseTexture>;
  94769. /**
  94770. * An event triggered when render targets are about to be rendered
  94771. * Can happen multiple times per frame.
  94772. */
  94773. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  94774. /**
  94775. * An event triggered when render targets were rendered.
  94776. * Can happen multiple times per frame.
  94777. */
  94778. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  94779. /**
  94780. * An event triggered before calculating deterministic simulation step
  94781. */
  94782. onBeforeStepObservable: Observable<Scene>;
  94783. /**
  94784. * An event triggered after calculating deterministic simulation step
  94785. */
  94786. onAfterStepObservable: Observable<Scene>;
  94787. /**
  94788. * An event triggered when the activeCamera property is updated
  94789. */
  94790. onActiveCameraChanged: Observable<Scene>;
  94791. /**
  94792. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  94793. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  94794. * 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)
  94795. */
  94796. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  94797. /**
  94798. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  94799. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  94800. * 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)
  94801. */
  94802. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  94803. /**
  94804. * This Observable will when a mesh has been imported into the scene.
  94805. */
  94806. onMeshImportedObservable: Observable<AbstractMesh>;
  94807. /**
  94808. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  94809. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  94810. */
  94811. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  94812. /** @hidden */
  94813. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  94814. /**
  94815. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  94816. */
  94817. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  94818. /**
  94819. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  94820. */
  94821. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  94822. /**
  94823. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  94824. */
  94825. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  94826. /** Callback called when a pointer move is detected */
  94827. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  94828. /** Callback called when a pointer down is detected */
  94829. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  94830. /** Callback called when a pointer up is detected */
  94831. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  94832. /** Callback called when a pointer pick is detected */
  94833. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  94834. /**
  94835. * 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).
  94836. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  94837. */
  94838. onPrePointerObservable: Observable<PointerInfoPre>;
  94839. /**
  94840. * Observable event triggered each time an input event is received from the rendering canvas
  94841. */
  94842. onPointerObservable: Observable<PointerInfo>;
  94843. /**
  94844. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  94845. */
  94846. readonly unTranslatedPointer: Vector2;
  94847. /**
  94848. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  94849. */
  94850. static DragMovementThreshold: number;
  94851. /**
  94852. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  94853. */
  94854. static LongPressDelay: number;
  94855. /**
  94856. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  94857. */
  94858. static DoubleClickDelay: number;
  94859. /** If you need to check double click without raising a single click at first click, enable this flag */
  94860. static ExclusiveDoubleClickMode: boolean;
  94861. /** @hidden */
  94862. _mirroredCameraPosition: Nullable<Vector3>;
  94863. /**
  94864. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  94865. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  94866. */
  94867. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  94868. /**
  94869. * Observable event triggered each time an keyboard event is received from the hosting window
  94870. */
  94871. onKeyboardObservable: Observable<KeyboardInfo>;
  94872. private _useRightHandedSystem;
  94873. /**
  94874. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  94875. */
  94876. useRightHandedSystem: boolean;
  94877. private _timeAccumulator;
  94878. private _currentStepId;
  94879. private _currentInternalStep;
  94880. /**
  94881. * Sets the step Id used by deterministic lock step
  94882. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94883. * @param newStepId defines the step Id
  94884. */
  94885. setStepId(newStepId: number): void;
  94886. /**
  94887. * Gets the step Id used by deterministic lock step
  94888. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94889. * @returns the step Id
  94890. */
  94891. getStepId(): number;
  94892. /**
  94893. * Gets the internal step used by deterministic lock step
  94894. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94895. * @returns the internal step
  94896. */
  94897. getInternalStep(): number;
  94898. private _fogEnabled;
  94899. /**
  94900. * Gets or sets a boolean indicating if fog is enabled on this scene
  94901. * @see http://doc.babylonjs.com/babylon101/environment#fog
  94902. * (Default is true)
  94903. */
  94904. fogEnabled: boolean;
  94905. private _fogMode;
  94906. /**
  94907. * Gets or sets the fog mode to use
  94908. * @see http://doc.babylonjs.com/babylon101/environment#fog
  94909. * | mode | value |
  94910. * | --- | --- |
  94911. * | FOGMODE_NONE | 0 |
  94912. * | FOGMODE_EXP | 1 |
  94913. * | FOGMODE_EXP2 | 2 |
  94914. * | FOGMODE_LINEAR | 3 |
  94915. */
  94916. fogMode: number;
  94917. /**
  94918. * Gets or sets the fog color to use
  94919. * @see http://doc.babylonjs.com/babylon101/environment#fog
  94920. * (Default is Color3(0.2, 0.2, 0.3))
  94921. */
  94922. fogColor: Color3;
  94923. /**
  94924. * Gets or sets the fog density to use
  94925. * @see http://doc.babylonjs.com/babylon101/environment#fog
  94926. * (Default is 0.1)
  94927. */
  94928. fogDensity: number;
  94929. /**
  94930. * Gets or sets the fog start distance to use
  94931. * @see http://doc.babylonjs.com/babylon101/environment#fog
  94932. * (Default is 0)
  94933. */
  94934. fogStart: number;
  94935. /**
  94936. * Gets or sets the fog end distance to use
  94937. * @see http://doc.babylonjs.com/babylon101/environment#fog
  94938. * (Default is 1000)
  94939. */
  94940. fogEnd: number;
  94941. private _shadowsEnabled;
  94942. /**
  94943. * Gets or sets a boolean indicating if shadows are enabled on this scene
  94944. */
  94945. shadowsEnabled: boolean;
  94946. private _lightsEnabled;
  94947. /**
  94948. * Gets or sets a boolean indicating if lights are enabled on this scene
  94949. */
  94950. lightsEnabled: boolean;
  94951. /** All of the active cameras added to this scene. */
  94952. activeCameras: Camera[];
  94953. /** @hidden */
  94954. _activeCamera: Nullable<Camera>;
  94955. /** Gets or sets the current active camera */
  94956. activeCamera: Nullable<Camera>;
  94957. private _defaultMaterial;
  94958. /** The default material used on meshes when no material is affected */
  94959. /** The default material used on meshes when no material is affected */
  94960. defaultMaterial: Material;
  94961. private _texturesEnabled;
  94962. /**
  94963. * Gets or sets a boolean indicating if textures are enabled on this scene
  94964. */
  94965. texturesEnabled: boolean;
  94966. /**
  94967. * Gets or sets a boolean indicating if particles are enabled on this scene
  94968. */
  94969. particlesEnabled: boolean;
  94970. /**
  94971. * Gets or sets a boolean indicating if sprites are enabled on this scene
  94972. */
  94973. spritesEnabled: boolean;
  94974. private _skeletonsEnabled;
  94975. /**
  94976. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  94977. */
  94978. skeletonsEnabled: boolean;
  94979. /**
  94980. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  94981. */
  94982. lensFlaresEnabled: boolean;
  94983. /**
  94984. * Gets or sets a boolean indicating if collisions are enabled on this scene
  94985. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94986. */
  94987. collisionsEnabled: boolean;
  94988. private _collisionCoordinator;
  94989. /** @hidden */
  94990. readonly collisionCoordinator: ICollisionCoordinator;
  94991. /**
  94992. * Defines the gravity applied to this scene (used only for collisions)
  94993. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94994. */
  94995. gravity: Vector3;
  94996. /**
  94997. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  94998. */
  94999. postProcessesEnabled: boolean;
  95000. /**
  95001. * The list of postprocesses added to the scene
  95002. */
  95003. postProcesses: PostProcess[];
  95004. /**
  95005. * Gets the current postprocess manager
  95006. */
  95007. postProcessManager: PostProcessManager;
  95008. /**
  95009. * Gets or sets a boolean indicating if render targets are enabled on this scene
  95010. */
  95011. renderTargetsEnabled: boolean;
  95012. /**
  95013. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  95014. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  95015. */
  95016. dumpNextRenderTargets: boolean;
  95017. /**
  95018. * The list of user defined render targets added to the scene
  95019. */
  95020. customRenderTargets: RenderTargetTexture[];
  95021. /**
  95022. * Defines if texture loading must be delayed
  95023. * If true, textures will only be loaded when they need to be rendered
  95024. */
  95025. useDelayedTextureLoading: boolean;
  95026. /**
  95027. * Gets the list of meshes imported to the scene through SceneLoader
  95028. */
  95029. importedMeshesFiles: String[];
  95030. /**
  95031. * Gets or sets a boolean indicating if probes are enabled on this scene
  95032. */
  95033. probesEnabled: boolean;
  95034. /**
  95035. * Gets or sets the current offline provider to use to store scene data
  95036. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  95037. */
  95038. offlineProvider: IOfflineProvider;
  95039. /**
  95040. * Gets or sets the action manager associated with the scene
  95041. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  95042. */
  95043. actionManager: AbstractActionManager;
  95044. private _meshesForIntersections;
  95045. /**
  95046. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  95047. */
  95048. proceduralTexturesEnabled: boolean;
  95049. private _engine;
  95050. private _totalVertices;
  95051. /** @hidden */
  95052. _activeIndices: PerfCounter;
  95053. /** @hidden */
  95054. _activeParticles: PerfCounter;
  95055. /** @hidden */
  95056. _activeBones: PerfCounter;
  95057. private _animationRatio;
  95058. /** @hidden */
  95059. _animationTimeLast: number;
  95060. /** @hidden */
  95061. _animationTime: number;
  95062. /**
  95063. * Gets or sets a general scale for animation speed
  95064. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  95065. */
  95066. animationTimeScale: number;
  95067. /** @hidden */
  95068. _cachedMaterial: Nullable<Material>;
  95069. /** @hidden */
  95070. _cachedEffect: Nullable<Effect>;
  95071. /** @hidden */
  95072. _cachedVisibility: Nullable<number>;
  95073. private _renderId;
  95074. private _frameId;
  95075. private _executeWhenReadyTimeoutId;
  95076. private _intermediateRendering;
  95077. private _viewUpdateFlag;
  95078. private _projectionUpdateFlag;
  95079. /** @hidden */
  95080. _toBeDisposed: Nullable<IDisposable>[];
  95081. private _activeRequests;
  95082. /** @hidden */
  95083. _pendingData: any[];
  95084. private _isDisposed;
  95085. /**
  95086. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  95087. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  95088. */
  95089. dispatchAllSubMeshesOfActiveMeshes: boolean;
  95090. private _activeMeshes;
  95091. private _processedMaterials;
  95092. private _renderTargets;
  95093. /** @hidden */
  95094. _activeParticleSystems: SmartArray<IParticleSystem>;
  95095. private _activeSkeletons;
  95096. private _softwareSkinnedMeshes;
  95097. private _renderingManager;
  95098. /** @hidden */
  95099. _activeAnimatables: Animatable[];
  95100. private _transformMatrix;
  95101. private _sceneUbo;
  95102. /** @hidden */
  95103. _viewMatrix: Matrix;
  95104. private _projectionMatrix;
  95105. /** @hidden */
  95106. _forcedViewPosition: Nullable<Vector3>;
  95107. /** @hidden */
  95108. _frustumPlanes: Plane[];
  95109. /**
  95110. * Gets the list of frustum planes (built from the active camera)
  95111. */
  95112. readonly frustumPlanes: Plane[];
  95113. /**
  95114. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  95115. * This is useful if there are more lights that the maximum simulteanous authorized
  95116. */
  95117. requireLightSorting: boolean;
  95118. /** @hidden */
  95119. readonly useMaterialMeshMap: boolean;
  95120. /** @hidden */
  95121. readonly useClonedMeshhMap: boolean;
  95122. private _externalData;
  95123. private _uid;
  95124. /**
  95125. * @hidden
  95126. * Backing store of defined scene components.
  95127. */
  95128. _components: ISceneComponent[];
  95129. /**
  95130. * @hidden
  95131. * Backing store of defined scene components.
  95132. */
  95133. _serializableComponents: ISceneSerializableComponent[];
  95134. /**
  95135. * List of components to register on the next registration step.
  95136. */
  95137. private _transientComponents;
  95138. /**
  95139. * Registers the transient components if needed.
  95140. */
  95141. private _registerTransientComponents;
  95142. /**
  95143. * @hidden
  95144. * Add a component to the scene.
  95145. * Note that the ccomponent could be registered on th next frame if this is called after
  95146. * the register component stage.
  95147. * @param component Defines the component to add to the scene
  95148. */
  95149. _addComponent(component: ISceneComponent): void;
  95150. /**
  95151. * @hidden
  95152. * Gets a component from the scene.
  95153. * @param name defines the name of the component to retrieve
  95154. * @returns the component or null if not present
  95155. */
  95156. _getComponent(name: string): Nullable<ISceneComponent>;
  95157. /**
  95158. * @hidden
  95159. * Defines the actions happening before camera updates.
  95160. */
  95161. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  95162. /**
  95163. * @hidden
  95164. * Defines the actions happening before clear the canvas.
  95165. */
  95166. _beforeClearStage: Stage<SimpleStageAction>;
  95167. /**
  95168. * @hidden
  95169. * Defines the actions when collecting render targets for the frame.
  95170. */
  95171. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  95172. /**
  95173. * @hidden
  95174. * Defines the actions happening for one camera in the frame.
  95175. */
  95176. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  95177. /**
  95178. * @hidden
  95179. * Defines the actions happening during the per mesh ready checks.
  95180. */
  95181. _isReadyForMeshStage: Stage<MeshStageAction>;
  95182. /**
  95183. * @hidden
  95184. * Defines the actions happening before evaluate active mesh checks.
  95185. */
  95186. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  95187. /**
  95188. * @hidden
  95189. * Defines the actions happening during the evaluate sub mesh checks.
  95190. */
  95191. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  95192. /**
  95193. * @hidden
  95194. * Defines the actions happening during the active mesh stage.
  95195. */
  95196. _activeMeshStage: Stage<ActiveMeshStageAction>;
  95197. /**
  95198. * @hidden
  95199. * Defines the actions happening during the per camera render target step.
  95200. */
  95201. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  95202. /**
  95203. * @hidden
  95204. * Defines the actions happening just before the active camera is drawing.
  95205. */
  95206. _beforeCameraDrawStage: Stage<CameraStageAction>;
  95207. /**
  95208. * @hidden
  95209. * Defines the actions happening just before a render target is drawing.
  95210. */
  95211. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  95212. /**
  95213. * @hidden
  95214. * Defines the actions happening just before a rendering group is drawing.
  95215. */
  95216. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  95217. /**
  95218. * @hidden
  95219. * Defines the actions happening just before a mesh is drawing.
  95220. */
  95221. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  95222. /**
  95223. * @hidden
  95224. * Defines the actions happening just after a mesh has been drawn.
  95225. */
  95226. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  95227. /**
  95228. * @hidden
  95229. * Defines the actions happening just after a rendering group has been drawn.
  95230. */
  95231. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  95232. /**
  95233. * @hidden
  95234. * Defines the actions happening just after the active camera has been drawn.
  95235. */
  95236. _afterCameraDrawStage: Stage<CameraStageAction>;
  95237. /**
  95238. * @hidden
  95239. * Defines the actions happening just after a render target has been drawn.
  95240. */
  95241. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  95242. /**
  95243. * @hidden
  95244. * Defines the actions happening just after rendering all cameras and computing intersections.
  95245. */
  95246. _afterRenderStage: Stage<SimpleStageAction>;
  95247. /**
  95248. * @hidden
  95249. * Defines the actions happening when a pointer move event happens.
  95250. */
  95251. _pointerMoveStage: Stage<PointerMoveStageAction>;
  95252. /**
  95253. * @hidden
  95254. * Defines the actions happening when a pointer down event happens.
  95255. */
  95256. _pointerDownStage: Stage<PointerUpDownStageAction>;
  95257. /**
  95258. * @hidden
  95259. * Defines the actions happening when a pointer up event happens.
  95260. */
  95261. _pointerUpStage: Stage<PointerUpDownStageAction>;
  95262. /**
  95263. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  95264. */
  95265. private geometriesByUniqueId;
  95266. /**
  95267. * Creates a new Scene
  95268. * @param engine defines the engine to use to render this scene
  95269. * @param options defines the scene options
  95270. */
  95271. constructor(engine: Engine, options?: SceneOptions);
  95272. /**
  95273. * Gets a string idenfifying the name of the class
  95274. * @returns "Scene" string
  95275. */
  95276. getClassName(): string;
  95277. private _defaultMeshCandidates;
  95278. /**
  95279. * @hidden
  95280. */
  95281. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  95282. private _defaultSubMeshCandidates;
  95283. /**
  95284. * @hidden
  95285. */
  95286. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  95287. /**
  95288. * Sets the default candidate providers for the scene.
  95289. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  95290. * and getCollidingSubMeshCandidates to their default function
  95291. */
  95292. setDefaultCandidateProviders(): void;
  95293. /**
  95294. * Gets the mesh that is currently under the pointer
  95295. */
  95296. readonly meshUnderPointer: Nullable<AbstractMesh>;
  95297. /**
  95298. * Gets or sets the current on-screen X position of the pointer
  95299. */
  95300. pointerX: number;
  95301. /**
  95302. * Gets or sets the current on-screen Y position of the pointer
  95303. */
  95304. pointerY: number;
  95305. /**
  95306. * Gets the cached material (ie. the latest rendered one)
  95307. * @returns the cached material
  95308. */
  95309. getCachedMaterial(): Nullable<Material>;
  95310. /**
  95311. * Gets the cached effect (ie. the latest rendered one)
  95312. * @returns the cached effect
  95313. */
  95314. getCachedEffect(): Nullable<Effect>;
  95315. /**
  95316. * Gets the cached visibility state (ie. the latest rendered one)
  95317. * @returns the cached visibility state
  95318. */
  95319. getCachedVisibility(): Nullable<number>;
  95320. /**
  95321. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  95322. * @param material defines the current material
  95323. * @param effect defines the current effect
  95324. * @param visibility defines the current visibility state
  95325. * @returns true if one parameter is not cached
  95326. */
  95327. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  95328. /**
  95329. * Gets the engine associated with the scene
  95330. * @returns an Engine
  95331. */
  95332. getEngine(): Engine;
  95333. /**
  95334. * Gets the total number of vertices rendered per frame
  95335. * @returns the total number of vertices rendered per frame
  95336. */
  95337. getTotalVertices(): number;
  95338. /**
  95339. * Gets the performance counter for total vertices
  95340. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95341. */
  95342. readonly totalVerticesPerfCounter: PerfCounter;
  95343. /**
  95344. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  95345. * @returns the total number of active indices rendered per frame
  95346. */
  95347. getActiveIndices(): number;
  95348. /**
  95349. * Gets the performance counter for active indices
  95350. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95351. */
  95352. readonly totalActiveIndicesPerfCounter: PerfCounter;
  95353. /**
  95354. * Gets the total number of active particles rendered per frame
  95355. * @returns the total number of active particles rendered per frame
  95356. */
  95357. getActiveParticles(): number;
  95358. /**
  95359. * Gets the performance counter for active particles
  95360. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95361. */
  95362. readonly activeParticlesPerfCounter: PerfCounter;
  95363. /**
  95364. * Gets the total number of active bones rendered per frame
  95365. * @returns the total number of active bones rendered per frame
  95366. */
  95367. getActiveBones(): number;
  95368. /**
  95369. * Gets the performance counter for active bones
  95370. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95371. */
  95372. readonly activeBonesPerfCounter: PerfCounter;
  95373. /**
  95374. * Gets the array of active meshes
  95375. * @returns an array of AbstractMesh
  95376. */
  95377. getActiveMeshes(): SmartArray<AbstractMesh>;
  95378. /**
  95379. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  95380. * @returns a number
  95381. */
  95382. getAnimationRatio(): number;
  95383. /**
  95384. * Gets an unique Id for the current render phase
  95385. * @returns a number
  95386. */
  95387. getRenderId(): number;
  95388. /**
  95389. * Gets an unique Id for the current frame
  95390. * @returns a number
  95391. */
  95392. getFrameId(): number;
  95393. /** Call this function if you want to manually increment the render Id*/
  95394. incrementRenderId(): void;
  95395. private _createUbo;
  95396. /**
  95397. * Use this method to simulate a pointer move on a mesh
  95398. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95399. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95400. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95401. * @returns the current scene
  95402. */
  95403. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  95404. /**
  95405. * Use this method to simulate a pointer down on a mesh
  95406. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95407. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95408. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95409. * @returns the current scene
  95410. */
  95411. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  95412. /**
  95413. * Use this method to simulate a pointer up on a mesh
  95414. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95415. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95416. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95417. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  95418. * @returns the current scene
  95419. */
  95420. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  95421. /**
  95422. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  95423. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  95424. * @returns true if the pointer was captured
  95425. */
  95426. isPointerCaptured(pointerId?: number): boolean;
  95427. /**
  95428. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  95429. * @param attachUp defines if you want to attach events to pointerup
  95430. * @param attachDown defines if you want to attach events to pointerdown
  95431. * @param attachMove defines if you want to attach events to pointermove
  95432. */
  95433. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  95434. /** Detaches all event handlers*/
  95435. detachControl(): void;
  95436. /**
  95437. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  95438. * Delay loaded resources are not taking in account
  95439. * @return true if all required resources are ready
  95440. */
  95441. isReady(): boolean;
  95442. /** Resets all cached information relative to material (including effect and visibility) */
  95443. resetCachedMaterial(): void;
  95444. /**
  95445. * Registers a function to be called before every frame render
  95446. * @param func defines the function to register
  95447. */
  95448. registerBeforeRender(func: () => void): void;
  95449. /**
  95450. * Unregisters a function called before every frame render
  95451. * @param func defines the function to unregister
  95452. */
  95453. unregisterBeforeRender(func: () => void): void;
  95454. /**
  95455. * Registers a function to be called after every frame render
  95456. * @param func defines the function to register
  95457. */
  95458. registerAfterRender(func: () => void): void;
  95459. /**
  95460. * Unregisters a function called after every frame render
  95461. * @param func defines the function to unregister
  95462. */
  95463. unregisterAfterRender(func: () => void): void;
  95464. private _executeOnceBeforeRender;
  95465. /**
  95466. * The provided function will run before render once and will be disposed afterwards.
  95467. * A timeout delay can be provided so that the function will be executed in N ms.
  95468. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  95469. * @param func The function to be executed.
  95470. * @param timeout optional delay in ms
  95471. */
  95472. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  95473. /** @hidden */
  95474. _addPendingData(data: any): void;
  95475. /** @hidden */
  95476. _removePendingData(data: any): void;
  95477. /**
  95478. * Returns the number of items waiting to be loaded
  95479. * @returns the number of items waiting to be loaded
  95480. */
  95481. getWaitingItemsCount(): number;
  95482. /**
  95483. * Returns a boolean indicating if the scene is still loading data
  95484. */
  95485. readonly isLoading: boolean;
  95486. /**
  95487. * Registers a function to be executed when the scene is ready
  95488. * @param {Function} func - the function to be executed
  95489. */
  95490. executeWhenReady(func: () => void): void;
  95491. /**
  95492. * Returns a promise that resolves when the scene is ready
  95493. * @returns A promise that resolves when the scene is ready
  95494. */
  95495. whenReadyAsync(): Promise<void>;
  95496. /** @hidden */
  95497. _checkIsReady(): void;
  95498. /**
  95499. * Gets all animatable attached to the scene
  95500. */
  95501. readonly animatables: Animatable[];
  95502. /**
  95503. * Resets the last animation time frame.
  95504. * Useful to override when animations start running when loading a scene for the first time.
  95505. */
  95506. resetLastAnimationTimeFrame(): void;
  95507. /**
  95508. * Gets the current view matrix
  95509. * @returns a Matrix
  95510. */
  95511. getViewMatrix(): Matrix;
  95512. /**
  95513. * Gets the current projection matrix
  95514. * @returns a Matrix
  95515. */
  95516. getProjectionMatrix(): Matrix;
  95517. /**
  95518. * Gets the current transform matrix
  95519. * @returns a Matrix made of View * Projection
  95520. */
  95521. getTransformMatrix(): Matrix;
  95522. /**
  95523. * Sets the current transform matrix
  95524. * @param viewL defines the View matrix to use
  95525. * @param projectionL defines the Projection matrix to use
  95526. * @param viewR defines the right View matrix to use (if provided)
  95527. * @param projectionR defines the right Projection matrix to use (if provided)
  95528. */
  95529. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  95530. /**
  95531. * Gets the uniform buffer used to store scene data
  95532. * @returns a UniformBuffer
  95533. */
  95534. getSceneUniformBuffer(): UniformBuffer;
  95535. /**
  95536. * Gets an unique (relatively to the current scene) Id
  95537. * @returns an unique number for the scene
  95538. */
  95539. getUniqueId(): number;
  95540. /**
  95541. * Add a mesh to the list of scene's meshes
  95542. * @param newMesh defines the mesh to add
  95543. * @param recursive if all child meshes should also be added to the scene
  95544. */
  95545. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  95546. /**
  95547. * Remove a mesh for the list of scene's meshes
  95548. * @param toRemove defines the mesh to remove
  95549. * @param recursive if all child meshes should also be removed from the scene
  95550. * @returns the index where the mesh was in the mesh list
  95551. */
  95552. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  95553. /**
  95554. * Add a transform node to the list of scene's transform nodes
  95555. * @param newTransformNode defines the transform node to add
  95556. */
  95557. addTransformNode(newTransformNode: TransformNode): void;
  95558. /**
  95559. * Remove a transform node for the list of scene's transform nodes
  95560. * @param toRemove defines the transform node to remove
  95561. * @returns the index where the transform node was in the transform node list
  95562. */
  95563. removeTransformNode(toRemove: TransformNode): number;
  95564. /**
  95565. * Remove a skeleton for the list of scene's skeletons
  95566. * @param toRemove defines the skeleton to remove
  95567. * @returns the index where the skeleton was in the skeleton list
  95568. */
  95569. removeSkeleton(toRemove: Skeleton): number;
  95570. /**
  95571. * Remove a morph target for the list of scene's morph targets
  95572. * @param toRemove defines the morph target to remove
  95573. * @returns the index where the morph target was in the morph target list
  95574. */
  95575. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  95576. /**
  95577. * Remove a light for the list of scene's lights
  95578. * @param toRemove defines the light to remove
  95579. * @returns the index where the light was in the light list
  95580. */
  95581. removeLight(toRemove: Light): number;
  95582. /**
  95583. * Remove a camera for the list of scene's cameras
  95584. * @param toRemove defines the camera to remove
  95585. * @returns the index where the camera was in the camera list
  95586. */
  95587. removeCamera(toRemove: Camera): number;
  95588. /**
  95589. * Remove a particle system for the list of scene's particle systems
  95590. * @param toRemove defines the particle system to remove
  95591. * @returns the index where the particle system was in the particle system list
  95592. */
  95593. removeParticleSystem(toRemove: IParticleSystem): number;
  95594. /**
  95595. * Remove a animation for the list of scene's animations
  95596. * @param toRemove defines the animation to remove
  95597. * @returns the index where the animation was in the animation list
  95598. */
  95599. removeAnimation(toRemove: Animation): number;
  95600. /**
  95601. * Will stop the animation of the given target
  95602. * @param target - the target
  95603. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  95604. * @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)
  95605. */
  95606. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  95607. /**
  95608. * Removes the given animation group from this scene.
  95609. * @param toRemove The animation group to remove
  95610. * @returns The index of the removed animation group
  95611. */
  95612. removeAnimationGroup(toRemove: AnimationGroup): number;
  95613. /**
  95614. * Removes the given multi-material from this scene.
  95615. * @param toRemove The multi-material to remove
  95616. * @returns The index of the removed multi-material
  95617. */
  95618. removeMultiMaterial(toRemove: MultiMaterial): number;
  95619. /**
  95620. * Removes the given material from this scene.
  95621. * @param toRemove The material to remove
  95622. * @returns The index of the removed material
  95623. */
  95624. removeMaterial(toRemove: Material): number;
  95625. /**
  95626. * Removes the given action manager from this scene.
  95627. * @param toRemove The action manager to remove
  95628. * @returns The index of the removed action manager
  95629. */
  95630. removeActionManager(toRemove: AbstractActionManager): number;
  95631. /**
  95632. * Removes the given texture from this scene.
  95633. * @param toRemove The texture to remove
  95634. * @returns The index of the removed texture
  95635. */
  95636. removeTexture(toRemove: BaseTexture): number;
  95637. /**
  95638. * Adds the given light to this scene
  95639. * @param newLight The light to add
  95640. */
  95641. addLight(newLight: Light): void;
  95642. /**
  95643. * Sorts the list list based on light priorities
  95644. */
  95645. sortLightsByPriority(): void;
  95646. /**
  95647. * Adds the given camera to this scene
  95648. * @param newCamera The camera to add
  95649. */
  95650. addCamera(newCamera: Camera): void;
  95651. /**
  95652. * Adds the given skeleton to this scene
  95653. * @param newSkeleton The skeleton to add
  95654. */
  95655. addSkeleton(newSkeleton: Skeleton): void;
  95656. /**
  95657. * Adds the given particle system to this scene
  95658. * @param newParticleSystem The particle system to add
  95659. */
  95660. addParticleSystem(newParticleSystem: IParticleSystem): void;
  95661. /**
  95662. * Adds the given animation to this scene
  95663. * @param newAnimation The animation to add
  95664. */
  95665. addAnimation(newAnimation: Animation): void;
  95666. /**
  95667. * Adds the given animation group to this scene.
  95668. * @param newAnimationGroup The animation group to add
  95669. */
  95670. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  95671. /**
  95672. * Adds the given multi-material to this scene
  95673. * @param newMultiMaterial The multi-material to add
  95674. */
  95675. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  95676. /**
  95677. * Adds the given material to this scene
  95678. * @param newMaterial The material to add
  95679. */
  95680. addMaterial(newMaterial: Material): void;
  95681. /**
  95682. * Adds the given morph target to this scene
  95683. * @param newMorphTargetManager The morph target to add
  95684. */
  95685. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  95686. /**
  95687. * Adds the given geometry to this scene
  95688. * @param newGeometry The geometry to add
  95689. */
  95690. addGeometry(newGeometry: Geometry): void;
  95691. /**
  95692. * Adds the given action manager to this scene
  95693. * @param newActionManager The action manager to add
  95694. */
  95695. addActionManager(newActionManager: AbstractActionManager): void;
  95696. /**
  95697. * Adds the given texture to this scene.
  95698. * @param newTexture The texture to add
  95699. */
  95700. addTexture(newTexture: BaseTexture): void;
  95701. /**
  95702. * Switch active camera
  95703. * @param newCamera defines the new active camera
  95704. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  95705. */
  95706. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  95707. /**
  95708. * sets the active camera of the scene using its ID
  95709. * @param id defines the camera's ID
  95710. * @return the new active camera or null if none found.
  95711. */
  95712. setActiveCameraByID(id: string): Nullable<Camera>;
  95713. /**
  95714. * sets the active camera of the scene using its name
  95715. * @param name defines the camera's name
  95716. * @returns the new active camera or null if none found.
  95717. */
  95718. setActiveCameraByName(name: string): Nullable<Camera>;
  95719. /**
  95720. * get an animation group using its name
  95721. * @param name defines the material's name
  95722. * @return the animation group or null if none found.
  95723. */
  95724. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  95725. /**
  95726. * Get a material using its unique id
  95727. * @param uniqueId defines the material's unique id
  95728. * @return the material or null if none found.
  95729. */
  95730. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  95731. /**
  95732. * get a material using its id
  95733. * @param id defines the material's ID
  95734. * @return the material or null if none found.
  95735. */
  95736. getMaterialByID(id: string): Nullable<Material>;
  95737. /**
  95738. * Gets a material using its name
  95739. * @param name defines the material's name
  95740. * @return the material or null if none found.
  95741. */
  95742. getMaterialByName(name: string): Nullable<Material>;
  95743. /**
  95744. * Gets a camera using its id
  95745. * @param id defines the id to look for
  95746. * @returns the camera or null if not found
  95747. */
  95748. getCameraByID(id: string): Nullable<Camera>;
  95749. /**
  95750. * Gets a camera using its unique id
  95751. * @param uniqueId defines the unique id to look for
  95752. * @returns the camera or null if not found
  95753. */
  95754. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  95755. /**
  95756. * Gets a camera using its name
  95757. * @param name defines the camera's name
  95758. * @return the camera or null if none found.
  95759. */
  95760. getCameraByName(name: string): Nullable<Camera>;
  95761. /**
  95762. * Gets a bone using its id
  95763. * @param id defines the bone's id
  95764. * @return the bone or null if not found
  95765. */
  95766. getBoneByID(id: string): Nullable<Bone>;
  95767. /**
  95768. * Gets a bone using its id
  95769. * @param name defines the bone's name
  95770. * @return the bone or null if not found
  95771. */
  95772. getBoneByName(name: string): Nullable<Bone>;
  95773. /**
  95774. * Gets a light node using its name
  95775. * @param name defines the the light's name
  95776. * @return the light or null if none found.
  95777. */
  95778. getLightByName(name: string): Nullable<Light>;
  95779. /**
  95780. * Gets a light node using its id
  95781. * @param id defines the light's id
  95782. * @return the light or null if none found.
  95783. */
  95784. getLightByID(id: string): Nullable<Light>;
  95785. /**
  95786. * Gets a light node using its scene-generated unique ID
  95787. * @param uniqueId defines the light's unique id
  95788. * @return the light or null if none found.
  95789. */
  95790. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  95791. /**
  95792. * Gets a particle system by id
  95793. * @param id defines the particle system id
  95794. * @return the corresponding system or null if none found
  95795. */
  95796. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  95797. /**
  95798. * Gets a geometry using its ID
  95799. * @param id defines the geometry's id
  95800. * @return the geometry or null if none found.
  95801. */
  95802. getGeometryByID(id: string): Nullable<Geometry>;
  95803. private _getGeometryByUniqueID;
  95804. /**
  95805. * Add a new geometry to this scene
  95806. * @param geometry defines the geometry to be added to the scene.
  95807. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  95808. * @return a boolean defining if the geometry was added or not
  95809. */
  95810. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  95811. /**
  95812. * Removes an existing geometry
  95813. * @param geometry defines the geometry to be removed from the scene
  95814. * @return a boolean defining if the geometry was removed or not
  95815. */
  95816. removeGeometry(geometry: Geometry): boolean;
  95817. /**
  95818. * Gets the list of geometries attached to the scene
  95819. * @returns an array of Geometry
  95820. */
  95821. getGeometries(): Geometry[];
  95822. /**
  95823. * Gets the first added mesh found of a given ID
  95824. * @param id defines the id to search for
  95825. * @return the mesh found or null if not found at all
  95826. */
  95827. getMeshByID(id: string): Nullable<AbstractMesh>;
  95828. /**
  95829. * Gets a list of meshes using their id
  95830. * @param id defines the id to search for
  95831. * @returns a list of meshes
  95832. */
  95833. getMeshesByID(id: string): Array<AbstractMesh>;
  95834. /**
  95835. * Gets the first added transform node found of a given ID
  95836. * @param id defines the id to search for
  95837. * @return the found transform node or null if not found at all.
  95838. */
  95839. getTransformNodeByID(id: string): Nullable<TransformNode>;
  95840. /**
  95841. * Gets a transform node with its auto-generated unique id
  95842. * @param uniqueId efines the unique id to search for
  95843. * @return the found transform node or null if not found at all.
  95844. */
  95845. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  95846. /**
  95847. * Gets a list of transform nodes using their id
  95848. * @param id defines the id to search for
  95849. * @returns a list of transform nodes
  95850. */
  95851. getTransformNodesByID(id: string): Array<TransformNode>;
  95852. /**
  95853. * Gets a mesh with its auto-generated unique id
  95854. * @param uniqueId defines the unique id to search for
  95855. * @return the found mesh or null if not found at all.
  95856. */
  95857. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  95858. /**
  95859. * Gets a the last added mesh using a given id
  95860. * @param id defines the id to search for
  95861. * @return the found mesh or null if not found at all.
  95862. */
  95863. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  95864. /**
  95865. * Gets a the last added node (Mesh, Camera, Light) using a given id
  95866. * @param id defines the id to search for
  95867. * @return the found node or null if not found at all
  95868. */
  95869. getLastEntryByID(id: string): Nullable<Node>;
  95870. /**
  95871. * Gets a node (Mesh, Camera, Light) using a given id
  95872. * @param id defines the id to search for
  95873. * @return the found node or null if not found at all
  95874. */
  95875. getNodeByID(id: string): Nullable<Node>;
  95876. /**
  95877. * Gets a node (Mesh, Camera, Light) using a given name
  95878. * @param name defines the name to search for
  95879. * @return the found node or null if not found at all.
  95880. */
  95881. getNodeByName(name: string): Nullable<Node>;
  95882. /**
  95883. * Gets a mesh using a given name
  95884. * @param name defines the name to search for
  95885. * @return the found mesh or null if not found at all.
  95886. */
  95887. getMeshByName(name: string): Nullable<AbstractMesh>;
  95888. /**
  95889. * Gets a transform node using a given name
  95890. * @param name defines the name to search for
  95891. * @return the found transform node or null if not found at all.
  95892. */
  95893. getTransformNodeByName(name: string): Nullable<TransformNode>;
  95894. /**
  95895. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  95896. * @param id defines the id to search for
  95897. * @return the found skeleton or null if not found at all.
  95898. */
  95899. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  95900. /**
  95901. * Gets a skeleton using a given auto generated unique id
  95902. * @param uniqueId defines the unique id to search for
  95903. * @return the found skeleton or null if not found at all.
  95904. */
  95905. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  95906. /**
  95907. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  95908. * @param id defines the id to search for
  95909. * @return the found skeleton or null if not found at all.
  95910. */
  95911. getSkeletonById(id: string): Nullable<Skeleton>;
  95912. /**
  95913. * Gets a skeleton using a given name
  95914. * @param name defines the name to search for
  95915. * @return the found skeleton or null if not found at all.
  95916. */
  95917. getSkeletonByName(name: string): Nullable<Skeleton>;
  95918. /**
  95919. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  95920. * @param id defines the id to search for
  95921. * @return the found morph target manager or null if not found at all.
  95922. */
  95923. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  95924. /**
  95925. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  95926. * @param id defines the id to search for
  95927. * @return the found morph target or null if not found at all.
  95928. */
  95929. getMorphTargetById(id: string): Nullable<MorphTarget>;
  95930. /**
  95931. * Gets a boolean indicating if the given mesh is active
  95932. * @param mesh defines the mesh to look for
  95933. * @returns true if the mesh is in the active list
  95934. */
  95935. isActiveMesh(mesh: AbstractMesh): boolean;
  95936. /**
  95937. * Return a unique id as a string which can serve as an identifier for the scene
  95938. */
  95939. readonly uid: string;
  95940. /**
  95941. * Add an externaly attached data from its key.
  95942. * This method call will fail and return false, if such key already exists.
  95943. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  95944. * @param key the unique key that identifies the data
  95945. * @param data the data object to associate to the key for this Engine instance
  95946. * @return true if no such key were already present and the data was added successfully, false otherwise
  95947. */
  95948. addExternalData<T>(key: string, data: T): boolean;
  95949. /**
  95950. * Get an externaly attached data from its key
  95951. * @param key the unique key that identifies the data
  95952. * @return the associated data, if present (can be null), or undefined if not present
  95953. */
  95954. getExternalData<T>(key: string): Nullable<T>;
  95955. /**
  95956. * Get an externaly attached data from its key, create it using a factory if it's not already present
  95957. * @param key the unique key that identifies the data
  95958. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  95959. * @return the associated data, can be null if the factory returned null.
  95960. */
  95961. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  95962. /**
  95963. * Remove an externaly attached data from the Engine instance
  95964. * @param key the unique key that identifies the data
  95965. * @return true if the data was successfully removed, false if it doesn't exist
  95966. */
  95967. removeExternalData(key: string): boolean;
  95968. private _evaluateSubMesh;
  95969. /**
  95970. * Clear the processed materials smart array preventing retention point in material dispose.
  95971. */
  95972. freeProcessedMaterials(): void;
  95973. private _preventFreeActiveMeshesAndRenderingGroups;
  95974. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  95975. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  95976. * when disposing several meshes in a row or a hierarchy of meshes.
  95977. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  95978. */
  95979. blockfreeActiveMeshesAndRenderingGroups: boolean;
  95980. /**
  95981. * Clear the active meshes smart array preventing retention point in mesh dispose.
  95982. */
  95983. freeActiveMeshes(): void;
  95984. /**
  95985. * Clear the info related to rendering groups preventing retention points during dispose.
  95986. */
  95987. freeRenderingGroups(): void;
  95988. /** @hidden */
  95989. _isInIntermediateRendering(): boolean;
  95990. /**
  95991. * Lambda returning the list of potentially active meshes.
  95992. */
  95993. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  95994. /**
  95995. * Lambda returning the list of potentially active sub meshes.
  95996. */
  95997. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  95998. /**
  95999. * Lambda returning the list of potentially intersecting sub meshes.
  96000. */
  96001. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  96002. /**
  96003. * Lambda returning the list of potentially colliding sub meshes.
  96004. */
  96005. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  96006. private _activeMeshesFrozen;
  96007. /**
  96008. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  96009. * @returns the current scene
  96010. */
  96011. freezeActiveMeshes(): Scene;
  96012. /**
  96013. * Use this function to restart evaluating active meshes on every frame
  96014. * @returns the current scene
  96015. */
  96016. unfreezeActiveMeshes(): Scene;
  96017. private _evaluateActiveMeshes;
  96018. private _activeMesh;
  96019. /**
  96020. * Update the transform matrix to update from the current active camera
  96021. * @param force defines a boolean used to force the update even if cache is up to date
  96022. */
  96023. updateTransformMatrix(force?: boolean): void;
  96024. private _bindFrameBuffer;
  96025. /** @hidden */
  96026. _allowPostProcessClearColor: boolean;
  96027. /** @hidden */
  96028. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  96029. private _processSubCameras;
  96030. private _checkIntersections;
  96031. /** @hidden */
  96032. _advancePhysicsEngineStep(step: number): void;
  96033. /**
  96034. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  96035. */
  96036. getDeterministicFrameTime: () => number;
  96037. /** @hidden */
  96038. _animate(): void;
  96039. /** Execute all animations (for a frame) */
  96040. animate(): void;
  96041. /**
  96042. * Render the scene
  96043. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  96044. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  96045. */
  96046. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  96047. /**
  96048. * Freeze all materials
  96049. * A frozen material will not be updatable but should be faster to render
  96050. */
  96051. freezeMaterials(): void;
  96052. /**
  96053. * Unfreeze all materials
  96054. * A frozen material will not be updatable but should be faster to render
  96055. */
  96056. unfreezeMaterials(): void;
  96057. /**
  96058. * Releases all held ressources
  96059. */
  96060. dispose(): void;
  96061. /**
  96062. * Gets if the scene is already disposed
  96063. */
  96064. readonly isDisposed: boolean;
  96065. /**
  96066. * Call this function to reduce memory footprint of the scene.
  96067. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  96068. */
  96069. clearCachedVertexData(): void;
  96070. /**
  96071. * This function will remove the local cached buffer data from texture.
  96072. * It will save memory but will prevent the texture from being rebuilt
  96073. */
  96074. cleanCachedTextureBuffer(): void;
  96075. /**
  96076. * Get the world extend vectors with an optional filter
  96077. *
  96078. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  96079. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  96080. */
  96081. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  96082. min: Vector3;
  96083. max: Vector3;
  96084. };
  96085. /**
  96086. * Creates a ray that can be used to pick in the scene
  96087. * @param x defines the x coordinate of the origin (on-screen)
  96088. * @param y defines the y coordinate of the origin (on-screen)
  96089. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  96090. * @param camera defines the camera to use for the picking
  96091. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  96092. * @returns a Ray
  96093. */
  96094. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  96095. /**
  96096. * Creates a ray that can be used to pick in the scene
  96097. * @param x defines the x coordinate of the origin (on-screen)
  96098. * @param y defines the y coordinate of the origin (on-screen)
  96099. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  96100. * @param result defines the ray where to store the picking ray
  96101. * @param camera defines the camera to use for the picking
  96102. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  96103. * @returns the current scene
  96104. */
  96105. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  96106. /**
  96107. * Creates a ray that can be used to pick in the scene
  96108. * @param x defines the x coordinate of the origin (on-screen)
  96109. * @param y defines the y coordinate of the origin (on-screen)
  96110. * @param camera defines the camera to use for the picking
  96111. * @returns a Ray
  96112. */
  96113. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  96114. /**
  96115. * Creates a ray that can be used to pick in the scene
  96116. * @param x defines the x coordinate of the origin (on-screen)
  96117. * @param y defines the y coordinate of the origin (on-screen)
  96118. * @param result defines the ray where to store the picking ray
  96119. * @param camera defines the camera to use for the picking
  96120. * @returns the current scene
  96121. */
  96122. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  96123. /** Launch a ray to try to pick a mesh in the scene
  96124. * @param x position on screen
  96125. * @param y position on screen
  96126. * @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
  96127. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  96128. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  96129. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96130. * @returns a PickingInfo
  96131. */
  96132. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  96133. /** Use the given ray to pick a mesh in the scene
  96134. * @param ray The ray to use to pick meshes
  96135. * @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
  96136. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  96137. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96138. * @returns a PickingInfo
  96139. */
  96140. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  96141. /**
  96142. * Launch a ray to try to pick a mesh in the scene
  96143. * @param x X position on screen
  96144. * @param y Y position on screen
  96145. * @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
  96146. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  96147. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96148. * @returns an array of PickingInfo
  96149. */
  96150. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  96151. /**
  96152. * Launch a ray to try to pick a mesh in the scene
  96153. * @param ray Ray to use
  96154. * @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
  96155. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96156. * @returns an array of PickingInfo
  96157. */
  96158. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  96159. /**
  96160. * Force the value of meshUnderPointer
  96161. * @param mesh defines the mesh to use
  96162. */
  96163. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  96164. /**
  96165. * Gets the mesh under the pointer
  96166. * @returns a Mesh or null if no mesh is under the pointer
  96167. */
  96168. getPointerOverMesh(): Nullable<AbstractMesh>;
  96169. /** @hidden */
  96170. _rebuildGeometries(): void;
  96171. /** @hidden */
  96172. _rebuildTextures(): void;
  96173. private _getByTags;
  96174. /**
  96175. * Get a list of meshes by tags
  96176. * @param tagsQuery defines the tags query to use
  96177. * @param forEach defines a predicate used to filter results
  96178. * @returns an array of Mesh
  96179. */
  96180. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  96181. /**
  96182. * Get a list of cameras by tags
  96183. * @param tagsQuery defines the tags query to use
  96184. * @param forEach defines a predicate used to filter results
  96185. * @returns an array of Camera
  96186. */
  96187. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  96188. /**
  96189. * Get a list of lights by tags
  96190. * @param tagsQuery defines the tags query to use
  96191. * @param forEach defines a predicate used to filter results
  96192. * @returns an array of Light
  96193. */
  96194. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  96195. /**
  96196. * Get a list of materials by tags
  96197. * @param tagsQuery defines the tags query to use
  96198. * @param forEach defines a predicate used to filter results
  96199. * @returns an array of Material
  96200. */
  96201. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  96202. /**
  96203. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  96204. * This allowed control for front to back rendering or reversly depending of the special needs.
  96205. *
  96206. * @param renderingGroupId The rendering group id corresponding to its index
  96207. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  96208. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  96209. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  96210. */
  96211. 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;
  96212. /**
  96213. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  96214. *
  96215. * @param renderingGroupId The rendering group id corresponding to its index
  96216. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  96217. * @param depth Automatically clears depth between groups if true and autoClear is true.
  96218. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  96219. */
  96220. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  96221. /**
  96222. * Gets the current auto clear configuration for one rendering group of the rendering
  96223. * manager.
  96224. * @param index the rendering group index to get the information for
  96225. * @returns The auto clear setup for the requested rendering group
  96226. */
  96227. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  96228. private _blockMaterialDirtyMechanism;
  96229. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  96230. blockMaterialDirtyMechanism: boolean;
  96231. /**
  96232. * Will flag all materials as dirty to trigger new shader compilation
  96233. * @param flag defines the flag used to specify which material part must be marked as dirty
  96234. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  96235. */
  96236. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  96237. /** @hidden */
  96238. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  96239. /** @hidden */
  96240. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  96241. }
  96242. }
  96243. declare module BABYLON {
  96244. /**
  96245. * Set of assets to keep when moving a scene into an asset container.
  96246. */
  96247. export class KeepAssets extends AbstractScene {
  96248. }
  96249. /**
  96250. * Container with a set of assets that can be added or removed from a scene.
  96251. */
  96252. export class AssetContainer extends AbstractScene {
  96253. /**
  96254. * The scene the AssetContainer belongs to.
  96255. */
  96256. scene: Scene;
  96257. /**
  96258. * Instantiates an AssetContainer.
  96259. * @param scene The scene the AssetContainer belongs to.
  96260. */
  96261. constructor(scene: Scene);
  96262. /**
  96263. * Adds all the assets from the container to the scene.
  96264. */
  96265. addAllToScene(): void;
  96266. /**
  96267. * Removes all the assets in the container from the scene
  96268. */
  96269. removeAllFromScene(): void;
  96270. /**
  96271. * Disposes all the assets in the container
  96272. */
  96273. dispose(): void;
  96274. private _moveAssets;
  96275. /**
  96276. * Removes all the assets contained in the scene and adds them to the container.
  96277. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  96278. */
  96279. moveAllFromScene(keepAssets?: KeepAssets): void;
  96280. /**
  96281. * 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.
  96282. * @returns the root mesh
  96283. */
  96284. createRootMesh(): Mesh;
  96285. }
  96286. }
  96287. declare module BABYLON {
  96288. /**
  96289. * Defines how the parser contract is defined.
  96290. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  96291. */
  96292. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  96293. /**
  96294. * Defines how the individual parser contract is defined.
  96295. * These parser can parse an individual asset
  96296. */
  96297. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  96298. /**
  96299. * Base class of the scene acting as a container for the different elements composing a scene.
  96300. * This class is dynamically extended by the different components of the scene increasing
  96301. * flexibility and reducing coupling
  96302. */
  96303. export abstract class AbstractScene {
  96304. /**
  96305. * Stores the list of available parsers in the application.
  96306. */
  96307. private static _BabylonFileParsers;
  96308. /**
  96309. * Stores the list of available individual parsers in the application.
  96310. */
  96311. private static _IndividualBabylonFileParsers;
  96312. /**
  96313. * Adds a parser in the list of available ones
  96314. * @param name Defines the name of the parser
  96315. * @param parser Defines the parser to add
  96316. */
  96317. static AddParser(name: string, parser: BabylonFileParser): void;
  96318. /**
  96319. * Gets a general parser from the list of avaialble ones
  96320. * @param name Defines the name of the parser
  96321. * @returns the requested parser or null
  96322. */
  96323. static GetParser(name: string): Nullable<BabylonFileParser>;
  96324. /**
  96325. * Adds n individual parser in the list of available ones
  96326. * @param name Defines the name of the parser
  96327. * @param parser Defines the parser to add
  96328. */
  96329. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  96330. /**
  96331. * Gets an individual parser from the list of avaialble ones
  96332. * @param name Defines the name of the parser
  96333. * @returns the requested parser or null
  96334. */
  96335. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  96336. /**
  96337. * Parser json data and populate both a scene and its associated container object
  96338. * @param jsonData Defines the data to parse
  96339. * @param scene Defines the scene to parse the data for
  96340. * @param container Defines the container attached to the parsing sequence
  96341. * @param rootUrl Defines the root url of the data
  96342. */
  96343. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  96344. /**
  96345. * Gets the list of root nodes (ie. nodes with no parent)
  96346. */
  96347. rootNodes: Node[];
  96348. /** All of the cameras added to this scene
  96349. * @see http://doc.babylonjs.com/babylon101/cameras
  96350. */
  96351. cameras: Camera[];
  96352. /**
  96353. * All of the lights added to this scene
  96354. * @see http://doc.babylonjs.com/babylon101/lights
  96355. */
  96356. lights: Light[];
  96357. /**
  96358. * All of the (abstract) meshes added to this scene
  96359. */
  96360. meshes: AbstractMesh[];
  96361. /**
  96362. * The list of skeletons added to the scene
  96363. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96364. */
  96365. skeletons: Skeleton[];
  96366. /**
  96367. * All of the particle systems added to this scene
  96368. * @see http://doc.babylonjs.com/babylon101/particles
  96369. */
  96370. particleSystems: IParticleSystem[];
  96371. /**
  96372. * Gets a list of Animations associated with the scene
  96373. */
  96374. animations: Animation[];
  96375. /**
  96376. * All of the animation groups added to this scene
  96377. * @see http://doc.babylonjs.com/how_to/group
  96378. */
  96379. animationGroups: AnimationGroup[];
  96380. /**
  96381. * All of the multi-materials added to this scene
  96382. * @see http://doc.babylonjs.com/how_to/multi_materials
  96383. */
  96384. multiMaterials: MultiMaterial[];
  96385. /**
  96386. * All of the materials added to this scene
  96387. * In the context of a Scene, it is not supposed to be modified manually.
  96388. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  96389. * Note also that the order of the Material wihin the array is not significant and might change.
  96390. * @see http://doc.babylonjs.com/babylon101/materials
  96391. */
  96392. materials: Material[];
  96393. /**
  96394. * The list of morph target managers added to the scene
  96395. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  96396. */
  96397. morphTargetManagers: MorphTargetManager[];
  96398. /**
  96399. * The list of geometries used in the scene.
  96400. */
  96401. geometries: Geometry[];
  96402. /**
  96403. * All of the tranform nodes added to this scene
  96404. * In the context of a Scene, it is not supposed to be modified manually.
  96405. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  96406. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  96407. * @see http://doc.babylonjs.com/how_to/transformnode
  96408. */
  96409. transformNodes: TransformNode[];
  96410. /**
  96411. * ActionManagers available on the scene.
  96412. */
  96413. actionManagers: AbstractActionManager[];
  96414. /**
  96415. * Textures to keep.
  96416. */
  96417. textures: BaseTexture[];
  96418. /**
  96419. * Environment texture for the scene
  96420. */
  96421. environmentTexture: Nullable<BaseTexture>;
  96422. }
  96423. }
  96424. declare module BABYLON {
  96425. /**
  96426. * Defines a sound that can be played in the application.
  96427. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  96428. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96429. */
  96430. export class Sound {
  96431. /**
  96432. * The name of the sound in the scene.
  96433. */
  96434. name: string;
  96435. /**
  96436. * Does the sound autoplay once loaded.
  96437. */
  96438. autoplay: boolean;
  96439. /**
  96440. * Does the sound loop after it finishes playing once.
  96441. */
  96442. loop: boolean;
  96443. /**
  96444. * Does the sound use a custom attenuation curve to simulate the falloff
  96445. * happening when the source gets further away from the camera.
  96446. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  96447. */
  96448. useCustomAttenuation: boolean;
  96449. /**
  96450. * The sound track id this sound belongs to.
  96451. */
  96452. soundTrackId: number;
  96453. /**
  96454. * Is this sound currently played.
  96455. */
  96456. isPlaying: boolean;
  96457. /**
  96458. * Is this sound currently paused.
  96459. */
  96460. isPaused: boolean;
  96461. /**
  96462. * Does this sound enables spatial sound.
  96463. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96464. */
  96465. spatialSound: boolean;
  96466. /**
  96467. * Define the reference distance the sound should be heard perfectly.
  96468. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96469. */
  96470. refDistance: number;
  96471. /**
  96472. * Define the roll off factor of spatial sounds.
  96473. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96474. */
  96475. rolloffFactor: number;
  96476. /**
  96477. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  96478. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96479. */
  96480. maxDistance: number;
  96481. /**
  96482. * Define the distance attenuation model the sound will follow.
  96483. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96484. */
  96485. distanceModel: string;
  96486. /**
  96487. * @hidden
  96488. * Back Compat
  96489. **/
  96490. onended: () => any;
  96491. /**
  96492. * Observable event when the current playing sound finishes.
  96493. */
  96494. onEndedObservable: Observable<Sound>;
  96495. private _panningModel;
  96496. private _playbackRate;
  96497. private _streaming;
  96498. private _startTime;
  96499. private _startOffset;
  96500. private _position;
  96501. /** @hidden */
  96502. _positionInEmitterSpace: boolean;
  96503. private _localDirection;
  96504. private _volume;
  96505. private _isReadyToPlay;
  96506. private _isDirectional;
  96507. private _readyToPlayCallback;
  96508. private _audioBuffer;
  96509. private _soundSource;
  96510. private _streamingSource;
  96511. private _soundPanner;
  96512. private _soundGain;
  96513. private _inputAudioNode;
  96514. private _outputAudioNode;
  96515. private _coneInnerAngle;
  96516. private _coneOuterAngle;
  96517. private _coneOuterGain;
  96518. private _scene;
  96519. private _connectedTransformNode;
  96520. private _customAttenuationFunction;
  96521. private _registerFunc;
  96522. private _isOutputConnected;
  96523. private _htmlAudioElement;
  96524. private _urlType;
  96525. /** @hidden */
  96526. static _SceneComponentInitialization: (scene: Scene) => void;
  96527. /**
  96528. * Create a sound and attach it to a scene
  96529. * @param name Name of your sound
  96530. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  96531. * @param scene defines the scene the sound belongs to
  96532. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  96533. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  96534. */
  96535. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  96536. /**
  96537. * Release the sound and its associated resources
  96538. */
  96539. dispose(): void;
  96540. /**
  96541. * Gets if the sounds is ready to be played or not.
  96542. * @returns true if ready, otherwise false
  96543. */
  96544. isReady(): boolean;
  96545. private _soundLoaded;
  96546. /**
  96547. * Sets the data of the sound from an audiobuffer
  96548. * @param audioBuffer The audioBuffer containing the data
  96549. */
  96550. setAudioBuffer(audioBuffer: AudioBuffer): void;
  96551. /**
  96552. * Updates the current sounds options such as maxdistance, loop...
  96553. * @param options A JSON object containing values named as the object properties
  96554. */
  96555. updateOptions(options: any): void;
  96556. private _createSpatialParameters;
  96557. private _updateSpatialParameters;
  96558. /**
  96559. * Switch the panning model to HRTF:
  96560. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  96561. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96562. */
  96563. switchPanningModelToHRTF(): void;
  96564. /**
  96565. * Switch the panning model to Equal Power:
  96566. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  96567. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96568. */
  96569. switchPanningModelToEqualPower(): void;
  96570. private _switchPanningModel;
  96571. /**
  96572. * Connect this sound to a sound track audio node like gain...
  96573. * @param soundTrackAudioNode the sound track audio node to connect to
  96574. */
  96575. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  96576. /**
  96577. * Transform this sound into a directional source
  96578. * @param coneInnerAngle Size of the inner cone in degree
  96579. * @param coneOuterAngle Size of the outer cone in degree
  96580. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  96581. */
  96582. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  96583. /**
  96584. * Gets or sets the inner angle for the directional cone.
  96585. */
  96586. /**
  96587. * Gets or sets the inner angle for the directional cone.
  96588. */
  96589. directionalConeInnerAngle: number;
  96590. /**
  96591. * Gets or sets the outer angle for the directional cone.
  96592. */
  96593. /**
  96594. * Gets or sets the outer angle for the directional cone.
  96595. */
  96596. directionalConeOuterAngle: number;
  96597. /**
  96598. * Sets the position of the emitter if spatial sound is enabled
  96599. * @param newPosition Defines the new posisiton
  96600. */
  96601. setPosition(newPosition: Vector3): void;
  96602. /**
  96603. * Sets the local direction of the emitter if spatial sound is enabled
  96604. * @param newLocalDirection Defines the new local direction
  96605. */
  96606. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  96607. private _updateDirection;
  96608. /** @hidden */
  96609. updateDistanceFromListener(): void;
  96610. /**
  96611. * Sets a new custom attenuation function for the sound.
  96612. * @param callback Defines the function used for the attenuation
  96613. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  96614. */
  96615. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  96616. /**
  96617. * Play the sound
  96618. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  96619. * @param offset (optional) Start the sound setting it at a specific time
  96620. */
  96621. play(time?: number, offset?: number): void;
  96622. private _onended;
  96623. /**
  96624. * Stop the sound
  96625. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  96626. */
  96627. stop(time?: number): void;
  96628. /**
  96629. * Put the sound in pause
  96630. */
  96631. pause(): void;
  96632. /**
  96633. * Sets a dedicated volume for this sounds
  96634. * @param newVolume Define the new volume of the sound
  96635. * @param time Define in how long the sound should be at this value
  96636. */
  96637. setVolume(newVolume: number, time?: number): void;
  96638. /**
  96639. * Set the sound play back rate
  96640. * @param newPlaybackRate Define the playback rate the sound should be played at
  96641. */
  96642. setPlaybackRate(newPlaybackRate: number): void;
  96643. /**
  96644. * Gets the volume of the sound.
  96645. * @returns the volume of the sound
  96646. */
  96647. getVolume(): number;
  96648. /**
  96649. * Attach the sound to a dedicated mesh
  96650. * @param transformNode The transform node to connect the sound with
  96651. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  96652. */
  96653. attachToMesh(transformNode: TransformNode): void;
  96654. /**
  96655. * Detach the sound from the previously attached mesh
  96656. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  96657. */
  96658. detachFromMesh(): void;
  96659. private _onRegisterAfterWorldMatrixUpdate;
  96660. /**
  96661. * Clone the current sound in the scene.
  96662. * @returns the new sound clone
  96663. */
  96664. clone(): Nullable<Sound>;
  96665. /**
  96666. * Gets the current underlying audio buffer containing the data
  96667. * @returns the audio buffer
  96668. */
  96669. getAudioBuffer(): Nullable<AudioBuffer>;
  96670. /**
  96671. * Serializes the Sound in a JSON representation
  96672. * @returns the JSON representation of the sound
  96673. */
  96674. serialize(): any;
  96675. /**
  96676. * Parse a JSON representation of a sound to innstantiate in a given scene
  96677. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  96678. * @param scene Define the scene the new parsed sound should be created in
  96679. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  96680. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  96681. * @returns the newly parsed sound
  96682. */
  96683. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  96684. }
  96685. }
  96686. declare module BABYLON {
  96687. /**
  96688. * This defines an action helpful to play a defined sound on a triggered action.
  96689. */
  96690. export class PlaySoundAction extends Action {
  96691. private _sound;
  96692. /**
  96693. * Instantiate the action
  96694. * @param triggerOptions defines the trigger options
  96695. * @param sound defines the sound to play
  96696. * @param condition defines the trigger related conditions
  96697. */
  96698. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  96699. /** @hidden */
  96700. _prepare(): void;
  96701. /**
  96702. * Execute the action and play the sound.
  96703. */
  96704. execute(): void;
  96705. /**
  96706. * Serializes the actions and its related information.
  96707. * @param parent defines the object to serialize in
  96708. * @returns the serialized object
  96709. */
  96710. serialize(parent: any): any;
  96711. }
  96712. /**
  96713. * This defines an action helpful to stop a defined sound on a triggered action.
  96714. */
  96715. export class StopSoundAction extends Action {
  96716. private _sound;
  96717. /**
  96718. * Instantiate the action
  96719. * @param triggerOptions defines the trigger options
  96720. * @param sound defines the sound to stop
  96721. * @param condition defines the trigger related conditions
  96722. */
  96723. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  96724. /** @hidden */
  96725. _prepare(): void;
  96726. /**
  96727. * Execute the action and stop the sound.
  96728. */
  96729. execute(): void;
  96730. /**
  96731. * Serializes the actions and its related information.
  96732. * @param parent defines the object to serialize in
  96733. * @returns the serialized object
  96734. */
  96735. serialize(parent: any): any;
  96736. }
  96737. }
  96738. declare module BABYLON {
  96739. /**
  96740. * This defines an action responsible to change the value of a property
  96741. * by interpolating between its current value and the newly set one once triggered.
  96742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  96743. */
  96744. export class InterpolateValueAction extends Action {
  96745. /**
  96746. * Defines the path of the property where the value should be interpolated
  96747. */
  96748. propertyPath: string;
  96749. /**
  96750. * Defines the target value at the end of the interpolation.
  96751. */
  96752. value: any;
  96753. /**
  96754. * Defines the time it will take for the property to interpolate to the value.
  96755. */
  96756. duration: number;
  96757. /**
  96758. * Defines if the other scene animations should be stopped when the action has been triggered
  96759. */
  96760. stopOtherAnimations?: boolean;
  96761. /**
  96762. * Defines a callback raised once the interpolation animation has been done.
  96763. */
  96764. onInterpolationDone?: () => void;
  96765. /**
  96766. * Observable triggered once the interpolation animation has been done.
  96767. */
  96768. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  96769. private _target;
  96770. private _effectiveTarget;
  96771. private _property;
  96772. /**
  96773. * Instantiate the action
  96774. * @param triggerOptions defines the trigger options
  96775. * @param target defines the object containing the value to interpolate
  96776. * @param propertyPath defines the path to the property in the target object
  96777. * @param value defines the target value at the end of the interpolation
  96778. * @param duration deines the time it will take for the property to interpolate to the value.
  96779. * @param condition defines the trigger related conditions
  96780. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  96781. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  96782. */
  96783. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  96784. /** @hidden */
  96785. _prepare(): void;
  96786. /**
  96787. * Execute the action starts the value interpolation.
  96788. */
  96789. execute(): void;
  96790. /**
  96791. * Serializes the actions and its related information.
  96792. * @param parent defines the object to serialize in
  96793. * @returns the serialized object
  96794. */
  96795. serialize(parent: any): any;
  96796. }
  96797. }
  96798. declare module BABYLON {
  96799. /**
  96800. * Options allowed during the creation of a sound track.
  96801. */
  96802. export interface ISoundTrackOptions {
  96803. /**
  96804. * The volume the sound track should take during creation
  96805. */
  96806. volume?: number;
  96807. /**
  96808. * Define if the sound track is the main sound track of the scene
  96809. */
  96810. mainTrack?: boolean;
  96811. }
  96812. /**
  96813. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  96814. * It will be also used in a future release to apply effects on a specific track.
  96815. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  96816. */
  96817. export class SoundTrack {
  96818. /**
  96819. * The unique identifier of the sound track in the scene.
  96820. */
  96821. id: number;
  96822. /**
  96823. * The list of sounds included in the sound track.
  96824. */
  96825. soundCollection: Array<Sound>;
  96826. private _outputAudioNode;
  96827. private _scene;
  96828. private _isMainTrack;
  96829. private _connectedAnalyser;
  96830. private _options;
  96831. private _isInitialized;
  96832. /**
  96833. * Creates a new sound track.
  96834. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  96835. * @param scene Define the scene the sound track belongs to
  96836. * @param options
  96837. */
  96838. constructor(scene: Scene, options?: ISoundTrackOptions);
  96839. private _initializeSoundTrackAudioGraph;
  96840. /**
  96841. * Release the sound track and its associated resources
  96842. */
  96843. dispose(): void;
  96844. /**
  96845. * Adds a sound to this sound track
  96846. * @param sound define the cound to add
  96847. * @ignoreNaming
  96848. */
  96849. AddSound(sound: Sound): void;
  96850. /**
  96851. * Removes a sound to this sound track
  96852. * @param sound define the cound to remove
  96853. * @ignoreNaming
  96854. */
  96855. RemoveSound(sound: Sound): void;
  96856. /**
  96857. * Set a global volume for the full sound track.
  96858. * @param newVolume Define the new volume of the sound track
  96859. */
  96860. setVolume(newVolume: number): void;
  96861. /**
  96862. * Switch the panning model to HRTF:
  96863. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  96864. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96865. */
  96866. switchPanningModelToHRTF(): void;
  96867. /**
  96868. * Switch the panning model to Equal Power:
  96869. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  96870. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96871. */
  96872. switchPanningModelToEqualPower(): void;
  96873. /**
  96874. * Connect the sound track to an audio analyser allowing some amazing
  96875. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  96876. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  96877. * @param analyser The analyser to connect to the engine
  96878. */
  96879. connectToAnalyser(analyser: Analyser): void;
  96880. }
  96881. }
  96882. declare module BABYLON {
  96883. interface AbstractScene {
  96884. /**
  96885. * The list of sounds used in the scene.
  96886. */
  96887. sounds: Nullable<Array<Sound>>;
  96888. }
  96889. interface Scene {
  96890. /**
  96891. * @hidden
  96892. * Backing field
  96893. */
  96894. _mainSoundTrack: SoundTrack;
  96895. /**
  96896. * The main sound track played by the scene.
  96897. * It cotains your primary collection of sounds.
  96898. */
  96899. mainSoundTrack: SoundTrack;
  96900. /**
  96901. * The list of sound tracks added to the scene
  96902. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96903. */
  96904. soundTracks: Nullable<Array<SoundTrack>>;
  96905. /**
  96906. * Gets a sound using a given name
  96907. * @param name defines the name to search for
  96908. * @return the found sound or null if not found at all.
  96909. */
  96910. getSoundByName(name: string): Nullable<Sound>;
  96911. /**
  96912. * Gets or sets if audio support is enabled
  96913. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96914. */
  96915. audioEnabled: boolean;
  96916. /**
  96917. * Gets or sets if audio will be output to headphones
  96918. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96919. */
  96920. headphone: boolean;
  96921. }
  96922. /**
  96923. * Defines the sound scene component responsible to manage any sounds
  96924. * in a given scene.
  96925. */
  96926. export class AudioSceneComponent implements ISceneSerializableComponent {
  96927. /**
  96928. * The component name helpfull to identify the component in the list of scene components.
  96929. */
  96930. readonly name: string;
  96931. /**
  96932. * The scene the component belongs to.
  96933. */
  96934. scene: Scene;
  96935. private _audioEnabled;
  96936. /**
  96937. * Gets whether audio is enabled or not.
  96938. * Please use related enable/disable method to switch state.
  96939. */
  96940. readonly audioEnabled: boolean;
  96941. private _headphone;
  96942. /**
  96943. * Gets whether audio is outputing to headphone or not.
  96944. * Please use the according Switch methods to change output.
  96945. */
  96946. readonly headphone: boolean;
  96947. /**
  96948. * Creates a new instance of the component for the given scene
  96949. * @param scene Defines the scene to register the component in
  96950. */
  96951. constructor(scene: Scene);
  96952. /**
  96953. * Registers the component in a given scene
  96954. */
  96955. register(): void;
  96956. /**
  96957. * Rebuilds the elements related to this component in case of
  96958. * context lost for instance.
  96959. */
  96960. rebuild(): void;
  96961. /**
  96962. * Serializes the component data to the specified json object
  96963. * @param serializationObject The object to serialize to
  96964. */
  96965. serialize(serializationObject: any): void;
  96966. /**
  96967. * Adds all the elements from the container to the scene
  96968. * @param container the container holding the elements
  96969. */
  96970. addFromContainer(container: AbstractScene): void;
  96971. /**
  96972. * Removes all the elements in the container from the scene
  96973. * @param container contains the elements to remove
  96974. * @param dispose if the removed element should be disposed (default: false)
  96975. */
  96976. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  96977. /**
  96978. * Disposes the component and the associated ressources.
  96979. */
  96980. dispose(): void;
  96981. /**
  96982. * Disables audio in the associated scene.
  96983. */
  96984. disableAudio(): void;
  96985. /**
  96986. * Enables audio in the associated scene.
  96987. */
  96988. enableAudio(): void;
  96989. /**
  96990. * Switch audio to headphone output.
  96991. */
  96992. switchAudioModeForHeadphones(): void;
  96993. /**
  96994. * Switch audio to normal speakers.
  96995. */
  96996. switchAudioModeForNormalSpeakers(): void;
  96997. private _afterRender;
  96998. }
  96999. }
  97000. declare module BABYLON {
  97001. /**
  97002. * Wraps one or more Sound objects and selects one with random weight for playback.
  97003. */
  97004. export class WeightedSound {
  97005. /** When true a Sound will be selected and played when the current playing Sound completes. */
  97006. loop: boolean;
  97007. private _coneInnerAngle;
  97008. private _coneOuterAngle;
  97009. private _volume;
  97010. /** A Sound is currently playing. */
  97011. isPlaying: boolean;
  97012. /** A Sound is currently paused. */
  97013. isPaused: boolean;
  97014. private _sounds;
  97015. private _weights;
  97016. private _currentIndex?;
  97017. /**
  97018. * Creates a new WeightedSound from the list of sounds given.
  97019. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  97020. * @param sounds Array of Sounds that will be selected from.
  97021. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  97022. */
  97023. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  97024. /**
  97025. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  97026. */
  97027. /**
  97028. * The size of cone in degress for a directional sound in which there will be no attenuation.
  97029. */
  97030. directionalConeInnerAngle: number;
  97031. /**
  97032. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  97033. * Listener angles between innerAngle and outerAngle will falloff linearly.
  97034. */
  97035. /**
  97036. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  97037. * Listener angles between innerAngle and outerAngle will falloff linearly.
  97038. */
  97039. directionalConeOuterAngle: number;
  97040. /**
  97041. * Playback volume.
  97042. */
  97043. /**
  97044. * Playback volume.
  97045. */
  97046. volume: number;
  97047. private _onended;
  97048. /**
  97049. * Suspend playback
  97050. */
  97051. pause(): void;
  97052. /**
  97053. * Stop playback
  97054. */
  97055. stop(): void;
  97056. /**
  97057. * Start playback.
  97058. * @param startOffset Position the clip head at a specific time in seconds.
  97059. */
  97060. play(startOffset?: number): void;
  97061. }
  97062. }
  97063. declare module BABYLON {
  97064. /**
  97065. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  97066. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  97067. */
  97068. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  97069. /**
  97070. * Gets the name of the behavior.
  97071. */
  97072. readonly name: string;
  97073. /**
  97074. * The easing function used by animations
  97075. */
  97076. static EasingFunction: BackEase;
  97077. /**
  97078. * The easing mode used by animations
  97079. */
  97080. static EasingMode: number;
  97081. /**
  97082. * The duration of the animation, in milliseconds
  97083. */
  97084. transitionDuration: number;
  97085. /**
  97086. * Length of the distance animated by the transition when lower radius is reached
  97087. */
  97088. lowerRadiusTransitionRange: number;
  97089. /**
  97090. * Length of the distance animated by the transition when upper radius is reached
  97091. */
  97092. upperRadiusTransitionRange: number;
  97093. private _autoTransitionRange;
  97094. /**
  97095. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  97096. */
  97097. /**
  97098. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  97099. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  97100. */
  97101. autoTransitionRange: boolean;
  97102. private _attachedCamera;
  97103. private _onAfterCheckInputsObserver;
  97104. private _onMeshTargetChangedObserver;
  97105. /**
  97106. * Initializes the behavior.
  97107. */
  97108. init(): void;
  97109. /**
  97110. * Attaches the behavior to its arc rotate camera.
  97111. * @param camera Defines the camera to attach the behavior to
  97112. */
  97113. attach(camera: ArcRotateCamera): void;
  97114. /**
  97115. * Detaches the behavior from its current arc rotate camera.
  97116. */
  97117. detach(): void;
  97118. private _radiusIsAnimating;
  97119. private _radiusBounceTransition;
  97120. private _animatables;
  97121. private _cachedWheelPrecision;
  97122. /**
  97123. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  97124. * @param radiusLimit The limit to check against.
  97125. * @return Bool to indicate if at limit.
  97126. */
  97127. private _isRadiusAtLimit;
  97128. /**
  97129. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  97130. * @param radiusDelta The delta by which to animate to. Can be negative.
  97131. */
  97132. private _applyBoundRadiusAnimation;
  97133. /**
  97134. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  97135. */
  97136. protected _clearAnimationLocks(): void;
  97137. /**
  97138. * Stops and removes all animations that have been applied to the camera
  97139. */
  97140. stopAllAnimations(): void;
  97141. }
  97142. }
  97143. declare module BABYLON {
  97144. /**
  97145. * 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.
  97146. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  97147. */
  97148. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  97149. /**
  97150. * Gets the name of the behavior.
  97151. */
  97152. readonly name: string;
  97153. private _mode;
  97154. private _radiusScale;
  97155. private _positionScale;
  97156. private _defaultElevation;
  97157. private _elevationReturnTime;
  97158. private _elevationReturnWaitTime;
  97159. private _zoomStopsAnimation;
  97160. private _framingTime;
  97161. /**
  97162. * The easing function used by animations
  97163. */
  97164. static EasingFunction: ExponentialEase;
  97165. /**
  97166. * The easing mode used by animations
  97167. */
  97168. static EasingMode: number;
  97169. /**
  97170. * Sets the current mode used by the behavior
  97171. */
  97172. /**
  97173. * Gets current mode used by the behavior.
  97174. */
  97175. mode: number;
  97176. /**
  97177. * Sets the scale applied to the radius (1 by default)
  97178. */
  97179. /**
  97180. * Gets the scale applied to the radius
  97181. */
  97182. radiusScale: number;
  97183. /**
  97184. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  97185. */
  97186. /**
  97187. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  97188. */
  97189. positionScale: number;
  97190. /**
  97191. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  97192. * behaviour is triggered, in radians.
  97193. */
  97194. /**
  97195. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  97196. * behaviour is triggered, in radians.
  97197. */
  97198. defaultElevation: number;
  97199. /**
  97200. * Sets the time (in milliseconds) taken to return to the default beta position.
  97201. * Negative value indicates camera should not return to default.
  97202. */
  97203. /**
  97204. * Gets the time (in milliseconds) taken to return to the default beta position.
  97205. * Negative value indicates camera should not return to default.
  97206. */
  97207. elevationReturnTime: number;
  97208. /**
  97209. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  97210. */
  97211. /**
  97212. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  97213. */
  97214. elevationReturnWaitTime: number;
  97215. /**
  97216. * Sets the flag that indicates if user zooming should stop animation.
  97217. */
  97218. /**
  97219. * Gets the flag that indicates if user zooming should stop animation.
  97220. */
  97221. zoomStopsAnimation: boolean;
  97222. /**
  97223. * Sets the transition time when framing the mesh, in milliseconds
  97224. */
  97225. /**
  97226. * Gets the transition time when framing the mesh, in milliseconds
  97227. */
  97228. framingTime: number;
  97229. /**
  97230. * Define if the behavior should automatically change the configured
  97231. * camera limits and sensibilities.
  97232. */
  97233. autoCorrectCameraLimitsAndSensibility: boolean;
  97234. private _onPrePointerObservableObserver;
  97235. private _onAfterCheckInputsObserver;
  97236. private _onMeshTargetChangedObserver;
  97237. private _attachedCamera;
  97238. private _isPointerDown;
  97239. private _lastInteractionTime;
  97240. /**
  97241. * Initializes the behavior.
  97242. */
  97243. init(): void;
  97244. /**
  97245. * Attaches the behavior to its arc rotate camera.
  97246. * @param camera Defines the camera to attach the behavior to
  97247. */
  97248. attach(camera: ArcRotateCamera): void;
  97249. /**
  97250. * Detaches the behavior from its current arc rotate camera.
  97251. */
  97252. detach(): void;
  97253. private _animatables;
  97254. private _betaIsAnimating;
  97255. private _betaTransition;
  97256. private _radiusTransition;
  97257. private _vectorTransition;
  97258. /**
  97259. * Targets the given mesh and updates zoom level accordingly.
  97260. * @param mesh The mesh to target.
  97261. * @param radius Optional. If a cached radius position already exists, overrides default.
  97262. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  97263. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97264. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97265. */
  97266. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97267. /**
  97268. * Targets the given mesh with its children and updates zoom level accordingly.
  97269. * @param mesh The mesh to target.
  97270. * @param radius Optional. If a cached radius position already exists, overrides default.
  97271. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  97272. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97273. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97274. */
  97275. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97276. /**
  97277. * Targets the given meshes with their children and updates zoom level accordingly.
  97278. * @param meshes The mesh to target.
  97279. * @param radius Optional. If a cached radius position already exists, overrides default.
  97280. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  97281. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97282. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97283. */
  97284. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97285. /**
  97286. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  97287. * @param minimumWorld Determines the smaller position of the bounding box extend
  97288. * @param maximumWorld Determines the bigger position of the bounding box extend
  97289. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97290. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97291. */
  97292. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97293. /**
  97294. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  97295. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  97296. * frustum width.
  97297. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  97298. * to fully enclose the mesh in the viewing frustum.
  97299. */
  97300. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  97301. /**
  97302. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  97303. * is automatically returned to its default position (expected to be above ground plane).
  97304. */
  97305. private _maintainCameraAboveGround;
  97306. /**
  97307. * Returns the frustum slope based on the canvas ratio and camera FOV
  97308. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  97309. */
  97310. private _getFrustumSlope;
  97311. /**
  97312. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  97313. */
  97314. private _clearAnimationLocks;
  97315. /**
  97316. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  97317. */
  97318. private _applyUserInteraction;
  97319. /**
  97320. * Stops and removes all animations that have been applied to the camera
  97321. */
  97322. stopAllAnimations(): void;
  97323. /**
  97324. * Gets a value indicating if the user is moving the camera
  97325. */
  97326. readonly isUserIsMoving: boolean;
  97327. /**
  97328. * The camera can move all the way towards the mesh.
  97329. */
  97330. static IgnoreBoundsSizeMode: number;
  97331. /**
  97332. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  97333. */
  97334. static FitFrustumSidesMode: number;
  97335. }
  97336. }
  97337. declare module BABYLON {
  97338. /**
  97339. * Base class for Camera Pointer Inputs.
  97340. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  97341. * for example usage.
  97342. */
  97343. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  97344. /**
  97345. * Defines the camera the input is attached to.
  97346. */
  97347. abstract camera: Camera;
  97348. /**
  97349. * Whether keyboard modifier keys are pressed at time of last mouse event.
  97350. */
  97351. protected _altKey: boolean;
  97352. protected _ctrlKey: boolean;
  97353. protected _metaKey: boolean;
  97354. protected _shiftKey: boolean;
  97355. /**
  97356. * Which mouse buttons were pressed at time of last mouse event.
  97357. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  97358. */
  97359. protected _buttonsPressed: number;
  97360. /**
  97361. * Defines the buttons associated with the input to handle camera move.
  97362. */
  97363. buttons: number[];
  97364. /**
  97365. * Attach the input controls to a specific dom element to get the input from.
  97366. * @param element Defines the element the controls should be listened from
  97367. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97368. */
  97369. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97370. /**
  97371. * Detach the current controls from the specified dom element.
  97372. * @param element Defines the element to stop listening the inputs from
  97373. */
  97374. detachControl(element: Nullable<HTMLElement>): void;
  97375. /**
  97376. * Gets the class name of the current input.
  97377. * @returns the class name
  97378. */
  97379. getClassName(): string;
  97380. /**
  97381. * Get the friendly name associated with the input class.
  97382. * @returns the input friendly name
  97383. */
  97384. getSimpleName(): string;
  97385. /**
  97386. * Called on pointer POINTERDOUBLETAP event.
  97387. * Override this method to provide functionality on POINTERDOUBLETAP event.
  97388. */
  97389. protected onDoubleTap(type: string): void;
  97390. /**
  97391. * Called on pointer POINTERMOVE event if only a single touch is active.
  97392. * Override this method to provide functionality.
  97393. */
  97394. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  97395. /**
  97396. * Called on pointer POINTERMOVE event if multiple touches are active.
  97397. * Override this method to provide functionality.
  97398. */
  97399. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  97400. /**
  97401. * Called on JS contextmenu event.
  97402. * Override this method to provide functionality.
  97403. */
  97404. protected onContextMenu(evt: PointerEvent): void;
  97405. /**
  97406. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  97407. * press.
  97408. * Override this method to provide functionality.
  97409. */
  97410. protected onButtonDown(evt: PointerEvent): void;
  97411. /**
  97412. * Called each time a new POINTERUP event occurs. Ie, for each button
  97413. * release.
  97414. * Override this method to provide functionality.
  97415. */
  97416. protected onButtonUp(evt: PointerEvent): void;
  97417. /**
  97418. * Called when window becomes inactive.
  97419. * Override this method to provide functionality.
  97420. */
  97421. protected onLostFocus(): void;
  97422. private _pointerInput;
  97423. private _observer;
  97424. private _onLostFocus;
  97425. private pointA;
  97426. private pointB;
  97427. }
  97428. }
  97429. declare module BABYLON {
  97430. /**
  97431. * Manage the pointers inputs to control an arc rotate camera.
  97432. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97433. */
  97434. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  97435. /**
  97436. * Defines the camera the input is attached to.
  97437. */
  97438. camera: ArcRotateCamera;
  97439. /**
  97440. * Gets the class name of the current input.
  97441. * @returns the class name
  97442. */
  97443. getClassName(): string;
  97444. /**
  97445. * Defines the buttons associated with the input to handle camera move.
  97446. */
  97447. buttons: number[];
  97448. /**
  97449. * Defines the pointer angular sensibility along the X axis or how fast is
  97450. * the camera rotating.
  97451. */
  97452. angularSensibilityX: number;
  97453. /**
  97454. * Defines the pointer angular sensibility along the Y axis or how fast is
  97455. * the camera rotating.
  97456. */
  97457. angularSensibilityY: number;
  97458. /**
  97459. * Defines the pointer pinch precision or how fast is the camera zooming.
  97460. */
  97461. pinchPrecision: number;
  97462. /**
  97463. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  97464. * from 0.
  97465. * It defines the percentage of current camera.radius to use as delta when
  97466. * pinch zoom is used.
  97467. */
  97468. pinchDeltaPercentage: number;
  97469. /**
  97470. * Defines the pointer panning sensibility or how fast is the camera moving.
  97471. */
  97472. panningSensibility: number;
  97473. /**
  97474. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  97475. */
  97476. multiTouchPanning: boolean;
  97477. /**
  97478. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  97479. * zoom (pinch) through multitouch.
  97480. */
  97481. multiTouchPanAndZoom: boolean;
  97482. /**
  97483. * Revers pinch action direction.
  97484. */
  97485. pinchInwards: boolean;
  97486. private _isPanClick;
  97487. private _twoFingerActivityCount;
  97488. private _isPinching;
  97489. /**
  97490. * Called on pointer POINTERMOVE event if only a single touch is active.
  97491. */
  97492. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  97493. /**
  97494. * Called on pointer POINTERDOUBLETAP event.
  97495. */
  97496. protected onDoubleTap(type: string): void;
  97497. /**
  97498. * Called on pointer POINTERMOVE event if multiple touches are active.
  97499. */
  97500. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  97501. /**
  97502. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  97503. * press.
  97504. */
  97505. protected onButtonDown(evt: PointerEvent): void;
  97506. /**
  97507. * Called each time a new POINTERUP event occurs. Ie, for each button
  97508. * release.
  97509. */
  97510. protected onButtonUp(evt: PointerEvent): void;
  97511. /**
  97512. * Called when window becomes inactive.
  97513. */
  97514. protected onLostFocus(): void;
  97515. }
  97516. }
  97517. declare module BABYLON {
  97518. /**
  97519. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  97520. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97521. */
  97522. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  97523. /**
  97524. * Defines the camera the input is attached to.
  97525. */
  97526. camera: ArcRotateCamera;
  97527. /**
  97528. * Defines the list of key codes associated with the up action (increase alpha)
  97529. */
  97530. keysUp: number[];
  97531. /**
  97532. * Defines the list of key codes associated with the down action (decrease alpha)
  97533. */
  97534. keysDown: number[];
  97535. /**
  97536. * Defines the list of key codes associated with the left action (increase beta)
  97537. */
  97538. keysLeft: number[];
  97539. /**
  97540. * Defines the list of key codes associated with the right action (decrease beta)
  97541. */
  97542. keysRight: number[];
  97543. /**
  97544. * Defines the list of key codes associated with the reset action.
  97545. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  97546. */
  97547. keysReset: number[];
  97548. /**
  97549. * Defines the panning sensibility of the inputs.
  97550. * (How fast is the camera paning)
  97551. */
  97552. panningSensibility: number;
  97553. /**
  97554. * Defines the zooming sensibility of the inputs.
  97555. * (How fast is the camera zooming)
  97556. */
  97557. zoomingSensibility: number;
  97558. /**
  97559. * Defines wether maintaining the alt key down switch the movement mode from
  97560. * orientation to zoom.
  97561. */
  97562. useAltToZoom: boolean;
  97563. /**
  97564. * Rotation speed of the camera
  97565. */
  97566. angularSpeed: number;
  97567. private _keys;
  97568. private _ctrlPressed;
  97569. private _altPressed;
  97570. private _onCanvasBlurObserver;
  97571. private _onKeyboardObserver;
  97572. private _engine;
  97573. private _scene;
  97574. /**
  97575. * Attach the input controls to a specific dom element to get the input from.
  97576. * @param element Defines the element the controls should be listened from
  97577. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97578. */
  97579. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97580. /**
  97581. * Detach the current controls from the specified dom element.
  97582. * @param element Defines the element to stop listening the inputs from
  97583. */
  97584. detachControl(element: Nullable<HTMLElement>): void;
  97585. /**
  97586. * Update the current camera state depending on the inputs that have been used this frame.
  97587. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97588. */
  97589. checkInputs(): void;
  97590. /**
  97591. * Gets the class name of the current intput.
  97592. * @returns the class name
  97593. */
  97594. getClassName(): string;
  97595. /**
  97596. * Get the friendly name associated with the input class.
  97597. * @returns the input friendly name
  97598. */
  97599. getSimpleName(): string;
  97600. }
  97601. }
  97602. declare module BABYLON {
  97603. /**
  97604. * Manage the mouse wheel inputs to control an arc rotate camera.
  97605. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97606. */
  97607. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  97608. /**
  97609. * Defines the camera the input is attached to.
  97610. */
  97611. camera: ArcRotateCamera;
  97612. /**
  97613. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  97614. */
  97615. wheelPrecision: number;
  97616. /**
  97617. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  97618. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  97619. */
  97620. wheelDeltaPercentage: number;
  97621. private _wheel;
  97622. private _observer;
  97623. private computeDeltaFromMouseWheelLegacyEvent;
  97624. /**
  97625. * Attach the input controls to a specific dom element to get the input from.
  97626. * @param element Defines the element the controls should be listened from
  97627. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97628. */
  97629. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97630. /**
  97631. * Detach the current controls from the specified dom element.
  97632. * @param element Defines the element to stop listening the inputs from
  97633. */
  97634. detachControl(element: Nullable<HTMLElement>): void;
  97635. /**
  97636. * Gets the class name of the current intput.
  97637. * @returns the class name
  97638. */
  97639. getClassName(): string;
  97640. /**
  97641. * Get the friendly name associated with the input class.
  97642. * @returns the input friendly name
  97643. */
  97644. getSimpleName(): string;
  97645. }
  97646. }
  97647. declare module BABYLON {
  97648. /**
  97649. * Default Inputs manager for the ArcRotateCamera.
  97650. * It groups all the default supported inputs for ease of use.
  97651. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97652. */
  97653. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  97654. /**
  97655. * Instantiates a new ArcRotateCameraInputsManager.
  97656. * @param camera Defines the camera the inputs belong to
  97657. */
  97658. constructor(camera: ArcRotateCamera);
  97659. /**
  97660. * Add mouse wheel input support to the input manager.
  97661. * @returns the current input manager
  97662. */
  97663. addMouseWheel(): ArcRotateCameraInputsManager;
  97664. /**
  97665. * Add pointers input support to the input manager.
  97666. * @returns the current input manager
  97667. */
  97668. addPointers(): ArcRotateCameraInputsManager;
  97669. /**
  97670. * Add keyboard input support to the input manager.
  97671. * @returns the current input manager
  97672. */
  97673. addKeyboard(): ArcRotateCameraInputsManager;
  97674. }
  97675. }
  97676. declare module BABYLON {
  97677. /**
  97678. * This represents an orbital type of camera.
  97679. *
  97680. * 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.
  97681. * 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.
  97682. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  97683. */
  97684. export class ArcRotateCamera extends TargetCamera {
  97685. /**
  97686. * Defines the rotation angle of the camera along the longitudinal axis.
  97687. */
  97688. alpha: number;
  97689. /**
  97690. * Defines the rotation angle of the camera along the latitudinal axis.
  97691. */
  97692. beta: number;
  97693. /**
  97694. * Defines the radius of the camera from it s target point.
  97695. */
  97696. radius: number;
  97697. protected _target: Vector3;
  97698. protected _targetHost: Nullable<AbstractMesh>;
  97699. /**
  97700. * Defines the target point of the camera.
  97701. * The camera looks towards it form the radius distance.
  97702. */
  97703. target: Vector3;
  97704. /**
  97705. * Define the current local position of the camera in the scene
  97706. */
  97707. position: Vector3;
  97708. protected _upVector: Vector3;
  97709. protected _upToYMatrix: Matrix;
  97710. protected _YToUpMatrix: Matrix;
  97711. /**
  97712. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  97713. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  97714. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  97715. */
  97716. upVector: Vector3;
  97717. /**
  97718. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  97719. */
  97720. setMatUp(): void;
  97721. /**
  97722. * Current inertia value on the longitudinal axis.
  97723. * The bigger this number the longer it will take for the camera to stop.
  97724. */
  97725. inertialAlphaOffset: number;
  97726. /**
  97727. * Current inertia value on the latitudinal axis.
  97728. * The bigger this number the longer it will take for the camera to stop.
  97729. */
  97730. inertialBetaOffset: number;
  97731. /**
  97732. * Current inertia value on the radius axis.
  97733. * The bigger this number the longer it will take for the camera to stop.
  97734. */
  97735. inertialRadiusOffset: number;
  97736. /**
  97737. * Minimum allowed angle on the longitudinal axis.
  97738. * This can help limiting how the Camera is able to move in the scene.
  97739. */
  97740. lowerAlphaLimit: Nullable<number>;
  97741. /**
  97742. * Maximum allowed angle on the longitudinal axis.
  97743. * This can help limiting how the Camera is able to move in the scene.
  97744. */
  97745. upperAlphaLimit: Nullable<number>;
  97746. /**
  97747. * Minimum allowed angle on the latitudinal axis.
  97748. * This can help limiting how the Camera is able to move in the scene.
  97749. */
  97750. lowerBetaLimit: number;
  97751. /**
  97752. * Maximum allowed angle on the latitudinal axis.
  97753. * This can help limiting how the Camera is able to move in the scene.
  97754. */
  97755. upperBetaLimit: number;
  97756. /**
  97757. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  97758. * This can help limiting how the Camera is able to move in the scene.
  97759. */
  97760. lowerRadiusLimit: Nullable<number>;
  97761. /**
  97762. * Maximum allowed distance of the camera to the target (The camera can not get further).
  97763. * This can help limiting how the Camera is able to move in the scene.
  97764. */
  97765. upperRadiusLimit: Nullable<number>;
  97766. /**
  97767. * Defines the current inertia value used during panning of the camera along the X axis.
  97768. */
  97769. inertialPanningX: number;
  97770. /**
  97771. * Defines the current inertia value used during panning of the camera along the Y axis.
  97772. */
  97773. inertialPanningY: number;
  97774. /**
  97775. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  97776. * Basically if your fingers moves away from more than this distance you will be considered
  97777. * in pinch mode.
  97778. */
  97779. pinchToPanMaxDistance: number;
  97780. /**
  97781. * Defines the maximum distance the camera can pan.
  97782. * This could help keeping the cammera always in your scene.
  97783. */
  97784. panningDistanceLimit: Nullable<number>;
  97785. /**
  97786. * Defines the target of the camera before paning.
  97787. */
  97788. panningOriginTarget: Vector3;
  97789. /**
  97790. * Defines the value of the inertia used during panning.
  97791. * 0 would mean stop inertia and one would mean no decelleration at all.
  97792. */
  97793. panningInertia: number;
  97794. /**
  97795. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  97796. */
  97797. angularSensibilityX: number;
  97798. /**
  97799. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  97800. */
  97801. angularSensibilityY: number;
  97802. /**
  97803. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  97804. */
  97805. pinchPrecision: number;
  97806. /**
  97807. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  97808. * It will be used instead of pinchDeltaPrecision if different from 0.
  97809. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  97810. */
  97811. pinchDeltaPercentage: number;
  97812. /**
  97813. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  97814. */
  97815. panningSensibility: number;
  97816. /**
  97817. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  97818. */
  97819. keysUp: number[];
  97820. /**
  97821. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  97822. */
  97823. keysDown: number[];
  97824. /**
  97825. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  97826. */
  97827. keysLeft: number[];
  97828. /**
  97829. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  97830. */
  97831. keysRight: number[];
  97832. /**
  97833. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  97834. */
  97835. wheelPrecision: number;
  97836. /**
  97837. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  97838. * It will be used instead of pinchDeltaPrecision if different from 0.
  97839. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  97840. */
  97841. wheelDeltaPercentage: number;
  97842. /**
  97843. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  97844. */
  97845. zoomOnFactor: number;
  97846. /**
  97847. * Defines a screen offset for the camera position.
  97848. */
  97849. targetScreenOffset: Vector2;
  97850. /**
  97851. * Allows the camera to be completely reversed.
  97852. * If false the camera can not arrive upside down.
  97853. */
  97854. allowUpsideDown: boolean;
  97855. /**
  97856. * Define if double tap/click is used to restore the previously saved state of the camera.
  97857. */
  97858. useInputToRestoreState: boolean;
  97859. /** @hidden */
  97860. _viewMatrix: Matrix;
  97861. /** @hidden */
  97862. _useCtrlForPanning: boolean;
  97863. /** @hidden */
  97864. _panningMouseButton: number;
  97865. /**
  97866. * Defines the input associated to the camera.
  97867. */
  97868. inputs: ArcRotateCameraInputsManager;
  97869. /** @hidden */
  97870. _reset: () => void;
  97871. /**
  97872. * Defines the allowed panning axis.
  97873. */
  97874. panningAxis: Vector3;
  97875. protected _localDirection: Vector3;
  97876. protected _transformedDirection: Vector3;
  97877. private _bouncingBehavior;
  97878. /**
  97879. * Gets the bouncing behavior of the camera if it has been enabled.
  97880. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  97881. */
  97882. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  97883. /**
  97884. * Defines if the bouncing behavior of the camera is enabled on the camera.
  97885. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  97886. */
  97887. useBouncingBehavior: boolean;
  97888. private _framingBehavior;
  97889. /**
  97890. * Gets the framing behavior of the camera if it has been enabled.
  97891. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  97892. */
  97893. readonly framingBehavior: Nullable<FramingBehavior>;
  97894. /**
  97895. * Defines if the framing behavior of the camera is enabled on the camera.
  97896. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  97897. */
  97898. useFramingBehavior: boolean;
  97899. private _autoRotationBehavior;
  97900. /**
  97901. * Gets the auto rotation behavior of the camera if it has been enabled.
  97902. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  97903. */
  97904. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  97905. /**
  97906. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  97907. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  97908. */
  97909. useAutoRotationBehavior: boolean;
  97910. /**
  97911. * Observable triggered when the mesh target has been changed on the camera.
  97912. */
  97913. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  97914. /**
  97915. * Event raised when the camera is colliding with a mesh.
  97916. */
  97917. onCollide: (collidedMesh: AbstractMesh) => void;
  97918. /**
  97919. * Defines whether the camera should check collision with the objects oh the scene.
  97920. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  97921. */
  97922. checkCollisions: boolean;
  97923. /**
  97924. * Defines the collision radius of the camera.
  97925. * This simulates a sphere around the camera.
  97926. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  97927. */
  97928. collisionRadius: Vector3;
  97929. protected _collider: Collider;
  97930. protected _previousPosition: Vector3;
  97931. protected _collisionVelocity: Vector3;
  97932. protected _newPosition: Vector3;
  97933. protected _previousAlpha: number;
  97934. protected _previousBeta: number;
  97935. protected _previousRadius: number;
  97936. protected _collisionTriggered: boolean;
  97937. protected _targetBoundingCenter: Nullable<Vector3>;
  97938. private _computationVector;
  97939. /**
  97940. * Instantiates a new ArcRotateCamera in a given scene
  97941. * @param name Defines the name of the camera
  97942. * @param alpha Defines the camera rotation along the logitudinal axis
  97943. * @param beta Defines the camera rotation along the latitudinal axis
  97944. * @param radius Defines the camera distance from its target
  97945. * @param target Defines the camera target
  97946. * @param scene Defines the scene the camera belongs to
  97947. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  97948. */
  97949. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  97950. /** @hidden */
  97951. _initCache(): void;
  97952. /** @hidden */
  97953. _updateCache(ignoreParentClass?: boolean): void;
  97954. protected _getTargetPosition(): Vector3;
  97955. private _storedAlpha;
  97956. private _storedBeta;
  97957. private _storedRadius;
  97958. private _storedTarget;
  97959. /**
  97960. * Stores the current state of the camera (alpha, beta, radius and target)
  97961. * @returns the camera itself
  97962. */
  97963. storeState(): Camera;
  97964. /**
  97965. * @hidden
  97966. * Restored camera state. You must call storeState() first
  97967. */
  97968. _restoreStateValues(): boolean;
  97969. /** @hidden */
  97970. _isSynchronizedViewMatrix(): boolean;
  97971. /**
  97972. * Attached controls to the current camera.
  97973. * @param element Defines the element the controls should be listened from
  97974. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97975. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  97976. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  97977. */
  97978. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  97979. /**
  97980. * Detach the current controls from the camera.
  97981. * The camera will stop reacting to inputs.
  97982. * @param element Defines the element to stop listening the inputs from
  97983. */
  97984. detachControl(element: HTMLElement): void;
  97985. /** @hidden */
  97986. _checkInputs(): void;
  97987. protected _checkLimits(): void;
  97988. /**
  97989. * Rebuilds angles (alpha, beta) and radius from the give position and target
  97990. */
  97991. rebuildAnglesAndRadius(): void;
  97992. /**
  97993. * Use a position to define the current camera related information like aplha, beta and radius
  97994. * @param position Defines the position to set the camera at
  97995. */
  97996. setPosition(position: Vector3): void;
  97997. /**
  97998. * Defines the target the camera should look at.
  97999. * This will automatically adapt alpha beta and radius to fit within the new target.
  98000. * @param target Defines the new target as a Vector or a mesh
  98001. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  98002. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  98003. */
  98004. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  98005. /** @hidden */
  98006. _getViewMatrix(): Matrix;
  98007. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  98008. /**
  98009. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  98010. * @param meshes Defines the mesh to zoom on
  98011. * @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)
  98012. */
  98013. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  98014. /**
  98015. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  98016. * The target will be changed but the radius
  98017. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  98018. * @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)
  98019. */
  98020. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  98021. min: Vector3;
  98022. max: Vector3;
  98023. distance: number;
  98024. }, doNotUpdateMaxZ?: boolean): void;
  98025. /**
  98026. * @override
  98027. * Override Camera.createRigCamera
  98028. */
  98029. createRigCamera(name: string, cameraIndex: number): Camera;
  98030. /**
  98031. * @hidden
  98032. * @override
  98033. * Override Camera._updateRigCameras
  98034. */
  98035. _updateRigCameras(): void;
  98036. /**
  98037. * Destroy the camera and release the current resources hold by it.
  98038. */
  98039. dispose(): void;
  98040. /**
  98041. * Gets the current object class name.
  98042. * @return the class name
  98043. */
  98044. getClassName(): string;
  98045. }
  98046. }
  98047. declare module BABYLON {
  98048. /**
  98049. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  98050. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98051. */
  98052. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  98053. /**
  98054. * Gets the name of the behavior.
  98055. */
  98056. readonly name: string;
  98057. private _zoomStopsAnimation;
  98058. private _idleRotationSpeed;
  98059. private _idleRotationWaitTime;
  98060. private _idleRotationSpinupTime;
  98061. /**
  98062. * Sets the flag that indicates if user zooming should stop animation.
  98063. */
  98064. /**
  98065. * Gets the flag that indicates if user zooming should stop animation.
  98066. */
  98067. zoomStopsAnimation: boolean;
  98068. /**
  98069. * Sets the default speed at which the camera rotates around the model.
  98070. */
  98071. /**
  98072. * Gets the default speed at which the camera rotates around the model.
  98073. */
  98074. idleRotationSpeed: number;
  98075. /**
  98076. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  98077. */
  98078. /**
  98079. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  98080. */
  98081. idleRotationWaitTime: number;
  98082. /**
  98083. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  98084. */
  98085. /**
  98086. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  98087. */
  98088. idleRotationSpinupTime: number;
  98089. /**
  98090. * Gets a value indicating if the camera is currently rotating because of this behavior
  98091. */
  98092. readonly rotationInProgress: boolean;
  98093. private _onPrePointerObservableObserver;
  98094. private _onAfterCheckInputsObserver;
  98095. private _attachedCamera;
  98096. private _isPointerDown;
  98097. private _lastFrameTime;
  98098. private _lastInteractionTime;
  98099. private _cameraRotationSpeed;
  98100. /**
  98101. * Initializes the behavior.
  98102. */
  98103. init(): void;
  98104. /**
  98105. * Attaches the behavior to its arc rotate camera.
  98106. * @param camera Defines the camera to attach the behavior to
  98107. */
  98108. attach(camera: ArcRotateCamera): void;
  98109. /**
  98110. * Detaches the behavior from its current arc rotate camera.
  98111. */
  98112. detach(): void;
  98113. /**
  98114. * Returns true if user is scrolling.
  98115. * @return true if user is scrolling.
  98116. */
  98117. private _userIsZooming;
  98118. private _lastFrameRadius;
  98119. private _shouldAnimationStopForInteraction;
  98120. /**
  98121. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  98122. */
  98123. private _applyUserInteraction;
  98124. private _userIsMoving;
  98125. }
  98126. }
  98127. declare module BABYLON {
  98128. /**
  98129. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  98130. */
  98131. export class AttachToBoxBehavior implements Behavior<Mesh> {
  98132. private ui;
  98133. /**
  98134. * The name of the behavior
  98135. */
  98136. name: string;
  98137. /**
  98138. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  98139. */
  98140. distanceAwayFromFace: number;
  98141. /**
  98142. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  98143. */
  98144. distanceAwayFromBottomOfFace: number;
  98145. private _faceVectors;
  98146. private _target;
  98147. private _scene;
  98148. private _onRenderObserver;
  98149. private _tmpMatrix;
  98150. private _tmpVector;
  98151. /**
  98152. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  98153. * @param ui The transform node that should be attched to the mesh
  98154. */
  98155. constructor(ui: TransformNode);
  98156. /**
  98157. * Initializes the behavior
  98158. */
  98159. init(): void;
  98160. private _closestFace;
  98161. private _zeroVector;
  98162. private _lookAtTmpMatrix;
  98163. private _lookAtToRef;
  98164. /**
  98165. * Attaches the AttachToBoxBehavior to the passed in mesh
  98166. * @param target The mesh that the specified node will be attached to
  98167. */
  98168. attach(target: Mesh): void;
  98169. /**
  98170. * Detaches the behavior from the mesh
  98171. */
  98172. detach(): void;
  98173. }
  98174. }
  98175. declare module BABYLON {
  98176. /**
  98177. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  98178. */
  98179. export class FadeInOutBehavior implements Behavior<Mesh> {
  98180. /**
  98181. * Time in milliseconds to delay before fading in (Default: 0)
  98182. */
  98183. delay: number;
  98184. /**
  98185. * Time in milliseconds for the mesh to fade in (Default: 300)
  98186. */
  98187. fadeInTime: number;
  98188. private _millisecondsPerFrame;
  98189. private _hovered;
  98190. private _hoverValue;
  98191. private _ownerNode;
  98192. /**
  98193. * Instatiates the FadeInOutBehavior
  98194. */
  98195. constructor();
  98196. /**
  98197. * The name of the behavior
  98198. */
  98199. readonly name: string;
  98200. /**
  98201. * Initializes the behavior
  98202. */
  98203. init(): void;
  98204. /**
  98205. * Attaches the fade behavior on the passed in mesh
  98206. * @param ownerNode The mesh that will be faded in/out once attached
  98207. */
  98208. attach(ownerNode: Mesh): void;
  98209. /**
  98210. * Detaches the behavior from the mesh
  98211. */
  98212. detach(): void;
  98213. /**
  98214. * Triggers the mesh to begin fading in or out
  98215. * @param value if the object should fade in or out (true to fade in)
  98216. */
  98217. fadeIn(value: boolean): void;
  98218. private _update;
  98219. private _setAllVisibility;
  98220. }
  98221. }
  98222. declare module BABYLON {
  98223. /**
  98224. * Class containing a set of static utilities functions for managing Pivots
  98225. * @hidden
  98226. */
  98227. export class PivotTools {
  98228. private static _PivotCached;
  98229. private static _OldPivotPoint;
  98230. private static _PivotTranslation;
  98231. private static _PivotTmpVector;
  98232. /** @hidden */
  98233. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  98234. /** @hidden */
  98235. static _RestorePivotPoint(mesh: AbstractMesh): void;
  98236. }
  98237. }
  98238. declare module BABYLON {
  98239. /**
  98240. * Class containing static functions to help procedurally build meshes
  98241. */
  98242. export class PlaneBuilder {
  98243. /**
  98244. * Creates a plane mesh
  98245. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  98246. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  98247. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  98248. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98249. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98250. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98251. * @param name defines the name of the mesh
  98252. * @param options defines the options used to create the mesh
  98253. * @param scene defines the hosting scene
  98254. * @returns the plane mesh
  98255. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  98256. */
  98257. static CreatePlane(name: string, options: {
  98258. size?: number;
  98259. width?: number;
  98260. height?: number;
  98261. sideOrientation?: number;
  98262. frontUVs?: Vector4;
  98263. backUVs?: Vector4;
  98264. updatable?: boolean;
  98265. sourcePlane?: Plane;
  98266. }, scene?: Nullable<Scene>): Mesh;
  98267. }
  98268. }
  98269. declare module BABYLON {
  98270. /**
  98271. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  98272. */
  98273. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  98274. private static _AnyMouseID;
  98275. /**
  98276. * Abstract mesh the behavior is set on
  98277. */
  98278. attachedNode: AbstractMesh;
  98279. private _dragPlane;
  98280. private _scene;
  98281. private _pointerObserver;
  98282. private _beforeRenderObserver;
  98283. private static _planeScene;
  98284. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  98285. /**
  98286. * 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)
  98287. */
  98288. maxDragAngle: number;
  98289. /**
  98290. * @hidden
  98291. */
  98292. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  98293. /**
  98294. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  98295. */
  98296. currentDraggingPointerID: number;
  98297. /**
  98298. * The last position where the pointer hit the drag plane in world space
  98299. */
  98300. lastDragPosition: Vector3;
  98301. /**
  98302. * If the behavior is currently in a dragging state
  98303. */
  98304. dragging: boolean;
  98305. /**
  98306. * 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)
  98307. */
  98308. dragDeltaRatio: number;
  98309. /**
  98310. * If the drag plane orientation should be updated during the dragging (Default: true)
  98311. */
  98312. updateDragPlane: boolean;
  98313. private _debugMode;
  98314. private _moving;
  98315. /**
  98316. * Fires each time the attached mesh is dragged with the pointer
  98317. * * delta between last drag position and current drag position in world space
  98318. * * dragDistance along the drag axis
  98319. * * dragPlaneNormal normal of the current drag plane used during the drag
  98320. * * dragPlanePoint in world space where the drag intersects the drag plane
  98321. */
  98322. onDragObservable: Observable<{
  98323. delta: Vector3;
  98324. dragPlanePoint: Vector3;
  98325. dragPlaneNormal: Vector3;
  98326. dragDistance: number;
  98327. pointerId: number;
  98328. }>;
  98329. /**
  98330. * Fires each time a drag begins (eg. mouse down on mesh)
  98331. */
  98332. onDragStartObservable: Observable<{
  98333. dragPlanePoint: Vector3;
  98334. pointerId: number;
  98335. }>;
  98336. /**
  98337. * Fires each time a drag ends (eg. mouse release after drag)
  98338. */
  98339. onDragEndObservable: Observable<{
  98340. dragPlanePoint: Vector3;
  98341. pointerId: number;
  98342. }>;
  98343. /**
  98344. * If the attached mesh should be moved when dragged
  98345. */
  98346. moveAttached: boolean;
  98347. /**
  98348. * If the drag behavior will react to drag events (Default: true)
  98349. */
  98350. enabled: boolean;
  98351. /**
  98352. * If camera controls should be detached during the drag
  98353. */
  98354. detachCameraControls: boolean;
  98355. /**
  98356. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  98357. */
  98358. useObjectOrienationForDragging: boolean;
  98359. private _options;
  98360. /**
  98361. * Creates a pointer drag behavior that can be attached to a mesh
  98362. * @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)
  98363. */
  98364. constructor(options?: {
  98365. dragAxis?: Vector3;
  98366. dragPlaneNormal?: Vector3;
  98367. });
  98368. /**
  98369. * Predicate to determine if it is valid to move the object to a new position when it is moved
  98370. */
  98371. validateDrag: (targetPosition: Vector3) => boolean;
  98372. /**
  98373. * The name of the behavior
  98374. */
  98375. readonly name: string;
  98376. /**
  98377. * Initializes the behavior
  98378. */
  98379. init(): void;
  98380. private _tmpVector;
  98381. private _alternatePickedPoint;
  98382. private _worldDragAxis;
  98383. private _targetPosition;
  98384. private _attachedElement;
  98385. /**
  98386. * Attaches the drag behavior the passed in mesh
  98387. * @param ownerNode The mesh that will be dragged around once attached
  98388. */
  98389. attach(ownerNode: AbstractMesh): void;
  98390. /**
  98391. * Force relase the drag action by code.
  98392. */
  98393. releaseDrag(): void;
  98394. private _startDragRay;
  98395. private _lastPointerRay;
  98396. /**
  98397. * Simulates the start of a pointer drag event on the behavior
  98398. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  98399. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  98400. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  98401. */
  98402. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  98403. private _startDrag;
  98404. private _dragDelta;
  98405. private _moveDrag;
  98406. private _pickWithRayOnDragPlane;
  98407. private _pointA;
  98408. private _pointB;
  98409. private _pointC;
  98410. private _lineA;
  98411. private _lineB;
  98412. private _localAxis;
  98413. private _lookAt;
  98414. private _updateDragPlanePosition;
  98415. /**
  98416. * Detaches the behavior from the mesh
  98417. */
  98418. detach(): void;
  98419. }
  98420. }
  98421. declare module BABYLON {
  98422. /**
  98423. * A behavior that when attached to a mesh will allow the mesh to be scaled
  98424. */
  98425. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  98426. private _dragBehaviorA;
  98427. private _dragBehaviorB;
  98428. private _startDistance;
  98429. private _initialScale;
  98430. private _targetScale;
  98431. private _ownerNode;
  98432. private _sceneRenderObserver;
  98433. /**
  98434. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  98435. */
  98436. constructor();
  98437. /**
  98438. * The name of the behavior
  98439. */
  98440. readonly name: string;
  98441. /**
  98442. * Initializes the behavior
  98443. */
  98444. init(): void;
  98445. private _getCurrentDistance;
  98446. /**
  98447. * Attaches the scale behavior the passed in mesh
  98448. * @param ownerNode The mesh that will be scaled around once attached
  98449. */
  98450. attach(ownerNode: Mesh): void;
  98451. /**
  98452. * Detaches the behavior from the mesh
  98453. */
  98454. detach(): void;
  98455. }
  98456. }
  98457. declare module BABYLON {
  98458. /**
  98459. * 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
  98460. */
  98461. export class SixDofDragBehavior implements Behavior<Mesh> {
  98462. private static _virtualScene;
  98463. private _ownerNode;
  98464. private _sceneRenderObserver;
  98465. private _scene;
  98466. private _targetPosition;
  98467. private _virtualOriginMesh;
  98468. private _virtualDragMesh;
  98469. private _pointerObserver;
  98470. private _moving;
  98471. private _startingOrientation;
  98472. /**
  98473. * 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)
  98474. */
  98475. private zDragFactor;
  98476. /**
  98477. * If the object should rotate to face the drag origin
  98478. */
  98479. rotateDraggedObject: boolean;
  98480. /**
  98481. * If the behavior is currently in a dragging state
  98482. */
  98483. dragging: boolean;
  98484. /**
  98485. * 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)
  98486. */
  98487. dragDeltaRatio: number;
  98488. /**
  98489. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  98490. */
  98491. currentDraggingPointerID: number;
  98492. /**
  98493. * If camera controls should be detached during the drag
  98494. */
  98495. detachCameraControls: boolean;
  98496. /**
  98497. * Fires each time a drag starts
  98498. */
  98499. onDragStartObservable: Observable<{}>;
  98500. /**
  98501. * Fires each time a drag ends (eg. mouse release after drag)
  98502. */
  98503. onDragEndObservable: Observable<{}>;
  98504. /**
  98505. * 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
  98506. */
  98507. constructor();
  98508. /**
  98509. * The name of the behavior
  98510. */
  98511. readonly name: string;
  98512. /**
  98513. * Initializes the behavior
  98514. */
  98515. init(): void;
  98516. /**
  98517. * Attaches the scale behavior the passed in mesh
  98518. * @param ownerNode The mesh that will be scaled around once attached
  98519. */
  98520. attach(ownerNode: Mesh): void;
  98521. /**
  98522. * Detaches the behavior from the mesh
  98523. */
  98524. detach(): void;
  98525. }
  98526. }
  98527. declare module BABYLON {
  98528. /**
  98529. * Class used to apply inverse kinematics to bones
  98530. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  98531. */
  98532. export class BoneIKController {
  98533. private static _tmpVecs;
  98534. private static _tmpQuat;
  98535. private static _tmpMats;
  98536. /**
  98537. * Gets or sets the target mesh
  98538. */
  98539. targetMesh: AbstractMesh;
  98540. /** Gets or sets the mesh used as pole */
  98541. poleTargetMesh: AbstractMesh;
  98542. /**
  98543. * Gets or sets the bone used as pole
  98544. */
  98545. poleTargetBone: Nullable<Bone>;
  98546. /**
  98547. * Gets or sets the target position
  98548. */
  98549. targetPosition: Vector3;
  98550. /**
  98551. * Gets or sets the pole target position
  98552. */
  98553. poleTargetPosition: Vector3;
  98554. /**
  98555. * Gets or sets the pole target local offset
  98556. */
  98557. poleTargetLocalOffset: Vector3;
  98558. /**
  98559. * Gets or sets the pole angle
  98560. */
  98561. poleAngle: number;
  98562. /**
  98563. * Gets or sets the mesh associated with the controller
  98564. */
  98565. mesh: AbstractMesh;
  98566. /**
  98567. * 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)
  98568. */
  98569. slerpAmount: number;
  98570. private _bone1Quat;
  98571. private _bone1Mat;
  98572. private _bone2Ang;
  98573. private _bone1;
  98574. private _bone2;
  98575. private _bone1Length;
  98576. private _bone2Length;
  98577. private _maxAngle;
  98578. private _maxReach;
  98579. private _rightHandedSystem;
  98580. private _bendAxis;
  98581. private _slerping;
  98582. private _adjustRoll;
  98583. /**
  98584. * Gets or sets maximum allowed angle
  98585. */
  98586. maxAngle: number;
  98587. /**
  98588. * Creates a new BoneIKController
  98589. * @param mesh defines the mesh to control
  98590. * @param bone defines the bone to control
  98591. * @param options defines options to set up the controller
  98592. */
  98593. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  98594. targetMesh?: AbstractMesh;
  98595. poleTargetMesh?: AbstractMesh;
  98596. poleTargetBone?: Bone;
  98597. poleTargetLocalOffset?: Vector3;
  98598. poleAngle?: number;
  98599. bendAxis?: Vector3;
  98600. maxAngle?: number;
  98601. slerpAmount?: number;
  98602. });
  98603. private _setMaxAngle;
  98604. /**
  98605. * Force the controller to update the bones
  98606. */
  98607. update(): void;
  98608. }
  98609. }
  98610. declare module BABYLON {
  98611. /**
  98612. * Class used to make a bone look toward a point in space
  98613. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  98614. */
  98615. export class BoneLookController {
  98616. private static _tmpVecs;
  98617. private static _tmpQuat;
  98618. private static _tmpMats;
  98619. /**
  98620. * The target Vector3 that the bone will look at
  98621. */
  98622. target: Vector3;
  98623. /**
  98624. * The mesh that the bone is attached to
  98625. */
  98626. mesh: AbstractMesh;
  98627. /**
  98628. * The bone that will be looking to the target
  98629. */
  98630. bone: Bone;
  98631. /**
  98632. * The up axis of the coordinate system that is used when the bone is rotated
  98633. */
  98634. upAxis: Vector3;
  98635. /**
  98636. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  98637. */
  98638. upAxisSpace: Space;
  98639. /**
  98640. * Used to make an adjustment to the yaw of the bone
  98641. */
  98642. adjustYaw: number;
  98643. /**
  98644. * Used to make an adjustment to the pitch of the bone
  98645. */
  98646. adjustPitch: number;
  98647. /**
  98648. * Used to make an adjustment to the roll of the bone
  98649. */
  98650. adjustRoll: number;
  98651. /**
  98652. * 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)
  98653. */
  98654. slerpAmount: number;
  98655. private _minYaw;
  98656. private _maxYaw;
  98657. private _minPitch;
  98658. private _maxPitch;
  98659. private _minYawSin;
  98660. private _minYawCos;
  98661. private _maxYawSin;
  98662. private _maxYawCos;
  98663. private _midYawConstraint;
  98664. private _minPitchTan;
  98665. private _maxPitchTan;
  98666. private _boneQuat;
  98667. private _slerping;
  98668. private _transformYawPitch;
  98669. private _transformYawPitchInv;
  98670. private _firstFrameSkipped;
  98671. private _yawRange;
  98672. private _fowardAxis;
  98673. /**
  98674. * Gets or sets the minimum yaw angle that the bone can look to
  98675. */
  98676. minYaw: number;
  98677. /**
  98678. * Gets or sets the maximum yaw angle that the bone can look to
  98679. */
  98680. maxYaw: number;
  98681. /**
  98682. * Gets or sets the minimum pitch angle that the bone can look to
  98683. */
  98684. minPitch: number;
  98685. /**
  98686. * Gets or sets the maximum pitch angle that the bone can look to
  98687. */
  98688. maxPitch: number;
  98689. /**
  98690. * Create a BoneLookController
  98691. * @param mesh the mesh that the bone belongs to
  98692. * @param bone the bone that will be looking to the target
  98693. * @param target the target Vector3 to look at
  98694. * @param options optional settings:
  98695. * * maxYaw: the maximum angle the bone will yaw to
  98696. * * minYaw: the minimum angle the bone will yaw to
  98697. * * maxPitch: the maximum angle the bone will pitch to
  98698. * * minPitch: the minimum angle the bone will yaw to
  98699. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  98700. * * upAxis: the up axis of the coordinate system
  98701. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  98702. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  98703. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  98704. * * adjustYaw: used to make an adjustment to the yaw of the bone
  98705. * * adjustPitch: used to make an adjustment to the pitch of the bone
  98706. * * adjustRoll: used to make an adjustment to the roll of the bone
  98707. **/
  98708. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  98709. maxYaw?: number;
  98710. minYaw?: number;
  98711. maxPitch?: number;
  98712. minPitch?: number;
  98713. slerpAmount?: number;
  98714. upAxis?: Vector3;
  98715. upAxisSpace?: Space;
  98716. yawAxis?: Vector3;
  98717. pitchAxis?: Vector3;
  98718. adjustYaw?: number;
  98719. adjustPitch?: number;
  98720. adjustRoll?: number;
  98721. });
  98722. /**
  98723. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  98724. */
  98725. update(): void;
  98726. private _getAngleDiff;
  98727. private _getAngleBetween;
  98728. private _isAngleBetween;
  98729. }
  98730. }
  98731. declare module BABYLON {
  98732. /**
  98733. * Manage the gamepad inputs to control an arc rotate camera.
  98734. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98735. */
  98736. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  98737. /**
  98738. * Defines the camera the input is attached to.
  98739. */
  98740. camera: ArcRotateCamera;
  98741. /**
  98742. * Defines the gamepad the input is gathering event from.
  98743. */
  98744. gamepad: Nullable<Gamepad>;
  98745. /**
  98746. * Defines the gamepad rotation sensiblity.
  98747. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  98748. */
  98749. gamepadRotationSensibility: number;
  98750. /**
  98751. * Defines the gamepad move sensiblity.
  98752. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  98753. */
  98754. gamepadMoveSensibility: number;
  98755. private _onGamepadConnectedObserver;
  98756. private _onGamepadDisconnectedObserver;
  98757. /**
  98758. * Attach the input controls to a specific dom element to get the input from.
  98759. * @param element Defines the element the controls should be listened from
  98760. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98761. */
  98762. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98763. /**
  98764. * Detach the current controls from the specified dom element.
  98765. * @param element Defines the element to stop listening the inputs from
  98766. */
  98767. detachControl(element: Nullable<HTMLElement>): void;
  98768. /**
  98769. * Update the current camera state depending on the inputs that have been used this frame.
  98770. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98771. */
  98772. checkInputs(): void;
  98773. /**
  98774. * Gets the class name of the current intput.
  98775. * @returns the class name
  98776. */
  98777. getClassName(): string;
  98778. /**
  98779. * Get the friendly name associated with the input class.
  98780. * @returns the input friendly name
  98781. */
  98782. getSimpleName(): string;
  98783. }
  98784. }
  98785. declare module BABYLON {
  98786. interface ArcRotateCameraInputsManager {
  98787. /**
  98788. * Add orientation input support to the input manager.
  98789. * @returns the current input manager
  98790. */
  98791. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  98792. }
  98793. /**
  98794. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  98795. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98796. */
  98797. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  98798. /**
  98799. * Defines the camera the input is attached to.
  98800. */
  98801. camera: ArcRotateCamera;
  98802. /**
  98803. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  98804. */
  98805. alphaCorrection: number;
  98806. /**
  98807. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  98808. */
  98809. gammaCorrection: number;
  98810. private _alpha;
  98811. private _gamma;
  98812. private _dirty;
  98813. private _deviceOrientationHandler;
  98814. /**
  98815. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  98816. */
  98817. constructor();
  98818. /**
  98819. * Attach the input controls to a specific dom element to get the input from.
  98820. * @param element Defines the element the controls should be listened from
  98821. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98822. */
  98823. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98824. /** @hidden */
  98825. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  98826. /**
  98827. * Update the current camera state depending on the inputs that have been used this frame.
  98828. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98829. */
  98830. checkInputs(): void;
  98831. /**
  98832. * Detach the current controls from the specified dom element.
  98833. * @param element Defines the element to stop listening the inputs from
  98834. */
  98835. detachControl(element: Nullable<HTMLElement>): void;
  98836. /**
  98837. * Gets the class name of the current intput.
  98838. * @returns the class name
  98839. */
  98840. getClassName(): string;
  98841. /**
  98842. * Get the friendly name associated with the input class.
  98843. * @returns the input friendly name
  98844. */
  98845. getSimpleName(): string;
  98846. }
  98847. }
  98848. declare module BABYLON {
  98849. /**
  98850. * Listen to mouse events to control the camera.
  98851. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98852. */
  98853. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  98854. /**
  98855. * Defines the camera the input is attached to.
  98856. */
  98857. camera: FlyCamera;
  98858. /**
  98859. * Defines if touch is enabled. (Default is true.)
  98860. */
  98861. touchEnabled: boolean;
  98862. /**
  98863. * Defines the buttons associated with the input to handle camera rotation.
  98864. */
  98865. buttons: number[];
  98866. /**
  98867. * Assign buttons for Yaw control.
  98868. */
  98869. buttonsYaw: number[];
  98870. /**
  98871. * Assign buttons for Pitch control.
  98872. */
  98873. buttonsPitch: number[];
  98874. /**
  98875. * Assign buttons for Roll control.
  98876. */
  98877. buttonsRoll: number[];
  98878. /**
  98879. * Detect if any button is being pressed while mouse is moved.
  98880. * -1 = Mouse locked.
  98881. * 0 = Left button.
  98882. * 1 = Middle Button.
  98883. * 2 = Right Button.
  98884. */
  98885. activeButton: number;
  98886. /**
  98887. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  98888. * Higher values reduce its sensitivity.
  98889. */
  98890. angularSensibility: number;
  98891. private _mousemoveCallback;
  98892. private _observer;
  98893. private _rollObserver;
  98894. private previousPosition;
  98895. private noPreventDefault;
  98896. private element;
  98897. /**
  98898. * Listen to mouse events to control the camera.
  98899. * @param touchEnabled Define if touch is enabled. (Default is true.)
  98900. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98901. */
  98902. constructor(touchEnabled?: boolean);
  98903. /**
  98904. * Attach the mouse control to the HTML DOM element.
  98905. * @param element Defines the element that listens to the input events.
  98906. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  98907. */
  98908. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98909. /**
  98910. * Detach the current controls from the specified dom element.
  98911. * @param element Defines the element to stop listening the inputs from
  98912. */
  98913. detachControl(element: Nullable<HTMLElement>): void;
  98914. /**
  98915. * Gets the class name of the current input.
  98916. * @returns the class name.
  98917. */
  98918. getClassName(): string;
  98919. /**
  98920. * Get the friendly name associated with the input class.
  98921. * @returns the input's friendly name.
  98922. */
  98923. getSimpleName(): string;
  98924. private _pointerInput;
  98925. private _onMouseMove;
  98926. /**
  98927. * Rotate camera by mouse offset.
  98928. */
  98929. private rotateCamera;
  98930. }
  98931. }
  98932. declare module BABYLON {
  98933. /**
  98934. * Default Inputs manager for the FlyCamera.
  98935. * It groups all the default supported inputs for ease of use.
  98936. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98937. */
  98938. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  98939. /**
  98940. * Instantiates a new FlyCameraInputsManager.
  98941. * @param camera Defines the camera the inputs belong to.
  98942. */
  98943. constructor(camera: FlyCamera);
  98944. /**
  98945. * Add keyboard input support to the input manager.
  98946. * @returns the new FlyCameraKeyboardMoveInput().
  98947. */
  98948. addKeyboard(): FlyCameraInputsManager;
  98949. /**
  98950. * Add mouse input support to the input manager.
  98951. * @param touchEnabled Enable touch screen support.
  98952. * @returns the new FlyCameraMouseInput().
  98953. */
  98954. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  98955. }
  98956. }
  98957. declare module BABYLON {
  98958. /**
  98959. * This is a flying camera, designed for 3D movement and rotation in all directions,
  98960. * such as in a 3D Space Shooter or a Flight Simulator.
  98961. */
  98962. export class FlyCamera extends TargetCamera {
  98963. /**
  98964. * Define the collision ellipsoid of the camera.
  98965. * This is helpful for simulating a camera body, like a player's body.
  98966. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  98967. */
  98968. ellipsoid: Vector3;
  98969. /**
  98970. * Define an offset for the position of the ellipsoid around the camera.
  98971. * This can be helpful if the camera is attached away from the player's body center,
  98972. * such as at its head.
  98973. */
  98974. ellipsoidOffset: Vector3;
  98975. /**
  98976. * Enable or disable collisions of the camera with the rest of the scene objects.
  98977. */
  98978. checkCollisions: boolean;
  98979. /**
  98980. * Enable or disable gravity on the camera.
  98981. */
  98982. applyGravity: boolean;
  98983. /**
  98984. * Define the current direction the camera is moving to.
  98985. */
  98986. cameraDirection: Vector3;
  98987. /**
  98988. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  98989. * This overrides and empties cameraRotation.
  98990. */
  98991. rotationQuaternion: Quaternion;
  98992. /**
  98993. * Track Roll to maintain the wanted Rolling when looking around.
  98994. */
  98995. _trackRoll: number;
  98996. /**
  98997. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  98998. */
  98999. rollCorrect: number;
  99000. /**
  99001. * Mimic a banked turn, Rolling the camera when Yawing.
  99002. * It's recommended to use rollCorrect = 10 for faster banking correction.
  99003. */
  99004. bankedTurn: boolean;
  99005. /**
  99006. * Limit in radians for how much Roll banking will add. (Default: 90°)
  99007. */
  99008. bankedTurnLimit: number;
  99009. /**
  99010. * Value of 0 disables the banked Roll.
  99011. * Value of 1 is equal to the Yaw angle in radians.
  99012. */
  99013. bankedTurnMultiplier: number;
  99014. /**
  99015. * The inputs manager loads all the input sources, such as keyboard and mouse.
  99016. */
  99017. inputs: FlyCameraInputsManager;
  99018. /**
  99019. * Gets the input sensibility for mouse input.
  99020. * Higher values reduce sensitivity.
  99021. */
  99022. /**
  99023. * Sets the input sensibility for a mouse input.
  99024. * Higher values reduce sensitivity.
  99025. */
  99026. angularSensibility: number;
  99027. /**
  99028. * Get the keys for camera movement forward.
  99029. */
  99030. /**
  99031. * Set the keys for camera movement forward.
  99032. */
  99033. keysForward: number[];
  99034. /**
  99035. * Get the keys for camera movement backward.
  99036. */
  99037. keysBackward: number[];
  99038. /**
  99039. * Get the keys for camera movement up.
  99040. */
  99041. /**
  99042. * Set the keys for camera movement up.
  99043. */
  99044. keysUp: number[];
  99045. /**
  99046. * Get the keys for camera movement down.
  99047. */
  99048. /**
  99049. * Set the keys for camera movement down.
  99050. */
  99051. keysDown: number[];
  99052. /**
  99053. * Get the keys for camera movement left.
  99054. */
  99055. /**
  99056. * Set the keys for camera movement left.
  99057. */
  99058. keysLeft: number[];
  99059. /**
  99060. * Set the keys for camera movement right.
  99061. */
  99062. /**
  99063. * Set the keys for camera movement right.
  99064. */
  99065. keysRight: number[];
  99066. /**
  99067. * Event raised when the camera collides with a mesh in the scene.
  99068. */
  99069. onCollide: (collidedMesh: AbstractMesh) => void;
  99070. private _collider;
  99071. private _needMoveForGravity;
  99072. private _oldPosition;
  99073. private _diffPosition;
  99074. private _newPosition;
  99075. /** @hidden */
  99076. _localDirection: Vector3;
  99077. /** @hidden */
  99078. _transformedDirection: Vector3;
  99079. /**
  99080. * Instantiates a FlyCamera.
  99081. * This is a flying camera, designed for 3D movement and rotation in all directions,
  99082. * such as in a 3D Space Shooter or a Flight Simulator.
  99083. * @param name Define the name of the camera in the scene.
  99084. * @param position Define the starting position of the camera in the scene.
  99085. * @param scene Define the scene the camera belongs to.
  99086. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  99087. */
  99088. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99089. /**
  99090. * Attach a control to the HTML DOM element.
  99091. * @param element Defines the element that listens to the input events.
  99092. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  99093. */
  99094. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99095. /**
  99096. * Detach a control from the HTML DOM element.
  99097. * The camera will stop reacting to that input.
  99098. * @param element Defines the element that listens to the input events.
  99099. */
  99100. detachControl(element: HTMLElement): void;
  99101. private _collisionMask;
  99102. /**
  99103. * Get the mask that the camera ignores in collision events.
  99104. */
  99105. /**
  99106. * Set the mask that the camera ignores in collision events.
  99107. */
  99108. collisionMask: number;
  99109. /** @hidden */
  99110. _collideWithWorld(displacement: Vector3): void;
  99111. /** @hidden */
  99112. private _onCollisionPositionChange;
  99113. /** @hidden */
  99114. _checkInputs(): void;
  99115. /** @hidden */
  99116. _decideIfNeedsToMove(): boolean;
  99117. /** @hidden */
  99118. _updatePosition(): void;
  99119. /**
  99120. * Restore the Roll to its target value at the rate specified.
  99121. * @param rate - Higher means slower restoring.
  99122. * @hidden
  99123. */
  99124. restoreRoll(rate: number): void;
  99125. /**
  99126. * Destroy the camera and release the current resources held by it.
  99127. */
  99128. dispose(): void;
  99129. /**
  99130. * Get the current object class name.
  99131. * @returns the class name.
  99132. */
  99133. getClassName(): string;
  99134. }
  99135. }
  99136. declare module BABYLON {
  99137. /**
  99138. * Listen to keyboard events to control the camera.
  99139. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99140. */
  99141. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  99142. /**
  99143. * Defines the camera the input is attached to.
  99144. */
  99145. camera: FlyCamera;
  99146. /**
  99147. * The list of keyboard keys used to control the forward move of the camera.
  99148. */
  99149. keysForward: number[];
  99150. /**
  99151. * The list of keyboard keys used to control the backward move of the camera.
  99152. */
  99153. keysBackward: number[];
  99154. /**
  99155. * The list of keyboard keys used to control the forward move of the camera.
  99156. */
  99157. keysUp: number[];
  99158. /**
  99159. * The list of keyboard keys used to control the backward move of the camera.
  99160. */
  99161. keysDown: number[];
  99162. /**
  99163. * The list of keyboard keys used to control the right strafe move of the camera.
  99164. */
  99165. keysRight: number[];
  99166. /**
  99167. * The list of keyboard keys used to control the left strafe move of the camera.
  99168. */
  99169. keysLeft: number[];
  99170. private _keys;
  99171. private _onCanvasBlurObserver;
  99172. private _onKeyboardObserver;
  99173. private _engine;
  99174. private _scene;
  99175. /**
  99176. * Attach the input controls to a specific dom element to get the input from.
  99177. * @param element Defines the element the controls should be listened from
  99178. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99179. */
  99180. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99181. /**
  99182. * Detach the current controls from the specified dom element.
  99183. * @param element Defines the element to stop listening the inputs from
  99184. */
  99185. detachControl(element: Nullable<HTMLElement>): void;
  99186. /**
  99187. * Gets the class name of the current intput.
  99188. * @returns the class name
  99189. */
  99190. getClassName(): string;
  99191. /** @hidden */
  99192. _onLostFocus(e: FocusEvent): void;
  99193. /**
  99194. * Get the friendly name associated with the input class.
  99195. * @returns the input friendly name
  99196. */
  99197. getSimpleName(): string;
  99198. /**
  99199. * Update the current camera state depending on the inputs that have been used this frame.
  99200. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99201. */
  99202. checkInputs(): void;
  99203. }
  99204. }
  99205. declare module BABYLON {
  99206. /**
  99207. * Manage the mouse wheel inputs to control a follow camera.
  99208. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99209. */
  99210. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  99211. /**
  99212. * Defines the camera the input is attached to.
  99213. */
  99214. camera: FollowCamera;
  99215. /**
  99216. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  99217. */
  99218. axisControlRadius: boolean;
  99219. /**
  99220. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  99221. */
  99222. axisControlHeight: boolean;
  99223. /**
  99224. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  99225. */
  99226. axisControlRotation: boolean;
  99227. /**
  99228. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  99229. * relation to mouseWheel events.
  99230. */
  99231. wheelPrecision: number;
  99232. /**
  99233. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  99234. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  99235. */
  99236. wheelDeltaPercentage: number;
  99237. private _wheel;
  99238. private _observer;
  99239. /**
  99240. * Attach the input controls to a specific dom element to get the input from.
  99241. * @param element Defines the element the controls should be listened from
  99242. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99243. */
  99244. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99245. /**
  99246. * Detach the current controls from the specified dom element.
  99247. * @param element Defines the element to stop listening the inputs from
  99248. */
  99249. detachControl(element: Nullable<HTMLElement>): void;
  99250. /**
  99251. * Gets the class name of the current intput.
  99252. * @returns the class name
  99253. */
  99254. getClassName(): string;
  99255. /**
  99256. * Get the friendly name associated with the input class.
  99257. * @returns the input friendly name
  99258. */
  99259. getSimpleName(): string;
  99260. }
  99261. }
  99262. declare module BABYLON {
  99263. /**
  99264. * Manage the pointers inputs to control an follow camera.
  99265. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99266. */
  99267. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  99268. /**
  99269. * Defines the camera the input is attached to.
  99270. */
  99271. camera: FollowCamera;
  99272. /**
  99273. * Gets the class name of the current input.
  99274. * @returns the class name
  99275. */
  99276. getClassName(): string;
  99277. /**
  99278. * Defines the pointer angular sensibility along the X axis or how fast is
  99279. * the camera rotating.
  99280. * A negative number will reverse the axis direction.
  99281. */
  99282. angularSensibilityX: number;
  99283. /**
  99284. * Defines the pointer angular sensibility along the Y axis or how fast is
  99285. * the camera rotating.
  99286. * A negative number will reverse the axis direction.
  99287. */
  99288. angularSensibilityY: number;
  99289. /**
  99290. * Defines the pointer pinch precision or how fast is the camera zooming.
  99291. * A negative number will reverse the axis direction.
  99292. */
  99293. pinchPrecision: number;
  99294. /**
  99295. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  99296. * from 0.
  99297. * It defines the percentage of current camera.radius to use as delta when
  99298. * pinch zoom is used.
  99299. */
  99300. pinchDeltaPercentage: number;
  99301. /**
  99302. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  99303. */
  99304. axisXControlRadius: boolean;
  99305. /**
  99306. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  99307. */
  99308. axisXControlHeight: boolean;
  99309. /**
  99310. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  99311. */
  99312. axisXControlRotation: boolean;
  99313. /**
  99314. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  99315. */
  99316. axisYControlRadius: boolean;
  99317. /**
  99318. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  99319. */
  99320. axisYControlHeight: boolean;
  99321. /**
  99322. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  99323. */
  99324. axisYControlRotation: boolean;
  99325. /**
  99326. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  99327. */
  99328. axisPinchControlRadius: boolean;
  99329. /**
  99330. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  99331. */
  99332. axisPinchControlHeight: boolean;
  99333. /**
  99334. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  99335. */
  99336. axisPinchControlRotation: boolean;
  99337. /**
  99338. * Log error messages if basic misconfiguration has occurred.
  99339. */
  99340. warningEnable: boolean;
  99341. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  99342. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  99343. private _warningCounter;
  99344. private _warning;
  99345. }
  99346. }
  99347. declare module BABYLON {
  99348. /**
  99349. * Default Inputs manager for the FollowCamera.
  99350. * It groups all the default supported inputs for ease of use.
  99351. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99352. */
  99353. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  99354. /**
  99355. * Instantiates a new FollowCameraInputsManager.
  99356. * @param camera Defines the camera the inputs belong to
  99357. */
  99358. constructor(camera: FollowCamera);
  99359. /**
  99360. * Add keyboard input support to the input manager.
  99361. * @returns the current input manager
  99362. */
  99363. addKeyboard(): FollowCameraInputsManager;
  99364. /**
  99365. * Add mouse wheel input support to the input manager.
  99366. * @returns the current input manager
  99367. */
  99368. addMouseWheel(): FollowCameraInputsManager;
  99369. /**
  99370. * Add pointers input support to the input manager.
  99371. * @returns the current input manager
  99372. */
  99373. addPointers(): FollowCameraInputsManager;
  99374. /**
  99375. * Add orientation input support to the input manager.
  99376. * @returns the current input manager
  99377. */
  99378. addVRDeviceOrientation(): FollowCameraInputsManager;
  99379. }
  99380. }
  99381. declare module BABYLON {
  99382. /**
  99383. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  99384. * an arc rotate version arcFollowCamera are available.
  99385. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  99386. */
  99387. export class FollowCamera extends TargetCamera {
  99388. /**
  99389. * Distance the follow camera should follow an object at
  99390. */
  99391. radius: number;
  99392. /**
  99393. * Minimum allowed distance of the camera to the axis of rotation
  99394. * (The camera can not get closer).
  99395. * This can help limiting how the Camera is able to move in the scene.
  99396. */
  99397. lowerRadiusLimit: Nullable<number>;
  99398. /**
  99399. * Maximum allowed distance of the camera to the axis of rotation
  99400. * (The camera can not get further).
  99401. * This can help limiting how the Camera is able to move in the scene.
  99402. */
  99403. upperRadiusLimit: Nullable<number>;
  99404. /**
  99405. * Define a rotation offset between the camera and the object it follows
  99406. */
  99407. rotationOffset: number;
  99408. /**
  99409. * Minimum allowed angle to camera position relative to target object.
  99410. * This can help limiting how the Camera is able to move in the scene.
  99411. */
  99412. lowerRotationOffsetLimit: Nullable<number>;
  99413. /**
  99414. * Maximum allowed angle to camera position relative to target object.
  99415. * This can help limiting how the Camera is able to move in the scene.
  99416. */
  99417. upperRotationOffsetLimit: Nullable<number>;
  99418. /**
  99419. * Define a height offset between the camera and the object it follows.
  99420. * It can help following an object from the top (like a car chaing a plane)
  99421. */
  99422. heightOffset: number;
  99423. /**
  99424. * Minimum allowed height of camera position relative to target object.
  99425. * This can help limiting how the Camera is able to move in the scene.
  99426. */
  99427. lowerHeightOffsetLimit: Nullable<number>;
  99428. /**
  99429. * Maximum allowed height of camera position relative to target object.
  99430. * This can help limiting how the Camera is able to move in the scene.
  99431. */
  99432. upperHeightOffsetLimit: Nullable<number>;
  99433. /**
  99434. * Define how fast the camera can accelerate to follow it s target.
  99435. */
  99436. cameraAcceleration: number;
  99437. /**
  99438. * Define the speed limit of the camera following an object.
  99439. */
  99440. maxCameraSpeed: number;
  99441. /**
  99442. * Define the target of the camera.
  99443. */
  99444. lockedTarget: Nullable<AbstractMesh>;
  99445. /**
  99446. * Defines the input associated with the camera.
  99447. */
  99448. inputs: FollowCameraInputsManager;
  99449. /**
  99450. * Instantiates the follow camera.
  99451. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  99452. * @param name Define the name of the camera in the scene
  99453. * @param position Define the position of the camera
  99454. * @param scene Define the scene the camera belong to
  99455. * @param lockedTarget Define the target of the camera
  99456. */
  99457. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  99458. private _follow;
  99459. /**
  99460. * Attached controls to the current camera.
  99461. * @param element Defines the element the controls should be listened from
  99462. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99463. */
  99464. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99465. /**
  99466. * Detach the current controls from the camera.
  99467. * The camera will stop reacting to inputs.
  99468. * @param element Defines the element to stop listening the inputs from
  99469. */
  99470. detachControl(element: HTMLElement): void;
  99471. /** @hidden */
  99472. _checkInputs(): void;
  99473. private _checkLimits;
  99474. /**
  99475. * Gets the camera class name.
  99476. * @returns the class name
  99477. */
  99478. getClassName(): string;
  99479. }
  99480. /**
  99481. * Arc Rotate version of the follow camera.
  99482. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  99483. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  99484. */
  99485. export class ArcFollowCamera extends TargetCamera {
  99486. /** The longitudinal angle of the camera */
  99487. alpha: number;
  99488. /** The latitudinal angle of the camera */
  99489. beta: number;
  99490. /** The radius of the camera from its target */
  99491. radius: number;
  99492. /** Define the camera target (the messh it should follow) */
  99493. target: Nullable<AbstractMesh>;
  99494. private _cartesianCoordinates;
  99495. /**
  99496. * Instantiates a new ArcFollowCamera
  99497. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  99498. * @param name Define the name of the camera
  99499. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  99500. * @param beta Define the rotation angle of the camera around the elevation axis
  99501. * @param radius Define the radius of the camera from its target point
  99502. * @param target Define the target of the camera
  99503. * @param scene Define the scene the camera belongs to
  99504. */
  99505. constructor(name: string,
  99506. /** The longitudinal angle of the camera */
  99507. alpha: number,
  99508. /** The latitudinal angle of the camera */
  99509. beta: number,
  99510. /** The radius of the camera from its target */
  99511. radius: number,
  99512. /** Define the camera target (the messh it should follow) */
  99513. target: Nullable<AbstractMesh>, scene: Scene);
  99514. private _follow;
  99515. /** @hidden */
  99516. _checkInputs(): void;
  99517. /**
  99518. * Returns the class name of the object.
  99519. * It is mostly used internally for serialization purposes.
  99520. */
  99521. getClassName(): string;
  99522. }
  99523. }
  99524. declare module BABYLON {
  99525. /**
  99526. * Manage the keyboard inputs to control the movement of a follow camera.
  99527. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99528. */
  99529. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  99530. /**
  99531. * Defines the camera the input is attached to.
  99532. */
  99533. camera: FollowCamera;
  99534. /**
  99535. * Defines the list of key codes associated with the up action (increase heightOffset)
  99536. */
  99537. keysHeightOffsetIncr: number[];
  99538. /**
  99539. * Defines the list of key codes associated with the down action (decrease heightOffset)
  99540. */
  99541. keysHeightOffsetDecr: number[];
  99542. /**
  99543. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  99544. */
  99545. keysHeightOffsetModifierAlt: boolean;
  99546. /**
  99547. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  99548. */
  99549. keysHeightOffsetModifierCtrl: boolean;
  99550. /**
  99551. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  99552. */
  99553. keysHeightOffsetModifierShift: boolean;
  99554. /**
  99555. * Defines the list of key codes associated with the left action (increase rotationOffset)
  99556. */
  99557. keysRotationOffsetIncr: number[];
  99558. /**
  99559. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  99560. */
  99561. keysRotationOffsetDecr: number[];
  99562. /**
  99563. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  99564. */
  99565. keysRotationOffsetModifierAlt: boolean;
  99566. /**
  99567. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  99568. */
  99569. keysRotationOffsetModifierCtrl: boolean;
  99570. /**
  99571. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  99572. */
  99573. keysRotationOffsetModifierShift: boolean;
  99574. /**
  99575. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  99576. */
  99577. keysRadiusIncr: number[];
  99578. /**
  99579. * Defines the list of key codes associated with the zoom-out action (increase radius)
  99580. */
  99581. keysRadiusDecr: number[];
  99582. /**
  99583. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  99584. */
  99585. keysRadiusModifierAlt: boolean;
  99586. /**
  99587. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  99588. */
  99589. keysRadiusModifierCtrl: boolean;
  99590. /**
  99591. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  99592. */
  99593. keysRadiusModifierShift: boolean;
  99594. /**
  99595. * Defines the rate of change of heightOffset.
  99596. */
  99597. heightSensibility: number;
  99598. /**
  99599. * Defines the rate of change of rotationOffset.
  99600. */
  99601. rotationSensibility: number;
  99602. /**
  99603. * Defines the rate of change of radius.
  99604. */
  99605. radiusSensibility: number;
  99606. private _keys;
  99607. private _ctrlPressed;
  99608. private _altPressed;
  99609. private _shiftPressed;
  99610. private _onCanvasBlurObserver;
  99611. private _onKeyboardObserver;
  99612. private _engine;
  99613. private _scene;
  99614. /**
  99615. * Attach the input controls to a specific dom element to get the input from.
  99616. * @param element Defines the element the controls should be listened from
  99617. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99618. */
  99619. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99620. /**
  99621. * Detach the current controls from the specified dom element.
  99622. * @param element Defines the element to stop listening the inputs from
  99623. */
  99624. detachControl(element: Nullable<HTMLElement>): void;
  99625. /**
  99626. * Update the current camera state depending on the inputs that have been used this frame.
  99627. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99628. */
  99629. checkInputs(): void;
  99630. /**
  99631. * Gets the class name of the current input.
  99632. * @returns the class name
  99633. */
  99634. getClassName(): string;
  99635. /**
  99636. * Get the friendly name associated with the input class.
  99637. * @returns the input friendly name
  99638. */
  99639. getSimpleName(): string;
  99640. /**
  99641. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  99642. * allow modification of the heightOffset value.
  99643. */
  99644. private _modifierHeightOffset;
  99645. /**
  99646. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  99647. * allow modification of the rotationOffset value.
  99648. */
  99649. private _modifierRotationOffset;
  99650. /**
  99651. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  99652. * allow modification of the radius value.
  99653. */
  99654. private _modifierRadius;
  99655. }
  99656. }
  99657. declare module BABYLON {
  99658. interface FreeCameraInputsManager {
  99659. /**
  99660. * @hidden
  99661. */
  99662. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  99663. /**
  99664. * Add orientation input support to the input manager.
  99665. * @returns the current input manager
  99666. */
  99667. addDeviceOrientation(): FreeCameraInputsManager;
  99668. }
  99669. /**
  99670. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  99671. * Screen rotation is taken into account.
  99672. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99673. */
  99674. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  99675. private _camera;
  99676. private _screenOrientationAngle;
  99677. private _constantTranform;
  99678. private _screenQuaternion;
  99679. private _alpha;
  99680. private _beta;
  99681. private _gamma;
  99682. /**
  99683. * @hidden
  99684. */
  99685. _onDeviceOrientationChangedObservable: Observable<void>;
  99686. /**
  99687. * Instantiates a new input
  99688. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99689. */
  99690. constructor();
  99691. /**
  99692. * Define the camera controlled by the input.
  99693. */
  99694. camera: FreeCamera;
  99695. /**
  99696. * Attach the input controls to a specific dom element to get the input from.
  99697. * @param element Defines the element the controls should be listened from
  99698. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99699. */
  99700. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99701. private _orientationChanged;
  99702. private _deviceOrientation;
  99703. /**
  99704. * Detach the current controls from the specified dom element.
  99705. * @param element Defines the element to stop listening the inputs from
  99706. */
  99707. detachControl(element: Nullable<HTMLElement>): void;
  99708. /**
  99709. * Update the current camera state depending on the inputs that have been used this frame.
  99710. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99711. */
  99712. checkInputs(): void;
  99713. /**
  99714. * Gets the class name of the current intput.
  99715. * @returns the class name
  99716. */
  99717. getClassName(): string;
  99718. /**
  99719. * Get the friendly name associated with the input class.
  99720. * @returns the input friendly name
  99721. */
  99722. getSimpleName(): string;
  99723. }
  99724. }
  99725. declare module BABYLON {
  99726. /**
  99727. * Manage the gamepad inputs to control a free camera.
  99728. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99729. */
  99730. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  99731. /**
  99732. * Define the camera the input is attached to.
  99733. */
  99734. camera: FreeCamera;
  99735. /**
  99736. * Define the Gamepad controlling the input
  99737. */
  99738. gamepad: Nullable<Gamepad>;
  99739. /**
  99740. * Defines the gamepad rotation sensiblity.
  99741. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  99742. */
  99743. gamepadAngularSensibility: number;
  99744. /**
  99745. * Defines the gamepad move sensiblity.
  99746. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  99747. */
  99748. gamepadMoveSensibility: number;
  99749. private _onGamepadConnectedObserver;
  99750. private _onGamepadDisconnectedObserver;
  99751. private _cameraTransform;
  99752. private _deltaTransform;
  99753. private _vector3;
  99754. private _vector2;
  99755. /**
  99756. * Attach the input controls to a specific dom element to get the input from.
  99757. * @param element Defines the element the controls should be listened from
  99758. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99759. */
  99760. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99761. /**
  99762. * Detach the current controls from the specified dom element.
  99763. * @param element Defines the element to stop listening the inputs from
  99764. */
  99765. detachControl(element: Nullable<HTMLElement>): void;
  99766. /**
  99767. * Update the current camera state depending on the inputs that have been used this frame.
  99768. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99769. */
  99770. checkInputs(): void;
  99771. /**
  99772. * Gets the class name of the current intput.
  99773. * @returns the class name
  99774. */
  99775. getClassName(): string;
  99776. /**
  99777. * Get the friendly name associated with the input class.
  99778. * @returns the input friendly name
  99779. */
  99780. getSimpleName(): string;
  99781. }
  99782. }
  99783. declare module BABYLON {
  99784. /**
  99785. * Defines the potential axis of a Joystick
  99786. */
  99787. export enum JoystickAxis {
  99788. /** X axis */
  99789. X = 0,
  99790. /** Y axis */
  99791. Y = 1,
  99792. /** Z axis */
  99793. Z = 2
  99794. }
  99795. /**
  99796. * Class used to define virtual joystick (used in touch mode)
  99797. */
  99798. export class VirtualJoystick {
  99799. /**
  99800. * Gets or sets a boolean indicating that left and right values must be inverted
  99801. */
  99802. reverseLeftRight: boolean;
  99803. /**
  99804. * Gets or sets a boolean indicating that up and down values must be inverted
  99805. */
  99806. reverseUpDown: boolean;
  99807. /**
  99808. * Gets the offset value for the position (ie. the change of the position value)
  99809. */
  99810. deltaPosition: Vector3;
  99811. /**
  99812. * Gets a boolean indicating if the virtual joystick was pressed
  99813. */
  99814. pressed: boolean;
  99815. /**
  99816. * Canvas the virtual joystick will render onto, default z-index of this is 5
  99817. */
  99818. static Canvas: Nullable<HTMLCanvasElement>;
  99819. private static _globalJoystickIndex;
  99820. private static vjCanvasContext;
  99821. private static vjCanvasWidth;
  99822. private static vjCanvasHeight;
  99823. private static halfWidth;
  99824. private _action;
  99825. private _axisTargetedByLeftAndRight;
  99826. private _axisTargetedByUpAndDown;
  99827. private _joystickSensibility;
  99828. private _inversedSensibility;
  99829. private _joystickPointerID;
  99830. private _joystickColor;
  99831. private _joystickPointerPos;
  99832. private _joystickPreviousPointerPos;
  99833. private _joystickPointerStartPos;
  99834. private _deltaJoystickVector;
  99835. private _leftJoystick;
  99836. private _touches;
  99837. private _onPointerDownHandlerRef;
  99838. private _onPointerMoveHandlerRef;
  99839. private _onPointerUpHandlerRef;
  99840. private _onResize;
  99841. /**
  99842. * Creates a new virtual joystick
  99843. * @param leftJoystick defines that the joystick is for left hand (false by default)
  99844. */
  99845. constructor(leftJoystick?: boolean);
  99846. /**
  99847. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  99848. * @param newJoystickSensibility defines the new sensibility
  99849. */
  99850. setJoystickSensibility(newJoystickSensibility: number): void;
  99851. private _onPointerDown;
  99852. private _onPointerMove;
  99853. private _onPointerUp;
  99854. /**
  99855. * Change the color of the virtual joystick
  99856. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  99857. */
  99858. setJoystickColor(newColor: string): void;
  99859. /**
  99860. * Defines a callback to call when the joystick is touched
  99861. * @param action defines the callback
  99862. */
  99863. setActionOnTouch(action: () => any): void;
  99864. /**
  99865. * Defines which axis you'd like to control for left & right
  99866. * @param axis defines the axis to use
  99867. */
  99868. setAxisForLeftRight(axis: JoystickAxis): void;
  99869. /**
  99870. * Defines which axis you'd like to control for up & down
  99871. * @param axis defines the axis to use
  99872. */
  99873. setAxisForUpDown(axis: JoystickAxis): void;
  99874. private _drawVirtualJoystick;
  99875. /**
  99876. * Release internal HTML canvas
  99877. */
  99878. releaseCanvas(): void;
  99879. }
  99880. }
  99881. declare module BABYLON {
  99882. interface FreeCameraInputsManager {
  99883. /**
  99884. * Add virtual joystick input support to the input manager.
  99885. * @returns the current input manager
  99886. */
  99887. addVirtualJoystick(): FreeCameraInputsManager;
  99888. }
  99889. /**
  99890. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  99891. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99892. */
  99893. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  99894. /**
  99895. * Defines the camera the input is attached to.
  99896. */
  99897. camera: FreeCamera;
  99898. private _leftjoystick;
  99899. private _rightjoystick;
  99900. /**
  99901. * Gets the left stick of the virtual joystick.
  99902. * @returns The virtual Joystick
  99903. */
  99904. getLeftJoystick(): VirtualJoystick;
  99905. /**
  99906. * Gets the right stick of the virtual joystick.
  99907. * @returns The virtual Joystick
  99908. */
  99909. getRightJoystick(): VirtualJoystick;
  99910. /**
  99911. * Update the current camera state depending on the inputs that have been used this frame.
  99912. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99913. */
  99914. checkInputs(): void;
  99915. /**
  99916. * Attach the input controls to a specific dom element to get the input from.
  99917. * @param element Defines the element the controls should be listened from
  99918. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99919. */
  99920. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99921. /**
  99922. * Detach the current controls from the specified dom element.
  99923. * @param element Defines the element to stop listening the inputs from
  99924. */
  99925. detachControl(element: Nullable<HTMLElement>): void;
  99926. /**
  99927. * Gets the class name of the current intput.
  99928. * @returns the class name
  99929. */
  99930. getClassName(): string;
  99931. /**
  99932. * Get the friendly name associated with the input class.
  99933. * @returns the input friendly name
  99934. */
  99935. getSimpleName(): string;
  99936. }
  99937. }
  99938. declare module BABYLON {
  99939. /**
  99940. * This represents a FPS type of camera controlled by touch.
  99941. * This is like a universal camera minus the Gamepad controls.
  99942. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  99943. */
  99944. export class TouchCamera extends FreeCamera {
  99945. /**
  99946. * Defines the touch sensibility for rotation.
  99947. * The higher the faster.
  99948. */
  99949. touchAngularSensibility: number;
  99950. /**
  99951. * Defines the touch sensibility for move.
  99952. * The higher the faster.
  99953. */
  99954. touchMoveSensibility: number;
  99955. /**
  99956. * Instantiates a new touch camera.
  99957. * This represents a FPS type of camera controlled by touch.
  99958. * This is like a universal camera minus the Gamepad controls.
  99959. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  99960. * @param name Define the name of the camera in the scene
  99961. * @param position Define the start position of the camera in the scene
  99962. * @param scene Define the scene the camera belongs to
  99963. */
  99964. constructor(name: string, position: Vector3, scene: Scene);
  99965. /**
  99966. * Gets the current object class name.
  99967. * @return the class name
  99968. */
  99969. getClassName(): string;
  99970. /** @hidden */
  99971. _setupInputs(): void;
  99972. }
  99973. }
  99974. declare module BABYLON {
  99975. /**
  99976. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  99977. * being tilted forward or back and left or right.
  99978. */
  99979. export class DeviceOrientationCamera extends FreeCamera {
  99980. private _initialQuaternion;
  99981. private _quaternionCache;
  99982. private _tmpDragQuaternion;
  99983. /**
  99984. * Creates a new device orientation camera
  99985. * @param name The name of the camera
  99986. * @param position The start position camera
  99987. * @param scene The scene the camera belongs to
  99988. */
  99989. constructor(name: string, position: Vector3, scene: Scene);
  99990. /**
  99991. * @hidden
  99992. * Disabled pointer input on first orientation sensor update (Default: true)
  99993. */
  99994. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  99995. private _dragFactor;
  99996. /**
  99997. * Enabled turning on the y axis when the orientation sensor is active
  99998. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  99999. */
  100000. enableHorizontalDragging(dragFactor?: number): void;
  100001. /**
  100002. * Gets the current instance class name ("DeviceOrientationCamera").
  100003. * This helps avoiding instanceof at run time.
  100004. * @returns the class name
  100005. */
  100006. getClassName(): string;
  100007. /**
  100008. * @hidden
  100009. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  100010. */
  100011. _checkInputs(): void;
  100012. /**
  100013. * Reset the camera to its default orientation on the specified axis only.
  100014. * @param axis The axis to reset
  100015. */
  100016. resetToCurrentRotation(axis?: Axis): void;
  100017. }
  100018. }
  100019. declare module BABYLON {
  100020. /**
  100021. * Defines supported buttons for XBox360 compatible gamepads
  100022. */
  100023. export enum Xbox360Button {
  100024. /** A */
  100025. A = 0,
  100026. /** B */
  100027. B = 1,
  100028. /** X */
  100029. X = 2,
  100030. /** Y */
  100031. Y = 3,
  100032. /** Start */
  100033. Start = 4,
  100034. /** Back */
  100035. Back = 5,
  100036. /** Left button */
  100037. LB = 6,
  100038. /** Right button */
  100039. RB = 7,
  100040. /** Left stick */
  100041. LeftStick = 8,
  100042. /** Right stick */
  100043. RightStick = 9
  100044. }
  100045. /** Defines values for XBox360 DPad */
  100046. export enum Xbox360Dpad {
  100047. /** Up */
  100048. Up = 0,
  100049. /** Down */
  100050. Down = 1,
  100051. /** Left */
  100052. Left = 2,
  100053. /** Right */
  100054. Right = 3
  100055. }
  100056. /**
  100057. * Defines a XBox360 gamepad
  100058. */
  100059. export class Xbox360Pad extends Gamepad {
  100060. private _leftTrigger;
  100061. private _rightTrigger;
  100062. private _onlefttriggerchanged;
  100063. private _onrighttriggerchanged;
  100064. private _onbuttondown;
  100065. private _onbuttonup;
  100066. private _ondpaddown;
  100067. private _ondpadup;
  100068. /** Observable raised when a button is pressed */
  100069. onButtonDownObservable: Observable<Xbox360Button>;
  100070. /** Observable raised when a button is released */
  100071. onButtonUpObservable: Observable<Xbox360Button>;
  100072. /** Observable raised when a pad is pressed */
  100073. onPadDownObservable: Observable<Xbox360Dpad>;
  100074. /** Observable raised when a pad is released */
  100075. onPadUpObservable: Observable<Xbox360Dpad>;
  100076. private _buttonA;
  100077. private _buttonB;
  100078. private _buttonX;
  100079. private _buttonY;
  100080. private _buttonBack;
  100081. private _buttonStart;
  100082. private _buttonLB;
  100083. private _buttonRB;
  100084. private _buttonLeftStick;
  100085. private _buttonRightStick;
  100086. private _dPadUp;
  100087. private _dPadDown;
  100088. private _dPadLeft;
  100089. private _dPadRight;
  100090. private _isXboxOnePad;
  100091. /**
  100092. * Creates a new XBox360 gamepad object
  100093. * @param id defines the id of this gamepad
  100094. * @param index defines its index
  100095. * @param gamepad defines the internal HTML gamepad object
  100096. * @param xboxOne defines if it is a XBox One gamepad
  100097. */
  100098. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  100099. /**
  100100. * Defines the callback to call when left trigger is pressed
  100101. * @param callback defines the callback to use
  100102. */
  100103. onlefttriggerchanged(callback: (value: number) => void): void;
  100104. /**
  100105. * Defines the callback to call when right trigger is pressed
  100106. * @param callback defines the callback to use
  100107. */
  100108. onrighttriggerchanged(callback: (value: number) => void): void;
  100109. /**
  100110. * Gets the left trigger value
  100111. */
  100112. /**
  100113. * Sets the left trigger value
  100114. */
  100115. leftTrigger: number;
  100116. /**
  100117. * Gets the right trigger value
  100118. */
  100119. /**
  100120. * Sets the right trigger value
  100121. */
  100122. rightTrigger: number;
  100123. /**
  100124. * Defines the callback to call when a button is pressed
  100125. * @param callback defines the callback to use
  100126. */
  100127. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  100128. /**
  100129. * Defines the callback to call when a button is released
  100130. * @param callback defines the callback to use
  100131. */
  100132. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  100133. /**
  100134. * Defines the callback to call when a pad is pressed
  100135. * @param callback defines the callback to use
  100136. */
  100137. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  100138. /**
  100139. * Defines the callback to call when a pad is released
  100140. * @param callback defines the callback to use
  100141. */
  100142. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  100143. private _setButtonValue;
  100144. private _setDPadValue;
  100145. /**
  100146. * Gets the value of the `A` button
  100147. */
  100148. /**
  100149. * Sets the value of the `A` button
  100150. */
  100151. buttonA: number;
  100152. /**
  100153. * Gets the value of the `B` button
  100154. */
  100155. /**
  100156. * Sets the value of the `B` button
  100157. */
  100158. buttonB: number;
  100159. /**
  100160. * Gets the value of the `X` button
  100161. */
  100162. /**
  100163. * Sets the value of the `X` button
  100164. */
  100165. buttonX: number;
  100166. /**
  100167. * Gets the value of the `Y` button
  100168. */
  100169. /**
  100170. * Sets the value of the `Y` button
  100171. */
  100172. buttonY: number;
  100173. /**
  100174. * Gets the value of the `Start` button
  100175. */
  100176. /**
  100177. * Sets the value of the `Start` button
  100178. */
  100179. buttonStart: number;
  100180. /**
  100181. * Gets the value of the `Back` button
  100182. */
  100183. /**
  100184. * Sets the value of the `Back` button
  100185. */
  100186. buttonBack: number;
  100187. /**
  100188. * Gets the value of the `Left` button
  100189. */
  100190. /**
  100191. * Sets the value of the `Left` button
  100192. */
  100193. buttonLB: number;
  100194. /**
  100195. * Gets the value of the `Right` button
  100196. */
  100197. /**
  100198. * Sets the value of the `Right` button
  100199. */
  100200. buttonRB: number;
  100201. /**
  100202. * Gets the value of the Left joystick
  100203. */
  100204. /**
  100205. * Sets the value of the Left joystick
  100206. */
  100207. buttonLeftStick: number;
  100208. /**
  100209. * Gets the value of the Right joystick
  100210. */
  100211. /**
  100212. * Sets the value of the Right joystick
  100213. */
  100214. buttonRightStick: number;
  100215. /**
  100216. * Gets the value of D-pad up
  100217. */
  100218. /**
  100219. * Sets the value of D-pad up
  100220. */
  100221. dPadUp: number;
  100222. /**
  100223. * Gets the value of D-pad down
  100224. */
  100225. /**
  100226. * Sets the value of D-pad down
  100227. */
  100228. dPadDown: number;
  100229. /**
  100230. * Gets the value of D-pad left
  100231. */
  100232. /**
  100233. * Sets the value of D-pad left
  100234. */
  100235. dPadLeft: number;
  100236. /**
  100237. * Gets the value of D-pad right
  100238. */
  100239. /**
  100240. * Sets the value of D-pad right
  100241. */
  100242. dPadRight: number;
  100243. /**
  100244. * Force the gamepad to synchronize with device values
  100245. */
  100246. update(): void;
  100247. /**
  100248. * Disposes the gamepad
  100249. */
  100250. dispose(): void;
  100251. }
  100252. }
  100253. declare module BABYLON {
  100254. /**
  100255. * Manager for handling gamepads
  100256. */
  100257. export class GamepadManager {
  100258. private _scene?;
  100259. private _babylonGamepads;
  100260. private _oneGamepadConnected;
  100261. /** @hidden */
  100262. _isMonitoring: boolean;
  100263. private _gamepadEventSupported;
  100264. private _gamepadSupport;
  100265. /**
  100266. * observable to be triggered when the gamepad controller has been connected
  100267. */
  100268. onGamepadConnectedObservable: Observable<Gamepad>;
  100269. /**
  100270. * observable to be triggered when the gamepad controller has been disconnected
  100271. */
  100272. onGamepadDisconnectedObservable: Observable<Gamepad>;
  100273. private _onGamepadConnectedEvent;
  100274. private _onGamepadDisconnectedEvent;
  100275. /**
  100276. * Initializes the gamepad manager
  100277. * @param _scene BabylonJS scene
  100278. */
  100279. constructor(_scene?: Scene | undefined);
  100280. /**
  100281. * The gamepads in the game pad manager
  100282. */
  100283. readonly gamepads: Gamepad[];
  100284. /**
  100285. * Get the gamepad controllers based on type
  100286. * @param type The type of gamepad controller
  100287. * @returns Nullable gamepad
  100288. */
  100289. getGamepadByType(type?: number): Nullable<Gamepad>;
  100290. /**
  100291. * Disposes the gamepad manager
  100292. */
  100293. dispose(): void;
  100294. private _addNewGamepad;
  100295. private _startMonitoringGamepads;
  100296. private _stopMonitoringGamepads;
  100297. /** @hidden */
  100298. _checkGamepadsStatus(): void;
  100299. private _updateGamepadObjects;
  100300. }
  100301. }
  100302. declare module BABYLON {
  100303. interface Scene {
  100304. /** @hidden */
  100305. _gamepadManager: Nullable<GamepadManager>;
  100306. /**
  100307. * Gets the gamepad manager associated with the scene
  100308. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  100309. */
  100310. gamepadManager: GamepadManager;
  100311. }
  100312. /**
  100313. * Interface representing a free camera inputs manager
  100314. */
  100315. interface FreeCameraInputsManager {
  100316. /**
  100317. * Adds gamepad input support to the FreeCameraInputsManager.
  100318. * @returns the FreeCameraInputsManager
  100319. */
  100320. addGamepad(): FreeCameraInputsManager;
  100321. }
  100322. /**
  100323. * Interface representing an arc rotate camera inputs manager
  100324. */
  100325. interface ArcRotateCameraInputsManager {
  100326. /**
  100327. * Adds gamepad input support to the ArcRotateCamera InputManager.
  100328. * @returns the camera inputs manager
  100329. */
  100330. addGamepad(): ArcRotateCameraInputsManager;
  100331. }
  100332. /**
  100333. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  100334. */
  100335. export class GamepadSystemSceneComponent implements ISceneComponent {
  100336. /**
  100337. * The component name helpfull to identify the component in the list of scene components.
  100338. */
  100339. readonly name: string;
  100340. /**
  100341. * The scene the component belongs to.
  100342. */
  100343. scene: Scene;
  100344. /**
  100345. * Creates a new instance of the component for the given scene
  100346. * @param scene Defines the scene to register the component in
  100347. */
  100348. constructor(scene: Scene);
  100349. /**
  100350. * Registers the component in a given scene
  100351. */
  100352. register(): void;
  100353. /**
  100354. * Rebuilds the elements related to this component in case of
  100355. * context lost for instance.
  100356. */
  100357. rebuild(): void;
  100358. /**
  100359. * Disposes the component and the associated ressources
  100360. */
  100361. dispose(): void;
  100362. private _beforeCameraUpdate;
  100363. }
  100364. }
  100365. declare module BABYLON {
  100366. /**
  100367. * 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,
  100368. * which still works and will still be found in many Playgrounds.
  100369. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100370. */
  100371. export class UniversalCamera extends TouchCamera {
  100372. /**
  100373. * Defines the gamepad rotation sensiblity.
  100374. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  100375. */
  100376. gamepadAngularSensibility: number;
  100377. /**
  100378. * Defines the gamepad move sensiblity.
  100379. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  100380. */
  100381. gamepadMoveSensibility: number;
  100382. /**
  100383. * 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,
  100384. * which still works and will still be found in many Playgrounds.
  100385. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100386. * @param name Define the name of the camera in the scene
  100387. * @param position Define the start position of the camera in the scene
  100388. * @param scene Define the scene the camera belongs to
  100389. */
  100390. constructor(name: string, position: Vector3, scene: Scene);
  100391. /**
  100392. * Gets the current object class name.
  100393. * @return the class name
  100394. */
  100395. getClassName(): string;
  100396. }
  100397. }
  100398. declare module BABYLON {
  100399. /**
  100400. * This represents a FPS type of camera. This is only here for back compat purpose.
  100401. * Please use the UniversalCamera instead as both are identical.
  100402. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100403. */
  100404. export class GamepadCamera extends UniversalCamera {
  100405. /**
  100406. * Instantiates a new Gamepad Camera
  100407. * This represents a FPS type of camera. This is only here for back compat purpose.
  100408. * Please use the UniversalCamera instead as both are identical.
  100409. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100410. * @param name Define the name of the camera in the scene
  100411. * @param position Define the start position of the camera in the scene
  100412. * @param scene Define the scene the camera belongs to
  100413. */
  100414. constructor(name: string, position: Vector3, scene: Scene);
  100415. /**
  100416. * Gets the current object class name.
  100417. * @return the class name
  100418. */
  100419. getClassName(): string;
  100420. }
  100421. }
  100422. declare module BABYLON {
  100423. /** @hidden */
  100424. export var passPixelShader: {
  100425. name: string;
  100426. shader: string;
  100427. };
  100428. }
  100429. declare module BABYLON {
  100430. /** @hidden */
  100431. export var passCubePixelShader: {
  100432. name: string;
  100433. shader: string;
  100434. };
  100435. }
  100436. declare module BABYLON {
  100437. /**
  100438. * PassPostProcess which produces an output the same as it's input
  100439. */
  100440. export class PassPostProcess extends PostProcess {
  100441. /**
  100442. * Creates the PassPostProcess
  100443. * @param name The name of the effect.
  100444. * @param options The required width/height ratio to downsize to before computing the render pass.
  100445. * @param camera The camera to apply the render pass to.
  100446. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100447. * @param engine The engine which the post process will be applied. (default: current engine)
  100448. * @param reusable If the post process can be reused on the same frame. (default: false)
  100449. * @param textureType The type of texture to be used when performing the post processing.
  100450. * @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)
  100451. */
  100452. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  100453. }
  100454. /**
  100455. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  100456. */
  100457. export class PassCubePostProcess extends PostProcess {
  100458. private _face;
  100459. /**
  100460. * Gets or sets the cube face to display.
  100461. * * 0 is +X
  100462. * * 1 is -X
  100463. * * 2 is +Y
  100464. * * 3 is -Y
  100465. * * 4 is +Z
  100466. * * 5 is -Z
  100467. */
  100468. face: number;
  100469. /**
  100470. * Creates the PassCubePostProcess
  100471. * @param name The name of the effect.
  100472. * @param options The required width/height ratio to downsize to before computing the render pass.
  100473. * @param camera The camera to apply the render pass to.
  100474. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100475. * @param engine The engine which the post process will be applied. (default: current engine)
  100476. * @param reusable If the post process can be reused on the same frame. (default: false)
  100477. * @param textureType The type of texture to be used when performing the post processing.
  100478. * @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)
  100479. */
  100480. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  100481. }
  100482. }
  100483. declare module BABYLON {
  100484. /** @hidden */
  100485. export var anaglyphPixelShader: {
  100486. name: string;
  100487. shader: string;
  100488. };
  100489. }
  100490. declare module BABYLON {
  100491. /**
  100492. * Postprocess used to generate anaglyphic rendering
  100493. */
  100494. export class AnaglyphPostProcess extends PostProcess {
  100495. private _passedProcess;
  100496. /**
  100497. * Creates a new AnaglyphPostProcess
  100498. * @param name defines postprocess name
  100499. * @param options defines creation options or target ratio scale
  100500. * @param rigCameras defines cameras using this postprocess
  100501. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  100502. * @param engine defines hosting engine
  100503. * @param reusable defines if the postprocess will be reused multiple times per frame
  100504. */
  100505. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  100506. }
  100507. }
  100508. declare module BABYLON {
  100509. /**
  100510. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  100511. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  100512. */
  100513. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  100514. /**
  100515. * Creates a new AnaglyphArcRotateCamera
  100516. * @param name defines camera name
  100517. * @param alpha defines alpha angle (in radians)
  100518. * @param beta defines beta angle (in radians)
  100519. * @param radius defines radius
  100520. * @param target defines camera target
  100521. * @param interaxialDistance defines distance between each color axis
  100522. * @param scene defines the hosting scene
  100523. */
  100524. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  100525. /**
  100526. * Gets camera class name
  100527. * @returns AnaglyphArcRotateCamera
  100528. */
  100529. getClassName(): string;
  100530. }
  100531. }
  100532. declare module BABYLON {
  100533. /**
  100534. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  100535. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  100536. */
  100537. export class AnaglyphFreeCamera extends FreeCamera {
  100538. /**
  100539. * Creates a new AnaglyphFreeCamera
  100540. * @param name defines camera name
  100541. * @param position defines initial position
  100542. * @param interaxialDistance defines distance between each color axis
  100543. * @param scene defines the hosting scene
  100544. */
  100545. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  100546. /**
  100547. * Gets camera class name
  100548. * @returns AnaglyphFreeCamera
  100549. */
  100550. getClassName(): string;
  100551. }
  100552. }
  100553. declare module BABYLON {
  100554. /**
  100555. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  100556. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  100557. */
  100558. export class AnaglyphGamepadCamera extends GamepadCamera {
  100559. /**
  100560. * Creates a new AnaglyphGamepadCamera
  100561. * @param name defines camera name
  100562. * @param position defines initial position
  100563. * @param interaxialDistance defines distance between each color axis
  100564. * @param scene defines the hosting scene
  100565. */
  100566. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  100567. /**
  100568. * Gets camera class name
  100569. * @returns AnaglyphGamepadCamera
  100570. */
  100571. getClassName(): string;
  100572. }
  100573. }
  100574. declare module BABYLON {
  100575. /**
  100576. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  100577. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  100578. */
  100579. export class AnaglyphUniversalCamera extends UniversalCamera {
  100580. /**
  100581. * Creates a new AnaglyphUniversalCamera
  100582. * @param name defines camera name
  100583. * @param position defines initial position
  100584. * @param interaxialDistance defines distance between each color axis
  100585. * @param scene defines the hosting scene
  100586. */
  100587. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  100588. /**
  100589. * Gets camera class name
  100590. * @returns AnaglyphUniversalCamera
  100591. */
  100592. getClassName(): string;
  100593. }
  100594. }
  100595. declare module BABYLON {
  100596. /** @hidden */
  100597. export var stereoscopicInterlacePixelShader: {
  100598. name: string;
  100599. shader: string;
  100600. };
  100601. }
  100602. declare module BABYLON {
  100603. /**
  100604. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  100605. */
  100606. export class StereoscopicInterlacePostProcess extends PostProcess {
  100607. private _stepSize;
  100608. private _passedProcess;
  100609. /**
  100610. * Initializes a StereoscopicInterlacePostProcess
  100611. * @param name The name of the effect.
  100612. * @param rigCameras The rig cameras to be appled to the post process
  100613. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  100614. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100615. * @param engine The engine which the post process will be applied. (default: current engine)
  100616. * @param reusable If the post process can be reused on the same frame. (default: false)
  100617. */
  100618. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  100619. }
  100620. }
  100621. declare module BABYLON {
  100622. /**
  100623. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  100624. * @see http://doc.babylonjs.com/features/cameras
  100625. */
  100626. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  100627. /**
  100628. * Creates a new StereoscopicArcRotateCamera
  100629. * @param name defines camera name
  100630. * @param alpha defines alpha angle (in radians)
  100631. * @param beta defines beta angle (in radians)
  100632. * @param radius defines radius
  100633. * @param target defines camera target
  100634. * @param interaxialDistance defines distance between each color axis
  100635. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  100636. * @param scene defines the hosting scene
  100637. */
  100638. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  100639. /**
  100640. * Gets camera class name
  100641. * @returns StereoscopicArcRotateCamera
  100642. */
  100643. getClassName(): string;
  100644. }
  100645. }
  100646. declare module BABYLON {
  100647. /**
  100648. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  100649. * @see http://doc.babylonjs.com/features/cameras
  100650. */
  100651. export class StereoscopicFreeCamera extends FreeCamera {
  100652. /**
  100653. * Creates a new StereoscopicFreeCamera
  100654. * @param name defines camera name
  100655. * @param position defines initial position
  100656. * @param interaxialDistance defines distance between each color axis
  100657. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  100658. * @param scene defines the hosting scene
  100659. */
  100660. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  100661. /**
  100662. * Gets camera class name
  100663. * @returns StereoscopicFreeCamera
  100664. */
  100665. getClassName(): string;
  100666. }
  100667. }
  100668. declare module BABYLON {
  100669. /**
  100670. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  100671. * @see http://doc.babylonjs.com/features/cameras
  100672. */
  100673. export class StereoscopicGamepadCamera extends GamepadCamera {
  100674. /**
  100675. * Creates a new StereoscopicGamepadCamera
  100676. * @param name defines camera name
  100677. * @param position defines initial position
  100678. * @param interaxialDistance defines distance between each color axis
  100679. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  100680. * @param scene defines the hosting scene
  100681. */
  100682. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  100683. /**
  100684. * Gets camera class name
  100685. * @returns StereoscopicGamepadCamera
  100686. */
  100687. getClassName(): string;
  100688. }
  100689. }
  100690. declare module BABYLON {
  100691. /**
  100692. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  100693. * @see http://doc.babylonjs.com/features/cameras
  100694. */
  100695. export class StereoscopicUniversalCamera extends UniversalCamera {
  100696. /**
  100697. * Creates a new StereoscopicUniversalCamera
  100698. * @param name defines camera name
  100699. * @param position defines initial position
  100700. * @param interaxialDistance defines distance between each color axis
  100701. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  100702. * @param scene defines the hosting scene
  100703. */
  100704. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  100705. /**
  100706. * Gets camera class name
  100707. * @returns StereoscopicUniversalCamera
  100708. */
  100709. getClassName(): string;
  100710. }
  100711. }
  100712. declare module BABYLON {
  100713. /**
  100714. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  100715. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  100716. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  100717. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  100718. */
  100719. export class VirtualJoysticksCamera extends FreeCamera {
  100720. /**
  100721. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  100722. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  100723. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  100724. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  100725. * @param name Define the name of the camera in the scene
  100726. * @param position Define the start position of the camera in the scene
  100727. * @param scene Define the scene the camera belongs to
  100728. */
  100729. constructor(name: string, position: Vector3, scene: Scene);
  100730. /**
  100731. * Gets the current object class name.
  100732. * @return the class name
  100733. */
  100734. getClassName(): string;
  100735. }
  100736. }
  100737. declare module BABYLON {
  100738. /**
  100739. * This represents all the required metrics to create a VR camera.
  100740. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  100741. */
  100742. export class VRCameraMetrics {
  100743. /**
  100744. * Define the horizontal resolution off the screen.
  100745. */
  100746. hResolution: number;
  100747. /**
  100748. * Define the vertical resolution off the screen.
  100749. */
  100750. vResolution: number;
  100751. /**
  100752. * Define the horizontal screen size.
  100753. */
  100754. hScreenSize: number;
  100755. /**
  100756. * Define the vertical screen size.
  100757. */
  100758. vScreenSize: number;
  100759. /**
  100760. * Define the vertical screen center position.
  100761. */
  100762. vScreenCenter: number;
  100763. /**
  100764. * Define the distance of the eyes to the screen.
  100765. */
  100766. eyeToScreenDistance: number;
  100767. /**
  100768. * Define the distance between both lenses
  100769. */
  100770. lensSeparationDistance: number;
  100771. /**
  100772. * Define the distance between both viewer's eyes.
  100773. */
  100774. interpupillaryDistance: number;
  100775. /**
  100776. * Define the distortion factor of the VR postprocess.
  100777. * Please, touch with care.
  100778. */
  100779. distortionK: number[];
  100780. /**
  100781. * Define the chromatic aberration correction factors for the VR post process.
  100782. */
  100783. chromaAbCorrection: number[];
  100784. /**
  100785. * Define the scale factor of the post process.
  100786. * The smaller the better but the slower.
  100787. */
  100788. postProcessScaleFactor: number;
  100789. /**
  100790. * Define an offset for the lens center.
  100791. */
  100792. lensCenterOffset: number;
  100793. /**
  100794. * Define if the current vr camera should compensate the distortion of the lense or not.
  100795. */
  100796. compensateDistortion: boolean;
  100797. /**
  100798. * Defines if multiview should be enabled when rendering (Default: false)
  100799. */
  100800. multiviewEnabled: boolean;
  100801. /**
  100802. * Gets the rendering aspect ratio based on the provided resolutions.
  100803. */
  100804. readonly aspectRatio: number;
  100805. /**
  100806. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  100807. */
  100808. readonly aspectRatioFov: number;
  100809. /**
  100810. * @hidden
  100811. */
  100812. readonly leftHMatrix: Matrix;
  100813. /**
  100814. * @hidden
  100815. */
  100816. readonly rightHMatrix: Matrix;
  100817. /**
  100818. * @hidden
  100819. */
  100820. readonly leftPreViewMatrix: Matrix;
  100821. /**
  100822. * @hidden
  100823. */
  100824. readonly rightPreViewMatrix: Matrix;
  100825. /**
  100826. * Get the default VRMetrics based on the most generic setup.
  100827. * @returns the default vr metrics
  100828. */
  100829. static GetDefault(): VRCameraMetrics;
  100830. }
  100831. }
  100832. declare module BABYLON {
  100833. /** @hidden */
  100834. export var vrDistortionCorrectionPixelShader: {
  100835. name: string;
  100836. shader: string;
  100837. };
  100838. }
  100839. declare module BABYLON {
  100840. /**
  100841. * VRDistortionCorrectionPostProcess used for mobile VR
  100842. */
  100843. export class VRDistortionCorrectionPostProcess extends PostProcess {
  100844. private _isRightEye;
  100845. private _distortionFactors;
  100846. private _postProcessScaleFactor;
  100847. private _lensCenterOffset;
  100848. private _scaleIn;
  100849. private _scaleFactor;
  100850. private _lensCenter;
  100851. /**
  100852. * Initializes the VRDistortionCorrectionPostProcess
  100853. * @param name The name of the effect.
  100854. * @param camera The camera to apply the render pass to.
  100855. * @param isRightEye If this is for the right eye distortion
  100856. * @param vrMetrics All the required metrics for the VR camera
  100857. */
  100858. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  100859. }
  100860. }
  100861. declare module BABYLON {
  100862. /**
  100863. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  100864. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  100865. */
  100866. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  100867. /**
  100868. * Creates a new VRDeviceOrientationArcRotateCamera
  100869. * @param name defines camera name
  100870. * @param alpha defines the camera rotation along the logitudinal axis
  100871. * @param beta defines the camera rotation along the latitudinal axis
  100872. * @param radius defines the camera distance from its target
  100873. * @param target defines the camera target
  100874. * @param scene defines the scene the camera belongs to
  100875. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  100876. * @param vrCameraMetrics defines the vr metrics associated to the camera
  100877. */
  100878. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  100879. /**
  100880. * Gets camera class name
  100881. * @returns VRDeviceOrientationArcRotateCamera
  100882. */
  100883. getClassName(): string;
  100884. }
  100885. }
  100886. declare module BABYLON {
  100887. /**
  100888. * Camera used to simulate VR rendering (based on FreeCamera)
  100889. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  100890. */
  100891. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  100892. /**
  100893. * Creates a new VRDeviceOrientationFreeCamera
  100894. * @param name defines camera name
  100895. * @param position defines the start position of the camera
  100896. * @param scene defines the scene the camera belongs to
  100897. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  100898. * @param vrCameraMetrics defines the vr metrics associated to the camera
  100899. */
  100900. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  100901. /**
  100902. * Gets camera class name
  100903. * @returns VRDeviceOrientationFreeCamera
  100904. */
  100905. getClassName(): string;
  100906. }
  100907. }
  100908. declare module BABYLON {
  100909. /**
  100910. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  100911. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  100912. */
  100913. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  100914. /**
  100915. * Creates a new VRDeviceOrientationGamepadCamera
  100916. * @param name defines camera name
  100917. * @param position defines the start position of the camera
  100918. * @param scene defines the scene the camera belongs to
  100919. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  100920. * @param vrCameraMetrics defines the vr metrics associated to the camera
  100921. */
  100922. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  100923. /**
  100924. * Gets camera class name
  100925. * @returns VRDeviceOrientationGamepadCamera
  100926. */
  100927. getClassName(): string;
  100928. }
  100929. }
  100930. declare module BABYLON {
  100931. /**
  100932. * Base class of materials working in push mode in babylon JS
  100933. * @hidden
  100934. */
  100935. export class PushMaterial extends Material {
  100936. protected _activeEffect: Effect;
  100937. protected _normalMatrix: Matrix;
  100938. /**
  100939. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  100940. * This means that the material can keep using a previous shader while a new one is being compiled.
  100941. * This is mostly used when shader parallel compilation is supported (true by default)
  100942. */
  100943. allowShaderHotSwapping: boolean;
  100944. constructor(name: string, scene: Scene);
  100945. getEffect(): Effect;
  100946. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  100947. /**
  100948. * Binds the given world matrix to the active effect
  100949. *
  100950. * @param world the matrix to bind
  100951. */
  100952. bindOnlyWorldMatrix(world: Matrix): void;
  100953. /**
  100954. * Binds the given normal matrix to the active effect
  100955. *
  100956. * @param normalMatrix the matrix to bind
  100957. */
  100958. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  100959. bind(world: Matrix, mesh?: Mesh): void;
  100960. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  100961. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  100962. }
  100963. }
  100964. declare module BABYLON {
  100965. /**
  100966. * This groups all the flags used to control the materials channel.
  100967. */
  100968. export class MaterialFlags {
  100969. private static _DiffuseTextureEnabled;
  100970. /**
  100971. * Are diffuse textures enabled in the application.
  100972. */
  100973. static DiffuseTextureEnabled: boolean;
  100974. private static _AmbientTextureEnabled;
  100975. /**
  100976. * Are ambient textures enabled in the application.
  100977. */
  100978. static AmbientTextureEnabled: boolean;
  100979. private static _OpacityTextureEnabled;
  100980. /**
  100981. * Are opacity textures enabled in the application.
  100982. */
  100983. static OpacityTextureEnabled: boolean;
  100984. private static _ReflectionTextureEnabled;
  100985. /**
  100986. * Are reflection textures enabled in the application.
  100987. */
  100988. static ReflectionTextureEnabled: boolean;
  100989. private static _EmissiveTextureEnabled;
  100990. /**
  100991. * Are emissive textures enabled in the application.
  100992. */
  100993. static EmissiveTextureEnabled: boolean;
  100994. private static _SpecularTextureEnabled;
  100995. /**
  100996. * Are specular textures enabled in the application.
  100997. */
  100998. static SpecularTextureEnabled: boolean;
  100999. private static _BumpTextureEnabled;
  101000. /**
  101001. * Are bump textures enabled in the application.
  101002. */
  101003. static BumpTextureEnabled: boolean;
  101004. private static _LightmapTextureEnabled;
  101005. /**
  101006. * Are lightmap textures enabled in the application.
  101007. */
  101008. static LightmapTextureEnabled: boolean;
  101009. private static _RefractionTextureEnabled;
  101010. /**
  101011. * Are refraction textures enabled in the application.
  101012. */
  101013. static RefractionTextureEnabled: boolean;
  101014. private static _ColorGradingTextureEnabled;
  101015. /**
  101016. * Are color grading textures enabled in the application.
  101017. */
  101018. static ColorGradingTextureEnabled: boolean;
  101019. private static _FresnelEnabled;
  101020. /**
  101021. * Are fresnels enabled in the application.
  101022. */
  101023. static FresnelEnabled: boolean;
  101024. private static _ClearCoatTextureEnabled;
  101025. /**
  101026. * Are clear coat textures enabled in the application.
  101027. */
  101028. static ClearCoatTextureEnabled: boolean;
  101029. private static _ClearCoatBumpTextureEnabled;
  101030. /**
  101031. * Are clear coat bump textures enabled in the application.
  101032. */
  101033. static ClearCoatBumpTextureEnabled: boolean;
  101034. private static _ClearCoatTintTextureEnabled;
  101035. /**
  101036. * Are clear coat tint textures enabled in the application.
  101037. */
  101038. static ClearCoatTintTextureEnabled: boolean;
  101039. private static _SheenTextureEnabled;
  101040. /**
  101041. * Are sheen textures enabled in the application.
  101042. */
  101043. static SheenTextureEnabled: boolean;
  101044. private static _AnisotropicTextureEnabled;
  101045. /**
  101046. * Are anisotropic textures enabled in the application.
  101047. */
  101048. static AnisotropicTextureEnabled: boolean;
  101049. private static _ThicknessTextureEnabled;
  101050. /**
  101051. * Are thickness textures enabled in the application.
  101052. */
  101053. static ThicknessTextureEnabled: boolean;
  101054. }
  101055. }
  101056. declare module BABYLON {
  101057. /** @hidden */
  101058. export var defaultFragmentDeclaration: {
  101059. name: string;
  101060. shader: string;
  101061. };
  101062. }
  101063. declare module BABYLON {
  101064. /** @hidden */
  101065. export var defaultUboDeclaration: {
  101066. name: string;
  101067. shader: string;
  101068. };
  101069. }
  101070. declare module BABYLON {
  101071. /** @hidden */
  101072. export var lightFragmentDeclaration: {
  101073. name: string;
  101074. shader: string;
  101075. };
  101076. }
  101077. declare module BABYLON {
  101078. /** @hidden */
  101079. export var lightUboDeclaration: {
  101080. name: string;
  101081. shader: string;
  101082. };
  101083. }
  101084. declare module BABYLON {
  101085. /** @hidden */
  101086. export var lightsFragmentFunctions: {
  101087. name: string;
  101088. shader: string;
  101089. };
  101090. }
  101091. declare module BABYLON {
  101092. /** @hidden */
  101093. export var shadowsFragmentFunctions: {
  101094. name: string;
  101095. shader: string;
  101096. };
  101097. }
  101098. declare module BABYLON {
  101099. /** @hidden */
  101100. export var fresnelFunction: {
  101101. name: string;
  101102. shader: string;
  101103. };
  101104. }
  101105. declare module BABYLON {
  101106. /** @hidden */
  101107. export var reflectionFunction: {
  101108. name: string;
  101109. shader: string;
  101110. };
  101111. }
  101112. declare module BABYLON {
  101113. /** @hidden */
  101114. export var bumpFragmentFunctions: {
  101115. name: string;
  101116. shader: string;
  101117. };
  101118. }
  101119. declare module BABYLON {
  101120. /** @hidden */
  101121. export var logDepthDeclaration: {
  101122. name: string;
  101123. shader: string;
  101124. };
  101125. }
  101126. declare module BABYLON {
  101127. /** @hidden */
  101128. export var bumpFragment: {
  101129. name: string;
  101130. shader: string;
  101131. };
  101132. }
  101133. declare module BABYLON {
  101134. /** @hidden */
  101135. export var depthPrePass: {
  101136. name: string;
  101137. shader: string;
  101138. };
  101139. }
  101140. declare module BABYLON {
  101141. /** @hidden */
  101142. export var lightFragment: {
  101143. name: string;
  101144. shader: string;
  101145. };
  101146. }
  101147. declare module BABYLON {
  101148. /** @hidden */
  101149. export var logDepthFragment: {
  101150. name: string;
  101151. shader: string;
  101152. };
  101153. }
  101154. declare module BABYLON {
  101155. /** @hidden */
  101156. export var defaultPixelShader: {
  101157. name: string;
  101158. shader: string;
  101159. };
  101160. }
  101161. declare module BABYLON {
  101162. /** @hidden */
  101163. export var defaultVertexDeclaration: {
  101164. name: string;
  101165. shader: string;
  101166. };
  101167. }
  101168. declare module BABYLON {
  101169. /** @hidden */
  101170. export var bumpVertexDeclaration: {
  101171. name: string;
  101172. shader: string;
  101173. };
  101174. }
  101175. declare module BABYLON {
  101176. /** @hidden */
  101177. export var bumpVertex: {
  101178. name: string;
  101179. shader: string;
  101180. };
  101181. }
  101182. declare module BABYLON {
  101183. /** @hidden */
  101184. export var fogVertex: {
  101185. name: string;
  101186. shader: string;
  101187. };
  101188. }
  101189. declare module BABYLON {
  101190. /** @hidden */
  101191. export var shadowsVertex: {
  101192. name: string;
  101193. shader: string;
  101194. };
  101195. }
  101196. declare module BABYLON {
  101197. /** @hidden */
  101198. export var pointCloudVertex: {
  101199. name: string;
  101200. shader: string;
  101201. };
  101202. }
  101203. declare module BABYLON {
  101204. /** @hidden */
  101205. export var logDepthVertex: {
  101206. name: string;
  101207. shader: string;
  101208. };
  101209. }
  101210. declare module BABYLON {
  101211. /** @hidden */
  101212. export var defaultVertexShader: {
  101213. name: string;
  101214. shader: string;
  101215. };
  101216. }
  101217. declare module BABYLON {
  101218. /** @hidden */
  101219. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  101220. MAINUV1: boolean;
  101221. MAINUV2: boolean;
  101222. DIFFUSE: boolean;
  101223. DIFFUSEDIRECTUV: number;
  101224. AMBIENT: boolean;
  101225. AMBIENTDIRECTUV: number;
  101226. OPACITY: boolean;
  101227. OPACITYDIRECTUV: number;
  101228. OPACITYRGB: boolean;
  101229. REFLECTION: boolean;
  101230. EMISSIVE: boolean;
  101231. EMISSIVEDIRECTUV: number;
  101232. SPECULAR: boolean;
  101233. SPECULARDIRECTUV: number;
  101234. BUMP: boolean;
  101235. BUMPDIRECTUV: number;
  101236. PARALLAX: boolean;
  101237. PARALLAXOCCLUSION: boolean;
  101238. SPECULAROVERALPHA: boolean;
  101239. CLIPPLANE: boolean;
  101240. CLIPPLANE2: boolean;
  101241. CLIPPLANE3: boolean;
  101242. CLIPPLANE4: boolean;
  101243. ALPHATEST: boolean;
  101244. DEPTHPREPASS: boolean;
  101245. ALPHAFROMDIFFUSE: boolean;
  101246. POINTSIZE: boolean;
  101247. FOG: boolean;
  101248. SPECULARTERM: boolean;
  101249. DIFFUSEFRESNEL: boolean;
  101250. OPACITYFRESNEL: boolean;
  101251. REFLECTIONFRESNEL: boolean;
  101252. REFRACTIONFRESNEL: boolean;
  101253. EMISSIVEFRESNEL: boolean;
  101254. FRESNEL: boolean;
  101255. NORMAL: boolean;
  101256. UV1: boolean;
  101257. UV2: boolean;
  101258. VERTEXCOLOR: boolean;
  101259. VERTEXALPHA: boolean;
  101260. NUM_BONE_INFLUENCERS: number;
  101261. BonesPerMesh: number;
  101262. BONETEXTURE: boolean;
  101263. INSTANCES: boolean;
  101264. GLOSSINESS: boolean;
  101265. ROUGHNESS: boolean;
  101266. EMISSIVEASILLUMINATION: boolean;
  101267. LINKEMISSIVEWITHDIFFUSE: boolean;
  101268. REFLECTIONFRESNELFROMSPECULAR: boolean;
  101269. LIGHTMAP: boolean;
  101270. LIGHTMAPDIRECTUV: number;
  101271. OBJECTSPACE_NORMALMAP: boolean;
  101272. USELIGHTMAPASSHADOWMAP: boolean;
  101273. REFLECTIONMAP_3D: boolean;
  101274. REFLECTIONMAP_SPHERICAL: boolean;
  101275. REFLECTIONMAP_PLANAR: boolean;
  101276. REFLECTIONMAP_CUBIC: boolean;
  101277. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  101278. REFLECTIONMAP_PROJECTION: boolean;
  101279. REFLECTIONMAP_SKYBOX: boolean;
  101280. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  101281. REFLECTIONMAP_EXPLICIT: boolean;
  101282. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  101283. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  101284. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  101285. INVERTCUBICMAP: boolean;
  101286. LOGARITHMICDEPTH: boolean;
  101287. REFRACTION: boolean;
  101288. REFRACTIONMAP_3D: boolean;
  101289. REFLECTIONOVERALPHA: boolean;
  101290. TWOSIDEDLIGHTING: boolean;
  101291. SHADOWFLOAT: boolean;
  101292. MORPHTARGETS: boolean;
  101293. MORPHTARGETS_NORMAL: boolean;
  101294. MORPHTARGETS_TANGENT: boolean;
  101295. NUM_MORPH_INFLUENCERS: number;
  101296. NONUNIFORMSCALING: boolean;
  101297. PREMULTIPLYALPHA: boolean;
  101298. IMAGEPROCESSING: boolean;
  101299. VIGNETTE: boolean;
  101300. VIGNETTEBLENDMODEMULTIPLY: boolean;
  101301. VIGNETTEBLENDMODEOPAQUE: boolean;
  101302. TONEMAPPING: boolean;
  101303. TONEMAPPING_ACES: boolean;
  101304. CONTRAST: boolean;
  101305. COLORCURVES: boolean;
  101306. COLORGRADING: boolean;
  101307. COLORGRADING3D: boolean;
  101308. SAMPLER3DGREENDEPTH: boolean;
  101309. SAMPLER3DBGRMAP: boolean;
  101310. IMAGEPROCESSINGPOSTPROCESS: boolean;
  101311. MULTIVIEW: boolean;
  101312. /**
  101313. * If the reflection texture on this material is in linear color space
  101314. * @hidden
  101315. */
  101316. IS_REFLECTION_LINEAR: boolean;
  101317. /**
  101318. * If the refraction texture on this material is in linear color space
  101319. * @hidden
  101320. */
  101321. IS_REFRACTION_LINEAR: boolean;
  101322. EXPOSURE: boolean;
  101323. constructor();
  101324. setReflectionMode(modeToEnable: string): void;
  101325. }
  101326. /**
  101327. * This is the default material used in Babylon. It is the best trade off between quality
  101328. * and performances.
  101329. * @see http://doc.babylonjs.com/babylon101/materials
  101330. */
  101331. export class StandardMaterial extends PushMaterial {
  101332. private _diffuseTexture;
  101333. /**
  101334. * The basic texture of the material as viewed under a light.
  101335. */
  101336. diffuseTexture: Nullable<BaseTexture>;
  101337. private _ambientTexture;
  101338. /**
  101339. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  101340. */
  101341. ambientTexture: Nullable<BaseTexture>;
  101342. private _opacityTexture;
  101343. /**
  101344. * Define the transparency of the material from a texture.
  101345. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  101346. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  101347. */
  101348. opacityTexture: Nullable<BaseTexture>;
  101349. private _reflectionTexture;
  101350. /**
  101351. * Define the texture used to display the reflection.
  101352. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101353. */
  101354. reflectionTexture: Nullable<BaseTexture>;
  101355. private _emissiveTexture;
  101356. /**
  101357. * Define texture of the material as if self lit.
  101358. * This will be mixed in the final result even in the absence of light.
  101359. */
  101360. emissiveTexture: Nullable<BaseTexture>;
  101361. private _specularTexture;
  101362. /**
  101363. * Define how the color and intensity of the highlight given by the light in the material.
  101364. */
  101365. specularTexture: Nullable<BaseTexture>;
  101366. private _bumpTexture;
  101367. /**
  101368. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  101369. * 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.
  101370. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  101371. */
  101372. bumpTexture: Nullable<BaseTexture>;
  101373. private _lightmapTexture;
  101374. /**
  101375. * Complex lighting can be computationally expensive to compute at runtime.
  101376. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  101377. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  101378. */
  101379. lightmapTexture: Nullable<BaseTexture>;
  101380. private _refractionTexture;
  101381. /**
  101382. * Define the texture used to display the refraction.
  101383. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101384. */
  101385. refractionTexture: Nullable<BaseTexture>;
  101386. /**
  101387. * The color of the material lit by the environmental background lighting.
  101388. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  101389. */
  101390. ambientColor: Color3;
  101391. /**
  101392. * The basic color of the material as viewed under a light.
  101393. */
  101394. diffuseColor: Color3;
  101395. /**
  101396. * Define how the color and intensity of the highlight given by the light in the material.
  101397. */
  101398. specularColor: Color3;
  101399. /**
  101400. * Define the color of the material as if self lit.
  101401. * This will be mixed in the final result even in the absence of light.
  101402. */
  101403. emissiveColor: Color3;
  101404. /**
  101405. * Defines how sharp are the highlights in the material.
  101406. * The bigger the value the sharper giving a more glossy feeling to the result.
  101407. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  101408. */
  101409. specularPower: number;
  101410. private _useAlphaFromDiffuseTexture;
  101411. /**
  101412. * Does the transparency come from the diffuse texture alpha channel.
  101413. */
  101414. useAlphaFromDiffuseTexture: boolean;
  101415. private _useEmissiveAsIllumination;
  101416. /**
  101417. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  101418. */
  101419. useEmissiveAsIllumination: boolean;
  101420. private _linkEmissiveWithDiffuse;
  101421. /**
  101422. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  101423. * the emissive level when the final color is close to one.
  101424. */
  101425. linkEmissiveWithDiffuse: boolean;
  101426. private _useSpecularOverAlpha;
  101427. /**
  101428. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  101429. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  101430. */
  101431. useSpecularOverAlpha: boolean;
  101432. private _useReflectionOverAlpha;
  101433. /**
  101434. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101435. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101436. */
  101437. useReflectionOverAlpha: boolean;
  101438. private _disableLighting;
  101439. /**
  101440. * Does lights from the scene impacts this material.
  101441. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  101442. */
  101443. disableLighting: boolean;
  101444. private _useObjectSpaceNormalMap;
  101445. /**
  101446. * Allows using an object space normal map (instead of tangent space).
  101447. */
  101448. useObjectSpaceNormalMap: boolean;
  101449. private _useParallax;
  101450. /**
  101451. * Is parallax enabled or not.
  101452. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  101453. */
  101454. useParallax: boolean;
  101455. private _useParallaxOcclusion;
  101456. /**
  101457. * Is parallax occlusion enabled or not.
  101458. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  101459. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  101460. */
  101461. useParallaxOcclusion: boolean;
  101462. /**
  101463. * 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.
  101464. */
  101465. parallaxScaleBias: number;
  101466. private _roughness;
  101467. /**
  101468. * Helps to define how blurry the reflections should appears in the material.
  101469. */
  101470. roughness: number;
  101471. /**
  101472. * In case of refraction, define the value of the indice of refraction.
  101473. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101474. */
  101475. indexOfRefraction: number;
  101476. /**
  101477. * Invert the refraction texture alongside the y axis.
  101478. * It can be useful with procedural textures or probe for instance.
  101479. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101480. */
  101481. invertRefractionY: boolean;
  101482. /**
  101483. * Defines the alpha limits in alpha test mode.
  101484. */
  101485. alphaCutOff: number;
  101486. private _useLightmapAsShadowmap;
  101487. /**
  101488. * In case of light mapping, define whether the map contains light or shadow informations.
  101489. */
  101490. useLightmapAsShadowmap: boolean;
  101491. private _diffuseFresnelParameters;
  101492. /**
  101493. * Define the diffuse fresnel parameters of the material.
  101494. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101495. */
  101496. diffuseFresnelParameters: FresnelParameters;
  101497. private _opacityFresnelParameters;
  101498. /**
  101499. * Define the opacity fresnel parameters of the material.
  101500. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101501. */
  101502. opacityFresnelParameters: FresnelParameters;
  101503. private _reflectionFresnelParameters;
  101504. /**
  101505. * Define the reflection fresnel parameters of the material.
  101506. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101507. */
  101508. reflectionFresnelParameters: FresnelParameters;
  101509. private _refractionFresnelParameters;
  101510. /**
  101511. * Define the refraction fresnel parameters of the material.
  101512. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101513. */
  101514. refractionFresnelParameters: FresnelParameters;
  101515. private _emissiveFresnelParameters;
  101516. /**
  101517. * Define the emissive fresnel parameters of the material.
  101518. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101519. */
  101520. emissiveFresnelParameters: FresnelParameters;
  101521. private _useReflectionFresnelFromSpecular;
  101522. /**
  101523. * If true automatically deducts the fresnels values from the material specularity.
  101524. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101525. */
  101526. useReflectionFresnelFromSpecular: boolean;
  101527. private _useGlossinessFromSpecularMapAlpha;
  101528. /**
  101529. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  101530. */
  101531. useGlossinessFromSpecularMapAlpha: boolean;
  101532. private _maxSimultaneousLights;
  101533. /**
  101534. * Defines the maximum number of lights that can be used in the material
  101535. */
  101536. maxSimultaneousLights: number;
  101537. private _invertNormalMapX;
  101538. /**
  101539. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  101540. */
  101541. invertNormalMapX: boolean;
  101542. private _invertNormalMapY;
  101543. /**
  101544. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  101545. */
  101546. invertNormalMapY: boolean;
  101547. private _twoSidedLighting;
  101548. /**
  101549. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101550. */
  101551. twoSidedLighting: boolean;
  101552. /**
  101553. * Default configuration related to image processing available in the standard Material.
  101554. */
  101555. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101556. /**
  101557. * Gets the image processing configuration used either in this material.
  101558. */
  101559. /**
  101560. * Sets the Default image processing configuration used either in the this material.
  101561. *
  101562. * If sets to null, the scene one is in use.
  101563. */
  101564. imageProcessingConfiguration: ImageProcessingConfiguration;
  101565. /**
  101566. * Keep track of the image processing observer to allow dispose and replace.
  101567. */
  101568. private _imageProcessingObserver;
  101569. /**
  101570. * Attaches a new image processing configuration to the Standard Material.
  101571. * @param configuration
  101572. */
  101573. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  101574. /**
  101575. * Gets wether the color curves effect is enabled.
  101576. */
  101577. /**
  101578. * Sets wether the color curves effect is enabled.
  101579. */
  101580. cameraColorCurvesEnabled: boolean;
  101581. /**
  101582. * Gets wether the color grading effect is enabled.
  101583. */
  101584. /**
  101585. * Gets wether the color grading effect is enabled.
  101586. */
  101587. cameraColorGradingEnabled: boolean;
  101588. /**
  101589. * Gets wether tonemapping is enabled or not.
  101590. */
  101591. /**
  101592. * Sets wether tonemapping is enabled or not
  101593. */
  101594. cameraToneMappingEnabled: boolean;
  101595. /**
  101596. * The camera exposure used on this material.
  101597. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101598. * This corresponds to a photographic exposure.
  101599. */
  101600. /**
  101601. * The camera exposure used on this material.
  101602. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101603. * This corresponds to a photographic exposure.
  101604. */
  101605. cameraExposure: number;
  101606. /**
  101607. * Gets The camera contrast used on this material.
  101608. */
  101609. /**
  101610. * Sets The camera contrast used on this material.
  101611. */
  101612. cameraContrast: number;
  101613. /**
  101614. * Gets the Color Grading 2D Lookup Texture.
  101615. */
  101616. /**
  101617. * Sets the Color Grading 2D Lookup Texture.
  101618. */
  101619. cameraColorGradingTexture: Nullable<BaseTexture>;
  101620. /**
  101621. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101622. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101623. * 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;
  101624. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101625. */
  101626. /**
  101627. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101628. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101629. * 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;
  101630. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101631. */
  101632. cameraColorCurves: Nullable<ColorCurves>;
  101633. /**
  101634. * Custom callback helping to override the default shader used in the material.
  101635. */
  101636. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  101637. protected _renderTargets: SmartArray<RenderTargetTexture>;
  101638. protected _worldViewProjectionMatrix: Matrix;
  101639. protected _globalAmbientColor: Color3;
  101640. protected _useLogarithmicDepth: boolean;
  101641. /**
  101642. * Instantiates a new standard material.
  101643. * This is the default material used in Babylon. It is the best trade off between quality
  101644. * and performances.
  101645. * @see http://doc.babylonjs.com/babylon101/materials
  101646. * @param name Define the name of the material in the scene
  101647. * @param scene Define the scene the material belong to
  101648. */
  101649. constructor(name: string, scene: Scene);
  101650. /**
  101651. * Gets a boolean indicating that current material needs to register RTT
  101652. */
  101653. readonly hasRenderTargetTextures: boolean;
  101654. /**
  101655. * Gets the current class name of the material e.g. "StandardMaterial"
  101656. * Mainly use in serialization.
  101657. * @returns the class name
  101658. */
  101659. getClassName(): string;
  101660. /**
  101661. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  101662. * You can try switching to logarithmic depth.
  101663. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  101664. */
  101665. useLogarithmicDepth: boolean;
  101666. /**
  101667. * Specifies if the material will require alpha blending
  101668. * @returns a boolean specifying if alpha blending is needed
  101669. */
  101670. needAlphaBlending(): boolean;
  101671. /**
  101672. * Specifies if this material should be rendered in alpha test mode
  101673. * @returns a boolean specifying if an alpha test is needed.
  101674. */
  101675. needAlphaTesting(): boolean;
  101676. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  101677. /**
  101678. * Get the texture used for alpha test purpose.
  101679. * @returns the diffuse texture in case of the standard material.
  101680. */
  101681. getAlphaTestTexture(): Nullable<BaseTexture>;
  101682. /**
  101683. * Get if the submesh is ready to be used and all its information available.
  101684. * Child classes can use it to update shaders
  101685. * @param mesh defines the mesh to check
  101686. * @param subMesh defines which submesh to check
  101687. * @param useInstances specifies that instances should be used
  101688. * @returns a boolean indicating that the submesh is ready or not
  101689. */
  101690. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101691. /**
  101692. * Builds the material UBO layouts.
  101693. * Used internally during the effect preparation.
  101694. */
  101695. buildUniformLayout(): void;
  101696. /**
  101697. * Unbinds the material from the mesh
  101698. */
  101699. unbind(): void;
  101700. /**
  101701. * Binds the submesh to this material by preparing the effect and shader to draw
  101702. * @param world defines the world transformation matrix
  101703. * @param mesh defines the mesh containing the submesh
  101704. * @param subMesh defines the submesh to bind the material to
  101705. */
  101706. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101707. /**
  101708. * Get the list of animatables in the material.
  101709. * @returns the list of animatables object used in the material
  101710. */
  101711. getAnimatables(): IAnimatable[];
  101712. /**
  101713. * Gets the active textures from the material
  101714. * @returns an array of textures
  101715. */
  101716. getActiveTextures(): BaseTexture[];
  101717. /**
  101718. * Specifies if the material uses a texture
  101719. * @param texture defines the texture to check against the material
  101720. * @returns a boolean specifying if the material uses the texture
  101721. */
  101722. hasTexture(texture: BaseTexture): boolean;
  101723. /**
  101724. * Disposes the material
  101725. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  101726. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  101727. */
  101728. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  101729. /**
  101730. * Makes a duplicate of the material, and gives it a new name
  101731. * @param name defines the new name for the duplicated material
  101732. * @returns the cloned material
  101733. */
  101734. clone(name: string): StandardMaterial;
  101735. /**
  101736. * Serializes this material in a JSON representation
  101737. * @returns the serialized material object
  101738. */
  101739. serialize(): any;
  101740. /**
  101741. * Creates a standard material from parsed material data
  101742. * @param source defines the JSON representation of the material
  101743. * @param scene defines the hosting scene
  101744. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101745. * @returns a new standard material
  101746. */
  101747. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  101748. /**
  101749. * Are diffuse textures enabled in the application.
  101750. */
  101751. static DiffuseTextureEnabled: boolean;
  101752. /**
  101753. * Are ambient textures enabled in the application.
  101754. */
  101755. static AmbientTextureEnabled: boolean;
  101756. /**
  101757. * Are opacity textures enabled in the application.
  101758. */
  101759. static OpacityTextureEnabled: boolean;
  101760. /**
  101761. * Are reflection textures enabled in the application.
  101762. */
  101763. static ReflectionTextureEnabled: boolean;
  101764. /**
  101765. * Are emissive textures enabled in the application.
  101766. */
  101767. static EmissiveTextureEnabled: boolean;
  101768. /**
  101769. * Are specular textures enabled in the application.
  101770. */
  101771. static SpecularTextureEnabled: boolean;
  101772. /**
  101773. * Are bump textures enabled in the application.
  101774. */
  101775. static BumpTextureEnabled: boolean;
  101776. /**
  101777. * Are lightmap textures enabled in the application.
  101778. */
  101779. static LightmapTextureEnabled: boolean;
  101780. /**
  101781. * Are refraction textures enabled in the application.
  101782. */
  101783. static RefractionTextureEnabled: boolean;
  101784. /**
  101785. * Are color grading textures enabled in the application.
  101786. */
  101787. static ColorGradingTextureEnabled: boolean;
  101788. /**
  101789. * Are fresnels enabled in the application.
  101790. */
  101791. static FresnelEnabled: boolean;
  101792. }
  101793. }
  101794. declare module BABYLON {
  101795. /**
  101796. * A class extending Texture allowing drawing on a texture
  101797. * @see http://doc.babylonjs.com/how_to/dynamictexture
  101798. */
  101799. export class DynamicTexture extends Texture {
  101800. private _generateMipMaps;
  101801. private _canvas;
  101802. private _context;
  101803. private _engine;
  101804. /**
  101805. * Creates a DynamicTexture
  101806. * @param name defines the name of the texture
  101807. * @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
  101808. * @param scene defines the scene where you want the texture
  101809. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  101810. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  101811. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  101812. */
  101813. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  101814. /**
  101815. * Get the current class name of the texture useful for serialization or dynamic coding.
  101816. * @returns "DynamicTexture"
  101817. */
  101818. getClassName(): string;
  101819. /**
  101820. * Gets the current state of canRescale
  101821. */
  101822. readonly canRescale: boolean;
  101823. private _recreate;
  101824. /**
  101825. * Scales the texture
  101826. * @param ratio the scale factor to apply to both width and height
  101827. */
  101828. scale(ratio: number): void;
  101829. /**
  101830. * Resizes the texture
  101831. * @param width the new width
  101832. * @param height the new height
  101833. */
  101834. scaleTo(width: number, height: number): void;
  101835. /**
  101836. * Gets the context of the canvas used by the texture
  101837. * @returns the canvas context of the dynamic texture
  101838. */
  101839. getContext(): CanvasRenderingContext2D;
  101840. /**
  101841. * Clears the texture
  101842. */
  101843. clear(): void;
  101844. /**
  101845. * Updates the texture
  101846. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  101847. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  101848. */
  101849. update(invertY?: boolean, premulAlpha?: boolean): void;
  101850. /**
  101851. * Draws text onto the texture
  101852. * @param text defines the text to be drawn
  101853. * @param x defines the placement of the text from the left
  101854. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  101855. * @param font defines the font to be used with font-style, font-size, font-name
  101856. * @param color defines the color used for the text
  101857. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  101858. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  101859. * @param update defines whether texture is immediately update (default is true)
  101860. */
  101861. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  101862. /**
  101863. * Clones the texture
  101864. * @returns the clone of the texture.
  101865. */
  101866. clone(): DynamicTexture;
  101867. /**
  101868. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  101869. * @returns a serialized dynamic texture object
  101870. */
  101871. serialize(): any;
  101872. /** @hidden */
  101873. _rebuild(): void;
  101874. }
  101875. }
  101876. declare module BABYLON {
  101877. /** @hidden */
  101878. export var imageProcessingPixelShader: {
  101879. name: string;
  101880. shader: string;
  101881. };
  101882. }
  101883. declare module BABYLON {
  101884. /**
  101885. * ImageProcessingPostProcess
  101886. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  101887. */
  101888. export class ImageProcessingPostProcess extends PostProcess {
  101889. /**
  101890. * Default configuration related to image processing available in the PBR Material.
  101891. */
  101892. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101893. /**
  101894. * Gets the image processing configuration used either in this material.
  101895. */
  101896. /**
  101897. * Sets the Default image processing configuration used either in the this material.
  101898. *
  101899. * If sets to null, the scene one is in use.
  101900. */
  101901. imageProcessingConfiguration: ImageProcessingConfiguration;
  101902. /**
  101903. * Keep track of the image processing observer to allow dispose and replace.
  101904. */
  101905. private _imageProcessingObserver;
  101906. /**
  101907. * Attaches a new image processing configuration to the PBR Material.
  101908. * @param configuration
  101909. */
  101910. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  101911. /**
  101912. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  101913. */
  101914. /**
  101915. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  101916. */
  101917. colorCurves: Nullable<ColorCurves>;
  101918. /**
  101919. * Gets wether the color curves effect is enabled.
  101920. */
  101921. /**
  101922. * Sets wether the color curves effect is enabled.
  101923. */
  101924. colorCurvesEnabled: boolean;
  101925. /**
  101926. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  101927. */
  101928. /**
  101929. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  101930. */
  101931. colorGradingTexture: Nullable<BaseTexture>;
  101932. /**
  101933. * Gets wether the color grading effect is enabled.
  101934. */
  101935. /**
  101936. * Gets wether the color grading effect is enabled.
  101937. */
  101938. colorGradingEnabled: boolean;
  101939. /**
  101940. * Gets exposure used in the effect.
  101941. */
  101942. /**
  101943. * Sets exposure used in the effect.
  101944. */
  101945. exposure: number;
  101946. /**
  101947. * Gets wether tonemapping is enabled or not.
  101948. */
  101949. /**
  101950. * Sets wether tonemapping is enabled or not
  101951. */
  101952. toneMappingEnabled: boolean;
  101953. /**
  101954. * Gets the type of tone mapping effect.
  101955. */
  101956. /**
  101957. * Sets the type of tone mapping effect.
  101958. */
  101959. toneMappingType: number;
  101960. /**
  101961. * Gets contrast used in the effect.
  101962. */
  101963. /**
  101964. * Sets contrast used in the effect.
  101965. */
  101966. contrast: number;
  101967. /**
  101968. * Gets Vignette stretch size.
  101969. */
  101970. /**
  101971. * Sets Vignette stretch size.
  101972. */
  101973. vignetteStretch: number;
  101974. /**
  101975. * Gets Vignette centre X Offset.
  101976. */
  101977. /**
  101978. * Sets Vignette centre X Offset.
  101979. */
  101980. vignetteCentreX: number;
  101981. /**
  101982. * Gets Vignette centre Y Offset.
  101983. */
  101984. /**
  101985. * Sets Vignette centre Y Offset.
  101986. */
  101987. vignetteCentreY: number;
  101988. /**
  101989. * Gets Vignette weight or intensity of the vignette effect.
  101990. */
  101991. /**
  101992. * Sets Vignette weight or intensity of the vignette effect.
  101993. */
  101994. vignetteWeight: number;
  101995. /**
  101996. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  101997. * if vignetteEnabled is set to true.
  101998. */
  101999. /**
  102000. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102001. * if vignetteEnabled is set to true.
  102002. */
  102003. vignetteColor: Color4;
  102004. /**
  102005. * Gets Camera field of view used by the Vignette effect.
  102006. */
  102007. /**
  102008. * Sets Camera field of view used by the Vignette effect.
  102009. */
  102010. vignetteCameraFov: number;
  102011. /**
  102012. * Gets the vignette blend mode allowing different kind of effect.
  102013. */
  102014. /**
  102015. * Sets the vignette blend mode allowing different kind of effect.
  102016. */
  102017. vignetteBlendMode: number;
  102018. /**
  102019. * Gets wether the vignette effect is enabled.
  102020. */
  102021. /**
  102022. * Sets wether the vignette effect is enabled.
  102023. */
  102024. vignetteEnabled: boolean;
  102025. private _fromLinearSpace;
  102026. /**
  102027. * Gets wether the input of the processing is in Gamma or Linear Space.
  102028. */
  102029. /**
  102030. * Sets wether the input of the processing is in Gamma or Linear Space.
  102031. */
  102032. fromLinearSpace: boolean;
  102033. /**
  102034. * Defines cache preventing GC.
  102035. */
  102036. private _defines;
  102037. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  102038. /**
  102039. * "ImageProcessingPostProcess"
  102040. * @returns "ImageProcessingPostProcess"
  102041. */
  102042. getClassName(): string;
  102043. protected _updateParameters(): void;
  102044. dispose(camera?: Camera): void;
  102045. }
  102046. }
  102047. declare module BABYLON {
  102048. /**
  102049. * Class containing static functions to help procedurally build meshes
  102050. */
  102051. export class GroundBuilder {
  102052. /**
  102053. * Creates a ground mesh
  102054. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  102055. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  102056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102057. * @param name defines the name of the mesh
  102058. * @param options defines the options used to create the mesh
  102059. * @param scene defines the hosting scene
  102060. * @returns the ground mesh
  102061. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  102062. */
  102063. static CreateGround(name: string, options: {
  102064. width?: number;
  102065. height?: number;
  102066. subdivisions?: number;
  102067. subdivisionsX?: number;
  102068. subdivisionsY?: number;
  102069. updatable?: boolean;
  102070. }, scene: any): Mesh;
  102071. /**
  102072. * Creates a tiled ground mesh
  102073. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  102074. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  102075. * * 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
  102076. * * 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
  102077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102078. * @param name defines the name of the mesh
  102079. * @param options defines the options used to create the mesh
  102080. * @param scene defines the hosting scene
  102081. * @returns the tiled ground mesh
  102082. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  102083. */
  102084. static CreateTiledGround(name: string, options: {
  102085. xmin: number;
  102086. zmin: number;
  102087. xmax: number;
  102088. zmax: number;
  102089. subdivisions?: {
  102090. w: number;
  102091. h: number;
  102092. };
  102093. precision?: {
  102094. w: number;
  102095. h: number;
  102096. };
  102097. updatable?: boolean;
  102098. }, scene?: Nullable<Scene>): Mesh;
  102099. /**
  102100. * Creates a ground mesh from a height map
  102101. * * The parameter `url` sets the URL of the height map image resource.
  102102. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  102103. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  102104. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  102105. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  102106. * * 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.
  102107. * * 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).
  102108. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  102109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102110. * @param name defines the name of the mesh
  102111. * @param url defines the url to the height map
  102112. * @param options defines the options used to create the mesh
  102113. * @param scene defines the hosting scene
  102114. * @returns the ground mesh
  102115. * @see https://doc.babylonjs.com/babylon101/height_map
  102116. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  102117. */
  102118. static CreateGroundFromHeightMap(name: string, url: string, options: {
  102119. width?: number;
  102120. height?: number;
  102121. subdivisions?: number;
  102122. minHeight?: number;
  102123. maxHeight?: number;
  102124. colorFilter?: Color3;
  102125. alphaFilter?: number;
  102126. updatable?: boolean;
  102127. onReady?: (mesh: GroundMesh) => void;
  102128. }, scene?: Nullable<Scene>): GroundMesh;
  102129. }
  102130. }
  102131. declare module BABYLON {
  102132. /**
  102133. * Class containing static functions to help procedurally build meshes
  102134. */
  102135. export class TorusBuilder {
  102136. /**
  102137. * Creates a torus mesh
  102138. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  102139. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  102140. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  102141. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102142. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102143. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102144. * @param name defines the name of the mesh
  102145. * @param options defines the options used to create the mesh
  102146. * @param scene defines the hosting scene
  102147. * @returns the torus mesh
  102148. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  102149. */
  102150. static CreateTorus(name: string, options: {
  102151. diameter?: number;
  102152. thickness?: number;
  102153. tessellation?: number;
  102154. updatable?: boolean;
  102155. sideOrientation?: number;
  102156. frontUVs?: Vector4;
  102157. backUVs?: Vector4;
  102158. }, scene: any): Mesh;
  102159. }
  102160. }
  102161. declare module BABYLON {
  102162. /**
  102163. * Class containing static functions to help procedurally build meshes
  102164. */
  102165. export class CylinderBuilder {
  102166. /**
  102167. * Creates a cylinder or a cone mesh
  102168. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  102169. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  102170. * * 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.
  102171. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  102172. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  102173. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  102174. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  102175. * * 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).
  102176. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  102177. * * 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).
  102178. * * 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
  102179. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  102180. * * 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
  102181. * * 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.
  102182. * * If `enclose` is false, a ring surface is one element.
  102183. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  102184. * * 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
  102185. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102186. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102187. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102188. * @param name defines the name of the mesh
  102189. * @param options defines the options used to create the mesh
  102190. * @param scene defines the hosting scene
  102191. * @returns the cylinder mesh
  102192. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  102193. */
  102194. static CreateCylinder(name: string, options: {
  102195. height?: number;
  102196. diameterTop?: number;
  102197. diameterBottom?: number;
  102198. diameter?: number;
  102199. tessellation?: number;
  102200. subdivisions?: number;
  102201. arc?: number;
  102202. faceColors?: Color4[];
  102203. faceUV?: Vector4[];
  102204. updatable?: boolean;
  102205. hasRings?: boolean;
  102206. enclose?: boolean;
  102207. cap?: number;
  102208. sideOrientation?: number;
  102209. frontUVs?: Vector4;
  102210. backUVs?: Vector4;
  102211. }, scene: any): Mesh;
  102212. }
  102213. }
  102214. declare module BABYLON {
  102215. /**
  102216. * Options to modify the vr teleportation behavior.
  102217. */
  102218. export interface VRTeleportationOptions {
  102219. /**
  102220. * The name of the mesh which should be used as the teleportation floor. (default: null)
  102221. */
  102222. floorMeshName?: string;
  102223. /**
  102224. * A list of meshes to be used as the teleportation floor. (default: empty)
  102225. */
  102226. floorMeshes?: Mesh[];
  102227. }
  102228. /**
  102229. * Options to modify the vr experience helper's behavior.
  102230. */
  102231. export interface VRExperienceHelperOptions extends WebVROptions {
  102232. /**
  102233. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  102234. */
  102235. createDeviceOrientationCamera?: boolean;
  102236. /**
  102237. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  102238. */
  102239. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  102240. /**
  102241. * Uses the main button on the controller to toggle the laser casted. (default: true)
  102242. */
  102243. laserToggle?: boolean;
  102244. /**
  102245. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  102246. */
  102247. floorMeshes?: Mesh[];
  102248. /**
  102249. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  102250. */
  102251. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  102252. }
  102253. /**
  102254. * Event containing information after VR has been entered
  102255. */
  102256. export class OnAfterEnteringVRObservableEvent {
  102257. /**
  102258. * If entering vr was successful
  102259. */
  102260. success: boolean;
  102261. }
  102262. /**
  102263. * Helps to quickly add VR support to an existing scene.
  102264. * See http://doc.babylonjs.com/how_to/webvr_helper
  102265. */
  102266. export class VRExperienceHelper {
  102267. /** Options to modify the vr experience helper's behavior. */
  102268. webVROptions: VRExperienceHelperOptions;
  102269. private _scene;
  102270. private _position;
  102271. private _btnVR;
  102272. private _btnVRDisplayed;
  102273. private _webVRsupported;
  102274. private _webVRready;
  102275. private _webVRrequesting;
  102276. private _webVRpresenting;
  102277. private _hasEnteredVR;
  102278. private _fullscreenVRpresenting;
  102279. private _canvas;
  102280. private _webVRCamera;
  102281. private _vrDeviceOrientationCamera;
  102282. private _deviceOrientationCamera;
  102283. private _existingCamera;
  102284. private _onKeyDown;
  102285. private _onVrDisplayPresentChange;
  102286. private _onVRDisplayChanged;
  102287. private _onVRRequestPresentStart;
  102288. private _onVRRequestPresentComplete;
  102289. /**
  102290. * Observable raised right before entering VR.
  102291. */
  102292. onEnteringVRObservable: Observable<VRExperienceHelper>;
  102293. /**
  102294. * Observable raised when entering VR has completed.
  102295. */
  102296. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  102297. /**
  102298. * Observable raised when exiting VR.
  102299. */
  102300. onExitingVRObservable: Observable<VRExperienceHelper>;
  102301. /**
  102302. * Observable raised when controller mesh is loaded.
  102303. */
  102304. onControllerMeshLoadedObservable: Observable<WebVRController>;
  102305. /** Return this.onEnteringVRObservable
  102306. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  102307. */
  102308. readonly onEnteringVR: Observable<VRExperienceHelper>;
  102309. /** Return this.onExitingVRObservable
  102310. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  102311. */
  102312. readonly onExitingVR: Observable<VRExperienceHelper>;
  102313. /** Return this.onControllerMeshLoadedObservable
  102314. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  102315. */
  102316. readonly onControllerMeshLoaded: Observable<WebVRController>;
  102317. private _rayLength;
  102318. private _useCustomVRButton;
  102319. private _teleportationRequested;
  102320. private _teleportActive;
  102321. private _floorMeshName;
  102322. private _floorMeshesCollection;
  102323. private _rotationAllowed;
  102324. private _teleportBackwardsVector;
  102325. private _teleportationTarget;
  102326. private _isDefaultTeleportationTarget;
  102327. private _postProcessMove;
  102328. private _teleportationFillColor;
  102329. private _teleportationBorderColor;
  102330. private _rotationAngle;
  102331. private _haloCenter;
  102332. private _cameraGazer;
  102333. private _padSensibilityUp;
  102334. private _padSensibilityDown;
  102335. private _leftController;
  102336. private _rightController;
  102337. /**
  102338. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  102339. */
  102340. onNewMeshSelected: Observable<AbstractMesh>;
  102341. /**
  102342. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  102343. */
  102344. onNewMeshPicked: Observable<PickingInfo>;
  102345. private _circleEase;
  102346. /**
  102347. * Observable raised before camera teleportation
  102348. */
  102349. onBeforeCameraTeleport: Observable<Vector3>;
  102350. /**
  102351. * Observable raised after camera teleportation
  102352. */
  102353. onAfterCameraTeleport: Observable<Vector3>;
  102354. /**
  102355. * Observable raised when current selected mesh gets unselected
  102356. */
  102357. onSelectedMeshUnselected: Observable<AbstractMesh>;
  102358. private _raySelectionPredicate;
  102359. /**
  102360. * To be optionaly changed by user to define custom ray selection
  102361. */
  102362. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  102363. /**
  102364. * To be optionaly changed by user to define custom selection logic (after ray selection)
  102365. */
  102366. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  102367. /**
  102368. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  102369. */
  102370. teleportationEnabled: boolean;
  102371. private _defaultHeight;
  102372. private _teleportationInitialized;
  102373. private _interactionsEnabled;
  102374. private _interactionsRequested;
  102375. private _displayGaze;
  102376. private _displayLaserPointer;
  102377. /**
  102378. * The mesh used to display where the user is going to teleport.
  102379. */
  102380. /**
  102381. * Sets the mesh to be used to display where the user is going to teleport.
  102382. */
  102383. teleportationTarget: Mesh;
  102384. /**
  102385. * 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
  102386. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  102387. * See http://doc.babylonjs.com/resources/baking_transformations
  102388. */
  102389. gazeTrackerMesh: Mesh;
  102390. /**
  102391. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  102392. */
  102393. updateGazeTrackerScale: boolean;
  102394. /**
  102395. * If the gaze trackers color should be updated when selecting meshes
  102396. */
  102397. updateGazeTrackerColor: boolean;
  102398. /**
  102399. * The gaze tracking mesh corresponding to the left controller
  102400. */
  102401. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  102402. /**
  102403. * The gaze tracking mesh corresponding to the right controller
  102404. */
  102405. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  102406. /**
  102407. * If the ray of the gaze should be displayed.
  102408. */
  102409. /**
  102410. * Sets if the ray of the gaze should be displayed.
  102411. */
  102412. displayGaze: boolean;
  102413. /**
  102414. * If the ray of the LaserPointer should be displayed.
  102415. */
  102416. /**
  102417. * Sets if the ray of the LaserPointer should be displayed.
  102418. */
  102419. displayLaserPointer: boolean;
  102420. /**
  102421. * The deviceOrientationCamera used as the camera when not in VR.
  102422. */
  102423. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  102424. /**
  102425. * Based on the current WebVR support, returns the current VR camera used.
  102426. */
  102427. readonly currentVRCamera: Nullable<Camera>;
  102428. /**
  102429. * The webVRCamera which is used when in VR.
  102430. */
  102431. readonly webVRCamera: WebVRFreeCamera;
  102432. /**
  102433. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  102434. */
  102435. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  102436. private readonly _teleportationRequestInitiated;
  102437. /**
  102438. * Defines wether or not Pointer lock should be requested when switching to
  102439. * full screen.
  102440. */
  102441. requestPointerLockOnFullScreen: boolean;
  102442. /**
  102443. * Instantiates a VRExperienceHelper.
  102444. * Helps to quickly add VR support to an existing scene.
  102445. * @param scene The scene the VRExperienceHelper belongs to.
  102446. * @param webVROptions Options to modify the vr experience helper's behavior.
  102447. */
  102448. constructor(scene: Scene,
  102449. /** Options to modify the vr experience helper's behavior. */
  102450. webVROptions?: VRExperienceHelperOptions);
  102451. private _onDefaultMeshLoaded;
  102452. private _onResize;
  102453. private _onFullscreenChange;
  102454. /**
  102455. * Gets a value indicating if we are currently in VR mode.
  102456. */
  102457. readonly isInVRMode: boolean;
  102458. private onVrDisplayPresentChange;
  102459. private onVRDisplayChanged;
  102460. private moveButtonToBottomRight;
  102461. private displayVRButton;
  102462. private updateButtonVisibility;
  102463. private _cachedAngularSensibility;
  102464. /**
  102465. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  102466. * Otherwise, will use the fullscreen API.
  102467. */
  102468. enterVR(): void;
  102469. /**
  102470. * Attempt to exit VR, or fullscreen.
  102471. */
  102472. exitVR(): void;
  102473. /**
  102474. * The position of the vr experience helper.
  102475. */
  102476. /**
  102477. * Sets the position of the vr experience helper.
  102478. */
  102479. position: Vector3;
  102480. /**
  102481. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  102482. */
  102483. enableInteractions(): void;
  102484. private readonly _noControllerIsActive;
  102485. private beforeRender;
  102486. private _isTeleportationFloor;
  102487. /**
  102488. * Adds a floor mesh to be used for teleportation.
  102489. * @param floorMesh the mesh to be used for teleportation.
  102490. */
  102491. addFloorMesh(floorMesh: Mesh): void;
  102492. /**
  102493. * Removes a floor mesh from being used for teleportation.
  102494. * @param floorMesh the mesh to be removed.
  102495. */
  102496. removeFloorMesh(floorMesh: Mesh): void;
  102497. /**
  102498. * Enables interactions and teleportation using the VR controllers and gaze.
  102499. * @param vrTeleportationOptions options to modify teleportation behavior.
  102500. */
  102501. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  102502. private _onNewGamepadConnected;
  102503. private _tryEnableInteractionOnController;
  102504. private _onNewGamepadDisconnected;
  102505. private _enableInteractionOnController;
  102506. private _checkTeleportWithRay;
  102507. private _checkRotate;
  102508. private _checkTeleportBackwards;
  102509. private _enableTeleportationOnController;
  102510. private _createTeleportationCircles;
  102511. private _displayTeleportationTarget;
  102512. private _hideTeleportationTarget;
  102513. private _rotateCamera;
  102514. private _moveTeleportationSelectorTo;
  102515. private _workingVector;
  102516. private _workingQuaternion;
  102517. private _workingMatrix;
  102518. /**
  102519. * Teleports the users feet to the desired location
  102520. * @param location The location where the user's feet should be placed
  102521. */
  102522. teleportCamera(location: Vector3): void;
  102523. private _convertNormalToDirectionOfRay;
  102524. private _castRayAndSelectObject;
  102525. private _notifySelectedMeshUnselected;
  102526. /**
  102527. * Sets the color of the laser ray from the vr controllers.
  102528. * @param color new color for the ray.
  102529. */
  102530. changeLaserColor(color: Color3): void;
  102531. /**
  102532. * Sets the color of the ray from the vr headsets gaze.
  102533. * @param color new color for the ray.
  102534. */
  102535. changeGazeColor(color: Color3): void;
  102536. /**
  102537. * Exits VR and disposes of the vr experience helper
  102538. */
  102539. dispose(): void;
  102540. /**
  102541. * Gets the name of the VRExperienceHelper class
  102542. * @returns "VRExperienceHelper"
  102543. */
  102544. getClassName(): string;
  102545. }
  102546. }
  102547. declare module BABYLON {
  102548. /**
  102549. * Manages an XRSession
  102550. * @see https://doc.babylonjs.com/how_to/webxr
  102551. */
  102552. export class WebXRSessionManager implements IDisposable {
  102553. private scene;
  102554. /**
  102555. * Fires every time a new xrFrame arrives which can be used to update the camera
  102556. */
  102557. onXRFrameObservable: Observable<any>;
  102558. /**
  102559. * Fires when the xr session is ended either by the device or manually done
  102560. */
  102561. onXRSessionEnded: Observable<any>;
  102562. /** @hidden */
  102563. _xrSession: XRSession;
  102564. /** @hidden */
  102565. _frameOfReference: XRFrameOfReference;
  102566. /** @hidden */
  102567. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  102568. /** @hidden */
  102569. _currentXRFrame: Nullable<XRFrame>;
  102570. private _xrNavigator;
  102571. private _xrDevice;
  102572. private _tmpMatrix;
  102573. /**
  102574. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  102575. * @param scene The scene which the session should be created for
  102576. */
  102577. constructor(scene: Scene);
  102578. /**
  102579. * Initializes the manager
  102580. * After initialization enterXR can be called to start an XR session
  102581. * @returns Promise which resolves after it is initialized
  102582. */
  102583. initializeAsync(): Promise<void>;
  102584. /**
  102585. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  102586. * @param sessionCreationOptions xr options to create the session with
  102587. * @param frameOfReferenceType option to configure how the xr pose is expressed
  102588. * @returns Promise which resolves after it enters XR
  102589. */
  102590. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  102591. /**
  102592. * Stops the xrSession and restores the renderloop
  102593. * @returns Promise which resolves after it exits XR
  102594. */
  102595. exitXRAsync(): Promise<void>;
  102596. /**
  102597. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  102598. * @param ray ray to cast into the environment
  102599. * @returns Promise which resolves with a collision point in the environment if it exists
  102600. */
  102601. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  102602. /**
  102603. * Checks if a session would be supported for the creation options specified
  102604. * @param options creation options to check if they are supported
  102605. * @returns true if supported
  102606. */
  102607. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  102608. /**
  102609. * @hidden
  102610. * Converts the render layer of xrSession to a render target
  102611. * @param session session to create render target for
  102612. * @param scene scene the new render target should be created for
  102613. */
  102614. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  102615. /**
  102616. * Disposes of the session manager
  102617. */
  102618. dispose(): void;
  102619. }
  102620. }
  102621. declare module BABYLON {
  102622. /**
  102623. * WebXR Camera which holds the views for the xrSession
  102624. * @see https://doc.babylonjs.com/how_to/webxr
  102625. */
  102626. export class WebXRCamera extends FreeCamera {
  102627. private static _TmpMatrix;
  102628. /**
  102629. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  102630. * @param name the name of the camera
  102631. * @param scene the scene to add the camera to
  102632. */
  102633. constructor(name: string, scene: Scene);
  102634. private _updateNumberOfRigCameras;
  102635. /** @hidden */
  102636. _updateForDualEyeDebugging(pupilDistance?: number): void;
  102637. /**
  102638. * Updates the cameras position from the current pose information of the XR session
  102639. * @param xrSessionManager the session containing pose information
  102640. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  102641. */
  102642. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  102643. }
  102644. }
  102645. declare module BABYLON {
  102646. /**
  102647. * States of the webXR experience
  102648. */
  102649. export enum WebXRState {
  102650. /**
  102651. * Transitioning to being in XR mode
  102652. */
  102653. ENTERING_XR = 0,
  102654. /**
  102655. * Transitioning to non XR mode
  102656. */
  102657. EXITING_XR = 1,
  102658. /**
  102659. * In XR mode and presenting
  102660. */
  102661. IN_XR = 2,
  102662. /**
  102663. * Not entered XR mode
  102664. */
  102665. NOT_IN_XR = 3
  102666. }
  102667. /**
  102668. * Helper class used to enable XR
  102669. * @see https://doc.babylonjs.com/how_to/webxr
  102670. */
  102671. export class WebXRExperienceHelper implements IDisposable {
  102672. private scene;
  102673. /**
  102674. * 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
  102675. */
  102676. container: AbstractMesh;
  102677. /**
  102678. * Camera used to render xr content
  102679. */
  102680. camera: WebXRCamera;
  102681. /**
  102682. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  102683. */
  102684. state: WebXRState;
  102685. private _setState;
  102686. private static _TmpVector;
  102687. /**
  102688. * Fires when the state of the experience helper has changed
  102689. */
  102690. onStateChangedObservable: Observable<WebXRState>;
  102691. /** @hidden */
  102692. _sessionManager: WebXRSessionManager;
  102693. private _nonVRCamera;
  102694. private _originalSceneAutoClear;
  102695. private _supported;
  102696. /**
  102697. * Creates the experience helper
  102698. * @param scene the scene to attach the experience helper to
  102699. * @returns a promise for the experience helper
  102700. */
  102701. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  102702. /**
  102703. * Creates a WebXRExperienceHelper
  102704. * @param scene The scene the helper should be created in
  102705. */
  102706. private constructor();
  102707. /**
  102708. * Exits XR mode and returns the scene to its original state
  102709. * @returns promise that resolves after xr mode has exited
  102710. */
  102711. exitXRAsync(): Promise<void>;
  102712. /**
  102713. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  102714. * @param sessionCreationOptions options for the XR session
  102715. * @param frameOfReference frame of reference of the XR session
  102716. * @returns promise that resolves after xr mode has entered
  102717. */
  102718. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  102719. /**
  102720. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  102721. * @param ray ray to cast into the environment
  102722. * @returns Promise which resolves with a collision point in the environment if it exists
  102723. */
  102724. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  102725. /**
  102726. * Updates the global position of the camera by moving the camera's container
  102727. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  102728. * @param position The desired global position of the camera
  102729. */
  102730. setPositionOfCameraUsingContainer(position: Vector3): void;
  102731. /**
  102732. * Rotates the xr camera by rotating the camera's container around the camera's position
  102733. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  102734. * @param rotation the desired quaternion rotation to apply to the camera
  102735. */
  102736. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  102737. /**
  102738. * Checks if the creation options are supported by the xr session
  102739. * @param options creation options
  102740. * @returns true if supported
  102741. */
  102742. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  102743. /**
  102744. * Disposes of the experience helper
  102745. */
  102746. dispose(): void;
  102747. }
  102748. }
  102749. declare module BABYLON {
  102750. /**
  102751. * Button which can be used to enter a different mode of XR
  102752. */
  102753. export class WebXREnterExitUIButton {
  102754. /** button element */
  102755. element: HTMLElement;
  102756. /** XR initialization options for the button */
  102757. initializationOptions: XRSessionCreationOptions;
  102758. /**
  102759. * Creates a WebXREnterExitUIButton
  102760. * @param element button element
  102761. * @param initializationOptions XR initialization options for the button
  102762. */
  102763. constructor(
  102764. /** button element */
  102765. element: HTMLElement,
  102766. /** XR initialization options for the button */
  102767. initializationOptions: XRSessionCreationOptions);
  102768. /**
  102769. * Overwritable function which can be used to update the button's visuals when the state changes
  102770. * @param activeButton the current active button in the UI
  102771. */
  102772. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  102773. }
  102774. /**
  102775. * Options to create the webXR UI
  102776. */
  102777. export class WebXREnterExitUIOptions {
  102778. /**
  102779. * Context to enter xr with
  102780. */
  102781. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  102782. /**
  102783. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  102784. */
  102785. customButtons?: Array<WebXREnterExitUIButton>;
  102786. }
  102787. /**
  102788. * UI to allow the user to enter/exit XR mode
  102789. */
  102790. export class WebXREnterExitUI implements IDisposable {
  102791. private scene;
  102792. private _overlay;
  102793. private _buttons;
  102794. private _activeButton;
  102795. /**
  102796. * Fired every time the active button is changed.
  102797. *
  102798. * When xr is entered via a button that launches xr that button will be the callback parameter
  102799. *
  102800. * When exiting xr the callback parameter will be null)
  102801. */
  102802. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  102803. /**
  102804. * Creates UI to allow the user to enter/exit XR mode
  102805. * @param scene the scene to add the ui to
  102806. * @param helper the xr experience helper to enter/exit xr with
  102807. * @param options options to configure the UI
  102808. * @returns the created ui
  102809. */
  102810. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  102811. private constructor();
  102812. private _updateButtons;
  102813. /**
  102814. * Disposes of the object
  102815. */
  102816. dispose(): void;
  102817. }
  102818. }
  102819. declare module BABYLON {
  102820. /**
  102821. * Represents an XR input
  102822. */
  102823. export class WebXRController {
  102824. /**
  102825. * 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
  102826. */
  102827. grip?: AbstractMesh;
  102828. /**
  102829. * Pointer which can be used to select objects or attach a visible laser to
  102830. */
  102831. pointer: AbstractMesh;
  102832. /**
  102833. * Creates the controller
  102834. * @see https://doc.babylonjs.com/how_to/webxr
  102835. * @param scene the scene which the controller should be associated to
  102836. */
  102837. constructor(scene: Scene);
  102838. /**
  102839. * Disposes of the object
  102840. */
  102841. dispose(): void;
  102842. }
  102843. /**
  102844. * XR input used to track XR inputs such as controllers/rays
  102845. */
  102846. export class WebXRInput implements IDisposable {
  102847. private helper;
  102848. /**
  102849. * XR controllers being tracked
  102850. */
  102851. controllers: Array<WebXRController>;
  102852. private _tmpMatrix;
  102853. private _frameObserver;
  102854. /**
  102855. * Initializes the WebXRInput
  102856. * @param helper experience helper which the input should be created for
  102857. */
  102858. constructor(helper: WebXRExperienceHelper);
  102859. /**
  102860. * Disposes of the object
  102861. */
  102862. dispose(): void;
  102863. }
  102864. }
  102865. declare module BABYLON {
  102866. /**
  102867. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  102868. */
  102869. export class WebXRManagedOutputCanvas implements IDisposable {
  102870. private _canvas;
  102871. /**
  102872. * xrpresent context of the canvas which can be used to display/mirror xr content
  102873. */
  102874. canvasContext: Nullable<WebGLRenderingContext>;
  102875. /**
  102876. * Initializes the canvas to be added/removed upon entering/exiting xr
  102877. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  102878. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  102879. */
  102880. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  102881. /**
  102882. * Disposes of the object
  102883. */
  102884. dispose(): void;
  102885. private _setManagedOutputCanvas;
  102886. private _addCanvas;
  102887. private _removeCanvas;
  102888. }
  102889. }
  102890. declare module BABYLON {
  102891. /**
  102892. * Contains an array of blocks representing the octree
  102893. */
  102894. export interface IOctreeContainer<T> {
  102895. /**
  102896. * Blocks within the octree
  102897. */
  102898. blocks: Array<OctreeBlock<T>>;
  102899. }
  102900. /**
  102901. * Class used to store a cell in an octree
  102902. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  102903. */
  102904. export class OctreeBlock<T> {
  102905. /**
  102906. * Gets the content of the current block
  102907. */
  102908. entries: T[];
  102909. /**
  102910. * Gets the list of block children
  102911. */
  102912. blocks: Array<OctreeBlock<T>>;
  102913. private _depth;
  102914. private _maxDepth;
  102915. private _capacity;
  102916. private _minPoint;
  102917. private _maxPoint;
  102918. private _boundingVectors;
  102919. private _creationFunc;
  102920. /**
  102921. * Creates a new block
  102922. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  102923. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  102924. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  102925. * @param depth defines the current depth of this block in the octree
  102926. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  102927. * @param creationFunc defines a callback to call when an element is added to the block
  102928. */
  102929. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  102930. /**
  102931. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  102932. */
  102933. readonly capacity: number;
  102934. /**
  102935. * Gets the minimum vector (in world space) of the block's bounding box
  102936. */
  102937. readonly minPoint: Vector3;
  102938. /**
  102939. * Gets the maximum vector (in world space) of the block's bounding box
  102940. */
  102941. readonly maxPoint: Vector3;
  102942. /**
  102943. * Add a new element to this block
  102944. * @param entry defines the element to add
  102945. */
  102946. addEntry(entry: T): void;
  102947. /**
  102948. * Remove an element from this block
  102949. * @param entry defines the element to remove
  102950. */
  102951. removeEntry(entry: T): void;
  102952. /**
  102953. * Add an array of elements to this block
  102954. * @param entries defines the array of elements to add
  102955. */
  102956. addEntries(entries: T[]): void;
  102957. /**
  102958. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  102959. * @param frustumPlanes defines the frustum planes to test
  102960. * @param selection defines the array to store current content if selection is positive
  102961. * @param allowDuplicate defines if the selection array can contains duplicated entries
  102962. */
  102963. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  102964. /**
  102965. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  102966. * @param sphereCenter defines the bounding sphere center
  102967. * @param sphereRadius defines the bounding sphere radius
  102968. * @param selection defines the array to store current content if selection is positive
  102969. * @param allowDuplicate defines if the selection array can contains duplicated entries
  102970. */
  102971. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  102972. /**
  102973. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  102974. * @param ray defines the ray to test with
  102975. * @param selection defines the array to store current content if selection is positive
  102976. */
  102977. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  102978. /**
  102979. * Subdivide the content into child blocks (this block will then be empty)
  102980. */
  102981. createInnerBlocks(): void;
  102982. /**
  102983. * @hidden
  102984. */
  102985. 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;
  102986. }
  102987. }
  102988. declare module BABYLON {
  102989. /**
  102990. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  102991. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  102992. */
  102993. export class Octree<T> {
  102994. /** 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.) */
  102995. maxDepth: number;
  102996. /**
  102997. * Blocks within the octree containing objects
  102998. */
  102999. blocks: Array<OctreeBlock<T>>;
  103000. /**
  103001. * Content stored in the octree
  103002. */
  103003. dynamicContent: T[];
  103004. private _maxBlockCapacity;
  103005. private _selectionContent;
  103006. private _creationFunc;
  103007. /**
  103008. * Creates a octree
  103009. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103010. * @param creationFunc function to be used to instatiate the octree
  103011. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  103012. * @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.)
  103013. */
  103014. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  103015. /** 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.) */
  103016. maxDepth?: number);
  103017. /**
  103018. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  103019. * @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);
  103020. * @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);
  103021. * @param entries meshes to be added to the octree blocks
  103022. */
  103023. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  103024. /**
  103025. * Adds a mesh to the octree
  103026. * @param entry Mesh to add to the octree
  103027. */
  103028. addMesh(entry: T): void;
  103029. /**
  103030. * Remove an element from the octree
  103031. * @param entry defines the element to remove
  103032. */
  103033. removeMesh(entry: T): void;
  103034. /**
  103035. * Selects an array of meshes within the frustum
  103036. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  103037. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  103038. * @returns array of meshes within the frustum
  103039. */
  103040. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  103041. /**
  103042. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  103043. * @param sphereCenter defines the bounding sphere center
  103044. * @param sphereRadius defines the bounding sphere radius
  103045. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103046. * @returns an array of objects that intersect the sphere
  103047. */
  103048. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  103049. /**
  103050. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  103051. * @param ray defines the ray to test with
  103052. * @returns array of intersected objects
  103053. */
  103054. intersectsRay(ray: Ray): SmartArray<T>;
  103055. /**
  103056. * Adds a mesh into the octree block if it intersects the block
  103057. */
  103058. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  103059. /**
  103060. * Adds a submesh into the octree block if it intersects the block
  103061. */
  103062. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  103063. }
  103064. }
  103065. declare module BABYLON {
  103066. interface Scene {
  103067. /**
  103068. * @hidden
  103069. * Backing Filed
  103070. */
  103071. _selectionOctree: Octree<AbstractMesh>;
  103072. /**
  103073. * Gets the octree used to boost mesh selection (picking)
  103074. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103075. */
  103076. selectionOctree: Octree<AbstractMesh>;
  103077. /**
  103078. * Creates or updates the octree used to boost selection (picking)
  103079. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103080. * @param maxCapacity defines the maximum capacity per leaf
  103081. * @param maxDepth defines the maximum depth of the octree
  103082. * @returns an octree of AbstractMesh
  103083. */
  103084. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  103085. }
  103086. interface AbstractMesh {
  103087. /**
  103088. * @hidden
  103089. * Backing Field
  103090. */
  103091. _submeshesOctree: Octree<SubMesh>;
  103092. /**
  103093. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  103094. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  103095. * @param maxCapacity defines the maximum size of each block (64 by default)
  103096. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  103097. * @returns the new octree
  103098. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  103099. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103100. */
  103101. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  103102. }
  103103. /**
  103104. * Defines the octree scene component responsible to manage any octrees
  103105. * in a given scene.
  103106. */
  103107. export class OctreeSceneComponent {
  103108. /**
  103109. * The component name help to identify the component in the list of scene components.
  103110. */
  103111. readonly name: string;
  103112. /**
  103113. * The scene the component belongs to.
  103114. */
  103115. scene: Scene;
  103116. /**
  103117. * Indicates if the meshes have been checked to make sure they are isEnabled()
  103118. */
  103119. readonly checksIsEnabled: boolean;
  103120. /**
  103121. * Creates a new instance of the component for the given scene
  103122. * @param scene Defines the scene to register the component in
  103123. */
  103124. constructor(scene: Scene);
  103125. /**
  103126. * Registers the component in a given scene
  103127. */
  103128. register(): void;
  103129. /**
  103130. * Return the list of active meshes
  103131. * @returns the list of active meshes
  103132. */
  103133. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  103134. /**
  103135. * Return the list of active sub meshes
  103136. * @param mesh The mesh to get the candidates sub meshes from
  103137. * @returns the list of active sub meshes
  103138. */
  103139. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  103140. private _tempRay;
  103141. /**
  103142. * Return the list of sub meshes intersecting with a given local ray
  103143. * @param mesh defines the mesh to find the submesh for
  103144. * @param localRay defines the ray in local space
  103145. * @returns the list of intersecting sub meshes
  103146. */
  103147. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  103148. /**
  103149. * Return the list of sub meshes colliding with a collider
  103150. * @param mesh defines the mesh to find the submesh for
  103151. * @param collider defines the collider to evaluate the collision against
  103152. * @returns the list of colliding sub meshes
  103153. */
  103154. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  103155. /**
  103156. * Rebuilds the elements related to this component in case of
  103157. * context lost for instance.
  103158. */
  103159. rebuild(): void;
  103160. /**
  103161. * Disposes the component and the associated ressources.
  103162. */
  103163. dispose(): void;
  103164. }
  103165. }
  103166. declare module BABYLON {
  103167. /**
  103168. * Renders a layer on top of an existing scene
  103169. */
  103170. export class UtilityLayerRenderer implements IDisposable {
  103171. /** the original scene that will be rendered on top of */
  103172. originalScene: Scene;
  103173. private _pointerCaptures;
  103174. private _lastPointerEvents;
  103175. private static _DefaultUtilityLayer;
  103176. private static _DefaultKeepDepthUtilityLayer;
  103177. private _sharedGizmoLight;
  103178. /**
  103179. * @hidden
  103180. * Light which used by gizmos to get light shading
  103181. */
  103182. _getSharedGizmoLight(): HemisphericLight;
  103183. /**
  103184. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  103185. */
  103186. pickUtilitySceneFirst: boolean;
  103187. /**
  103188. * 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)
  103189. */
  103190. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  103191. /**
  103192. * 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)
  103193. */
  103194. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  103195. /**
  103196. * The scene that is rendered on top of the original scene
  103197. */
  103198. utilityLayerScene: Scene;
  103199. /**
  103200. * If the utility layer should automatically be rendered on top of existing scene
  103201. */
  103202. shouldRender: boolean;
  103203. /**
  103204. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  103205. */
  103206. onlyCheckPointerDownEvents: boolean;
  103207. /**
  103208. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  103209. */
  103210. processAllEvents: boolean;
  103211. /**
  103212. * Observable raised when the pointer move from the utility layer scene to the main scene
  103213. */
  103214. onPointerOutObservable: Observable<number>;
  103215. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  103216. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  103217. private _afterRenderObserver;
  103218. private _sceneDisposeObserver;
  103219. private _originalPointerObserver;
  103220. /**
  103221. * Instantiates a UtilityLayerRenderer
  103222. * @param originalScene the original scene that will be rendered on top of
  103223. * @param handleEvents boolean indicating if the utility layer should handle events
  103224. */
  103225. constructor(
  103226. /** the original scene that will be rendered on top of */
  103227. originalScene: Scene, handleEvents?: boolean);
  103228. private _notifyObservers;
  103229. /**
  103230. * Renders the utility layers scene on top of the original scene
  103231. */
  103232. render(): void;
  103233. /**
  103234. * Disposes of the renderer
  103235. */
  103236. dispose(): void;
  103237. private _updateCamera;
  103238. }
  103239. }
  103240. declare module BABYLON {
  103241. /**
  103242. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  103243. */
  103244. export class Gizmo implements IDisposable {
  103245. /** The utility layer the gizmo will be added to */
  103246. gizmoLayer: UtilityLayerRenderer;
  103247. /**
  103248. * The root mesh of the gizmo
  103249. */
  103250. _rootMesh: Mesh;
  103251. private _attachedMesh;
  103252. /**
  103253. * Ratio for the scale of the gizmo (Default: 1)
  103254. */
  103255. scaleRatio: number;
  103256. /**
  103257. * If a custom mesh has been set (Default: false)
  103258. */
  103259. protected _customMeshSet: boolean;
  103260. /**
  103261. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  103262. * * When set, interactions will be enabled
  103263. */
  103264. attachedMesh: Nullable<AbstractMesh>;
  103265. /**
  103266. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  103267. * @param mesh The mesh to replace the default mesh of the gizmo
  103268. */
  103269. setCustomMesh(mesh: Mesh): void;
  103270. /**
  103271. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  103272. */
  103273. updateGizmoRotationToMatchAttachedMesh: boolean;
  103274. /**
  103275. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  103276. */
  103277. updateGizmoPositionToMatchAttachedMesh: boolean;
  103278. /**
  103279. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  103280. */
  103281. protected _updateScale: boolean;
  103282. protected _interactionsEnabled: boolean;
  103283. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  103284. private _beforeRenderObserver;
  103285. private _tempVector;
  103286. /**
  103287. * Creates a gizmo
  103288. * @param gizmoLayer The utility layer the gizmo will be added to
  103289. */
  103290. constructor(
  103291. /** The utility layer the gizmo will be added to */
  103292. gizmoLayer?: UtilityLayerRenderer);
  103293. /**
  103294. * Updates the gizmo to match the attached mesh's position/rotation
  103295. */
  103296. protected _update(): void;
  103297. /**
  103298. * Disposes of the gizmo
  103299. */
  103300. dispose(): void;
  103301. }
  103302. }
  103303. declare module BABYLON {
  103304. /**
  103305. * Single plane drag gizmo
  103306. */
  103307. export class PlaneDragGizmo extends Gizmo {
  103308. /**
  103309. * Drag behavior responsible for the gizmos dragging interactions
  103310. */
  103311. dragBehavior: PointerDragBehavior;
  103312. private _pointerObserver;
  103313. /**
  103314. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  103315. */
  103316. snapDistance: number;
  103317. /**
  103318. * Event that fires each time the gizmo snaps to a new location.
  103319. * * snapDistance is the the change in distance
  103320. */
  103321. onSnapObservable: Observable<{
  103322. snapDistance: number;
  103323. }>;
  103324. private _plane;
  103325. private _coloredMaterial;
  103326. private _hoverMaterial;
  103327. private _isEnabled;
  103328. private _parent;
  103329. /** @hidden */
  103330. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  103331. /** @hidden */
  103332. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  103333. /**
  103334. * Creates a PlaneDragGizmo
  103335. * @param gizmoLayer The utility layer the gizmo will be added to
  103336. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  103337. * @param color The color of the gizmo
  103338. */
  103339. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  103340. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  103341. /**
  103342. * If the gizmo is enabled
  103343. */
  103344. isEnabled: boolean;
  103345. /**
  103346. * Disposes of the gizmo
  103347. */
  103348. dispose(): void;
  103349. }
  103350. }
  103351. declare module BABYLON {
  103352. /**
  103353. * Gizmo that enables dragging a mesh along 3 axis
  103354. */
  103355. export class PositionGizmo extends Gizmo {
  103356. /**
  103357. * Internal gizmo used for interactions on the x axis
  103358. */
  103359. xGizmo: AxisDragGizmo;
  103360. /**
  103361. * Internal gizmo used for interactions on the y axis
  103362. */
  103363. yGizmo: AxisDragGizmo;
  103364. /**
  103365. * Internal gizmo used for interactions on the z axis
  103366. */
  103367. zGizmo: AxisDragGizmo;
  103368. /**
  103369. * Internal gizmo used for interactions on the yz plane
  103370. */
  103371. xPlaneGizmo: PlaneDragGizmo;
  103372. /**
  103373. * Internal gizmo used for interactions on the xz plane
  103374. */
  103375. yPlaneGizmo: PlaneDragGizmo;
  103376. /**
  103377. * Internal gizmo used for interactions on the xy plane
  103378. */
  103379. zPlaneGizmo: PlaneDragGizmo;
  103380. /**
  103381. * private variables
  103382. */
  103383. private _meshAttached;
  103384. private _updateGizmoRotationToMatchAttachedMesh;
  103385. private _snapDistance;
  103386. private _scaleRatio;
  103387. /** Fires an event when any of it's sub gizmos are dragged */
  103388. onDragStartObservable: Observable<{}>;
  103389. /** Fires an event when any of it's sub gizmos are released from dragging */
  103390. onDragEndObservable: Observable<{}>;
  103391. /**
  103392. * If set to true, planar drag is enabled
  103393. */
  103394. private _planarGizmoEnabled;
  103395. attachedMesh: Nullable<AbstractMesh>;
  103396. /**
  103397. * Creates a PositionGizmo
  103398. * @param gizmoLayer The utility layer the gizmo will be added to
  103399. */
  103400. constructor(gizmoLayer?: UtilityLayerRenderer);
  103401. /**
  103402. * If the planar drag gizmo is enabled
  103403. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  103404. */
  103405. planarGizmoEnabled: boolean;
  103406. updateGizmoRotationToMatchAttachedMesh: boolean;
  103407. /**
  103408. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  103409. */
  103410. snapDistance: number;
  103411. /**
  103412. * Ratio for the scale of the gizmo (Default: 1)
  103413. */
  103414. scaleRatio: number;
  103415. /**
  103416. * Disposes of the gizmo
  103417. */
  103418. dispose(): void;
  103419. /**
  103420. * CustomMeshes are not supported by this gizmo
  103421. * @param mesh The mesh to replace the default mesh of the gizmo
  103422. */
  103423. setCustomMesh(mesh: Mesh): void;
  103424. }
  103425. }
  103426. declare module BABYLON {
  103427. /**
  103428. * Single axis drag gizmo
  103429. */
  103430. export class AxisDragGizmo extends Gizmo {
  103431. /**
  103432. * Drag behavior responsible for the gizmos dragging interactions
  103433. */
  103434. dragBehavior: PointerDragBehavior;
  103435. private _pointerObserver;
  103436. /**
  103437. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  103438. */
  103439. snapDistance: number;
  103440. /**
  103441. * Event that fires each time the gizmo snaps to a new location.
  103442. * * snapDistance is the the change in distance
  103443. */
  103444. onSnapObservable: Observable<{
  103445. snapDistance: number;
  103446. }>;
  103447. private _isEnabled;
  103448. private _parent;
  103449. private _arrow;
  103450. private _coloredMaterial;
  103451. private _hoverMaterial;
  103452. /** @hidden */
  103453. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  103454. /** @hidden */
  103455. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  103456. /**
  103457. * Creates an AxisDragGizmo
  103458. * @param gizmoLayer The utility layer the gizmo will be added to
  103459. * @param dragAxis The axis which the gizmo will be able to drag on
  103460. * @param color The color of the gizmo
  103461. */
  103462. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  103463. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  103464. /**
  103465. * If the gizmo is enabled
  103466. */
  103467. isEnabled: boolean;
  103468. /**
  103469. * Disposes of the gizmo
  103470. */
  103471. dispose(): void;
  103472. }
  103473. }
  103474. declare module BABYLON.Debug {
  103475. /**
  103476. * The Axes viewer will show 3 axes in a specific point in space
  103477. */
  103478. export class AxesViewer {
  103479. private _xAxis;
  103480. private _yAxis;
  103481. private _zAxis;
  103482. private _scaleLinesFactor;
  103483. private _instanced;
  103484. /**
  103485. * Gets the hosting scene
  103486. */
  103487. scene: Scene;
  103488. /**
  103489. * Gets or sets a number used to scale line length
  103490. */
  103491. scaleLines: number;
  103492. /** Gets the node hierarchy used to render x-axis */
  103493. readonly xAxis: TransformNode;
  103494. /** Gets the node hierarchy used to render y-axis */
  103495. readonly yAxis: TransformNode;
  103496. /** Gets the node hierarchy used to render z-axis */
  103497. readonly zAxis: TransformNode;
  103498. /**
  103499. * Creates a new AxesViewer
  103500. * @param scene defines the hosting scene
  103501. * @param scaleLines defines a number used to scale line length (1 by default)
  103502. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  103503. * @param xAxis defines the node hierarchy used to render the x-axis
  103504. * @param yAxis defines the node hierarchy used to render the y-axis
  103505. * @param zAxis defines the node hierarchy used to render the z-axis
  103506. */
  103507. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  103508. /**
  103509. * Force the viewer to update
  103510. * @param position defines the position of the viewer
  103511. * @param xaxis defines the x axis of the viewer
  103512. * @param yaxis defines the y axis of the viewer
  103513. * @param zaxis defines the z axis of the viewer
  103514. */
  103515. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  103516. /**
  103517. * Creates an instance of this axes viewer.
  103518. * @returns a new axes viewer with instanced meshes
  103519. */
  103520. createInstance(): AxesViewer;
  103521. /** Releases resources */
  103522. dispose(): void;
  103523. private static _SetRenderingGroupId;
  103524. }
  103525. }
  103526. declare module BABYLON.Debug {
  103527. /**
  103528. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  103529. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  103530. */
  103531. export class BoneAxesViewer extends AxesViewer {
  103532. /**
  103533. * Gets or sets the target mesh where to display the axes viewer
  103534. */
  103535. mesh: Nullable<Mesh>;
  103536. /**
  103537. * Gets or sets the target bone where to display the axes viewer
  103538. */
  103539. bone: Nullable<Bone>;
  103540. /** Gets current position */
  103541. pos: Vector3;
  103542. /** Gets direction of X axis */
  103543. xaxis: Vector3;
  103544. /** Gets direction of Y axis */
  103545. yaxis: Vector3;
  103546. /** Gets direction of Z axis */
  103547. zaxis: Vector3;
  103548. /**
  103549. * Creates a new BoneAxesViewer
  103550. * @param scene defines the hosting scene
  103551. * @param bone defines the target bone
  103552. * @param mesh defines the target mesh
  103553. * @param scaleLines defines a scaling factor for line length (1 by default)
  103554. */
  103555. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  103556. /**
  103557. * Force the viewer to update
  103558. */
  103559. update(): void;
  103560. /** Releases resources */
  103561. dispose(): void;
  103562. }
  103563. }
  103564. declare module BABYLON {
  103565. /**
  103566. * Interface used to define scene explorer extensibility option
  103567. */
  103568. export interface IExplorerExtensibilityOption {
  103569. /**
  103570. * Define the option label
  103571. */
  103572. label: string;
  103573. /**
  103574. * Defines the action to execute on click
  103575. */
  103576. action: (entity: any) => void;
  103577. }
  103578. /**
  103579. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  103580. */
  103581. export interface IExplorerExtensibilityGroup {
  103582. /**
  103583. * Defines a predicate to test if a given type mut be extended
  103584. */
  103585. predicate: (entity: any) => boolean;
  103586. /**
  103587. * Gets the list of options added to a type
  103588. */
  103589. entries: IExplorerExtensibilityOption[];
  103590. }
  103591. /**
  103592. * Interface used to define the options to use to create the Inspector
  103593. */
  103594. export interface IInspectorOptions {
  103595. /**
  103596. * Display in overlay mode (default: false)
  103597. */
  103598. overlay?: boolean;
  103599. /**
  103600. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  103601. */
  103602. globalRoot?: HTMLElement;
  103603. /**
  103604. * Display the Scene explorer
  103605. */
  103606. showExplorer?: boolean;
  103607. /**
  103608. * Display the property inspector
  103609. */
  103610. showInspector?: boolean;
  103611. /**
  103612. * Display in embed mode (both panes on the right)
  103613. */
  103614. embedMode?: boolean;
  103615. /**
  103616. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  103617. */
  103618. handleResize?: boolean;
  103619. /**
  103620. * Allow the panes to popup (default: true)
  103621. */
  103622. enablePopup?: boolean;
  103623. /**
  103624. * Allow the panes to be closed by users (default: true)
  103625. */
  103626. enableClose?: boolean;
  103627. /**
  103628. * Optional list of extensibility entries
  103629. */
  103630. explorerExtensibility?: IExplorerExtensibilityGroup[];
  103631. /**
  103632. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  103633. */
  103634. inspectorURL?: string;
  103635. }
  103636. interface Scene {
  103637. /**
  103638. * @hidden
  103639. * Backing field
  103640. */
  103641. _debugLayer: DebugLayer;
  103642. /**
  103643. * Gets the debug layer (aka Inspector) associated with the scene
  103644. * @see http://doc.babylonjs.com/features/playground_debuglayer
  103645. */
  103646. debugLayer: DebugLayer;
  103647. }
  103648. /**
  103649. * The debug layer (aka Inspector) is the go to tool in order to better understand
  103650. * what is happening in your scene
  103651. * @see http://doc.babylonjs.com/features/playground_debuglayer
  103652. */
  103653. export class DebugLayer {
  103654. /**
  103655. * Define the url to get the inspector script from.
  103656. * By default it uses the babylonjs CDN.
  103657. * @ignoreNaming
  103658. */
  103659. static InspectorURL: string;
  103660. private _scene;
  103661. private BJSINSPECTOR;
  103662. /**
  103663. * Observable triggered when a property is changed through the inspector.
  103664. */
  103665. onPropertyChangedObservable: Observable<{
  103666. object: any;
  103667. property: string;
  103668. value: any;
  103669. initialValue: any;
  103670. }>;
  103671. /**
  103672. * Instantiates a new debug layer.
  103673. * The debug layer (aka Inspector) is the go to tool in order to better understand
  103674. * what is happening in your scene
  103675. * @see http://doc.babylonjs.com/features/playground_debuglayer
  103676. * @param scene Defines the scene to inspect
  103677. */
  103678. constructor(scene: Scene);
  103679. /** Creates the inspector window. */
  103680. private _createInspector;
  103681. /**
  103682. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  103683. * @param entity defines the entity to select
  103684. * @param lineContainerTitle defines the specific block to highlight
  103685. */
  103686. select(entity: any, lineContainerTitle?: string): void;
  103687. /** Get the inspector from bundle or global */
  103688. private _getGlobalInspector;
  103689. /**
  103690. * Get if the inspector is visible or not.
  103691. * @returns true if visible otherwise, false
  103692. */
  103693. isVisible(): boolean;
  103694. /**
  103695. * Hide the inspector and close its window.
  103696. */
  103697. hide(): void;
  103698. /**
  103699. * Launch the debugLayer.
  103700. * @param config Define the configuration of the inspector
  103701. * @return a promise fulfilled when the debug layer is visible
  103702. */
  103703. show(config?: IInspectorOptions): Promise<DebugLayer>;
  103704. }
  103705. }
  103706. declare module BABYLON {
  103707. /**
  103708. * Class containing static functions to help procedurally build meshes
  103709. */
  103710. export class BoxBuilder {
  103711. /**
  103712. * Creates a box mesh
  103713. * * The parameter `size` sets the size (float) of each box side (default 1)
  103714. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  103715. * * 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)
  103716. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  103717. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103718. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103719. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103720. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  103721. * @param name defines the name of the mesh
  103722. * @param options defines the options used to create the mesh
  103723. * @param scene defines the hosting scene
  103724. * @returns the box mesh
  103725. */
  103726. static CreateBox(name: string, options: {
  103727. size?: number;
  103728. width?: number;
  103729. height?: number;
  103730. depth?: number;
  103731. faceUV?: Vector4[];
  103732. faceColors?: Color4[];
  103733. sideOrientation?: number;
  103734. frontUVs?: Vector4;
  103735. backUVs?: Vector4;
  103736. wrap?: boolean;
  103737. topBaseAt?: number;
  103738. bottomBaseAt?: number;
  103739. updatable?: boolean;
  103740. }, scene?: Nullable<Scene>): Mesh;
  103741. }
  103742. }
  103743. declare module BABYLON {
  103744. /**
  103745. * Class containing static functions to help procedurally build meshes
  103746. */
  103747. export class SphereBuilder {
  103748. /**
  103749. * Creates a sphere mesh
  103750. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  103751. * * 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`)
  103752. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  103753. * * 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
  103754. * * 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)
  103755. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103756. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103757. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103758. * @param name defines the name of the mesh
  103759. * @param options defines the options used to create the mesh
  103760. * @param scene defines the hosting scene
  103761. * @returns the sphere mesh
  103762. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  103763. */
  103764. static CreateSphere(name: string, options: {
  103765. segments?: number;
  103766. diameter?: number;
  103767. diameterX?: number;
  103768. diameterY?: number;
  103769. diameterZ?: number;
  103770. arc?: number;
  103771. slice?: number;
  103772. sideOrientation?: number;
  103773. frontUVs?: Vector4;
  103774. backUVs?: Vector4;
  103775. updatable?: boolean;
  103776. }, scene: any): Mesh;
  103777. }
  103778. }
  103779. declare module BABYLON.Debug {
  103780. /**
  103781. * Used to show the physics impostor around the specific mesh
  103782. */
  103783. export class PhysicsViewer {
  103784. /** @hidden */
  103785. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  103786. /** @hidden */
  103787. protected _meshes: Array<Nullable<AbstractMesh>>;
  103788. /** @hidden */
  103789. protected _scene: Nullable<Scene>;
  103790. /** @hidden */
  103791. protected _numMeshes: number;
  103792. /** @hidden */
  103793. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  103794. private _renderFunction;
  103795. private _utilityLayer;
  103796. private _debugBoxMesh;
  103797. private _debugSphereMesh;
  103798. private _debugCylinderMesh;
  103799. private _debugMaterial;
  103800. private _debugMeshMeshes;
  103801. /**
  103802. * Creates a new PhysicsViewer
  103803. * @param scene defines the hosting scene
  103804. */
  103805. constructor(scene: Scene);
  103806. /** @hidden */
  103807. protected _updateDebugMeshes(): void;
  103808. /**
  103809. * Renders a specified physic impostor
  103810. * @param impostor defines the impostor to render
  103811. * @param targetMesh defines the mesh represented by the impostor
  103812. * @returns the new debug mesh used to render the impostor
  103813. */
  103814. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  103815. /**
  103816. * Hides a specified physic impostor
  103817. * @param impostor defines the impostor to hide
  103818. */
  103819. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  103820. private _getDebugMaterial;
  103821. private _getDebugBoxMesh;
  103822. private _getDebugSphereMesh;
  103823. private _getDebugCylinderMesh;
  103824. private _getDebugMeshMesh;
  103825. private _getDebugMesh;
  103826. /** Releases all resources */
  103827. dispose(): void;
  103828. }
  103829. }
  103830. declare module BABYLON {
  103831. /**
  103832. * Class containing static functions to help procedurally build meshes
  103833. */
  103834. export class LinesBuilder {
  103835. /**
  103836. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  103837. * * 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
  103838. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  103839. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  103840. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  103841. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  103842. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  103843. * * 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
  103844. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  103845. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103846. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  103847. * @param name defines the name of the new line system
  103848. * @param options defines the options used to create the line system
  103849. * @param scene defines the hosting scene
  103850. * @returns a new line system mesh
  103851. */
  103852. static CreateLineSystem(name: string, options: {
  103853. lines: Vector3[][];
  103854. updatable?: boolean;
  103855. instance?: Nullable<LinesMesh>;
  103856. colors?: Nullable<Color4[][]>;
  103857. useVertexAlpha?: boolean;
  103858. }, scene: Nullable<Scene>): LinesMesh;
  103859. /**
  103860. * Creates a line mesh
  103861. * 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
  103862. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  103863. * * The parameter `points` is an array successive Vector3
  103864. * * 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
  103865. * * The optional parameter `colors` is an array of successive Color4, one per line point
  103866. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  103867. * * When updating an instance, remember that only point positions can change, not the number of points
  103868. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103869. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  103870. * @param name defines the name of the new line system
  103871. * @param options defines the options used to create the line system
  103872. * @param scene defines the hosting scene
  103873. * @returns a new line mesh
  103874. */
  103875. static CreateLines(name: string, options: {
  103876. points: Vector3[];
  103877. updatable?: boolean;
  103878. instance?: Nullable<LinesMesh>;
  103879. colors?: Color4[];
  103880. useVertexAlpha?: boolean;
  103881. }, scene?: Nullable<Scene>): LinesMesh;
  103882. /**
  103883. * Creates a dashed line mesh
  103884. * * 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
  103885. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  103886. * * The parameter `points` is an array successive Vector3
  103887. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  103888. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  103889. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  103890. * * 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
  103891. * * When updating an instance, remember that only point positions can change, not the number of points
  103892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103893. * @param name defines the name of the mesh
  103894. * @param options defines the options used to create the mesh
  103895. * @param scene defines the hosting scene
  103896. * @returns the dashed line mesh
  103897. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  103898. */
  103899. static CreateDashedLines(name: string, options: {
  103900. points: Vector3[];
  103901. dashSize?: number;
  103902. gapSize?: number;
  103903. dashNb?: number;
  103904. updatable?: boolean;
  103905. instance?: LinesMesh;
  103906. }, scene?: Nullable<Scene>): LinesMesh;
  103907. }
  103908. }
  103909. declare module BABYLON {
  103910. /**
  103911. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  103912. * in order to better appreciate the issue one might have.
  103913. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  103914. */
  103915. export class RayHelper {
  103916. /**
  103917. * Defines the ray we are currently tryin to visualize.
  103918. */
  103919. ray: Nullable<Ray>;
  103920. private _renderPoints;
  103921. private _renderLine;
  103922. private _renderFunction;
  103923. private _scene;
  103924. private _updateToMeshFunction;
  103925. private _attachedToMesh;
  103926. private _meshSpaceDirection;
  103927. private _meshSpaceOrigin;
  103928. /**
  103929. * Helper function to create a colored helper in a scene in one line.
  103930. * @param ray Defines the ray we are currently tryin to visualize
  103931. * @param scene Defines the scene the ray is used in
  103932. * @param color Defines the color we want to see the ray in
  103933. * @returns The newly created ray helper.
  103934. */
  103935. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  103936. /**
  103937. * Instantiate a new ray helper.
  103938. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  103939. * in order to better appreciate the issue one might have.
  103940. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  103941. * @param ray Defines the ray we are currently tryin to visualize
  103942. */
  103943. constructor(ray: Ray);
  103944. /**
  103945. * Shows the ray we are willing to debug.
  103946. * @param scene Defines the scene the ray needs to be rendered in
  103947. * @param color Defines the color the ray needs to be rendered in
  103948. */
  103949. show(scene: Scene, color?: Color3): void;
  103950. /**
  103951. * Hides the ray we are debugging.
  103952. */
  103953. hide(): void;
  103954. private _render;
  103955. /**
  103956. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  103957. * @param mesh Defines the mesh we want the helper attached to
  103958. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  103959. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  103960. * @param length Defines the length of the ray
  103961. */
  103962. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  103963. /**
  103964. * Detach the ray helper from the mesh it has previously been attached to.
  103965. */
  103966. detachFromMesh(): void;
  103967. private _updateToMesh;
  103968. /**
  103969. * Dispose the helper and release its associated resources.
  103970. */
  103971. dispose(): void;
  103972. }
  103973. }
  103974. declare module BABYLON.Debug {
  103975. /**
  103976. * Class used to render a debug view of a given skeleton
  103977. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  103978. */
  103979. export class SkeletonViewer {
  103980. /** defines the skeleton to render */
  103981. skeleton: Skeleton;
  103982. /** defines the mesh attached to the skeleton */
  103983. mesh: AbstractMesh;
  103984. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  103985. autoUpdateBonesMatrices: boolean;
  103986. /** defines the rendering group id to use with the viewer */
  103987. renderingGroupId: number;
  103988. /** Gets or sets the color used to render the skeleton */
  103989. color: Color3;
  103990. private _scene;
  103991. private _debugLines;
  103992. private _debugMesh;
  103993. private _isEnabled;
  103994. private _renderFunction;
  103995. private _utilityLayer;
  103996. /**
  103997. * Returns the mesh used to render the bones
  103998. */
  103999. readonly debugMesh: Nullable<LinesMesh>;
  104000. /**
  104001. * Creates a new SkeletonViewer
  104002. * @param skeleton defines the skeleton to render
  104003. * @param mesh defines the mesh attached to the skeleton
  104004. * @param scene defines the hosting scene
  104005. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  104006. * @param renderingGroupId defines the rendering group id to use with the viewer
  104007. */
  104008. constructor(
  104009. /** defines the skeleton to render */
  104010. skeleton: Skeleton,
  104011. /** defines the mesh attached to the skeleton */
  104012. mesh: AbstractMesh, scene: Scene,
  104013. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  104014. autoUpdateBonesMatrices?: boolean,
  104015. /** defines the rendering group id to use with the viewer */
  104016. renderingGroupId?: number);
  104017. /** Gets or sets a boolean indicating if the viewer is enabled */
  104018. isEnabled: boolean;
  104019. private _getBonePosition;
  104020. private _getLinesForBonesWithLength;
  104021. private _getLinesForBonesNoLength;
  104022. /** Update the viewer to sync with current skeleton state */
  104023. update(): void;
  104024. /** Release associated resources */
  104025. dispose(): void;
  104026. }
  104027. }
  104028. declare module BABYLON {
  104029. /**
  104030. * Options to create the null engine
  104031. */
  104032. export class NullEngineOptions {
  104033. /**
  104034. * Render width (Default: 512)
  104035. */
  104036. renderWidth: number;
  104037. /**
  104038. * Render height (Default: 256)
  104039. */
  104040. renderHeight: number;
  104041. /**
  104042. * Texture size (Default: 512)
  104043. */
  104044. textureSize: number;
  104045. /**
  104046. * If delta time between frames should be constant
  104047. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104048. */
  104049. deterministicLockstep: boolean;
  104050. /**
  104051. * Maximum about of steps between frames (Default: 4)
  104052. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104053. */
  104054. lockstepMaxSteps: number;
  104055. }
  104056. /**
  104057. * The null engine class provides support for headless version of babylon.js.
  104058. * This can be used in server side scenario or for testing purposes
  104059. */
  104060. export class NullEngine extends Engine {
  104061. private _options;
  104062. /**
  104063. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104064. */
  104065. isDeterministicLockStep(): boolean;
  104066. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  104067. getLockstepMaxSteps(): number;
  104068. /**
  104069. * Sets hardware scaling, used to save performance if needed
  104070. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  104071. */
  104072. getHardwareScalingLevel(): number;
  104073. constructor(options?: NullEngineOptions);
  104074. createVertexBuffer(vertices: FloatArray): DataBuffer;
  104075. createIndexBuffer(indices: IndicesArray): DataBuffer;
  104076. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  104077. getRenderWidth(useScreen?: boolean): number;
  104078. getRenderHeight(useScreen?: boolean): number;
  104079. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  104080. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  104081. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  104082. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  104083. bindSamplers(effect: Effect): void;
  104084. enableEffect(effect: Effect): void;
  104085. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  104086. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  104087. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  104088. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  104089. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  104090. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  104091. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  104092. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  104093. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  104094. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  104095. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  104096. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  104097. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  104098. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  104099. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  104100. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  104101. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  104102. setFloat(uniform: WebGLUniformLocation, value: number): void;
  104103. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  104104. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  104105. setBool(uniform: WebGLUniformLocation, bool: number): void;
  104106. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  104107. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  104108. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  104109. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  104110. bindBuffers(vertexBuffers: {
  104111. [key: string]: VertexBuffer;
  104112. }, indexBuffer: DataBuffer, effect: Effect): void;
  104113. wipeCaches(bruteForce?: boolean): void;
  104114. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  104115. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  104116. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104117. /** @hidden */
  104118. _createTexture(): WebGLTexture;
  104119. /** @hidden */
  104120. _releaseTexture(texture: InternalTexture): void;
  104121. 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;
  104122. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  104123. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  104124. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  104125. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  104126. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  104127. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  104128. areAllEffectsReady(): boolean;
  104129. /**
  104130. * @hidden
  104131. * Get the current error code of the webGL context
  104132. * @returns the error code
  104133. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  104134. */
  104135. getError(): number;
  104136. /** @hidden */
  104137. _getUnpackAlignement(): number;
  104138. /** @hidden */
  104139. _unpackFlipY(value: boolean): void;
  104140. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  104141. /**
  104142. * Updates a dynamic vertex buffer.
  104143. * @param vertexBuffer the vertex buffer to update
  104144. * @param data the data used to update the vertex buffer
  104145. * @param byteOffset the byte offset of the data (optional)
  104146. * @param byteLength the byte length of the data (optional)
  104147. */
  104148. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  104149. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  104150. /** @hidden */
  104151. _bindTexture(channel: number, texture: InternalTexture): void;
  104152. /** @hidden */
  104153. _releaseBuffer(buffer: DataBuffer): boolean;
  104154. releaseEffects(): void;
  104155. displayLoadingUI(): void;
  104156. hideLoadingUI(): void;
  104157. /** @hidden */
  104158. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104159. /** @hidden */
  104160. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104161. /** @hidden */
  104162. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104163. /** @hidden */
  104164. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  104165. }
  104166. }
  104167. declare module BABYLON {
  104168. /** @hidden */
  104169. export class _OcclusionDataStorage {
  104170. /** @hidden */
  104171. occlusionInternalRetryCounter: number;
  104172. /** @hidden */
  104173. isOcclusionQueryInProgress: boolean;
  104174. /** @hidden */
  104175. isOccluded: boolean;
  104176. /** @hidden */
  104177. occlusionRetryCount: number;
  104178. /** @hidden */
  104179. occlusionType: number;
  104180. /** @hidden */
  104181. occlusionQueryAlgorithmType: number;
  104182. }
  104183. interface Engine {
  104184. /**
  104185. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  104186. * @return the new query
  104187. */
  104188. createQuery(): WebGLQuery;
  104189. /**
  104190. * Delete and release a webGL query
  104191. * @param query defines the query to delete
  104192. * @return the current engine
  104193. */
  104194. deleteQuery(query: WebGLQuery): Engine;
  104195. /**
  104196. * Check if a given query has resolved and got its value
  104197. * @param query defines the query to check
  104198. * @returns true if the query got its value
  104199. */
  104200. isQueryResultAvailable(query: WebGLQuery): boolean;
  104201. /**
  104202. * Gets the value of a given query
  104203. * @param query defines the query to check
  104204. * @returns the value of the query
  104205. */
  104206. getQueryResult(query: WebGLQuery): number;
  104207. /**
  104208. * Initiates an occlusion query
  104209. * @param algorithmType defines the algorithm to use
  104210. * @param query defines the query to use
  104211. * @returns the current engine
  104212. * @see http://doc.babylonjs.com/features/occlusionquery
  104213. */
  104214. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  104215. /**
  104216. * Ends an occlusion query
  104217. * @see http://doc.babylonjs.com/features/occlusionquery
  104218. * @param algorithmType defines the algorithm to use
  104219. * @returns the current engine
  104220. */
  104221. endOcclusionQuery(algorithmType: number): Engine;
  104222. /**
  104223. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  104224. * Please note that only one query can be issued at a time
  104225. * @returns a time token used to track the time span
  104226. */
  104227. startTimeQuery(): Nullable<_TimeToken>;
  104228. /**
  104229. * Ends a time query
  104230. * @param token defines the token used to measure the time span
  104231. * @returns the time spent (in ns)
  104232. */
  104233. endTimeQuery(token: _TimeToken): int;
  104234. /** @hidden */
  104235. _currentNonTimestampToken: Nullable<_TimeToken>;
  104236. /** @hidden */
  104237. _createTimeQuery(): WebGLQuery;
  104238. /** @hidden */
  104239. _deleteTimeQuery(query: WebGLQuery): void;
  104240. /** @hidden */
  104241. _getGlAlgorithmType(algorithmType: number): number;
  104242. /** @hidden */
  104243. _getTimeQueryResult(query: WebGLQuery): any;
  104244. /** @hidden */
  104245. _getTimeQueryAvailability(query: WebGLQuery): any;
  104246. }
  104247. interface AbstractMesh {
  104248. /**
  104249. * Backing filed
  104250. * @hidden
  104251. */
  104252. __occlusionDataStorage: _OcclusionDataStorage;
  104253. /**
  104254. * Access property
  104255. * @hidden
  104256. */
  104257. _occlusionDataStorage: _OcclusionDataStorage;
  104258. /**
  104259. * 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.
  104260. * The default value is -1 which means don't break the query and wait till the result
  104261. * @see http://doc.babylonjs.com/features/occlusionquery
  104262. */
  104263. occlusionRetryCount: number;
  104264. /**
  104265. * 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:
  104266. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  104267. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  104268. * * 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.
  104269. * @see http://doc.babylonjs.com/features/occlusionquery
  104270. */
  104271. occlusionType: number;
  104272. /**
  104273. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  104274. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  104275. * * 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.
  104276. * @see http://doc.babylonjs.com/features/occlusionquery
  104277. */
  104278. occlusionQueryAlgorithmType: number;
  104279. /**
  104280. * 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
  104281. * @see http://doc.babylonjs.com/features/occlusionquery
  104282. */
  104283. isOccluded: boolean;
  104284. /**
  104285. * Flag to check the progress status of the query
  104286. * @see http://doc.babylonjs.com/features/occlusionquery
  104287. */
  104288. isOcclusionQueryInProgress: boolean;
  104289. }
  104290. }
  104291. declare module BABYLON {
  104292. /** @hidden */
  104293. export var _forceTransformFeedbackToBundle: boolean;
  104294. interface Engine {
  104295. /**
  104296. * Creates a webGL transform feedback object
  104297. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  104298. * @returns the webGL transform feedback object
  104299. */
  104300. createTransformFeedback(): WebGLTransformFeedback;
  104301. /**
  104302. * Delete a webGL transform feedback object
  104303. * @param value defines the webGL transform feedback object to delete
  104304. */
  104305. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  104306. /**
  104307. * Bind a webGL transform feedback object to the webgl context
  104308. * @param value defines the webGL transform feedback object to bind
  104309. */
  104310. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  104311. /**
  104312. * Begins a transform feedback operation
  104313. * @param usePoints defines if points or triangles must be used
  104314. */
  104315. beginTransformFeedback(usePoints: boolean): void;
  104316. /**
  104317. * Ends a transform feedback operation
  104318. */
  104319. endTransformFeedback(): void;
  104320. /**
  104321. * Specify the varyings to use with transform feedback
  104322. * @param program defines the associated webGL program
  104323. * @param value defines the list of strings representing the varying names
  104324. */
  104325. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  104326. /**
  104327. * Bind a webGL buffer for a transform feedback operation
  104328. * @param value defines the webGL buffer to bind
  104329. */
  104330. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  104331. }
  104332. }
  104333. declare module BABYLON {
  104334. /**
  104335. * Creation options of the multi render target texture.
  104336. */
  104337. export interface IMultiRenderTargetOptions {
  104338. /**
  104339. * Define if the texture needs to create mip maps after render.
  104340. */
  104341. generateMipMaps?: boolean;
  104342. /**
  104343. * Define the types of all the draw buffers we want to create
  104344. */
  104345. types?: number[];
  104346. /**
  104347. * Define the sampling modes of all the draw buffers we want to create
  104348. */
  104349. samplingModes?: number[];
  104350. /**
  104351. * Define if a depth buffer is required
  104352. */
  104353. generateDepthBuffer?: boolean;
  104354. /**
  104355. * Define if a stencil buffer is required
  104356. */
  104357. generateStencilBuffer?: boolean;
  104358. /**
  104359. * Define if a depth texture is required instead of a depth buffer
  104360. */
  104361. generateDepthTexture?: boolean;
  104362. /**
  104363. * Define the number of desired draw buffers
  104364. */
  104365. textureCount?: number;
  104366. /**
  104367. * Define if aspect ratio should be adapted to the texture or stay the scene one
  104368. */
  104369. doNotChangeAspectRatio?: boolean;
  104370. /**
  104371. * Define the default type of the buffers we are creating
  104372. */
  104373. defaultType?: number;
  104374. }
  104375. /**
  104376. * A multi render target, like a render target provides the ability to render to a texture.
  104377. * Unlike the render target, it can render to several draw buffers in one draw.
  104378. * This is specially interesting in deferred rendering or for any effects requiring more than
  104379. * just one color from a single pass.
  104380. */
  104381. export class MultiRenderTarget extends RenderTargetTexture {
  104382. private _internalTextures;
  104383. private _textures;
  104384. private _multiRenderTargetOptions;
  104385. /**
  104386. * Get if draw buffers are currently supported by the used hardware and browser.
  104387. */
  104388. readonly isSupported: boolean;
  104389. /**
  104390. * Get the list of textures generated by the multi render target.
  104391. */
  104392. readonly textures: Texture[];
  104393. /**
  104394. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  104395. */
  104396. readonly depthTexture: Texture;
  104397. /**
  104398. * Set the wrapping mode on U of all the textures we are rendering to.
  104399. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104400. */
  104401. wrapU: number;
  104402. /**
  104403. * Set the wrapping mode on V of all the textures we are rendering to.
  104404. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104405. */
  104406. wrapV: number;
  104407. /**
  104408. * Instantiate a new multi render target texture.
  104409. * A multi render target, like a render target provides the ability to render to a texture.
  104410. * Unlike the render target, it can render to several draw buffers in one draw.
  104411. * This is specially interesting in deferred rendering or for any effects requiring more than
  104412. * just one color from a single pass.
  104413. * @param name Define the name of the texture
  104414. * @param size Define the size of the buffers to render to
  104415. * @param count Define the number of target we are rendering into
  104416. * @param scene Define the scene the texture belongs to
  104417. * @param options Define the options used to create the multi render target
  104418. */
  104419. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  104420. /** @hidden */
  104421. _rebuild(): void;
  104422. private _createInternalTextures;
  104423. private _createTextures;
  104424. /**
  104425. * Define the number of samples used if MSAA is enabled.
  104426. */
  104427. samples: number;
  104428. /**
  104429. * Resize all the textures in the multi render target.
  104430. * Be carrefull as it will recreate all the data in the new texture.
  104431. * @param size Define the new size
  104432. */
  104433. resize(size: any): void;
  104434. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  104435. /**
  104436. * Dispose the render targets and their associated resources
  104437. */
  104438. dispose(): void;
  104439. /**
  104440. * Release all the underlying texture used as draw buffers.
  104441. */
  104442. releaseInternalTextures(): void;
  104443. }
  104444. }
  104445. declare module BABYLON {
  104446. interface Engine {
  104447. /**
  104448. * Unbind a list of render target textures from the webGL context
  104449. * This is used only when drawBuffer extension or webGL2 are active
  104450. * @param textures defines the render target textures to unbind
  104451. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  104452. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  104453. */
  104454. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  104455. /**
  104456. * Create a multi render target texture
  104457. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  104458. * @param size defines the size of the texture
  104459. * @param options defines the creation options
  104460. * @returns the cube texture as an InternalTexture
  104461. */
  104462. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  104463. /**
  104464. * Update the sample count for a given multiple render target texture
  104465. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  104466. * @param textures defines the textures to update
  104467. * @param samples defines the sample count to set
  104468. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  104469. */
  104470. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  104471. }
  104472. }
  104473. declare module BABYLON {
  104474. /**
  104475. * Gather the list of clipboard event types as constants.
  104476. */
  104477. export class ClipboardEventTypes {
  104478. /**
  104479. * The clipboard event is fired when a copy command is active (pressed).
  104480. */
  104481. static readonly COPY: number;
  104482. /**
  104483. * The clipboard event is fired when a cut command is active (pressed).
  104484. */
  104485. static readonly CUT: number;
  104486. /**
  104487. * The clipboard event is fired when a paste command is active (pressed).
  104488. */
  104489. static readonly PASTE: number;
  104490. }
  104491. /**
  104492. * This class is used to store clipboard related info for the onClipboardObservable event.
  104493. */
  104494. export class ClipboardInfo {
  104495. /**
  104496. * Defines the type of event (BABYLON.ClipboardEventTypes)
  104497. */
  104498. type: number;
  104499. /**
  104500. * Defines the related dom event
  104501. */
  104502. event: ClipboardEvent;
  104503. /**
  104504. *Creates an instance of ClipboardInfo.
  104505. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  104506. * @param event Defines the related dom event
  104507. */
  104508. constructor(
  104509. /**
  104510. * Defines the type of event (BABYLON.ClipboardEventTypes)
  104511. */
  104512. type: number,
  104513. /**
  104514. * Defines the related dom event
  104515. */
  104516. event: ClipboardEvent);
  104517. /**
  104518. * Get the clipboard event's type from the keycode.
  104519. * @param keyCode Defines the keyCode for the current keyboard event.
  104520. * @return {number}
  104521. */
  104522. static GetTypeFromCharacter(keyCode: number): number;
  104523. }
  104524. }
  104525. declare module BABYLON {
  104526. /**
  104527. * Class used to represent data loading progression
  104528. */
  104529. export class SceneLoaderProgressEvent {
  104530. /** defines if data length to load can be evaluated */
  104531. readonly lengthComputable: boolean;
  104532. /** defines the loaded data length */
  104533. readonly loaded: number;
  104534. /** defines the data length to load */
  104535. readonly total: number;
  104536. /**
  104537. * Create a new progress event
  104538. * @param lengthComputable defines if data length to load can be evaluated
  104539. * @param loaded defines the loaded data length
  104540. * @param total defines the data length to load
  104541. */
  104542. constructor(
  104543. /** defines if data length to load can be evaluated */
  104544. lengthComputable: boolean,
  104545. /** defines the loaded data length */
  104546. loaded: number,
  104547. /** defines the data length to load */
  104548. total: number);
  104549. /**
  104550. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  104551. * @param event defines the source event
  104552. * @returns a new SceneLoaderProgressEvent
  104553. */
  104554. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  104555. }
  104556. /**
  104557. * Interface used by SceneLoader plugins to define supported file extensions
  104558. */
  104559. export interface ISceneLoaderPluginExtensions {
  104560. /**
  104561. * Defines the list of supported extensions
  104562. */
  104563. [extension: string]: {
  104564. isBinary: boolean;
  104565. };
  104566. }
  104567. /**
  104568. * Interface used by SceneLoader plugin factory
  104569. */
  104570. export interface ISceneLoaderPluginFactory {
  104571. /**
  104572. * Defines the name of the factory
  104573. */
  104574. name: string;
  104575. /**
  104576. * Function called to create a new plugin
  104577. * @return the new plugin
  104578. */
  104579. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  104580. /**
  104581. * Boolean indicating if the plugin can direct load specific data
  104582. */
  104583. canDirectLoad?: (data: string) => boolean;
  104584. }
  104585. /**
  104586. * Interface used to define a SceneLoader plugin
  104587. */
  104588. export interface ISceneLoaderPlugin {
  104589. /**
  104590. * The friendly name of this plugin.
  104591. */
  104592. name: string;
  104593. /**
  104594. * The file extensions supported by this plugin.
  104595. */
  104596. extensions: string | ISceneLoaderPluginExtensions;
  104597. /**
  104598. * Import meshes into a scene.
  104599. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  104600. * @param scene The scene to import into
  104601. * @param data The data to import
  104602. * @param rootUrl The root url for scene and resources
  104603. * @param meshes The meshes array to import into
  104604. * @param particleSystems The particle systems array to import into
  104605. * @param skeletons The skeletons array to import into
  104606. * @param onError The callback when import fails
  104607. * @returns True if successful or false otherwise
  104608. */
  104609. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  104610. /**
  104611. * Load into a scene.
  104612. * @param scene The scene to load into
  104613. * @param data The data to import
  104614. * @param rootUrl The root url for scene and resources
  104615. * @param onError The callback when import fails
  104616. * @returns true if successful or false otherwise
  104617. */
  104618. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  104619. /**
  104620. * The callback that returns true if the data can be directly loaded.
  104621. */
  104622. canDirectLoad?: (data: string) => boolean;
  104623. /**
  104624. * The callback that allows custom handling of the root url based on the response url.
  104625. */
  104626. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  104627. /**
  104628. * Load into an asset container.
  104629. * @param scene The scene to load into
  104630. * @param data The data to import
  104631. * @param rootUrl The root url for scene and resources
  104632. * @param onError The callback when import fails
  104633. * @returns The loaded asset container
  104634. */
  104635. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  104636. }
  104637. /**
  104638. * Interface used to define an async SceneLoader plugin
  104639. */
  104640. export interface ISceneLoaderPluginAsync {
  104641. /**
  104642. * The friendly name of this plugin.
  104643. */
  104644. name: string;
  104645. /**
  104646. * The file extensions supported by this plugin.
  104647. */
  104648. extensions: string | ISceneLoaderPluginExtensions;
  104649. /**
  104650. * Import meshes into a scene.
  104651. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  104652. * @param scene The scene to import into
  104653. * @param data The data to import
  104654. * @param rootUrl The root url for scene and resources
  104655. * @param onProgress The callback when the load progresses
  104656. * @param fileName Defines the name of the file to load
  104657. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  104658. */
  104659. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  104660. meshes: AbstractMesh[];
  104661. particleSystems: IParticleSystem[];
  104662. skeletons: Skeleton[];
  104663. animationGroups: AnimationGroup[];
  104664. }>;
  104665. /**
  104666. * Load into a scene.
  104667. * @param scene The scene to load into
  104668. * @param data The data to import
  104669. * @param rootUrl The root url for scene and resources
  104670. * @param onProgress The callback when the load progresses
  104671. * @param fileName Defines the name of the file to load
  104672. * @returns Nothing
  104673. */
  104674. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  104675. /**
  104676. * The callback that returns true if the data can be directly loaded.
  104677. */
  104678. canDirectLoad?: (data: string) => boolean;
  104679. /**
  104680. * The callback that allows custom handling of the root url based on the response url.
  104681. */
  104682. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  104683. /**
  104684. * Load into an asset container.
  104685. * @param scene The scene to load into
  104686. * @param data The data to import
  104687. * @param rootUrl The root url for scene and resources
  104688. * @param onProgress The callback when the load progresses
  104689. * @param fileName Defines the name of the file to load
  104690. * @returns The loaded asset container
  104691. */
  104692. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  104693. }
  104694. /**
  104695. * Class used to load scene from various file formats using registered plugins
  104696. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  104697. */
  104698. export class SceneLoader {
  104699. /**
  104700. * No logging while loading
  104701. */
  104702. static readonly NO_LOGGING: number;
  104703. /**
  104704. * Minimal logging while loading
  104705. */
  104706. static readonly MINIMAL_LOGGING: number;
  104707. /**
  104708. * Summary logging while loading
  104709. */
  104710. static readonly SUMMARY_LOGGING: number;
  104711. /**
  104712. * Detailled logging while loading
  104713. */
  104714. static readonly DETAILED_LOGGING: number;
  104715. /**
  104716. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  104717. */
  104718. static ForceFullSceneLoadingForIncremental: boolean;
  104719. /**
  104720. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  104721. */
  104722. static ShowLoadingScreen: boolean;
  104723. /**
  104724. * Defines the current logging level (while loading the scene)
  104725. * @ignorenaming
  104726. */
  104727. static loggingLevel: number;
  104728. /**
  104729. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  104730. */
  104731. static CleanBoneMatrixWeights: boolean;
  104732. /**
  104733. * Event raised when a plugin is used to load a scene
  104734. */
  104735. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  104736. private static _registeredPlugins;
  104737. private static _getDefaultPlugin;
  104738. private static _getPluginForExtension;
  104739. private static _getPluginForDirectLoad;
  104740. private static _getPluginForFilename;
  104741. private static _getDirectLoad;
  104742. private static _loadData;
  104743. private static _getFileInfo;
  104744. /**
  104745. * Gets a plugin that can load the given extension
  104746. * @param extension defines the extension to load
  104747. * @returns a plugin or null if none works
  104748. */
  104749. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  104750. /**
  104751. * Gets a boolean indicating that the given extension can be loaded
  104752. * @param extension defines the extension to load
  104753. * @returns true if the extension is supported
  104754. */
  104755. static IsPluginForExtensionAvailable(extension: string): boolean;
  104756. /**
  104757. * Adds a new plugin to the list of registered plugins
  104758. * @param plugin defines the plugin to add
  104759. */
  104760. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  104761. /**
  104762. * Import meshes into a scene
  104763. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  104764. * @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)
  104765. * @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)
  104766. * @param scene the instance of BABYLON.Scene to append to
  104767. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  104768. * @param onProgress a callback with a progress event for each file being loaded
  104769. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  104770. * @param pluginExtension the extension used to determine the plugin
  104771. * @returns The loaded plugin
  104772. */
  104773. 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>;
  104774. /**
  104775. * Import meshes into a scene
  104776. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  104777. * @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)
  104778. * @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)
  104779. * @param scene the instance of BABYLON.Scene to append to
  104780. * @param onProgress a callback with a progress event for each file being loaded
  104781. * @param pluginExtension the extension used to determine the plugin
  104782. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  104783. */
  104784. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  104785. meshes: AbstractMesh[];
  104786. particleSystems: IParticleSystem[];
  104787. skeletons: Skeleton[];
  104788. animationGroups: AnimationGroup[];
  104789. }>;
  104790. /**
  104791. * Load a scene
  104792. * @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)
  104793. * @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)
  104794. * @param engine is the instance of BABYLON.Engine to use to create the scene
  104795. * @param onSuccess a callback with the scene when import succeeds
  104796. * @param onProgress a callback with a progress event for each file being loaded
  104797. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  104798. * @param pluginExtension the extension used to determine the plugin
  104799. * @returns The loaded plugin
  104800. */
  104801. 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>;
  104802. /**
  104803. * Load a scene
  104804. * @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)
  104805. * @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)
  104806. * @param engine is the instance of BABYLON.Engine to use to create the scene
  104807. * @param onProgress a callback with a progress event for each file being loaded
  104808. * @param pluginExtension the extension used to determine the plugin
  104809. * @returns The loaded scene
  104810. */
  104811. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  104812. /**
  104813. * Append a scene
  104814. * @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)
  104815. * @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)
  104816. * @param scene is the instance of BABYLON.Scene to append to
  104817. * @param onSuccess a callback with the scene when import succeeds
  104818. * @param onProgress a callback with a progress event for each file being loaded
  104819. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  104820. * @param pluginExtension the extension used to determine the plugin
  104821. * @returns The loaded plugin
  104822. */
  104823. 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>;
  104824. /**
  104825. * Append a scene
  104826. * @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)
  104827. * @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)
  104828. * @param scene is the instance of BABYLON.Scene to append to
  104829. * @param onProgress a callback with a progress event for each file being loaded
  104830. * @param pluginExtension the extension used to determine the plugin
  104831. * @returns The given scene
  104832. */
  104833. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  104834. /**
  104835. * Load a scene into an asset container
  104836. * @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)
  104837. * @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)
  104838. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  104839. * @param onSuccess a callback with the scene when import succeeds
  104840. * @param onProgress a callback with a progress event for each file being loaded
  104841. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  104842. * @param pluginExtension the extension used to determine the plugin
  104843. * @returns The loaded plugin
  104844. */
  104845. 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>;
  104846. /**
  104847. * Load a scene into an asset container
  104848. * @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)
  104849. * @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)
  104850. * @param scene is the instance of Scene to append to
  104851. * @param onProgress a callback with a progress event for each file being loaded
  104852. * @param pluginExtension the extension used to determine the plugin
  104853. * @returns The loaded asset container
  104854. */
  104855. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  104856. }
  104857. }
  104858. declare module BABYLON {
  104859. /**
  104860. * Google Daydream controller
  104861. */
  104862. export class DaydreamController extends WebVRController {
  104863. /**
  104864. * Base Url for the controller model.
  104865. */
  104866. static MODEL_BASE_URL: string;
  104867. /**
  104868. * File name for the controller model.
  104869. */
  104870. static MODEL_FILENAME: string;
  104871. /**
  104872. * Gamepad Id prefix used to identify Daydream Controller.
  104873. */
  104874. static readonly GAMEPAD_ID_PREFIX: string;
  104875. /**
  104876. * Creates a new DaydreamController from a gamepad
  104877. * @param vrGamepad the gamepad that the controller should be created from
  104878. */
  104879. constructor(vrGamepad: any);
  104880. /**
  104881. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  104882. * @param scene scene in which to add meshes
  104883. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  104884. */
  104885. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  104886. /**
  104887. * Called once for each button that changed state since the last frame
  104888. * @param buttonIdx Which button index changed
  104889. * @param state New state of the button
  104890. * @param changes Which properties on the state changed since last frame
  104891. */
  104892. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  104893. }
  104894. }
  104895. declare module BABYLON {
  104896. /**
  104897. * Gear VR Controller
  104898. */
  104899. export class GearVRController extends WebVRController {
  104900. /**
  104901. * Base Url for the controller model.
  104902. */
  104903. static MODEL_BASE_URL: string;
  104904. /**
  104905. * File name for the controller model.
  104906. */
  104907. static MODEL_FILENAME: string;
  104908. /**
  104909. * Gamepad Id prefix used to identify this controller.
  104910. */
  104911. static readonly GAMEPAD_ID_PREFIX: string;
  104912. private readonly _buttonIndexToObservableNameMap;
  104913. /**
  104914. * Creates a new GearVRController from a gamepad
  104915. * @param vrGamepad the gamepad that the controller should be created from
  104916. */
  104917. constructor(vrGamepad: any);
  104918. /**
  104919. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  104920. * @param scene scene in which to add meshes
  104921. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  104922. */
  104923. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  104924. /**
  104925. * Called once for each button that changed state since the last frame
  104926. * @param buttonIdx Which button index changed
  104927. * @param state New state of the button
  104928. * @param changes Which properties on the state changed since last frame
  104929. */
  104930. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  104931. }
  104932. }
  104933. declare module BABYLON {
  104934. /**
  104935. * Generic Controller
  104936. */
  104937. export class GenericController extends WebVRController {
  104938. /**
  104939. * Base Url for the controller model.
  104940. */
  104941. static readonly MODEL_BASE_URL: string;
  104942. /**
  104943. * File name for the controller model.
  104944. */
  104945. static readonly MODEL_FILENAME: string;
  104946. /**
  104947. * Creates a new GenericController from a gamepad
  104948. * @param vrGamepad the gamepad that the controller should be created from
  104949. */
  104950. constructor(vrGamepad: any);
  104951. /**
  104952. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  104953. * @param scene scene in which to add meshes
  104954. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  104955. */
  104956. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  104957. /**
  104958. * Called once for each button that changed state since the last frame
  104959. * @param buttonIdx Which button index changed
  104960. * @param state New state of the button
  104961. * @param changes Which properties on the state changed since last frame
  104962. */
  104963. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  104964. }
  104965. }
  104966. declare module BABYLON {
  104967. /**
  104968. * Oculus Touch Controller
  104969. */
  104970. export class OculusTouchController extends WebVRController {
  104971. /**
  104972. * Base Url for the controller model.
  104973. */
  104974. static MODEL_BASE_URL: string;
  104975. /**
  104976. * File name for the left controller model.
  104977. */
  104978. static MODEL_LEFT_FILENAME: string;
  104979. /**
  104980. * File name for the right controller model.
  104981. */
  104982. static MODEL_RIGHT_FILENAME: string;
  104983. /**
  104984. * Fired when the secondary trigger on this controller is modified
  104985. */
  104986. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  104987. /**
  104988. * Fired when the thumb rest on this controller is modified
  104989. */
  104990. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  104991. /**
  104992. * Creates a new OculusTouchController from a gamepad
  104993. * @param vrGamepad the gamepad that the controller should be created from
  104994. */
  104995. constructor(vrGamepad: any);
  104996. /**
  104997. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  104998. * @param scene scene in which to add meshes
  104999. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105000. */
  105001. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105002. /**
  105003. * Fired when the A button on this controller is modified
  105004. */
  105005. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105006. /**
  105007. * Fired when the B button on this controller is modified
  105008. */
  105009. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105010. /**
  105011. * Fired when the X button on this controller is modified
  105012. */
  105013. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105014. /**
  105015. * Fired when the Y button on this controller is modified
  105016. */
  105017. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105018. /**
  105019. * Called once for each button that changed state since the last frame
  105020. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  105021. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  105022. * 2) secondary trigger (same)
  105023. * 3) A (right) X (left), touch, pressed = value
  105024. * 4) B / Y
  105025. * 5) thumb rest
  105026. * @param buttonIdx Which button index changed
  105027. * @param state New state of the button
  105028. * @param changes Which properties on the state changed since last frame
  105029. */
  105030. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105031. }
  105032. }
  105033. declare module BABYLON {
  105034. /**
  105035. * Vive Controller
  105036. */
  105037. export class ViveController extends WebVRController {
  105038. /**
  105039. * Base Url for the controller model.
  105040. */
  105041. static MODEL_BASE_URL: string;
  105042. /**
  105043. * File name for the controller model.
  105044. */
  105045. static MODEL_FILENAME: string;
  105046. /**
  105047. * Creates a new ViveController from a gamepad
  105048. * @param vrGamepad the gamepad that the controller should be created from
  105049. */
  105050. constructor(vrGamepad: any);
  105051. /**
  105052. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105053. * @param scene scene in which to add meshes
  105054. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105055. */
  105056. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105057. /**
  105058. * Fired when the left button on this controller is modified
  105059. */
  105060. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105061. /**
  105062. * Fired when the right button on this controller is modified
  105063. */
  105064. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105065. /**
  105066. * Fired when the menu button on this controller is modified
  105067. */
  105068. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105069. /**
  105070. * Called once for each button that changed state since the last frame
  105071. * Vive mapping:
  105072. * 0: touchpad
  105073. * 1: trigger
  105074. * 2: left AND right buttons
  105075. * 3: menu button
  105076. * @param buttonIdx Which button index changed
  105077. * @param state New state of the button
  105078. * @param changes Which properties on the state changed since last frame
  105079. */
  105080. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105081. }
  105082. }
  105083. declare module BABYLON {
  105084. /**
  105085. * Defines the WindowsMotionController object that the state of the windows motion controller
  105086. */
  105087. export class WindowsMotionController extends WebVRController {
  105088. /**
  105089. * The base url used to load the left and right controller models
  105090. */
  105091. static MODEL_BASE_URL: string;
  105092. /**
  105093. * The name of the left controller model file
  105094. */
  105095. static MODEL_LEFT_FILENAME: string;
  105096. /**
  105097. * The name of the right controller model file
  105098. */
  105099. static MODEL_RIGHT_FILENAME: string;
  105100. /**
  105101. * The controller name prefix for this controller type
  105102. */
  105103. static readonly GAMEPAD_ID_PREFIX: string;
  105104. /**
  105105. * The controller id pattern for this controller type
  105106. */
  105107. private static readonly GAMEPAD_ID_PATTERN;
  105108. private _loadedMeshInfo;
  105109. private readonly _mapping;
  105110. /**
  105111. * Fired when the trackpad on this controller is clicked
  105112. */
  105113. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  105114. /**
  105115. * Fired when the trackpad on this controller is modified
  105116. */
  105117. onTrackpadValuesChangedObservable: Observable<StickValues>;
  105118. /**
  105119. * The current x and y values of this controller's trackpad
  105120. */
  105121. trackpad: StickValues;
  105122. /**
  105123. * Creates a new WindowsMotionController from a gamepad
  105124. * @param vrGamepad the gamepad that the controller should be created from
  105125. */
  105126. constructor(vrGamepad: any);
  105127. /**
  105128. * Fired when the trigger on this controller is modified
  105129. */
  105130. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105131. /**
  105132. * Fired when the menu button on this controller is modified
  105133. */
  105134. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105135. /**
  105136. * Fired when the grip button on this controller is modified
  105137. */
  105138. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105139. /**
  105140. * Fired when the thumbstick button on this controller is modified
  105141. */
  105142. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105143. /**
  105144. * Fired when the touchpad button on this controller is modified
  105145. */
  105146. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105147. /**
  105148. * Fired when the touchpad values on this controller are modified
  105149. */
  105150. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  105151. private _updateTrackpad;
  105152. /**
  105153. * Called once per frame by the engine.
  105154. */
  105155. update(): void;
  105156. /**
  105157. * Called once for each button that changed state since the last frame
  105158. * @param buttonIdx Which button index changed
  105159. * @param state New state of the button
  105160. * @param changes Which properties on the state changed since last frame
  105161. */
  105162. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105163. /**
  105164. * Moves the buttons on the controller mesh based on their current state
  105165. * @param buttonName the name of the button to move
  105166. * @param buttonValue the value of the button which determines the buttons new position
  105167. */
  105168. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  105169. /**
  105170. * Moves the axis on the controller mesh based on its current state
  105171. * @param axis the index of the axis
  105172. * @param axisValue the value of the axis which determines the meshes new position
  105173. * @hidden
  105174. */
  105175. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  105176. /**
  105177. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105178. * @param scene scene in which to add meshes
  105179. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105180. */
  105181. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  105182. /**
  105183. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  105184. * can be transformed by button presses and axes values, based on this._mapping.
  105185. *
  105186. * @param scene scene in which the meshes exist
  105187. * @param meshes list of meshes that make up the controller model to process
  105188. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  105189. */
  105190. private processModel;
  105191. private createMeshInfo;
  105192. /**
  105193. * Gets the ray of the controller in the direction the controller is pointing
  105194. * @param length the length the resulting ray should be
  105195. * @returns a ray in the direction the controller is pointing
  105196. */
  105197. getForwardRay(length?: number): Ray;
  105198. /**
  105199. * Disposes of the controller
  105200. */
  105201. dispose(): void;
  105202. }
  105203. }
  105204. declare module BABYLON {
  105205. /**
  105206. * Class containing static functions to help procedurally build meshes
  105207. */
  105208. export class PolyhedronBuilder {
  105209. /**
  105210. * Creates a polyhedron mesh
  105211. * * 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
  105212. * * The parameter `size` (positive float, default 1) sets the polygon size
  105213. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  105214. * * 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`
  105215. * * 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
  105216. * * 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)`)
  105217. * * 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
  105218. * * 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
  105219. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105220. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105221. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105222. * @param name defines the name of the mesh
  105223. * @param options defines the options used to create the mesh
  105224. * @param scene defines the hosting scene
  105225. * @returns the polyhedron mesh
  105226. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  105227. */
  105228. static CreatePolyhedron(name: string, options: {
  105229. type?: number;
  105230. size?: number;
  105231. sizeX?: number;
  105232. sizeY?: number;
  105233. sizeZ?: number;
  105234. custom?: any;
  105235. faceUV?: Vector4[];
  105236. faceColors?: Color4[];
  105237. flat?: boolean;
  105238. updatable?: boolean;
  105239. sideOrientation?: number;
  105240. frontUVs?: Vector4;
  105241. backUVs?: Vector4;
  105242. }, scene?: Nullable<Scene>): Mesh;
  105243. }
  105244. }
  105245. declare module BABYLON {
  105246. /**
  105247. * Gizmo that enables scaling a mesh along 3 axis
  105248. */
  105249. export class ScaleGizmo extends Gizmo {
  105250. /**
  105251. * Internal gizmo used for interactions on the x axis
  105252. */
  105253. xGizmo: AxisScaleGizmo;
  105254. /**
  105255. * Internal gizmo used for interactions on the y axis
  105256. */
  105257. yGizmo: AxisScaleGizmo;
  105258. /**
  105259. * Internal gizmo used for interactions on the z axis
  105260. */
  105261. zGizmo: AxisScaleGizmo;
  105262. /**
  105263. * Internal gizmo used to scale all axis equally
  105264. */
  105265. uniformScaleGizmo: AxisScaleGizmo;
  105266. private _meshAttached;
  105267. private _updateGizmoRotationToMatchAttachedMesh;
  105268. private _snapDistance;
  105269. private _scaleRatio;
  105270. private _uniformScalingMesh;
  105271. private _octahedron;
  105272. /** Fires an event when any of it's sub gizmos are dragged */
  105273. onDragStartObservable: Observable<{}>;
  105274. /** Fires an event when any of it's sub gizmos are released from dragging */
  105275. onDragEndObservable: Observable<{}>;
  105276. attachedMesh: Nullable<AbstractMesh>;
  105277. /**
  105278. * Creates a ScaleGizmo
  105279. * @param gizmoLayer The utility layer the gizmo will be added to
  105280. */
  105281. constructor(gizmoLayer?: UtilityLayerRenderer);
  105282. updateGizmoRotationToMatchAttachedMesh: boolean;
  105283. /**
  105284. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  105285. */
  105286. snapDistance: number;
  105287. /**
  105288. * Ratio for the scale of the gizmo (Default: 1)
  105289. */
  105290. scaleRatio: number;
  105291. /**
  105292. * Disposes of the gizmo
  105293. */
  105294. dispose(): void;
  105295. }
  105296. }
  105297. declare module BABYLON {
  105298. /**
  105299. * Single axis scale gizmo
  105300. */
  105301. export class AxisScaleGizmo extends Gizmo {
  105302. /**
  105303. * Drag behavior responsible for the gizmos dragging interactions
  105304. */
  105305. dragBehavior: PointerDragBehavior;
  105306. private _pointerObserver;
  105307. /**
  105308. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  105309. */
  105310. snapDistance: number;
  105311. /**
  105312. * Event that fires each time the gizmo snaps to a new location.
  105313. * * snapDistance is the the change in distance
  105314. */
  105315. onSnapObservable: Observable<{
  105316. snapDistance: number;
  105317. }>;
  105318. /**
  105319. * If the scaling operation should be done on all axis (default: false)
  105320. */
  105321. uniformScaling: boolean;
  105322. private _isEnabled;
  105323. private _parent;
  105324. private _arrow;
  105325. private _coloredMaterial;
  105326. private _hoverMaterial;
  105327. /**
  105328. * Creates an AxisScaleGizmo
  105329. * @param gizmoLayer The utility layer the gizmo will be added to
  105330. * @param dragAxis The axis which the gizmo will be able to scale on
  105331. * @param color The color of the gizmo
  105332. */
  105333. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  105334. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  105335. /**
  105336. * If the gizmo is enabled
  105337. */
  105338. isEnabled: boolean;
  105339. /**
  105340. * Disposes of the gizmo
  105341. */
  105342. dispose(): void;
  105343. /**
  105344. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  105345. * @param mesh The mesh to replace the default mesh of the gizmo
  105346. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  105347. */
  105348. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  105349. }
  105350. }
  105351. declare module BABYLON {
  105352. /**
  105353. * Bounding box gizmo
  105354. */
  105355. export class BoundingBoxGizmo extends Gizmo {
  105356. private _lineBoundingBox;
  105357. private _rotateSpheresParent;
  105358. private _scaleBoxesParent;
  105359. private _boundingDimensions;
  105360. private _renderObserver;
  105361. private _pointerObserver;
  105362. private _scaleDragSpeed;
  105363. private _tmpQuaternion;
  105364. private _tmpVector;
  105365. private _tmpRotationMatrix;
  105366. /**
  105367. * 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)
  105368. */
  105369. ignoreChildren: boolean;
  105370. /**
  105371. * 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)
  105372. */
  105373. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  105374. /**
  105375. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  105376. */
  105377. rotationSphereSize: number;
  105378. /**
  105379. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  105380. */
  105381. scaleBoxSize: number;
  105382. /**
  105383. * 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)
  105384. */
  105385. fixedDragMeshScreenSize: boolean;
  105386. /**
  105387. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  105388. */
  105389. fixedDragMeshScreenSizeDistanceFactor: number;
  105390. /**
  105391. * Fired when a rotation sphere or scale box is dragged
  105392. */
  105393. onDragStartObservable: Observable<{}>;
  105394. /**
  105395. * Fired when a scale box is dragged
  105396. */
  105397. onScaleBoxDragObservable: Observable<{}>;
  105398. /**
  105399. * Fired when a scale box drag is ended
  105400. */
  105401. onScaleBoxDragEndObservable: Observable<{}>;
  105402. /**
  105403. * Fired when a rotation sphere is dragged
  105404. */
  105405. onRotationSphereDragObservable: Observable<{}>;
  105406. /**
  105407. * Fired when a rotation sphere drag is ended
  105408. */
  105409. onRotationSphereDragEndObservable: Observable<{}>;
  105410. /**
  105411. * 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)
  105412. */
  105413. scalePivot: Nullable<Vector3>;
  105414. /**
  105415. * Mesh used as a pivot to rotate the attached mesh
  105416. */
  105417. private _anchorMesh;
  105418. private _existingMeshScale;
  105419. private _dragMesh;
  105420. private pointerDragBehavior;
  105421. private coloredMaterial;
  105422. private hoverColoredMaterial;
  105423. /**
  105424. * Sets the color of the bounding box gizmo
  105425. * @param color the color to set
  105426. */
  105427. setColor(color: Color3): void;
  105428. /**
  105429. * Creates an BoundingBoxGizmo
  105430. * @param gizmoLayer The utility layer the gizmo will be added to
  105431. * @param color The color of the gizmo
  105432. */
  105433. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  105434. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  105435. private _selectNode;
  105436. /**
  105437. * Updates the bounding box information for the Gizmo
  105438. */
  105439. updateBoundingBox(): void;
  105440. private _updateRotationSpheres;
  105441. private _updateScaleBoxes;
  105442. /**
  105443. * Enables rotation on the specified axis and disables rotation on the others
  105444. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  105445. */
  105446. setEnabledRotationAxis(axis: string): void;
  105447. /**
  105448. * Enables/disables scaling
  105449. * @param enable if scaling should be enabled
  105450. */
  105451. setEnabledScaling(enable: boolean): void;
  105452. private _updateDummy;
  105453. /**
  105454. * Enables a pointer drag behavior on the bounding box of the gizmo
  105455. */
  105456. enableDragBehavior(): void;
  105457. /**
  105458. * Disposes of the gizmo
  105459. */
  105460. dispose(): void;
  105461. /**
  105462. * 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)
  105463. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  105464. * @returns the bounding box mesh with the passed in mesh as a child
  105465. */
  105466. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  105467. /**
  105468. * CustomMeshes are not supported by this gizmo
  105469. * @param mesh The mesh to replace the default mesh of the gizmo
  105470. */
  105471. setCustomMesh(mesh: Mesh): void;
  105472. }
  105473. }
  105474. declare module BABYLON {
  105475. /**
  105476. * Single plane rotation gizmo
  105477. */
  105478. export class PlaneRotationGizmo extends Gizmo {
  105479. /**
  105480. * Drag behavior responsible for the gizmos dragging interactions
  105481. */
  105482. dragBehavior: PointerDragBehavior;
  105483. private _pointerObserver;
  105484. /**
  105485. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  105486. */
  105487. snapDistance: number;
  105488. /**
  105489. * Event that fires each time the gizmo snaps to a new location.
  105490. * * snapDistance is the the change in distance
  105491. */
  105492. onSnapObservable: Observable<{
  105493. snapDistance: number;
  105494. }>;
  105495. private _isEnabled;
  105496. private _parent;
  105497. /**
  105498. * Creates a PlaneRotationGizmo
  105499. * @param gizmoLayer The utility layer the gizmo will be added to
  105500. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  105501. * @param color The color of the gizmo
  105502. * @param tessellation Amount of tessellation to be used when creating rotation circles
  105503. */
  105504. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  105505. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  105506. /**
  105507. * If the gizmo is enabled
  105508. */
  105509. isEnabled: boolean;
  105510. /**
  105511. * Disposes of the gizmo
  105512. */
  105513. dispose(): void;
  105514. }
  105515. }
  105516. declare module BABYLON {
  105517. /**
  105518. * Gizmo that enables rotating a mesh along 3 axis
  105519. */
  105520. export class RotationGizmo extends Gizmo {
  105521. /**
  105522. * Internal gizmo used for interactions on the x axis
  105523. */
  105524. xGizmo: PlaneRotationGizmo;
  105525. /**
  105526. * Internal gizmo used for interactions on the y axis
  105527. */
  105528. yGizmo: PlaneRotationGizmo;
  105529. /**
  105530. * Internal gizmo used for interactions on the z axis
  105531. */
  105532. zGizmo: PlaneRotationGizmo;
  105533. /** Fires an event when any of it's sub gizmos are dragged */
  105534. onDragStartObservable: Observable<{}>;
  105535. /** Fires an event when any of it's sub gizmos are released from dragging */
  105536. onDragEndObservable: Observable<{}>;
  105537. private _meshAttached;
  105538. attachedMesh: Nullable<AbstractMesh>;
  105539. /**
  105540. * Creates a RotationGizmo
  105541. * @param gizmoLayer The utility layer the gizmo will be added to
  105542. * @param tessellation Amount of tessellation to be used when creating rotation circles
  105543. */
  105544. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  105545. updateGizmoRotationToMatchAttachedMesh: boolean;
  105546. /**
  105547. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  105548. */
  105549. snapDistance: number;
  105550. /**
  105551. * Ratio for the scale of the gizmo (Default: 1)
  105552. */
  105553. scaleRatio: number;
  105554. /**
  105555. * Disposes of the gizmo
  105556. */
  105557. dispose(): void;
  105558. /**
  105559. * CustomMeshes are not supported by this gizmo
  105560. * @param mesh The mesh to replace the default mesh of the gizmo
  105561. */
  105562. setCustomMesh(mesh: Mesh): void;
  105563. }
  105564. }
  105565. declare module BABYLON {
  105566. /**
  105567. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  105568. */
  105569. export class GizmoManager implements IDisposable {
  105570. private scene;
  105571. /**
  105572. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  105573. */
  105574. gizmos: {
  105575. positionGizmo: Nullable<PositionGizmo>;
  105576. rotationGizmo: Nullable<RotationGizmo>;
  105577. scaleGizmo: Nullable<ScaleGizmo>;
  105578. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  105579. };
  105580. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  105581. clearGizmoOnEmptyPointerEvent: boolean;
  105582. /** Fires an event when the manager is attached to a mesh */
  105583. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  105584. private _gizmosEnabled;
  105585. private _pointerObserver;
  105586. private _attachedMesh;
  105587. private _boundingBoxColor;
  105588. private _defaultUtilityLayer;
  105589. private _defaultKeepDepthUtilityLayer;
  105590. /**
  105591. * When bounding box gizmo is enabled, this can be used to track drag/end events
  105592. */
  105593. boundingBoxDragBehavior: SixDofDragBehavior;
  105594. /**
  105595. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  105596. */
  105597. attachableMeshes: Nullable<Array<AbstractMesh>>;
  105598. /**
  105599. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  105600. */
  105601. usePointerToAttachGizmos: boolean;
  105602. /**
  105603. * Instatiates a gizmo manager
  105604. * @param scene the scene to overlay the gizmos on top of
  105605. */
  105606. constructor(scene: Scene);
  105607. /**
  105608. * Attaches a set of gizmos to the specified mesh
  105609. * @param mesh The mesh the gizmo's should be attached to
  105610. */
  105611. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  105612. /**
  105613. * If the position gizmo is enabled
  105614. */
  105615. positionGizmoEnabled: boolean;
  105616. /**
  105617. * If the rotation gizmo is enabled
  105618. */
  105619. rotationGizmoEnabled: boolean;
  105620. /**
  105621. * If the scale gizmo is enabled
  105622. */
  105623. scaleGizmoEnabled: boolean;
  105624. /**
  105625. * If the boundingBox gizmo is enabled
  105626. */
  105627. boundingBoxGizmoEnabled: boolean;
  105628. /**
  105629. * Disposes of the gizmo manager
  105630. */
  105631. dispose(): void;
  105632. }
  105633. }
  105634. declare module BABYLON {
  105635. /**
  105636. * A directional light is defined by a direction (what a surprise!).
  105637. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  105638. * 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.
  105639. * Documentation: https://doc.babylonjs.com/babylon101/lights
  105640. */
  105641. export class DirectionalLight extends ShadowLight {
  105642. private _shadowFrustumSize;
  105643. /**
  105644. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  105645. */
  105646. /**
  105647. * Specifies a fix frustum size for the shadow generation.
  105648. */
  105649. shadowFrustumSize: number;
  105650. private _shadowOrthoScale;
  105651. /**
  105652. * Gets the shadow projection scale against the optimal computed one.
  105653. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  105654. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  105655. */
  105656. /**
  105657. * Sets the shadow projection scale against the optimal computed one.
  105658. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  105659. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  105660. */
  105661. shadowOrthoScale: number;
  105662. /**
  105663. * Automatically compute the projection matrix to best fit (including all the casters)
  105664. * on each frame.
  105665. */
  105666. autoUpdateExtends: boolean;
  105667. private _orthoLeft;
  105668. private _orthoRight;
  105669. private _orthoTop;
  105670. private _orthoBottom;
  105671. /**
  105672. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  105673. * The directional light is emitted from everywhere in the given direction.
  105674. * It can cast shadows.
  105675. * Documentation : https://doc.babylonjs.com/babylon101/lights
  105676. * @param name The friendly name of the light
  105677. * @param direction The direction of the light
  105678. * @param scene The scene the light belongs to
  105679. */
  105680. constructor(name: string, direction: Vector3, scene: Scene);
  105681. /**
  105682. * Returns the string "DirectionalLight".
  105683. * @return The class name
  105684. */
  105685. getClassName(): string;
  105686. /**
  105687. * Returns the integer 1.
  105688. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  105689. */
  105690. getTypeID(): number;
  105691. /**
  105692. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  105693. * Returns the DirectionalLight Shadow projection matrix.
  105694. */
  105695. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105696. /**
  105697. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  105698. * Returns the DirectionalLight Shadow projection matrix.
  105699. */
  105700. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  105701. /**
  105702. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  105703. * Returns the DirectionalLight Shadow projection matrix.
  105704. */
  105705. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105706. protected _buildUniformLayout(): void;
  105707. /**
  105708. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  105709. * @param effect The effect to update
  105710. * @param lightIndex The index of the light in the effect to update
  105711. * @returns The directional light
  105712. */
  105713. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  105714. /**
  105715. * Gets the minZ used for shadow according to both the scene and the light.
  105716. *
  105717. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  105718. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  105719. * @param activeCamera The camera we are returning the min for
  105720. * @returns the depth min z
  105721. */
  105722. getDepthMinZ(activeCamera: Camera): number;
  105723. /**
  105724. * Gets the maxZ used for shadow according to both the scene and the light.
  105725. *
  105726. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  105727. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  105728. * @param activeCamera The camera we are returning the max for
  105729. * @returns the depth max z
  105730. */
  105731. getDepthMaxZ(activeCamera: Camera): number;
  105732. /**
  105733. * Prepares the list of defines specific to the light type.
  105734. * @param defines the list of defines
  105735. * @param lightIndex defines the index of the light for the effect
  105736. */
  105737. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  105738. }
  105739. }
  105740. declare module BABYLON {
  105741. /**
  105742. * Class containing static functions to help procedurally build meshes
  105743. */
  105744. export class HemisphereBuilder {
  105745. /**
  105746. * Creates a hemisphere mesh
  105747. * @param name defines the name of the mesh
  105748. * @param options defines the options used to create the mesh
  105749. * @param scene defines the hosting scene
  105750. * @returns the hemisphere mesh
  105751. */
  105752. static CreateHemisphere(name: string, options: {
  105753. segments?: number;
  105754. diameter?: number;
  105755. sideOrientation?: number;
  105756. }, scene: any): Mesh;
  105757. }
  105758. }
  105759. declare module BABYLON {
  105760. /**
  105761. * A spot light is defined by a position, a direction, an angle, and an exponent.
  105762. * These values define a cone of light starting from the position, emitting toward the direction.
  105763. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  105764. * and the exponent defines the speed of the decay of the light with distance (reach).
  105765. * Documentation: https://doc.babylonjs.com/babylon101/lights
  105766. */
  105767. export class SpotLight extends ShadowLight {
  105768. private _angle;
  105769. private _innerAngle;
  105770. private _cosHalfAngle;
  105771. private _lightAngleScale;
  105772. private _lightAngleOffset;
  105773. /**
  105774. * Gets the cone angle of the spot light in Radians.
  105775. */
  105776. /**
  105777. * Sets the cone angle of the spot light in Radians.
  105778. */
  105779. angle: number;
  105780. /**
  105781. * Only used in gltf falloff mode, this defines the angle where
  105782. * the directional falloff will start before cutting at angle which could be seen
  105783. * as outer angle.
  105784. */
  105785. /**
  105786. * Only used in gltf falloff mode, this defines the angle where
  105787. * the directional falloff will start before cutting at angle which could be seen
  105788. * as outer angle.
  105789. */
  105790. innerAngle: number;
  105791. private _shadowAngleScale;
  105792. /**
  105793. * Allows scaling the angle of the light for shadow generation only.
  105794. */
  105795. /**
  105796. * Allows scaling the angle of the light for shadow generation only.
  105797. */
  105798. shadowAngleScale: number;
  105799. /**
  105800. * The light decay speed with the distance from the emission spot.
  105801. */
  105802. exponent: number;
  105803. private _projectionTextureMatrix;
  105804. /**
  105805. * Allows reading the projecton texture
  105806. */
  105807. readonly projectionTextureMatrix: Matrix;
  105808. protected _projectionTextureLightNear: number;
  105809. /**
  105810. * Gets the near clip of the Spotlight for texture projection.
  105811. */
  105812. /**
  105813. * Sets the near clip of the Spotlight for texture projection.
  105814. */
  105815. projectionTextureLightNear: number;
  105816. protected _projectionTextureLightFar: number;
  105817. /**
  105818. * Gets the far clip of the Spotlight for texture projection.
  105819. */
  105820. /**
  105821. * Sets the far clip of the Spotlight for texture projection.
  105822. */
  105823. projectionTextureLightFar: number;
  105824. protected _projectionTextureUpDirection: Vector3;
  105825. /**
  105826. * Gets the Up vector of the Spotlight for texture projection.
  105827. */
  105828. /**
  105829. * Sets the Up vector of the Spotlight for texture projection.
  105830. */
  105831. projectionTextureUpDirection: Vector3;
  105832. private _projectionTexture;
  105833. /**
  105834. * Gets the projection texture of the light.
  105835. */
  105836. /**
  105837. * Sets the projection texture of the light.
  105838. */
  105839. projectionTexture: Nullable<BaseTexture>;
  105840. private _projectionTextureViewLightDirty;
  105841. private _projectionTextureProjectionLightDirty;
  105842. private _projectionTextureDirty;
  105843. private _projectionTextureViewTargetVector;
  105844. private _projectionTextureViewLightMatrix;
  105845. private _projectionTextureProjectionLightMatrix;
  105846. private _projectionTextureScalingMatrix;
  105847. /**
  105848. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  105849. * It can cast shadows.
  105850. * Documentation : https://doc.babylonjs.com/babylon101/lights
  105851. * @param name The light friendly name
  105852. * @param position The position of the spot light in the scene
  105853. * @param direction The direction of the light in the scene
  105854. * @param angle The cone angle of the light in Radians
  105855. * @param exponent The light decay speed with the distance from the emission spot
  105856. * @param scene The scene the lights belongs to
  105857. */
  105858. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  105859. /**
  105860. * Returns the string "SpotLight".
  105861. * @returns the class name
  105862. */
  105863. getClassName(): string;
  105864. /**
  105865. * Returns the integer 2.
  105866. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  105867. */
  105868. getTypeID(): number;
  105869. /**
  105870. * Overrides the direction setter to recompute the projection texture view light Matrix.
  105871. */
  105872. protected _setDirection(value: Vector3): void;
  105873. /**
  105874. * Overrides the position setter to recompute the projection texture view light Matrix.
  105875. */
  105876. protected _setPosition(value: Vector3): void;
  105877. /**
  105878. * 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.
  105879. * Returns the SpotLight.
  105880. */
  105881. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105882. protected _computeProjectionTextureViewLightMatrix(): void;
  105883. protected _computeProjectionTextureProjectionLightMatrix(): void;
  105884. /**
  105885. * Main function for light texture projection matrix computing.
  105886. */
  105887. protected _computeProjectionTextureMatrix(): void;
  105888. protected _buildUniformLayout(): void;
  105889. private _computeAngleValues;
  105890. /**
  105891. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  105892. * @param effect The effect to update
  105893. * @param lightIndex The index of the light in the effect to update
  105894. * @returns The spot light
  105895. */
  105896. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  105897. /**
  105898. * Disposes the light and the associated resources.
  105899. */
  105900. dispose(): void;
  105901. /**
  105902. * Prepares the list of defines specific to the light type.
  105903. * @param defines the list of defines
  105904. * @param lightIndex defines the index of the light for the effect
  105905. */
  105906. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  105907. }
  105908. }
  105909. declare module BABYLON {
  105910. /**
  105911. * Gizmo that enables viewing a light
  105912. */
  105913. export class LightGizmo extends Gizmo {
  105914. private _lightMesh;
  105915. private _material;
  105916. private cachedPosition;
  105917. private cachedForward;
  105918. /**
  105919. * Creates a LightGizmo
  105920. * @param gizmoLayer The utility layer the gizmo will be added to
  105921. */
  105922. constructor(gizmoLayer?: UtilityLayerRenderer);
  105923. private _light;
  105924. /**
  105925. * The light that the gizmo is attached to
  105926. */
  105927. light: Nullable<Light>;
  105928. /**
  105929. * @hidden
  105930. * Updates the gizmo to match the attached mesh's position/rotation
  105931. */
  105932. protected _update(): void;
  105933. private static _Scale;
  105934. /**
  105935. * Creates the lines for a light mesh
  105936. */
  105937. private static _createLightLines;
  105938. /**
  105939. * Disposes of the light gizmo
  105940. */
  105941. dispose(): void;
  105942. private static _CreateHemisphericLightMesh;
  105943. private static _CreatePointLightMesh;
  105944. private static _CreateSpotLightMesh;
  105945. private static _CreateDirectionalLightMesh;
  105946. }
  105947. }
  105948. declare module BABYLON {
  105949. /** @hidden */
  105950. export var backgroundFragmentDeclaration: {
  105951. name: string;
  105952. shader: string;
  105953. };
  105954. }
  105955. declare module BABYLON {
  105956. /** @hidden */
  105957. export var backgroundUboDeclaration: {
  105958. name: string;
  105959. shader: string;
  105960. };
  105961. }
  105962. declare module BABYLON {
  105963. /** @hidden */
  105964. export var backgroundPixelShader: {
  105965. name: string;
  105966. shader: string;
  105967. };
  105968. }
  105969. declare module BABYLON {
  105970. /** @hidden */
  105971. export var backgroundVertexDeclaration: {
  105972. name: string;
  105973. shader: string;
  105974. };
  105975. }
  105976. declare module BABYLON {
  105977. /** @hidden */
  105978. export var backgroundVertexShader: {
  105979. name: string;
  105980. shader: string;
  105981. };
  105982. }
  105983. declare module BABYLON {
  105984. /**
  105985. * Background material used to create an efficient environement around your scene.
  105986. */
  105987. export class BackgroundMaterial extends PushMaterial {
  105988. /**
  105989. * Standard reflectance value at parallel view angle.
  105990. */
  105991. static StandardReflectance0: number;
  105992. /**
  105993. * Standard reflectance value at grazing angle.
  105994. */
  105995. static StandardReflectance90: number;
  105996. protected _primaryColor: Color3;
  105997. /**
  105998. * Key light Color (multiply against the environement texture)
  105999. */
  106000. primaryColor: Color3;
  106001. protected __perceptualColor: Nullable<Color3>;
  106002. /**
  106003. * Experimental Internal Use Only.
  106004. *
  106005. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  106006. * This acts as a helper to set the primary color to a more "human friendly" value.
  106007. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  106008. * output color as close as possible from the chosen value.
  106009. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  106010. * part of lighting setup.)
  106011. */
  106012. _perceptualColor: Nullable<Color3>;
  106013. protected _primaryColorShadowLevel: float;
  106014. /**
  106015. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  106016. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  106017. */
  106018. primaryColorShadowLevel: float;
  106019. protected _primaryColorHighlightLevel: float;
  106020. /**
  106021. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  106022. * The primary color is used at the level chosen to define what the white area would look.
  106023. */
  106024. primaryColorHighlightLevel: float;
  106025. protected _reflectionTexture: Nullable<BaseTexture>;
  106026. /**
  106027. * Reflection Texture used in the material.
  106028. * Should be author in a specific way for the best result (refer to the documentation).
  106029. */
  106030. reflectionTexture: Nullable<BaseTexture>;
  106031. protected _reflectionBlur: float;
  106032. /**
  106033. * Reflection Texture level of blur.
  106034. *
  106035. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  106036. * texture twice.
  106037. */
  106038. reflectionBlur: float;
  106039. protected _diffuseTexture: Nullable<BaseTexture>;
  106040. /**
  106041. * Diffuse Texture used in the material.
  106042. * Should be author in a specific way for the best result (refer to the documentation).
  106043. */
  106044. diffuseTexture: Nullable<BaseTexture>;
  106045. protected _shadowLights: Nullable<IShadowLight[]>;
  106046. /**
  106047. * Specify the list of lights casting shadow on the material.
  106048. * All scene shadow lights will be included if null.
  106049. */
  106050. shadowLights: Nullable<IShadowLight[]>;
  106051. protected _shadowLevel: float;
  106052. /**
  106053. * Helps adjusting the shadow to a softer level if required.
  106054. * 0 means black shadows and 1 means no shadows.
  106055. */
  106056. shadowLevel: float;
  106057. protected _sceneCenter: Vector3;
  106058. /**
  106059. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  106060. * It is usually zero but might be interesting to modify according to your setup.
  106061. */
  106062. sceneCenter: Vector3;
  106063. protected _opacityFresnel: boolean;
  106064. /**
  106065. * This helps specifying that the material is falling off to the sky box at grazing angle.
  106066. * This helps ensuring a nice transition when the camera goes under the ground.
  106067. */
  106068. opacityFresnel: boolean;
  106069. protected _reflectionFresnel: boolean;
  106070. /**
  106071. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  106072. * This helps adding a mirror texture on the ground.
  106073. */
  106074. reflectionFresnel: boolean;
  106075. protected _reflectionFalloffDistance: number;
  106076. /**
  106077. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  106078. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  106079. */
  106080. reflectionFalloffDistance: number;
  106081. protected _reflectionAmount: number;
  106082. /**
  106083. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  106084. */
  106085. reflectionAmount: number;
  106086. protected _reflectionReflectance0: number;
  106087. /**
  106088. * This specifies the weight of the reflection at grazing angle.
  106089. */
  106090. reflectionReflectance0: number;
  106091. protected _reflectionReflectance90: number;
  106092. /**
  106093. * This specifies the weight of the reflection at a perpendicular point of view.
  106094. */
  106095. reflectionReflectance90: number;
  106096. /**
  106097. * Sets the reflection reflectance fresnel values according to the default standard
  106098. * empirically know to work well :-)
  106099. */
  106100. reflectionStandardFresnelWeight: number;
  106101. protected _useRGBColor: boolean;
  106102. /**
  106103. * Helps to directly use the maps channels instead of their level.
  106104. */
  106105. useRGBColor: boolean;
  106106. protected _enableNoise: boolean;
  106107. /**
  106108. * This helps reducing the banding effect that could occur on the background.
  106109. */
  106110. enableNoise: boolean;
  106111. /**
  106112. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  106113. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  106114. * Recommended to be keep at 1.0 except for special cases.
  106115. */
  106116. fovMultiplier: number;
  106117. private _fovMultiplier;
  106118. /**
  106119. * Enable the FOV adjustment feature controlled by fovMultiplier.
  106120. */
  106121. useEquirectangularFOV: boolean;
  106122. private _maxSimultaneousLights;
  106123. /**
  106124. * Number of Simultaneous lights allowed on the material.
  106125. */
  106126. maxSimultaneousLights: int;
  106127. /**
  106128. * Default configuration related to image processing available in the Background Material.
  106129. */
  106130. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106131. /**
  106132. * Keep track of the image processing observer to allow dispose and replace.
  106133. */
  106134. private _imageProcessingObserver;
  106135. /**
  106136. * Attaches a new image processing configuration to the PBR Material.
  106137. * @param configuration (if null the scene configuration will be use)
  106138. */
  106139. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  106140. /**
  106141. * Gets the image processing configuration used either in this material.
  106142. */
  106143. /**
  106144. * Sets the Default image processing configuration used either in the this material.
  106145. *
  106146. * If sets to null, the scene one is in use.
  106147. */
  106148. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  106149. /**
  106150. * Gets wether the color curves effect is enabled.
  106151. */
  106152. /**
  106153. * Sets wether the color curves effect is enabled.
  106154. */
  106155. cameraColorCurvesEnabled: boolean;
  106156. /**
  106157. * Gets wether the color grading effect is enabled.
  106158. */
  106159. /**
  106160. * Gets wether the color grading effect is enabled.
  106161. */
  106162. cameraColorGradingEnabled: boolean;
  106163. /**
  106164. * Gets wether tonemapping is enabled or not.
  106165. */
  106166. /**
  106167. * Sets wether tonemapping is enabled or not
  106168. */
  106169. cameraToneMappingEnabled: boolean;
  106170. /**
  106171. * The camera exposure used on this material.
  106172. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106173. * This corresponds to a photographic exposure.
  106174. */
  106175. /**
  106176. * The camera exposure used on this material.
  106177. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106178. * This corresponds to a photographic exposure.
  106179. */
  106180. cameraExposure: float;
  106181. /**
  106182. * Gets The camera contrast used on this material.
  106183. */
  106184. /**
  106185. * Sets The camera contrast used on this material.
  106186. */
  106187. cameraContrast: float;
  106188. /**
  106189. * Gets the Color Grading 2D Lookup Texture.
  106190. */
  106191. /**
  106192. * Sets the Color Grading 2D Lookup Texture.
  106193. */
  106194. cameraColorGradingTexture: Nullable<BaseTexture>;
  106195. /**
  106196. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106197. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106198. * 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;
  106199. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106200. */
  106201. /**
  106202. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106203. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106204. * 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;
  106205. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106206. */
  106207. cameraColorCurves: Nullable<ColorCurves>;
  106208. /**
  106209. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  106210. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  106211. */
  106212. switchToBGR: boolean;
  106213. private _renderTargets;
  106214. private _reflectionControls;
  106215. private _white;
  106216. private _primaryShadowColor;
  106217. private _primaryHighlightColor;
  106218. /**
  106219. * Instantiates a Background Material in the given scene
  106220. * @param name The friendly name of the material
  106221. * @param scene The scene to add the material to
  106222. */
  106223. constructor(name: string, scene: Scene);
  106224. /**
  106225. * Gets a boolean indicating that current material needs to register RTT
  106226. */
  106227. readonly hasRenderTargetTextures: boolean;
  106228. /**
  106229. * The entire material has been created in order to prevent overdraw.
  106230. * @returns false
  106231. */
  106232. needAlphaTesting(): boolean;
  106233. /**
  106234. * The entire material has been created in order to prevent overdraw.
  106235. * @returns true if blending is enable
  106236. */
  106237. needAlphaBlending(): boolean;
  106238. /**
  106239. * Checks wether the material is ready to be rendered for a given mesh.
  106240. * @param mesh The mesh to render
  106241. * @param subMesh The submesh to check against
  106242. * @param useInstances Specify wether or not the material is used with instances
  106243. * @returns true if all the dependencies are ready (Textures, Effects...)
  106244. */
  106245. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  106246. /**
  106247. * Compute the primary color according to the chosen perceptual color.
  106248. */
  106249. private _computePrimaryColorFromPerceptualColor;
  106250. /**
  106251. * Compute the highlights and shadow colors according to their chosen levels.
  106252. */
  106253. private _computePrimaryColors;
  106254. /**
  106255. * Build the uniform buffer used in the material.
  106256. */
  106257. buildUniformLayout(): void;
  106258. /**
  106259. * Unbind the material.
  106260. */
  106261. unbind(): void;
  106262. /**
  106263. * Bind only the world matrix to the material.
  106264. * @param world The world matrix to bind.
  106265. */
  106266. bindOnlyWorldMatrix(world: Matrix): void;
  106267. /**
  106268. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  106269. * @param world The world matrix to bind.
  106270. * @param subMesh The submesh to bind for.
  106271. */
  106272. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  106273. /**
  106274. * Dispose the material.
  106275. * @param forceDisposeEffect Force disposal of the associated effect.
  106276. * @param forceDisposeTextures Force disposal of the associated textures.
  106277. */
  106278. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  106279. /**
  106280. * Clones the material.
  106281. * @param name The cloned name.
  106282. * @returns The cloned material.
  106283. */
  106284. clone(name: string): BackgroundMaterial;
  106285. /**
  106286. * Serializes the current material to its JSON representation.
  106287. * @returns The JSON representation.
  106288. */
  106289. serialize(): any;
  106290. /**
  106291. * Gets the class name of the material
  106292. * @returns "BackgroundMaterial"
  106293. */
  106294. getClassName(): string;
  106295. /**
  106296. * Parse a JSON input to create back a background material.
  106297. * @param source The JSON data to parse
  106298. * @param scene The scene to create the parsed material in
  106299. * @param rootUrl The root url of the assets the material depends upon
  106300. * @returns the instantiated BackgroundMaterial.
  106301. */
  106302. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  106303. }
  106304. }
  106305. declare module BABYLON {
  106306. /**
  106307. * Represents the different options available during the creation of
  106308. * a Environment helper.
  106309. *
  106310. * This can control the default ground, skybox and image processing setup of your scene.
  106311. */
  106312. export interface IEnvironmentHelperOptions {
  106313. /**
  106314. * Specifies wether or not to create a ground.
  106315. * True by default.
  106316. */
  106317. createGround: boolean;
  106318. /**
  106319. * Specifies the ground size.
  106320. * 15 by default.
  106321. */
  106322. groundSize: number;
  106323. /**
  106324. * The texture used on the ground for the main color.
  106325. * Comes from the BabylonJS CDN by default.
  106326. *
  106327. * Remarks: Can be either a texture or a url.
  106328. */
  106329. groundTexture: string | BaseTexture;
  106330. /**
  106331. * The color mixed in the ground texture by default.
  106332. * BabylonJS clearColor by default.
  106333. */
  106334. groundColor: Color3;
  106335. /**
  106336. * Specifies the ground opacity.
  106337. * 1 by default.
  106338. */
  106339. groundOpacity: number;
  106340. /**
  106341. * Enables the ground to receive shadows.
  106342. * True by default.
  106343. */
  106344. enableGroundShadow: boolean;
  106345. /**
  106346. * Helps preventing the shadow to be fully black on the ground.
  106347. * 0.5 by default.
  106348. */
  106349. groundShadowLevel: number;
  106350. /**
  106351. * Creates a mirror texture attach to the ground.
  106352. * false by default.
  106353. */
  106354. enableGroundMirror: boolean;
  106355. /**
  106356. * Specifies the ground mirror size ratio.
  106357. * 0.3 by default as the default kernel is 64.
  106358. */
  106359. groundMirrorSizeRatio: number;
  106360. /**
  106361. * Specifies the ground mirror blur kernel size.
  106362. * 64 by default.
  106363. */
  106364. groundMirrorBlurKernel: number;
  106365. /**
  106366. * Specifies the ground mirror visibility amount.
  106367. * 1 by default
  106368. */
  106369. groundMirrorAmount: number;
  106370. /**
  106371. * Specifies the ground mirror reflectance weight.
  106372. * This uses the standard weight of the background material to setup the fresnel effect
  106373. * of the mirror.
  106374. * 1 by default.
  106375. */
  106376. groundMirrorFresnelWeight: number;
  106377. /**
  106378. * Specifies the ground mirror Falloff distance.
  106379. * This can helps reducing the size of the reflection.
  106380. * 0 by Default.
  106381. */
  106382. groundMirrorFallOffDistance: number;
  106383. /**
  106384. * Specifies the ground mirror texture type.
  106385. * Unsigned Int by Default.
  106386. */
  106387. groundMirrorTextureType: number;
  106388. /**
  106389. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  106390. * the shown objects.
  106391. */
  106392. groundYBias: number;
  106393. /**
  106394. * Specifies wether or not to create a skybox.
  106395. * True by default.
  106396. */
  106397. createSkybox: boolean;
  106398. /**
  106399. * Specifies the skybox size.
  106400. * 20 by default.
  106401. */
  106402. skyboxSize: number;
  106403. /**
  106404. * The texture used on the skybox for the main color.
  106405. * Comes from the BabylonJS CDN by default.
  106406. *
  106407. * Remarks: Can be either a texture or a url.
  106408. */
  106409. skyboxTexture: string | BaseTexture;
  106410. /**
  106411. * The color mixed in the skybox texture by default.
  106412. * BabylonJS clearColor by default.
  106413. */
  106414. skyboxColor: Color3;
  106415. /**
  106416. * The background rotation around the Y axis of the scene.
  106417. * This helps aligning the key lights of your scene with the background.
  106418. * 0 by default.
  106419. */
  106420. backgroundYRotation: number;
  106421. /**
  106422. * Compute automatically the size of the elements to best fit with the scene.
  106423. */
  106424. sizeAuto: boolean;
  106425. /**
  106426. * Default position of the rootMesh if autoSize is not true.
  106427. */
  106428. rootPosition: Vector3;
  106429. /**
  106430. * Sets up the image processing in the scene.
  106431. * true by default.
  106432. */
  106433. setupImageProcessing: boolean;
  106434. /**
  106435. * The texture used as your environment texture in the scene.
  106436. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  106437. *
  106438. * Remarks: Can be either a texture or a url.
  106439. */
  106440. environmentTexture: string | BaseTexture;
  106441. /**
  106442. * The value of the exposure to apply to the scene.
  106443. * 0.6 by default if setupImageProcessing is true.
  106444. */
  106445. cameraExposure: number;
  106446. /**
  106447. * The value of the contrast to apply to the scene.
  106448. * 1.6 by default if setupImageProcessing is true.
  106449. */
  106450. cameraContrast: number;
  106451. /**
  106452. * Specifies wether or not tonemapping should be enabled in the scene.
  106453. * true by default if setupImageProcessing is true.
  106454. */
  106455. toneMappingEnabled: boolean;
  106456. }
  106457. /**
  106458. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  106459. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  106460. * It also helps with the default setup of your imageProcessing configuration.
  106461. */
  106462. export class EnvironmentHelper {
  106463. /**
  106464. * Default ground texture URL.
  106465. */
  106466. private static _groundTextureCDNUrl;
  106467. /**
  106468. * Default skybox texture URL.
  106469. */
  106470. private static _skyboxTextureCDNUrl;
  106471. /**
  106472. * Default environment texture URL.
  106473. */
  106474. private static _environmentTextureCDNUrl;
  106475. /**
  106476. * Creates the default options for the helper.
  106477. */
  106478. private static _getDefaultOptions;
  106479. private _rootMesh;
  106480. /**
  106481. * Gets the root mesh created by the helper.
  106482. */
  106483. readonly rootMesh: Mesh;
  106484. private _skybox;
  106485. /**
  106486. * Gets the skybox created by the helper.
  106487. */
  106488. readonly skybox: Nullable<Mesh>;
  106489. private _skyboxTexture;
  106490. /**
  106491. * Gets the skybox texture created by the helper.
  106492. */
  106493. readonly skyboxTexture: Nullable<BaseTexture>;
  106494. private _skyboxMaterial;
  106495. /**
  106496. * Gets the skybox material created by the helper.
  106497. */
  106498. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  106499. private _ground;
  106500. /**
  106501. * Gets the ground mesh created by the helper.
  106502. */
  106503. readonly ground: Nullable<Mesh>;
  106504. private _groundTexture;
  106505. /**
  106506. * Gets the ground texture created by the helper.
  106507. */
  106508. readonly groundTexture: Nullable<BaseTexture>;
  106509. private _groundMirror;
  106510. /**
  106511. * Gets the ground mirror created by the helper.
  106512. */
  106513. readonly groundMirror: Nullable<MirrorTexture>;
  106514. /**
  106515. * Gets the ground mirror render list to helps pushing the meshes
  106516. * you wish in the ground reflection.
  106517. */
  106518. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  106519. private _groundMaterial;
  106520. /**
  106521. * Gets the ground material created by the helper.
  106522. */
  106523. readonly groundMaterial: Nullable<BackgroundMaterial>;
  106524. /**
  106525. * Stores the creation options.
  106526. */
  106527. private readonly _scene;
  106528. private _options;
  106529. /**
  106530. * This observable will be notified with any error during the creation of the environment,
  106531. * mainly texture creation errors.
  106532. */
  106533. onErrorObservable: Observable<{
  106534. message?: string;
  106535. exception?: any;
  106536. }>;
  106537. /**
  106538. * constructor
  106539. * @param options Defines the options we want to customize the helper
  106540. * @param scene The scene to add the material to
  106541. */
  106542. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  106543. /**
  106544. * Updates the background according to the new options
  106545. * @param options
  106546. */
  106547. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  106548. /**
  106549. * Sets the primary color of all the available elements.
  106550. * @param color the main color to affect to the ground and the background
  106551. */
  106552. setMainColor(color: Color3): void;
  106553. /**
  106554. * Setup the image processing according to the specified options.
  106555. */
  106556. private _setupImageProcessing;
  106557. /**
  106558. * Setup the environment texture according to the specified options.
  106559. */
  106560. private _setupEnvironmentTexture;
  106561. /**
  106562. * Setup the background according to the specified options.
  106563. */
  106564. private _setupBackground;
  106565. /**
  106566. * Get the scene sizes according to the setup.
  106567. */
  106568. private _getSceneSize;
  106569. /**
  106570. * Setup the ground according to the specified options.
  106571. */
  106572. private _setupGround;
  106573. /**
  106574. * Setup the ground material according to the specified options.
  106575. */
  106576. private _setupGroundMaterial;
  106577. /**
  106578. * Setup the ground diffuse texture according to the specified options.
  106579. */
  106580. private _setupGroundDiffuseTexture;
  106581. /**
  106582. * Setup the ground mirror texture according to the specified options.
  106583. */
  106584. private _setupGroundMirrorTexture;
  106585. /**
  106586. * Setup the ground to receive the mirror texture.
  106587. */
  106588. private _setupMirrorInGroundMaterial;
  106589. /**
  106590. * Setup the skybox according to the specified options.
  106591. */
  106592. private _setupSkybox;
  106593. /**
  106594. * Setup the skybox material according to the specified options.
  106595. */
  106596. private _setupSkyboxMaterial;
  106597. /**
  106598. * Setup the skybox reflection texture according to the specified options.
  106599. */
  106600. private _setupSkyboxReflectionTexture;
  106601. private _errorHandler;
  106602. /**
  106603. * Dispose all the elements created by the Helper.
  106604. */
  106605. dispose(): void;
  106606. }
  106607. }
  106608. declare module BABYLON {
  106609. /**
  106610. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  106611. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  106612. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  106613. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  106614. */
  106615. export class PhotoDome extends TransformNode {
  106616. /**
  106617. * Define the image as a Monoscopic panoramic 360 image.
  106618. */
  106619. static readonly MODE_MONOSCOPIC: number;
  106620. /**
  106621. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  106622. */
  106623. static readonly MODE_TOPBOTTOM: number;
  106624. /**
  106625. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  106626. */
  106627. static readonly MODE_SIDEBYSIDE: number;
  106628. private _useDirectMapping;
  106629. /**
  106630. * The texture being displayed on the sphere
  106631. */
  106632. protected _photoTexture: Texture;
  106633. /**
  106634. * Gets or sets the texture being displayed on the sphere
  106635. */
  106636. photoTexture: Texture;
  106637. /**
  106638. * Observable raised when an error occured while loading the 360 image
  106639. */
  106640. onLoadErrorObservable: Observable<string>;
  106641. /**
  106642. * The skybox material
  106643. */
  106644. protected _material: BackgroundMaterial;
  106645. /**
  106646. * The surface used for the skybox
  106647. */
  106648. protected _mesh: Mesh;
  106649. /**
  106650. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  106651. * Also see the options.resolution property.
  106652. */
  106653. fovMultiplier: number;
  106654. private _imageMode;
  106655. /**
  106656. * Gets or set the current video mode for the video. It can be:
  106657. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  106658. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  106659. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  106660. */
  106661. imageMode: number;
  106662. /**
  106663. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  106664. * @param name Element's name, child elements will append suffixes for their own names.
  106665. * @param urlsOfPhoto defines the url of the photo to display
  106666. * @param options defines an object containing optional or exposed sub element properties
  106667. * @param onError defines a callback called when an error occured while loading the texture
  106668. */
  106669. constructor(name: string, urlOfPhoto: string, options: {
  106670. resolution?: number;
  106671. size?: number;
  106672. useDirectMapping?: boolean;
  106673. faceForward?: boolean;
  106674. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  106675. private _onBeforeCameraRenderObserver;
  106676. private _changeImageMode;
  106677. /**
  106678. * Releases resources associated with this node.
  106679. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  106680. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  106681. */
  106682. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  106683. }
  106684. }
  106685. declare module BABYLON {
  106686. /** @hidden */
  106687. export var rgbdDecodePixelShader: {
  106688. name: string;
  106689. shader: string;
  106690. };
  106691. }
  106692. declare module BABYLON {
  106693. /**
  106694. * Class used to host texture specific utilities
  106695. */
  106696. export class BRDFTextureTools {
  106697. /**
  106698. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  106699. * @param texture the texture to expand.
  106700. */
  106701. private static _ExpandDefaultBRDFTexture;
  106702. /**
  106703. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  106704. * @param scene defines the hosting scene
  106705. * @returns the environment BRDF texture
  106706. */
  106707. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  106708. private static _environmentBRDFBase64Texture;
  106709. }
  106710. }
  106711. declare module BABYLON {
  106712. /**
  106713. * @hidden
  106714. */
  106715. export interface IMaterialClearCoatDefines {
  106716. CLEARCOAT: boolean;
  106717. CLEARCOAT_DEFAULTIOR: boolean;
  106718. CLEARCOAT_TEXTURE: boolean;
  106719. CLEARCOAT_TEXTUREDIRECTUV: number;
  106720. CLEARCOAT_BUMP: boolean;
  106721. CLEARCOAT_BUMPDIRECTUV: number;
  106722. CLEARCOAT_TINT: boolean;
  106723. CLEARCOAT_TINT_TEXTURE: boolean;
  106724. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  106725. /** @hidden */
  106726. _areTexturesDirty: boolean;
  106727. }
  106728. /**
  106729. * Define the code related to the clear coat parameters of the pbr material.
  106730. */
  106731. export class PBRClearCoatConfiguration {
  106732. /**
  106733. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  106734. * The default fits with a polyurethane material.
  106735. */
  106736. private static readonly _DefaultIndiceOfRefraction;
  106737. private _isEnabled;
  106738. /**
  106739. * Defines if the clear coat is enabled in the material.
  106740. */
  106741. isEnabled: boolean;
  106742. /**
  106743. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  106744. */
  106745. intensity: number;
  106746. /**
  106747. * Defines the clear coat layer roughness.
  106748. */
  106749. roughness: number;
  106750. private _indiceOfRefraction;
  106751. /**
  106752. * Defines the indice of refraction of the clear coat.
  106753. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  106754. * The default fits with a polyurethane material.
  106755. * Changing the default value is more performance intensive.
  106756. */
  106757. indiceOfRefraction: number;
  106758. private _texture;
  106759. /**
  106760. * Stores the clear coat values in a texture.
  106761. */
  106762. texture: Nullable<BaseTexture>;
  106763. private _bumpTexture;
  106764. /**
  106765. * Define the clear coat specific bump texture.
  106766. */
  106767. bumpTexture: Nullable<BaseTexture>;
  106768. private _isTintEnabled;
  106769. /**
  106770. * Defines if the clear coat tint is enabled in the material.
  106771. */
  106772. isTintEnabled: boolean;
  106773. /**
  106774. * Defines the clear coat tint of the material.
  106775. * This is only use if tint is enabled
  106776. */
  106777. tintColor: Color3;
  106778. /**
  106779. * Defines the distance at which the tint color should be found in the
  106780. * clear coat media.
  106781. * This is only use if tint is enabled
  106782. */
  106783. tintColorAtDistance: number;
  106784. /**
  106785. * Defines the clear coat layer thickness.
  106786. * This is only use if tint is enabled
  106787. */
  106788. tintThickness: number;
  106789. private _tintTexture;
  106790. /**
  106791. * Stores the clear tint values in a texture.
  106792. * rgb is tint
  106793. * a is a thickness factor
  106794. */
  106795. tintTexture: Nullable<BaseTexture>;
  106796. /** @hidden */
  106797. private _internalMarkAllSubMeshesAsTexturesDirty;
  106798. /** @hidden */
  106799. _markAllSubMeshesAsTexturesDirty(): void;
  106800. /**
  106801. * Instantiate a new istance of clear coat configuration.
  106802. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  106803. */
  106804. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  106805. /**
  106806. * Gets wehter the submesh is ready to be used or not.
  106807. * @param defines the list of "defines" to update.
  106808. * @param scene defines the scene the material belongs to.
  106809. * @param engine defines the engine the material belongs to.
  106810. * @param disableBumpMap defines wether the material disables bump or not.
  106811. * @returns - boolean indicating that the submesh is ready or not.
  106812. */
  106813. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  106814. /**
  106815. * Checks to see if a texture is used in the material.
  106816. * @param defines the list of "defines" to update.
  106817. * @param scene defines the scene to the material belongs to.
  106818. */
  106819. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  106820. /**
  106821. * Binds the material data.
  106822. * @param uniformBuffer defines the Uniform buffer to fill in.
  106823. * @param scene defines the scene the material belongs to.
  106824. * @param engine defines the engine the material belongs to.
  106825. * @param disableBumpMap defines wether the material disables bump or not.
  106826. * @param isFrozen defines wether the material is frozen or not.
  106827. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  106828. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  106829. */
  106830. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  106831. /**
  106832. * Checks to see if a texture is used in the material.
  106833. * @param texture - Base texture to use.
  106834. * @returns - Boolean specifying if a texture is used in the material.
  106835. */
  106836. hasTexture(texture: BaseTexture): boolean;
  106837. /**
  106838. * Returns an array of the actively used textures.
  106839. * @param activeTextures Array of BaseTextures
  106840. */
  106841. getActiveTextures(activeTextures: BaseTexture[]): void;
  106842. /**
  106843. * Returns the animatable textures.
  106844. * @param animatables Array of animatable textures.
  106845. */
  106846. getAnimatables(animatables: IAnimatable[]): void;
  106847. /**
  106848. * Disposes the resources of the material.
  106849. * @param forceDisposeTextures - Forces the disposal of all textures.
  106850. */
  106851. dispose(forceDisposeTextures?: boolean): void;
  106852. /**
  106853. * Get the current class name of the texture useful for serialization or dynamic coding.
  106854. * @returns "PBRClearCoatConfiguration"
  106855. */
  106856. getClassName(): string;
  106857. /**
  106858. * Add fallbacks to the effect fallbacks list.
  106859. * @param defines defines the Base texture to use.
  106860. * @param fallbacks defines the current fallback list.
  106861. * @param currentRank defines the current fallback rank.
  106862. * @returns the new fallback rank.
  106863. */
  106864. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  106865. /**
  106866. * Add the required uniforms to the current list.
  106867. * @param uniforms defines the current uniform list.
  106868. */
  106869. static AddUniforms(uniforms: string[]): void;
  106870. /**
  106871. * Add the required samplers to the current list.
  106872. * @param samplers defines the current sampler list.
  106873. */
  106874. static AddSamplers(samplers: string[]): void;
  106875. /**
  106876. * Add the required uniforms to the current buffer.
  106877. * @param uniformBuffer defines the current uniform buffer.
  106878. */
  106879. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  106880. /**
  106881. * Makes a duplicate of the current configuration into another one.
  106882. * @param clearCoatConfiguration define the config where to copy the info
  106883. */
  106884. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  106885. /**
  106886. * Serializes this clear coat configuration.
  106887. * @returns - An object with the serialized config.
  106888. */
  106889. serialize(): any;
  106890. /**
  106891. * Parses a Clear Coat Configuration from a serialized object.
  106892. * @param source - Serialized object.
  106893. */
  106894. parse(source: any): void;
  106895. }
  106896. }
  106897. declare module BABYLON {
  106898. /**
  106899. * @hidden
  106900. */
  106901. export interface IMaterialAnisotropicDefines {
  106902. ANISOTROPIC: boolean;
  106903. ANISOTROPIC_TEXTURE: boolean;
  106904. ANISOTROPIC_TEXTUREDIRECTUV: number;
  106905. MAINUV1: boolean;
  106906. _areTexturesDirty: boolean;
  106907. _needUVs: boolean;
  106908. }
  106909. /**
  106910. * Define the code related to the anisotropic parameters of the pbr material.
  106911. */
  106912. export class PBRAnisotropicConfiguration {
  106913. private _isEnabled;
  106914. /**
  106915. * Defines if the anisotropy is enabled in the material.
  106916. */
  106917. isEnabled: boolean;
  106918. /**
  106919. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  106920. */
  106921. intensity: number;
  106922. /**
  106923. * Defines if the effect is along the tangents, bitangents or in between.
  106924. * By default, the effect is "strectching" the highlights along the tangents.
  106925. */
  106926. direction: Vector2;
  106927. private _texture;
  106928. /**
  106929. * Stores the anisotropy values in a texture.
  106930. * rg is direction (like normal from -1 to 1)
  106931. * b is a intensity
  106932. */
  106933. texture: Nullable<BaseTexture>;
  106934. /** @hidden */
  106935. private _internalMarkAllSubMeshesAsTexturesDirty;
  106936. /** @hidden */
  106937. _markAllSubMeshesAsTexturesDirty(): void;
  106938. /**
  106939. * Instantiate a new istance of anisotropy configuration.
  106940. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  106941. */
  106942. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  106943. /**
  106944. * Specifies that the submesh is ready to be used.
  106945. * @param defines the list of "defines" to update.
  106946. * @param scene defines the scene the material belongs to.
  106947. * @returns - boolean indicating that the submesh is ready or not.
  106948. */
  106949. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  106950. /**
  106951. * Checks to see if a texture is used in the material.
  106952. * @param defines the list of "defines" to update.
  106953. * @param mesh the mesh we are preparing the defines for.
  106954. * @param scene defines the scene the material belongs to.
  106955. */
  106956. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  106957. /**
  106958. * Binds the material data.
  106959. * @param uniformBuffer defines the Uniform buffer to fill in.
  106960. * @param scene defines the scene the material belongs to.
  106961. * @param isFrozen defines wether the material is frozen or not.
  106962. */
  106963. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  106964. /**
  106965. * Checks to see if a texture is used in the material.
  106966. * @param texture - Base texture to use.
  106967. * @returns - Boolean specifying if a texture is used in the material.
  106968. */
  106969. hasTexture(texture: BaseTexture): boolean;
  106970. /**
  106971. * Returns an array of the actively used textures.
  106972. * @param activeTextures Array of BaseTextures
  106973. */
  106974. getActiveTextures(activeTextures: BaseTexture[]): void;
  106975. /**
  106976. * Returns the animatable textures.
  106977. * @param animatables Array of animatable textures.
  106978. */
  106979. getAnimatables(animatables: IAnimatable[]): void;
  106980. /**
  106981. * Disposes the resources of the material.
  106982. * @param forceDisposeTextures - Forces the disposal of all textures.
  106983. */
  106984. dispose(forceDisposeTextures?: boolean): void;
  106985. /**
  106986. * Get the current class name of the texture useful for serialization or dynamic coding.
  106987. * @returns "PBRAnisotropicConfiguration"
  106988. */
  106989. getClassName(): string;
  106990. /**
  106991. * Add fallbacks to the effect fallbacks list.
  106992. * @param defines defines the Base texture to use.
  106993. * @param fallbacks defines the current fallback list.
  106994. * @param currentRank defines the current fallback rank.
  106995. * @returns the new fallback rank.
  106996. */
  106997. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  106998. /**
  106999. * Add the required uniforms to the current list.
  107000. * @param uniforms defines the current uniform list.
  107001. */
  107002. static AddUniforms(uniforms: string[]): void;
  107003. /**
  107004. * Add the required uniforms to the current buffer.
  107005. * @param uniformBuffer defines the current uniform buffer.
  107006. */
  107007. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107008. /**
  107009. * Add the required samplers to the current list.
  107010. * @param samplers defines the current sampler list.
  107011. */
  107012. static AddSamplers(samplers: string[]): void;
  107013. /**
  107014. * Makes a duplicate of the current configuration into another one.
  107015. * @param anisotropicConfiguration define the config where to copy the info
  107016. */
  107017. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  107018. /**
  107019. * Serializes this anisotropy configuration.
  107020. * @returns - An object with the serialized config.
  107021. */
  107022. serialize(): any;
  107023. /**
  107024. * Parses a anisotropy Configuration from a serialized object.
  107025. * @param source - Serialized object.
  107026. */
  107027. parse(source: any): void;
  107028. }
  107029. }
  107030. declare module BABYLON {
  107031. /**
  107032. * @hidden
  107033. */
  107034. export interface IMaterialBRDFDefines {
  107035. BRDF_V_HEIGHT_CORRELATED: boolean;
  107036. MS_BRDF_ENERGY_CONSERVATION: boolean;
  107037. SPHERICAL_HARMONICS: boolean;
  107038. /** @hidden */
  107039. _areMiscDirty: boolean;
  107040. }
  107041. /**
  107042. * Define the code related to the BRDF parameters of the pbr material.
  107043. */
  107044. export class PBRBRDFConfiguration {
  107045. /**
  107046. * Default value used for the energy conservation.
  107047. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  107048. */
  107049. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  107050. /**
  107051. * Default value used for the Smith Visibility Height Correlated mode.
  107052. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  107053. */
  107054. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  107055. /**
  107056. * Default value used for the IBL diffuse part.
  107057. * This can help switching back to the polynomials mode globally which is a tiny bit
  107058. * less GPU intensive at the drawback of a lower quality.
  107059. */
  107060. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  107061. private _useEnergyConservation;
  107062. /**
  107063. * Defines if the material uses energy conservation.
  107064. */
  107065. useEnergyConservation: boolean;
  107066. private _useSmithVisibilityHeightCorrelated;
  107067. /**
  107068. * LEGACY Mode set to false
  107069. * Defines if the material uses height smith correlated visibility term.
  107070. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  107071. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  107072. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  107073. * Not relying on height correlated will also disable energy conservation.
  107074. */
  107075. useSmithVisibilityHeightCorrelated: boolean;
  107076. private _useSphericalHarmonics;
  107077. /**
  107078. * LEGACY Mode set to false
  107079. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  107080. * diffuse part of the IBL.
  107081. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  107082. * to the ground truth.
  107083. */
  107084. useSphericalHarmonics: boolean;
  107085. /** @hidden */
  107086. private _internalMarkAllSubMeshesAsMiscDirty;
  107087. /** @hidden */
  107088. _markAllSubMeshesAsMiscDirty(): void;
  107089. /**
  107090. * Instantiate a new istance of clear coat configuration.
  107091. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  107092. */
  107093. constructor(markAllSubMeshesAsMiscDirty: () => void);
  107094. /**
  107095. * Checks to see if a texture is used in the material.
  107096. * @param defines the list of "defines" to update.
  107097. */
  107098. prepareDefines(defines: IMaterialBRDFDefines): void;
  107099. /**
  107100. * Get the current class name of the texture useful for serialization or dynamic coding.
  107101. * @returns "PBRClearCoatConfiguration"
  107102. */
  107103. getClassName(): string;
  107104. /**
  107105. * Makes a duplicate of the current configuration into another one.
  107106. * @param brdfConfiguration define the config where to copy the info
  107107. */
  107108. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  107109. /**
  107110. * Serializes this BRDF configuration.
  107111. * @returns - An object with the serialized config.
  107112. */
  107113. serialize(): any;
  107114. /**
  107115. * Parses a BRDF Configuration from a serialized object.
  107116. * @param source - Serialized object.
  107117. */
  107118. parse(source: any): void;
  107119. }
  107120. }
  107121. declare module BABYLON {
  107122. /**
  107123. * @hidden
  107124. */
  107125. export interface IMaterialSheenDefines {
  107126. SHEEN: boolean;
  107127. SHEEN_TEXTURE: boolean;
  107128. SHEEN_TEXTUREDIRECTUV: number;
  107129. SHEEN_LINKWITHALBEDO: boolean;
  107130. /** @hidden */
  107131. _areTexturesDirty: boolean;
  107132. }
  107133. /**
  107134. * Define the code related to the Sheen parameters of the pbr material.
  107135. */
  107136. export class PBRSheenConfiguration {
  107137. private _isEnabled;
  107138. /**
  107139. * Defines if the material uses sheen.
  107140. */
  107141. isEnabled: boolean;
  107142. private _linkSheenWithAlbedo;
  107143. /**
  107144. * Defines if the sheen is linked to the sheen color.
  107145. */
  107146. linkSheenWithAlbedo: boolean;
  107147. /**
  107148. * Defines the sheen intensity.
  107149. */
  107150. intensity: number;
  107151. /**
  107152. * Defines the sheen color.
  107153. */
  107154. color: Color3;
  107155. private _texture;
  107156. /**
  107157. * Stores the sheen tint values in a texture.
  107158. * rgb is tint
  107159. * a is a intensity
  107160. */
  107161. texture: Nullable<BaseTexture>;
  107162. /** @hidden */
  107163. private _internalMarkAllSubMeshesAsTexturesDirty;
  107164. /** @hidden */
  107165. _markAllSubMeshesAsTexturesDirty(): void;
  107166. /**
  107167. * Instantiate a new istance of clear coat configuration.
  107168. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107169. */
  107170. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107171. /**
  107172. * Specifies that the submesh is ready to be used.
  107173. * @param defines the list of "defines" to update.
  107174. * @param scene defines the scene the material belongs to.
  107175. * @returns - boolean indicating that the submesh is ready or not.
  107176. */
  107177. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  107178. /**
  107179. * Checks to see if a texture is used in the material.
  107180. * @param defines the list of "defines" to update.
  107181. * @param scene defines the scene the material belongs to.
  107182. */
  107183. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  107184. /**
  107185. * Binds the material data.
  107186. * @param uniformBuffer defines the Uniform buffer to fill in.
  107187. * @param scene defines the scene the material belongs to.
  107188. * @param isFrozen defines wether the material is frozen or not.
  107189. */
  107190. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  107191. /**
  107192. * Checks to see if a texture is used in the material.
  107193. * @param texture - Base texture to use.
  107194. * @returns - Boolean specifying if a texture is used in the material.
  107195. */
  107196. hasTexture(texture: BaseTexture): boolean;
  107197. /**
  107198. * Returns an array of the actively used textures.
  107199. * @param activeTextures Array of BaseTextures
  107200. */
  107201. getActiveTextures(activeTextures: BaseTexture[]): void;
  107202. /**
  107203. * Returns the animatable textures.
  107204. * @param animatables Array of animatable textures.
  107205. */
  107206. getAnimatables(animatables: IAnimatable[]): void;
  107207. /**
  107208. * Disposes the resources of the material.
  107209. * @param forceDisposeTextures - Forces the disposal of all textures.
  107210. */
  107211. dispose(forceDisposeTextures?: boolean): void;
  107212. /**
  107213. * Get the current class name of the texture useful for serialization or dynamic coding.
  107214. * @returns "PBRSheenConfiguration"
  107215. */
  107216. getClassName(): string;
  107217. /**
  107218. * Add fallbacks to the effect fallbacks list.
  107219. * @param defines defines the Base texture to use.
  107220. * @param fallbacks defines the current fallback list.
  107221. * @param currentRank defines the current fallback rank.
  107222. * @returns the new fallback rank.
  107223. */
  107224. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107225. /**
  107226. * Add the required uniforms to the current list.
  107227. * @param uniforms defines the current uniform list.
  107228. */
  107229. static AddUniforms(uniforms: string[]): void;
  107230. /**
  107231. * Add the required uniforms to the current buffer.
  107232. * @param uniformBuffer defines the current uniform buffer.
  107233. */
  107234. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107235. /**
  107236. * Add the required samplers to the current list.
  107237. * @param samplers defines the current sampler list.
  107238. */
  107239. static AddSamplers(samplers: string[]): void;
  107240. /**
  107241. * Makes a duplicate of the current configuration into another one.
  107242. * @param sheenConfiguration define the config where to copy the info
  107243. */
  107244. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  107245. /**
  107246. * Serializes this BRDF configuration.
  107247. * @returns - An object with the serialized config.
  107248. */
  107249. serialize(): any;
  107250. /**
  107251. * Parses a Sheen Configuration from a serialized object.
  107252. * @param source - Serialized object.
  107253. */
  107254. parse(source: any): void;
  107255. }
  107256. }
  107257. declare module BABYLON {
  107258. /**
  107259. * @hidden
  107260. */
  107261. export interface IMaterialSubSurfaceDefines {
  107262. SUBSURFACE: boolean;
  107263. SS_REFRACTION: boolean;
  107264. SS_TRANSLUCENCY: boolean;
  107265. SS_SCATERRING: boolean;
  107266. SS_THICKNESSANDMASK_TEXTURE: boolean;
  107267. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  107268. SS_REFRACTIONMAP_3D: boolean;
  107269. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  107270. SS_LODINREFRACTIONALPHA: boolean;
  107271. SS_GAMMAREFRACTION: boolean;
  107272. SS_RGBDREFRACTION: boolean;
  107273. SS_LINEARSPECULARREFRACTION: boolean;
  107274. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  107275. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  107276. /** @hidden */
  107277. _areTexturesDirty: boolean;
  107278. }
  107279. /**
  107280. * Define the code related to the sub surface parameters of the pbr material.
  107281. */
  107282. export class PBRSubSurfaceConfiguration {
  107283. private _isRefractionEnabled;
  107284. /**
  107285. * Defines if the refraction is enabled in the material.
  107286. */
  107287. isRefractionEnabled: boolean;
  107288. private _isTranslucencyEnabled;
  107289. /**
  107290. * Defines if the translucency is enabled in the material.
  107291. */
  107292. isTranslucencyEnabled: boolean;
  107293. private _isScatteringEnabled;
  107294. /**
  107295. * Defines the refraction intensity of the material.
  107296. * The refraction when enabled replaces the Diffuse part of the material.
  107297. * The intensity helps transitionning between diffuse and refraction.
  107298. */
  107299. refractionIntensity: number;
  107300. /**
  107301. * Defines the translucency intensity of the material.
  107302. * When translucency has been enabled, this defines how much of the "translucency"
  107303. * is addded to the diffuse part of the material.
  107304. */
  107305. translucencyIntensity: number;
  107306. /**
  107307. * Defines the scattering intensity of the material.
  107308. * When scattering has been enabled, this defines how much of the "scattered light"
  107309. * is addded to the diffuse part of the material.
  107310. */
  107311. scatteringIntensity: number;
  107312. private _thicknessTexture;
  107313. /**
  107314. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  107315. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  107316. * 0 would mean minimumThickness
  107317. * 1 would mean maximumThickness
  107318. * The other channels might be use as a mask to vary the different effects intensity.
  107319. */
  107320. thicknessTexture: Nullable<BaseTexture>;
  107321. private _refractionTexture;
  107322. /**
  107323. * Defines the texture to use for refraction.
  107324. */
  107325. refractionTexture: Nullable<BaseTexture>;
  107326. private _indexOfRefraction;
  107327. /**
  107328. * Defines the indice of refraction used in the material.
  107329. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  107330. */
  107331. indexOfRefraction: number;
  107332. private _invertRefractionY;
  107333. /**
  107334. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  107335. */
  107336. invertRefractionY: boolean;
  107337. private _linkRefractionWithTransparency;
  107338. /**
  107339. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  107340. * Materials half opaque for instance using refraction could benefit from this control.
  107341. */
  107342. linkRefractionWithTransparency: boolean;
  107343. /**
  107344. * Defines the minimum thickness stored in the thickness map.
  107345. * If no thickness map is defined, this value will be used to simulate thickness.
  107346. */
  107347. minimumThickness: number;
  107348. /**
  107349. * Defines the maximum thickness stored in the thickness map.
  107350. */
  107351. maximumThickness: number;
  107352. /**
  107353. * Defines the volume tint of the material.
  107354. * This is used for both translucency and scattering.
  107355. */
  107356. tintColor: Color3;
  107357. /**
  107358. * Defines the distance at which the tint color should be found in the media.
  107359. * This is used for refraction only.
  107360. */
  107361. tintColorAtDistance: number;
  107362. /**
  107363. * Defines how far each channel transmit through the media.
  107364. * It is defined as a color to simplify it selection.
  107365. */
  107366. diffusionDistance: Color3;
  107367. private _useMaskFromThicknessTexture;
  107368. /**
  107369. * Stores the intensity of the different subsurface effects in the thickness texture.
  107370. * * the green channel is the translucency intensity.
  107371. * * the blue channel is the scattering intensity.
  107372. * * the alpha channel is the refraction intensity.
  107373. */
  107374. useMaskFromThicknessTexture: boolean;
  107375. /** @hidden */
  107376. private _internalMarkAllSubMeshesAsTexturesDirty;
  107377. /** @hidden */
  107378. _markAllSubMeshesAsTexturesDirty(): void;
  107379. /**
  107380. * Instantiate a new istance of sub surface configuration.
  107381. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107382. */
  107383. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107384. /**
  107385. * Gets wehter the submesh is ready to be used or not.
  107386. * @param defines the list of "defines" to update.
  107387. * @param scene defines the scene the material belongs to.
  107388. * @returns - boolean indicating that the submesh is ready or not.
  107389. */
  107390. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  107391. /**
  107392. * Checks to see if a texture is used in the material.
  107393. * @param defines the list of "defines" to update.
  107394. * @param scene defines the scene to the material belongs to.
  107395. */
  107396. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  107397. /**
  107398. * Binds the material data.
  107399. * @param uniformBuffer defines the Uniform buffer to fill in.
  107400. * @param scene defines the scene the material belongs to.
  107401. * @param engine defines the engine the material belongs to.
  107402. * @param isFrozen defines wether the material is frozen or not.
  107403. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  107404. */
  107405. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  107406. /**
  107407. * Unbinds the material from the mesh.
  107408. * @param activeEffect defines the effect that should be unbound from.
  107409. * @returns true if unbound, otherwise false
  107410. */
  107411. unbind(activeEffect: Effect): boolean;
  107412. /**
  107413. * Returns the texture used for refraction or null if none is used.
  107414. * @param scene defines the scene the material belongs to.
  107415. * @returns - Refraction texture if present. If no refraction texture and refraction
  107416. * is linked with transparency, returns environment texture. Otherwise, returns null.
  107417. */
  107418. private _getRefractionTexture;
  107419. /**
  107420. * Returns true if alpha blending should be disabled.
  107421. */
  107422. readonly disableAlphaBlending: boolean;
  107423. /**
  107424. * Fills the list of render target textures.
  107425. * @param renderTargets the list of render targets to update
  107426. */
  107427. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  107428. /**
  107429. * Checks to see if a texture is used in the material.
  107430. * @param texture - Base texture to use.
  107431. * @returns - Boolean specifying if a texture is used in the material.
  107432. */
  107433. hasTexture(texture: BaseTexture): boolean;
  107434. /**
  107435. * Gets a boolean indicating that current material needs to register RTT
  107436. * @returns true if this uses a render target otherwise false.
  107437. */
  107438. hasRenderTargetTextures(): boolean;
  107439. /**
  107440. * Returns an array of the actively used textures.
  107441. * @param activeTextures Array of BaseTextures
  107442. */
  107443. getActiveTextures(activeTextures: BaseTexture[]): void;
  107444. /**
  107445. * Returns the animatable textures.
  107446. * @param animatables Array of animatable textures.
  107447. */
  107448. getAnimatables(animatables: IAnimatable[]): void;
  107449. /**
  107450. * Disposes the resources of the material.
  107451. * @param forceDisposeTextures - Forces the disposal of all textures.
  107452. */
  107453. dispose(forceDisposeTextures?: boolean): void;
  107454. /**
  107455. * Get the current class name of the texture useful for serialization or dynamic coding.
  107456. * @returns "PBRSubSurfaceConfiguration"
  107457. */
  107458. getClassName(): string;
  107459. /**
  107460. * Add fallbacks to the effect fallbacks list.
  107461. * @param defines defines the Base texture to use.
  107462. * @param fallbacks defines the current fallback list.
  107463. * @param currentRank defines the current fallback rank.
  107464. * @returns the new fallback rank.
  107465. */
  107466. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107467. /**
  107468. * Add the required uniforms to the current list.
  107469. * @param uniforms defines the current uniform list.
  107470. */
  107471. static AddUniforms(uniforms: string[]): void;
  107472. /**
  107473. * Add the required samplers to the current list.
  107474. * @param samplers defines the current sampler list.
  107475. */
  107476. static AddSamplers(samplers: string[]): void;
  107477. /**
  107478. * Add the required uniforms to the current buffer.
  107479. * @param uniformBuffer defines the current uniform buffer.
  107480. */
  107481. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107482. /**
  107483. * Makes a duplicate of the current configuration into another one.
  107484. * @param configuration define the config where to copy the info
  107485. */
  107486. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  107487. /**
  107488. * Serializes this Sub Surface configuration.
  107489. * @returns - An object with the serialized config.
  107490. */
  107491. serialize(): any;
  107492. /**
  107493. * Parses a Sub Surface Configuration from a serialized object.
  107494. * @param source - Serialized object.
  107495. */
  107496. parse(source: any): void;
  107497. }
  107498. }
  107499. declare module BABYLON {
  107500. /** @hidden */
  107501. export var pbrFragmentDeclaration: {
  107502. name: string;
  107503. shader: string;
  107504. };
  107505. }
  107506. declare module BABYLON {
  107507. /** @hidden */
  107508. export var pbrUboDeclaration: {
  107509. name: string;
  107510. shader: string;
  107511. };
  107512. }
  107513. declare module BABYLON {
  107514. /** @hidden */
  107515. export var pbrFragmentExtraDeclaration: {
  107516. name: string;
  107517. shader: string;
  107518. };
  107519. }
  107520. declare module BABYLON {
  107521. /** @hidden */
  107522. export var pbrFragmentSamplersDeclaration: {
  107523. name: string;
  107524. shader: string;
  107525. };
  107526. }
  107527. declare module BABYLON {
  107528. /** @hidden */
  107529. export var pbrHelperFunctions: {
  107530. name: string;
  107531. shader: string;
  107532. };
  107533. }
  107534. declare module BABYLON {
  107535. /** @hidden */
  107536. export var harmonicsFunctions: {
  107537. name: string;
  107538. shader: string;
  107539. };
  107540. }
  107541. declare module BABYLON {
  107542. /** @hidden */
  107543. export var pbrDirectLightingSetupFunctions: {
  107544. name: string;
  107545. shader: string;
  107546. };
  107547. }
  107548. declare module BABYLON {
  107549. /** @hidden */
  107550. export var pbrDirectLightingFalloffFunctions: {
  107551. name: string;
  107552. shader: string;
  107553. };
  107554. }
  107555. declare module BABYLON {
  107556. /** @hidden */
  107557. export var pbrBRDFFunctions: {
  107558. name: string;
  107559. shader: string;
  107560. };
  107561. }
  107562. declare module BABYLON {
  107563. /** @hidden */
  107564. export var pbrDirectLightingFunctions: {
  107565. name: string;
  107566. shader: string;
  107567. };
  107568. }
  107569. declare module BABYLON {
  107570. /** @hidden */
  107571. export var pbrIBLFunctions: {
  107572. name: string;
  107573. shader: string;
  107574. };
  107575. }
  107576. declare module BABYLON {
  107577. /** @hidden */
  107578. export var pbrDebug: {
  107579. name: string;
  107580. shader: string;
  107581. };
  107582. }
  107583. declare module BABYLON {
  107584. /** @hidden */
  107585. export var pbrPixelShader: {
  107586. name: string;
  107587. shader: string;
  107588. };
  107589. }
  107590. declare module BABYLON {
  107591. /** @hidden */
  107592. export var pbrVertexDeclaration: {
  107593. name: string;
  107594. shader: string;
  107595. };
  107596. }
  107597. declare module BABYLON {
  107598. /** @hidden */
  107599. export var pbrVertexShader: {
  107600. name: string;
  107601. shader: string;
  107602. };
  107603. }
  107604. declare module BABYLON {
  107605. /**
  107606. * Manages the defines for the PBR Material.
  107607. * @hidden
  107608. */
  107609. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  107610. PBR: boolean;
  107611. MAINUV1: boolean;
  107612. MAINUV2: boolean;
  107613. UV1: boolean;
  107614. UV2: boolean;
  107615. ALBEDO: boolean;
  107616. ALBEDODIRECTUV: number;
  107617. VERTEXCOLOR: boolean;
  107618. AMBIENT: boolean;
  107619. AMBIENTDIRECTUV: number;
  107620. AMBIENTINGRAYSCALE: boolean;
  107621. OPACITY: boolean;
  107622. VERTEXALPHA: boolean;
  107623. OPACITYDIRECTUV: number;
  107624. OPACITYRGB: boolean;
  107625. ALPHATEST: boolean;
  107626. DEPTHPREPASS: boolean;
  107627. ALPHABLEND: boolean;
  107628. ALPHAFROMALBEDO: boolean;
  107629. ALPHATESTVALUE: string;
  107630. SPECULAROVERALPHA: boolean;
  107631. RADIANCEOVERALPHA: boolean;
  107632. ALPHAFRESNEL: boolean;
  107633. LINEARALPHAFRESNEL: boolean;
  107634. PREMULTIPLYALPHA: boolean;
  107635. EMISSIVE: boolean;
  107636. EMISSIVEDIRECTUV: number;
  107637. REFLECTIVITY: boolean;
  107638. REFLECTIVITYDIRECTUV: number;
  107639. SPECULARTERM: boolean;
  107640. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  107641. MICROSURFACEAUTOMATIC: boolean;
  107642. LODBASEDMICROSFURACE: boolean;
  107643. MICROSURFACEMAP: boolean;
  107644. MICROSURFACEMAPDIRECTUV: number;
  107645. METALLICWORKFLOW: boolean;
  107646. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  107647. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  107648. METALLNESSSTOREINMETALMAPBLUE: boolean;
  107649. AOSTOREINMETALMAPRED: boolean;
  107650. ENVIRONMENTBRDF: boolean;
  107651. ENVIRONMENTBRDF_RGBD: boolean;
  107652. NORMAL: boolean;
  107653. TANGENT: boolean;
  107654. BUMP: boolean;
  107655. BUMPDIRECTUV: number;
  107656. OBJECTSPACE_NORMALMAP: boolean;
  107657. PARALLAX: boolean;
  107658. PARALLAXOCCLUSION: boolean;
  107659. NORMALXYSCALE: boolean;
  107660. LIGHTMAP: boolean;
  107661. LIGHTMAPDIRECTUV: number;
  107662. USELIGHTMAPASSHADOWMAP: boolean;
  107663. GAMMALIGHTMAP: boolean;
  107664. REFLECTION: boolean;
  107665. REFLECTIONMAP_3D: boolean;
  107666. REFLECTIONMAP_SPHERICAL: boolean;
  107667. REFLECTIONMAP_PLANAR: boolean;
  107668. REFLECTIONMAP_CUBIC: boolean;
  107669. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  107670. REFLECTIONMAP_PROJECTION: boolean;
  107671. REFLECTIONMAP_SKYBOX: boolean;
  107672. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  107673. REFLECTIONMAP_EXPLICIT: boolean;
  107674. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  107675. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  107676. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  107677. INVERTCUBICMAP: boolean;
  107678. USESPHERICALFROMREFLECTIONMAP: boolean;
  107679. USEIRRADIANCEMAP: boolean;
  107680. SPHERICAL_HARMONICS: boolean;
  107681. USESPHERICALINVERTEX: boolean;
  107682. REFLECTIONMAP_OPPOSITEZ: boolean;
  107683. LODINREFLECTIONALPHA: boolean;
  107684. GAMMAREFLECTION: boolean;
  107685. RGBDREFLECTION: boolean;
  107686. LINEARSPECULARREFLECTION: boolean;
  107687. RADIANCEOCCLUSION: boolean;
  107688. HORIZONOCCLUSION: boolean;
  107689. INSTANCES: boolean;
  107690. NUM_BONE_INFLUENCERS: number;
  107691. BonesPerMesh: number;
  107692. BONETEXTURE: boolean;
  107693. NONUNIFORMSCALING: boolean;
  107694. MORPHTARGETS: boolean;
  107695. MORPHTARGETS_NORMAL: boolean;
  107696. MORPHTARGETS_TANGENT: boolean;
  107697. NUM_MORPH_INFLUENCERS: number;
  107698. IMAGEPROCESSING: boolean;
  107699. VIGNETTE: boolean;
  107700. VIGNETTEBLENDMODEMULTIPLY: boolean;
  107701. VIGNETTEBLENDMODEOPAQUE: boolean;
  107702. TONEMAPPING: boolean;
  107703. TONEMAPPING_ACES: boolean;
  107704. CONTRAST: boolean;
  107705. COLORCURVES: boolean;
  107706. COLORGRADING: boolean;
  107707. COLORGRADING3D: boolean;
  107708. SAMPLER3DGREENDEPTH: boolean;
  107709. SAMPLER3DBGRMAP: boolean;
  107710. IMAGEPROCESSINGPOSTPROCESS: boolean;
  107711. EXPOSURE: boolean;
  107712. MULTIVIEW: boolean;
  107713. USEPHYSICALLIGHTFALLOFF: boolean;
  107714. USEGLTFLIGHTFALLOFF: boolean;
  107715. TWOSIDEDLIGHTING: boolean;
  107716. SHADOWFLOAT: boolean;
  107717. CLIPPLANE: boolean;
  107718. CLIPPLANE2: boolean;
  107719. CLIPPLANE3: boolean;
  107720. CLIPPLANE4: boolean;
  107721. POINTSIZE: boolean;
  107722. FOG: boolean;
  107723. LOGARITHMICDEPTH: boolean;
  107724. FORCENORMALFORWARD: boolean;
  107725. SPECULARAA: boolean;
  107726. CLEARCOAT: boolean;
  107727. CLEARCOAT_DEFAULTIOR: boolean;
  107728. CLEARCOAT_TEXTURE: boolean;
  107729. CLEARCOAT_TEXTUREDIRECTUV: number;
  107730. CLEARCOAT_BUMP: boolean;
  107731. CLEARCOAT_BUMPDIRECTUV: number;
  107732. CLEARCOAT_TINT: boolean;
  107733. CLEARCOAT_TINT_TEXTURE: boolean;
  107734. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  107735. ANISOTROPIC: boolean;
  107736. ANISOTROPIC_TEXTURE: boolean;
  107737. ANISOTROPIC_TEXTUREDIRECTUV: number;
  107738. BRDF_V_HEIGHT_CORRELATED: boolean;
  107739. MS_BRDF_ENERGY_CONSERVATION: boolean;
  107740. SHEEN: boolean;
  107741. SHEEN_TEXTURE: boolean;
  107742. SHEEN_TEXTUREDIRECTUV: number;
  107743. SHEEN_LINKWITHALBEDO: boolean;
  107744. SUBSURFACE: boolean;
  107745. SS_REFRACTION: boolean;
  107746. SS_TRANSLUCENCY: boolean;
  107747. SS_SCATERRING: boolean;
  107748. SS_THICKNESSANDMASK_TEXTURE: boolean;
  107749. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  107750. SS_REFRACTIONMAP_3D: boolean;
  107751. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  107752. SS_LODINREFRACTIONALPHA: boolean;
  107753. SS_GAMMAREFRACTION: boolean;
  107754. SS_RGBDREFRACTION: boolean;
  107755. SS_LINEARSPECULARREFRACTION: boolean;
  107756. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  107757. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  107758. UNLIT: boolean;
  107759. DEBUGMODE: number;
  107760. /**
  107761. * Initializes the PBR Material defines.
  107762. */
  107763. constructor();
  107764. /**
  107765. * Resets the PBR Material defines.
  107766. */
  107767. reset(): void;
  107768. }
  107769. /**
  107770. * The Physically based material base class of BJS.
  107771. *
  107772. * This offers the main features of a standard PBR material.
  107773. * For more information, please refer to the documentation :
  107774. * https://doc.babylonjs.com/how_to/physically_based_rendering
  107775. */
  107776. export abstract class PBRBaseMaterial extends PushMaterial {
  107777. /**
  107778. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  107779. */
  107780. static readonly PBRMATERIAL_OPAQUE: number;
  107781. /**
  107782. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  107783. */
  107784. static readonly PBRMATERIAL_ALPHATEST: number;
  107785. /**
  107786. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107787. */
  107788. static readonly PBRMATERIAL_ALPHABLEND: number;
  107789. /**
  107790. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107791. * They are also discarded below the alpha cutoff threshold to improve performances.
  107792. */
  107793. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  107794. /**
  107795. * Defines the default value of how much AO map is occluding the analytical lights
  107796. * (point spot...).
  107797. */
  107798. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  107799. /**
  107800. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  107801. */
  107802. static readonly LIGHTFALLOFF_PHYSICAL: number;
  107803. /**
  107804. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  107805. * to enhance interoperability with other engines.
  107806. */
  107807. static readonly LIGHTFALLOFF_GLTF: number;
  107808. /**
  107809. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  107810. * to enhance interoperability with other materials.
  107811. */
  107812. static readonly LIGHTFALLOFF_STANDARD: number;
  107813. /**
  107814. * Intensity of the direct lights e.g. the four lights available in your scene.
  107815. * This impacts both the direct diffuse and specular highlights.
  107816. */
  107817. protected _directIntensity: number;
  107818. /**
  107819. * Intensity of the emissive part of the material.
  107820. * This helps controlling the emissive effect without modifying the emissive color.
  107821. */
  107822. protected _emissiveIntensity: number;
  107823. /**
  107824. * Intensity of the environment e.g. how much the environment will light the object
  107825. * either through harmonics for rough material or through the refelction for shiny ones.
  107826. */
  107827. protected _environmentIntensity: number;
  107828. /**
  107829. * This is a special control allowing the reduction of the specular highlights coming from the
  107830. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  107831. */
  107832. protected _specularIntensity: number;
  107833. /**
  107834. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  107835. */
  107836. private _lightingInfos;
  107837. /**
  107838. * Debug Control allowing disabling the bump map on this material.
  107839. */
  107840. protected _disableBumpMap: boolean;
  107841. /**
  107842. * AKA Diffuse Texture in standard nomenclature.
  107843. */
  107844. protected _albedoTexture: Nullable<BaseTexture>;
  107845. /**
  107846. * AKA Occlusion Texture in other nomenclature.
  107847. */
  107848. protected _ambientTexture: Nullable<BaseTexture>;
  107849. /**
  107850. * AKA Occlusion Texture Intensity in other nomenclature.
  107851. */
  107852. protected _ambientTextureStrength: number;
  107853. /**
  107854. * Defines how much the AO map is occluding the analytical lights (point spot...).
  107855. * 1 means it completely occludes it
  107856. * 0 mean it has no impact
  107857. */
  107858. protected _ambientTextureImpactOnAnalyticalLights: number;
  107859. /**
  107860. * Stores the alpha values in a texture.
  107861. */
  107862. protected _opacityTexture: Nullable<BaseTexture>;
  107863. /**
  107864. * Stores the reflection values in a texture.
  107865. */
  107866. protected _reflectionTexture: Nullable<BaseTexture>;
  107867. /**
  107868. * Stores the emissive values in a texture.
  107869. */
  107870. protected _emissiveTexture: Nullable<BaseTexture>;
  107871. /**
  107872. * AKA Specular texture in other nomenclature.
  107873. */
  107874. protected _reflectivityTexture: Nullable<BaseTexture>;
  107875. /**
  107876. * Used to switch from specular/glossiness to metallic/roughness workflow.
  107877. */
  107878. protected _metallicTexture: Nullable<BaseTexture>;
  107879. /**
  107880. * Specifies the metallic scalar of the metallic/roughness workflow.
  107881. * Can also be used to scale the metalness values of the metallic texture.
  107882. */
  107883. protected _metallic: Nullable<number>;
  107884. /**
  107885. * Specifies the roughness scalar of the metallic/roughness workflow.
  107886. * Can also be used to scale the roughness values of the metallic texture.
  107887. */
  107888. protected _roughness: Nullable<number>;
  107889. /**
  107890. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  107891. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  107892. */
  107893. protected _microSurfaceTexture: Nullable<BaseTexture>;
  107894. /**
  107895. * Stores surface normal data used to displace a mesh in a texture.
  107896. */
  107897. protected _bumpTexture: Nullable<BaseTexture>;
  107898. /**
  107899. * Stores the pre-calculated light information of a mesh in a texture.
  107900. */
  107901. protected _lightmapTexture: Nullable<BaseTexture>;
  107902. /**
  107903. * The color of a material in ambient lighting.
  107904. */
  107905. protected _ambientColor: Color3;
  107906. /**
  107907. * AKA Diffuse Color in other nomenclature.
  107908. */
  107909. protected _albedoColor: Color3;
  107910. /**
  107911. * AKA Specular Color in other nomenclature.
  107912. */
  107913. protected _reflectivityColor: Color3;
  107914. /**
  107915. * The color applied when light is reflected from a material.
  107916. */
  107917. protected _reflectionColor: Color3;
  107918. /**
  107919. * The color applied when light is emitted from a material.
  107920. */
  107921. protected _emissiveColor: Color3;
  107922. /**
  107923. * AKA Glossiness in other nomenclature.
  107924. */
  107925. protected _microSurface: number;
  107926. /**
  107927. * Specifies that the material will use the light map as a show map.
  107928. */
  107929. protected _useLightmapAsShadowmap: boolean;
  107930. /**
  107931. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  107932. * makes the reflect vector face the model (under horizon).
  107933. */
  107934. protected _useHorizonOcclusion: boolean;
  107935. /**
  107936. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  107937. * too much the area relying on ambient texture to define their ambient occlusion.
  107938. */
  107939. protected _useRadianceOcclusion: boolean;
  107940. /**
  107941. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  107942. */
  107943. protected _useAlphaFromAlbedoTexture: boolean;
  107944. /**
  107945. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  107946. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107947. */
  107948. protected _useSpecularOverAlpha: boolean;
  107949. /**
  107950. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  107951. */
  107952. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  107953. /**
  107954. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  107955. */
  107956. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  107957. /**
  107958. * Specifies if the metallic texture contains the roughness information in its green channel.
  107959. */
  107960. protected _useRoughnessFromMetallicTextureGreen: boolean;
  107961. /**
  107962. * Specifies if the metallic texture contains the metallness information in its blue channel.
  107963. */
  107964. protected _useMetallnessFromMetallicTextureBlue: boolean;
  107965. /**
  107966. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  107967. */
  107968. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  107969. /**
  107970. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  107971. */
  107972. protected _useAmbientInGrayScale: boolean;
  107973. /**
  107974. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  107975. * The material will try to infer what glossiness each pixel should be.
  107976. */
  107977. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  107978. /**
  107979. * Defines the falloff type used in this material.
  107980. * It by default is Physical.
  107981. */
  107982. protected _lightFalloff: number;
  107983. /**
  107984. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107985. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107986. */
  107987. protected _useRadianceOverAlpha: boolean;
  107988. /**
  107989. * Allows using an object space normal map (instead of tangent space).
  107990. */
  107991. protected _useObjectSpaceNormalMap: boolean;
  107992. /**
  107993. * Allows using the bump map in parallax mode.
  107994. */
  107995. protected _useParallax: boolean;
  107996. /**
  107997. * Allows using the bump map in parallax occlusion mode.
  107998. */
  107999. protected _useParallaxOcclusion: boolean;
  108000. /**
  108001. * Controls the scale bias of the parallax mode.
  108002. */
  108003. protected _parallaxScaleBias: number;
  108004. /**
  108005. * If sets to true, disables all the lights affecting the material.
  108006. */
  108007. protected _disableLighting: boolean;
  108008. /**
  108009. * Number of Simultaneous lights allowed on the material.
  108010. */
  108011. protected _maxSimultaneousLights: number;
  108012. /**
  108013. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  108014. */
  108015. protected _invertNormalMapX: boolean;
  108016. /**
  108017. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  108018. */
  108019. protected _invertNormalMapY: boolean;
  108020. /**
  108021. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108022. */
  108023. protected _twoSidedLighting: boolean;
  108024. /**
  108025. * Defines the alpha limits in alpha test mode.
  108026. */
  108027. protected _alphaCutOff: number;
  108028. /**
  108029. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  108030. */
  108031. protected _forceAlphaTest: boolean;
  108032. /**
  108033. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108034. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  108035. */
  108036. protected _useAlphaFresnel: boolean;
  108037. /**
  108038. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108039. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  108040. */
  108041. protected _useLinearAlphaFresnel: boolean;
  108042. /**
  108043. * The transparency mode of the material.
  108044. */
  108045. protected _transparencyMode: Nullable<number>;
  108046. /**
  108047. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  108048. * from cos thetav and roughness:
  108049. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  108050. */
  108051. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  108052. /**
  108053. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  108054. */
  108055. protected _forceIrradianceInFragment: boolean;
  108056. /**
  108057. * Force normal to face away from face.
  108058. */
  108059. protected _forceNormalForward: boolean;
  108060. /**
  108061. * Enables specular anti aliasing in the PBR shader.
  108062. * It will both interacts on the Geometry for analytical and IBL lighting.
  108063. * It also prefilter the roughness map based on the bump values.
  108064. */
  108065. protected _enableSpecularAntiAliasing: boolean;
  108066. /**
  108067. * Default configuration related to image processing available in the PBR Material.
  108068. */
  108069. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108070. /**
  108071. * Keep track of the image processing observer to allow dispose and replace.
  108072. */
  108073. private _imageProcessingObserver;
  108074. /**
  108075. * Attaches a new image processing configuration to the PBR Material.
  108076. * @param configuration
  108077. */
  108078. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  108079. /**
  108080. * Stores the available render targets.
  108081. */
  108082. private _renderTargets;
  108083. /**
  108084. * Sets the global ambient color for the material used in lighting calculations.
  108085. */
  108086. private _globalAmbientColor;
  108087. /**
  108088. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  108089. */
  108090. private _useLogarithmicDepth;
  108091. /**
  108092. * If set to true, no lighting calculations will be applied.
  108093. */
  108094. private _unlit;
  108095. private _debugMode;
  108096. /**
  108097. * @hidden
  108098. * This is reserved for the inspector.
  108099. * Defines the material debug mode.
  108100. * It helps seeing only some components of the material while troubleshooting.
  108101. */
  108102. debugMode: number;
  108103. /**
  108104. * @hidden
  108105. * This is reserved for the inspector.
  108106. * Specify from where on screen the debug mode should start.
  108107. * The value goes from -1 (full screen) to 1 (not visible)
  108108. * It helps with side by side comparison against the final render
  108109. * This defaults to -1
  108110. */
  108111. private debugLimit;
  108112. /**
  108113. * @hidden
  108114. * This is reserved for the inspector.
  108115. * As the default viewing range might not be enough (if the ambient is really small for instance)
  108116. * You can use the factor to better multiply the final value.
  108117. */
  108118. private debugFactor;
  108119. /**
  108120. * Defines the clear coat layer parameters for the material.
  108121. */
  108122. readonly clearCoat: PBRClearCoatConfiguration;
  108123. /**
  108124. * Defines the anisotropic parameters for the material.
  108125. */
  108126. readonly anisotropy: PBRAnisotropicConfiguration;
  108127. /**
  108128. * Defines the BRDF parameters for the material.
  108129. */
  108130. readonly brdf: PBRBRDFConfiguration;
  108131. /**
  108132. * Defines the Sheen parameters for the material.
  108133. */
  108134. readonly sheen: PBRSheenConfiguration;
  108135. /**
  108136. * Defines the SubSurface parameters for the material.
  108137. */
  108138. readonly subSurface: PBRSubSurfaceConfiguration;
  108139. /**
  108140. * Custom callback helping to override the default shader used in the material.
  108141. */
  108142. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  108143. /**
  108144. * Instantiates a new PBRMaterial instance.
  108145. *
  108146. * @param name The material name
  108147. * @param scene The scene the material will be use in.
  108148. */
  108149. constructor(name: string, scene: Scene);
  108150. /**
  108151. * Gets a boolean indicating that current material needs to register RTT
  108152. */
  108153. readonly hasRenderTargetTextures: boolean;
  108154. /**
  108155. * Gets the name of the material class.
  108156. */
  108157. getClassName(): string;
  108158. /**
  108159. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  108160. */
  108161. /**
  108162. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  108163. */
  108164. useLogarithmicDepth: boolean;
  108165. /**
  108166. * Gets the current transparency mode.
  108167. */
  108168. /**
  108169. * Sets the transparency mode of the material.
  108170. *
  108171. * | Value | Type | Description |
  108172. * | ----- | ----------------------------------- | ----------- |
  108173. * | 0 | OPAQUE | |
  108174. * | 1 | ALPHATEST | |
  108175. * | 2 | ALPHABLEND | |
  108176. * | 3 | ALPHATESTANDBLEND | |
  108177. *
  108178. */
  108179. transparencyMode: Nullable<number>;
  108180. /**
  108181. * Returns true if alpha blending should be disabled.
  108182. */
  108183. private readonly _disableAlphaBlending;
  108184. /**
  108185. * Specifies whether or not this material should be rendered in alpha blend mode.
  108186. */
  108187. needAlphaBlending(): boolean;
  108188. /**
  108189. * Specifies if the mesh will require alpha blending.
  108190. * @param mesh - BJS mesh.
  108191. */
  108192. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  108193. /**
  108194. * Specifies whether or not this material should be rendered in alpha test mode.
  108195. */
  108196. needAlphaTesting(): boolean;
  108197. /**
  108198. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  108199. */
  108200. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  108201. /**
  108202. * Gets the texture used for the alpha test.
  108203. */
  108204. getAlphaTestTexture(): Nullable<BaseTexture>;
  108205. /**
  108206. * Specifies that the submesh is ready to be used.
  108207. * @param mesh - BJS mesh.
  108208. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  108209. * @param useInstances - Specifies that instances should be used.
  108210. * @returns - boolean indicating that the submesh is ready or not.
  108211. */
  108212. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  108213. /**
  108214. * Specifies if the material uses metallic roughness workflow.
  108215. * @returns boolean specifiying if the material uses metallic roughness workflow.
  108216. */
  108217. isMetallicWorkflow(): boolean;
  108218. private _prepareEffect;
  108219. private _prepareDefines;
  108220. /**
  108221. * Force shader compilation
  108222. */
  108223. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  108224. clipPlane: boolean;
  108225. }>): void;
  108226. /**
  108227. * Initializes the uniform buffer layout for the shader.
  108228. */
  108229. buildUniformLayout(): void;
  108230. /**
  108231. * Unbinds the material from the mesh
  108232. */
  108233. unbind(): void;
  108234. /**
  108235. * Binds the submesh data.
  108236. * @param world - The world matrix.
  108237. * @param mesh - The BJS mesh.
  108238. * @param subMesh - A submesh of the BJS mesh.
  108239. */
  108240. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  108241. /**
  108242. * Returns the animatable textures.
  108243. * @returns - Array of animatable textures.
  108244. */
  108245. getAnimatables(): IAnimatable[];
  108246. /**
  108247. * Returns the texture used for reflections.
  108248. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  108249. */
  108250. private _getReflectionTexture;
  108251. /**
  108252. * Returns an array of the actively used textures.
  108253. * @returns - Array of BaseTextures
  108254. */
  108255. getActiveTextures(): BaseTexture[];
  108256. /**
  108257. * Checks to see if a texture is used in the material.
  108258. * @param texture - Base texture to use.
  108259. * @returns - Boolean specifying if a texture is used in the material.
  108260. */
  108261. hasTexture(texture: BaseTexture): boolean;
  108262. /**
  108263. * Disposes the resources of the material.
  108264. * @param forceDisposeEffect - Forces the disposal of effects.
  108265. * @param forceDisposeTextures - Forces the disposal of all textures.
  108266. */
  108267. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  108268. }
  108269. }
  108270. declare module BABYLON {
  108271. /**
  108272. * The Physically based material of BJS.
  108273. *
  108274. * This offers the main features of a standard PBR material.
  108275. * For more information, please refer to the documentation :
  108276. * https://doc.babylonjs.com/how_to/physically_based_rendering
  108277. */
  108278. export class PBRMaterial extends PBRBaseMaterial {
  108279. /**
  108280. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  108281. */
  108282. static readonly PBRMATERIAL_OPAQUE: number;
  108283. /**
  108284. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  108285. */
  108286. static readonly PBRMATERIAL_ALPHATEST: number;
  108287. /**
  108288. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108289. */
  108290. static readonly PBRMATERIAL_ALPHABLEND: number;
  108291. /**
  108292. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108293. * They are also discarded below the alpha cutoff threshold to improve performances.
  108294. */
  108295. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  108296. /**
  108297. * Defines the default value of how much AO map is occluding the analytical lights
  108298. * (point spot...).
  108299. */
  108300. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  108301. /**
  108302. * Intensity of the direct lights e.g. the four lights available in your scene.
  108303. * This impacts both the direct diffuse and specular highlights.
  108304. */
  108305. directIntensity: number;
  108306. /**
  108307. * Intensity of the emissive part of the material.
  108308. * This helps controlling the emissive effect without modifying the emissive color.
  108309. */
  108310. emissiveIntensity: number;
  108311. /**
  108312. * Intensity of the environment e.g. how much the environment will light the object
  108313. * either through harmonics for rough material or through the refelction for shiny ones.
  108314. */
  108315. environmentIntensity: number;
  108316. /**
  108317. * This is a special control allowing the reduction of the specular highlights coming from the
  108318. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  108319. */
  108320. specularIntensity: number;
  108321. /**
  108322. * Debug Control allowing disabling the bump map on this material.
  108323. */
  108324. disableBumpMap: boolean;
  108325. /**
  108326. * AKA Diffuse Texture in standard nomenclature.
  108327. */
  108328. albedoTexture: BaseTexture;
  108329. /**
  108330. * AKA Occlusion Texture in other nomenclature.
  108331. */
  108332. ambientTexture: BaseTexture;
  108333. /**
  108334. * AKA Occlusion Texture Intensity in other nomenclature.
  108335. */
  108336. ambientTextureStrength: number;
  108337. /**
  108338. * Defines how much the AO map is occluding the analytical lights (point spot...).
  108339. * 1 means it completely occludes it
  108340. * 0 mean it has no impact
  108341. */
  108342. ambientTextureImpactOnAnalyticalLights: number;
  108343. /**
  108344. * Stores the alpha values in a texture.
  108345. */
  108346. opacityTexture: BaseTexture;
  108347. /**
  108348. * Stores the reflection values in a texture.
  108349. */
  108350. reflectionTexture: Nullable<BaseTexture>;
  108351. /**
  108352. * Stores the emissive values in a texture.
  108353. */
  108354. emissiveTexture: BaseTexture;
  108355. /**
  108356. * AKA Specular texture in other nomenclature.
  108357. */
  108358. reflectivityTexture: BaseTexture;
  108359. /**
  108360. * Used to switch from specular/glossiness to metallic/roughness workflow.
  108361. */
  108362. metallicTexture: BaseTexture;
  108363. /**
  108364. * Specifies the metallic scalar of the metallic/roughness workflow.
  108365. * Can also be used to scale the metalness values of the metallic texture.
  108366. */
  108367. metallic: Nullable<number>;
  108368. /**
  108369. * Specifies the roughness scalar of the metallic/roughness workflow.
  108370. * Can also be used to scale the roughness values of the metallic texture.
  108371. */
  108372. roughness: Nullable<number>;
  108373. /**
  108374. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  108375. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  108376. */
  108377. microSurfaceTexture: BaseTexture;
  108378. /**
  108379. * Stores surface normal data used to displace a mesh in a texture.
  108380. */
  108381. bumpTexture: BaseTexture;
  108382. /**
  108383. * Stores the pre-calculated light information of a mesh in a texture.
  108384. */
  108385. lightmapTexture: BaseTexture;
  108386. /**
  108387. * Stores the refracted light information in a texture.
  108388. */
  108389. refractionTexture: Nullable<BaseTexture>;
  108390. /**
  108391. * The color of a material in ambient lighting.
  108392. */
  108393. ambientColor: Color3;
  108394. /**
  108395. * AKA Diffuse Color in other nomenclature.
  108396. */
  108397. albedoColor: Color3;
  108398. /**
  108399. * AKA Specular Color in other nomenclature.
  108400. */
  108401. reflectivityColor: Color3;
  108402. /**
  108403. * The color reflected from the material.
  108404. */
  108405. reflectionColor: Color3;
  108406. /**
  108407. * The color emitted from the material.
  108408. */
  108409. emissiveColor: Color3;
  108410. /**
  108411. * AKA Glossiness in other nomenclature.
  108412. */
  108413. microSurface: number;
  108414. /**
  108415. * source material index of refraction (IOR)' / 'destination material IOR.
  108416. */
  108417. indexOfRefraction: number;
  108418. /**
  108419. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  108420. */
  108421. invertRefractionY: boolean;
  108422. /**
  108423. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  108424. * Materials half opaque for instance using refraction could benefit from this control.
  108425. */
  108426. linkRefractionWithTransparency: boolean;
  108427. /**
  108428. * If true, the light map contains occlusion information instead of lighting info.
  108429. */
  108430. useLightmapAsShadowmap: boolean;
  108431. /**
  108432. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  108433. */
  108434. useAlphaFromAlbedoTexture: boolean;
  108435. /**
  108436. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  108437. */
  108438. forceAlphaTest: boolean;
  108439. /**
  108440. * Defines the alpha limits in alpha test mode.
  108441. */
  108442. alphaCutOff: number;
  108443. /**
  108444. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  108445. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  108446. */
  108447. useSpecularOverAlpha: boolean;
  108448. /**
  108449. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  108450. */
  108451. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  108452. /**
  108453. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  108454. */
  108455. useRoughnessFromMetallicTextureAlpha: boolean;
  108456. /**
  108457. * Specifies if the metallic texture contains the roughness information in its green channel.
  108458. */
  108459. useRoughnessFromMetallicTextureGreen: boolean;
  108460. /**
  108461. * Specifies if the metallic texture contains the metallness information in its blue channel.
  108462. */
  108463. useMetallnessFromMetallicTextureBlue: boolean;
  108464. /**
  108465. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  108466. */
  108467. useAmbientOcclusionFromMetallicTextureRed: boolean;
  108468. /**
  108469. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  108470. */
  108471. useAmbientInGrayScale: boolean;
  108472. /**
  108473. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  108474. * The material will try to infer what glossiness each pixel should be.
  108475. */
  108476. useAutoMicroSurfaceFromReflectivityMap: boolean;
  108477. /**
  108478. * BJS is using an harcoded light falloff based on a manually sets up range.
  108479. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  108480. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  108481. */
  108482. /**
  108483. * BJS is using an harcoded light falloff based on a manually sets up range.
  108484. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  108485. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  108486. */
  108487. usePhysicalLightFalloff: boolean;
  108488. /**
  108489. * In order to support the falloff compatibility with gltf, a special mode has been added
  108490. * to reproduce the gltf light falloff.
  108491. */
  108492. /**
  108493. * In order to support the falloff compatibility with gltf, a special mode has been added
  108494. * to reproduce the gltf light falloff.
  108495. */
  108496. useGLTFLightFalloff: boolean;
  108497. /**
  108498. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  108499. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  108500. */
  108501. useRadianceOverAlpha: boolean;
  108502. /**
  108503. * Allows using an object space normal map (instead of tangent space).
  108504. */
  108505. useObjectSpaceNormalMap: boolean;
  108506. /**
  108507. * Allows using the bump map in parallax mode.
  108508. */
  108509. useParallax: boolean;
  108510. /**
  108511. * Allows using the bump map in parallax occlusion mode.
  108512. */
  108513. useParallaxOcclusion: boolean;
  108514. /**
  108515. * Controls the scale bias of the parallax mode.
  108516. */
  108517. parallaxScaleBias: number;
  108518. /**
  108519. * If sets to true, disables all the lights affecting the material.
  108520. */
  108521. disableLighting: boolean;
  108522. /**
  108523. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  108524. */
  108525. forceIrradianceInFragment: boolean;
  108526. /**
  108527. * Number of Simultaneous lights allowed on the material.
  108528. */
  108529. maxSimultaneousLights: number;
  108530. /**
  108531. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108532. */
  108533. invertNormalMapX: boolean;
  108534. /**
  108535. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108536. */
  108537. invertNormalMapY: boolean;
  108538. /**
  108539. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108540. */
  108541. twoSidedLighting: boolean;
  108542. /**
  108543. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108544. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  108545. */
  108546. useAlphaFresnel: boolean;
  108547. /**
  108548. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108549. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  108550. */
  108551. useLinearAlphaFresnel: boolean;
  108552. /**
  108553. * Let user defines the brdf lookup texture used for IBL.
  108554. * A default 8bit version is embedded but you could point at :
  108555. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  108556. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  108557. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  108558. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  108559. */
  108560. environmentBRDFTexture: Nullable<BaseTexture>;
  108561. /**
  108562. * Force normal to face away from face.
  108563. */
  108564. forceNormalForward: boolean;
  108565. /**
  108566. * Enables specular anti aliasing in the PBR shader.
  108567. * It will both interacts on the Geometry for analytical and IBL lighting.
  108568. * It also prefilter the roughness map based on the bump values.
  108569. */
  108570. enableSpecularAntiAliasing: boolean;
  108571. /**
  108572. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  108573. * makes the reflect vector face the model (under horizon).
  108574. */
  108575. useHorizonOcclusion: boolean;
  108576. /**
  108577. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  108578. * too much the area relying on ambient texture to define their ambient occlusion.
  108579. */
  108580. useRadianceOcclusion: boolean;
  108581. /**
  108582. * If set to true, no lighting calculations will be applied.
  108583. */
  108584. unlit: boolean;
  108585. /**
  108586. * Gets the image processing configuration used either in this material.
  108587. */
  108588. /**
  108589. * Sets the Default image processing configuration used either in the this material.
  108590. *
  108591. * If sets to null, the scene one is in use.
  108592. */
  108593. imageProcessingConfiguration: ImageProcessingConfiguration;
  108594. /**
  108595. * Gets wether the color curves effect is enabled.
  108596. */
  108597. /**
  108598. * Sets wether the color curves effect is enabled.
  108599. */
  108600. cameraColorCurvesEnabled: boolean;
  108601. /**
  108602. * Gets wether the color grading effect is enabled.
  108603. */
  108604. /**
  108605. * Gets wether the color grading effect is enabled.
  108606. */
  108607. cameraColorGradingEnabled: boolean;
  108608. /**
  108609. * Gets wether tonemapping is enabled or not.
  108610. */
  108611. /**
  108612. * Sets wether tonemapping is enabled or not
  108613. */
  108614. cameraToneMappingEnabled: boolean;
  108615. /**
  108616. * The camera exposure used on this material.
  108617. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108618. * This corresponds to a photographic exposure.
  108619. */
  108620. /**
  108621. * The camera exposure used on this material.
  108622. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108623. * This corresponds to a photographic exposure.
  108624. */
  108625. cameraExposure: number;
  108626. /**
  108627. * Gets The camera contrast used on this material.
  108628. */
  108629. /**
  108630. * Sets The camera contrast used on this material.
  108631. */
  108632. cameraContrast: number;
  108633. /**
  108634. * Gets the Color Grading 2D Lookup Texture.
  108635. */
  108636. /**
  108637. * Sets the Color Grading 2D Lookup Texture.
  108638. */
  108639. cameraColorGradingTexture: Nullable<BaseTexture>;
  108640. /**
  108641. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108642. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108643. * 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;
  108644. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108645. */
  108646. /**
  108647. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108648. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108649. * 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;
  108650. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108651. */
  108652. cameraColorCurves: Nullable<ColorCurves>;
  108653. /**
  108654. * Instantiates a new PBRMaterial instance.
  108655. *
  108656. * @param name The material name
  108657. * @param scene The scene the material will be use in.
  108658. */
  108659. constructor(name: string, scene: Scene);
  108660. /**
  108661. * Returns the name of this material class.
  108662. */
  108663. getClassName(): string;
  108664. /**
  108665. * Makes a duplicate of the current material.
  108666. * @param name - name to use for the new material.
  108667. */
  108668. clone(name: string): PBRMaterial;
  108669. /**
  108670. * Serializes this PBR Material.
  108671. * @returns - An object with the serialized material.
  108672. */
  108673. serialize(): any;
  108674. /**
  108675. * Parses a PBR Material from a serialized object.
  108676. * @param source - Serialized object.
  108677. * @param scene - BJS scene instance.
  108678. * @param rootUrl - url for the scene object
  108679. * @returns - PBRMaterial
  108680. */
  108681. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  108682. }
  108683. }
  108684. declare module BABYLON {
  108685. /**
  108686. * Direct draw surface info
  108687. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  108688. */
  108689. export interface DDSInfo {
  108690. /**
  108691. * Width of the texture
  108692. */
  108693. width: number;
  108694. /**
  108695. * Width of the texture
  108696. */
  108697. height: number;
  108698. /**
  108699. * Number of Mipmaps for the texture
  108700. * @see https://en.wikipedia.org/wiki/Mipmap
  108701. */
  108702. mipmapCount: number;
  108703. /**
  108704. * If the textures format is a known fourCC format
  108705. * @see https://www.fourcc.org/
  108706. */
  108707. isFourCC: boolean;
  108708. /**
  108709. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  108710. */
  108711. isRGB: boolean;
  108712. /**
  108713. * If the texture is a lumincance format
  108714. */
  108715. isLuminance: boolean;
  108716. /**
  108717. * If this is a cube texture
  108718. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  108719. */
  108720. isCube: boolean;
  108721. /**
  108722. * If the texture is a compressed format eg. FOURCC_DXT1
  108723. */
  108724. isCompressed: boolean;
  108725. /**
  108726. * The dxgiFormat of the texture
  108727. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  108728. */
  108729. dxgiFormat: number;
  108730. /**
  108731. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  108732. */
  108733. textureType: number;
  108734. /**
  108735. * Sphericle polynomial created for the dds texture
  108736. */
  108737. sphericalPolynomial?: SphericalPolynomial;
  108738. }
  108739. /**
  108740. * Class used to provide DDS decompression tools
  108741. */
  108742. export class DDSTools {
  108743. /**
  108744. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  108745. */
  108746. static StoreLODInAlphaChannel: boolean;
  108747. /**
  108748. * Gets DDS information from an array buffer
  108749. * @param arrayBuffer defines the array buffer to read data from
  108750. * @returns the DDS information
  108751. */
  108752. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  108753. private static _FloatView;
  108754. private static _Int32View;
  108755. private static _ToHalfFloat;
  108756. private static _FromHalfFloat;
  108757. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  108758. private static _GetHalfFloatRGBAArrayBuffer;
  108759. private static _GetFloatRGBAArrayBuffer;
  108760. private static _GetFloatAsUIntRGBAArrayBuffer;
  108761. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  108762. private static _GetRGBAArrayBuffer;
  108763. private static _ExtractLongWordOrder;
  108764. private static _GetRGBArrayBuffer;
  108765. private static _GetLuminanceArrayBuffer;
  108766. /**
  108767. * Uploads DDS Levels to a Babylon Texture
  108768. * @hidden
  108769. */
  108770. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  108771. }
  108772. interface Engine {
  108773. /**
  108774. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  108775. * @param rootUrl defines the url where the file to load is located
  108776. * @param scene defines the current scene
  108777. * @param lodScale defines scale to apply to the mip map selection
  108778. * @param lodOffset defines offset to apply to the mip map selection
  108779. * @param onLoad defines an optional callback raised when the texture is loaded
  108780. * @param onError defines an optional callback raised if there is an issue to load the texture
  108781. * @param format defines the format of the data
  108782. * @param forcedExtension defines the extension to use to pick the right loader
  108783. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  108784. * @returns the cube texture as an InternalTexture
  108785. */
  108786. 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;
  108787. }
  108788. }
  108789. declare module BABYLON {
  108790. /**
  108791. * Implementation of the DDS Texture Loader.
  108792. * @hidden
  108793. */
  108794. export class _DDSTextureLoader implements IInternalTextureLoader {
  108795. /**
  108796. * Defines wether the loader supports cascade loading the different faces.
  108797. */
  108798. readonly supportCascades: boolean;
  108799. /**
  108800. * This returns if the loader support the current file information.
  108801. * @param extension defines the file extension of the file being loaded
  108802. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108803. * @param fallback defines the fallback internal texture if any
  108804. * @param isBase64 defines whether the texture is encoded as a base64
  108805. * @param isBuffer defines whether the texture data are stored as a buffer
  108806. * @returns true if the loader can load the specified file
  108807. */
  108808. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  108809. /**
  108810. * Transform the url before loading if required.
  108811. * @param rootUrl the url of the texture
  108812. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108813. * @returns the transformed texture
  108814. */
  108815. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  108816. /**
  108817. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  108818. * @param rootUrl the url of the texture
  108819. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108820. * @returns the fallback texture
  108821. */
  108822. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  108823. /**
  108824. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  108825. * @param data contains the texture data
  108826. * @param texture defines the BabylonJS internal texture
  108827. * @param createPolynomials will be true if polynomials have been requested
  108828. * @param onLoad defines the callback to trigger once the texture is ready
  108829. * @param onError defines the callback to trigger in case of error
  108830. */
  108831. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  108832. /**
  108833. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  108834. * @param data contains the texture data
  108835. * @param texture defines the BabylonJS internal texture
  108836. * @param callback defines the method to call once ready to upload
  108837. */
  108838. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  108839. }
  108840. }
  108841. declare module BABYLON {
  108842. /** @hidden */
  108843. export var rgbdEncodePixelShader: {
  108844. name: string;
  108845. shader: string;
  108846. };
  108847. }
  108848. declare module BABYLON {
  108849. /**
  108850. * Raw texture data and descriptor sufficient for WebGL texture upload
  108851. */
  108852. export interface EnvironmentTextureInfo {
  108853. /**
  108854. * Version of the environment map
  108855. */
  108856. version: number;
  108857. /**
  108858. * Width of image
  108859. */
  108860. width: number;
  108861. /**
  108862. * Irradiance information stored in the file.
  108863. */
  108864. irradiance: any;
  108865. /**
  108866. * Specular information stored in the file.
  108867. */
  108868. specular: any;
  108869. }
  108870. /**
  108871. * Sets of helpers addressing the serialization and deserialization of environment texture
  108872. * stored in a BabylonJS env file.
  108873. * Those files are usually stored as .env files.
  108874. */
  108875. export class EnvironmentTextureTools {
  108876. /**
  108877. * Magic number identifying the env file.
  108878. */
  108879. private static _MagicBytes;
  108880. /**
  108881. * Gets the environment info from an env file.
  108882. * @param data The array buffer containing the .env bytes.
  108883. * @returns the environment file info (the json header) if successfully parsed.
  108884. */
  108885. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  108886. /**
  108887. * Creates an environment texture from a loaded cube texture.
  108888. * @param texture defines the cube texture to convert in env file
  108889. * @return a promise containing the environment data if succesfull.
  108890. */
  108891. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  108892. /**
  108893. * Creates a JSON representation of the spherical data.
  108894. * @param texture defines the texture containing the polynomials
  108895. * @return the JSON representation of the spherical info
  108896. */
  108897. private static _CreateEnvTextureIrradiance;
  108898. /**
  108899. * Uploads the texture info contained in the env file to the GPU.
  108900. * @param texture defines the internal texture to upload to
  108901. * @param arrayBuffer defines the buffer cotaining the data to load
  108902. * @param info defines the texture info retrieved through the GetEnvInfo method
  108903. * @returns a promise
  108904. */
  108905. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  108906. /**
  108907. * Uploads the levels of image data to the GPU.
  108908. * @param texture defines the internal texture to upload to
  108909. * @param imageData defines the array buffer views of image data [mipmap][face]
  108910. * @returns a promise
  108911. */
  108912. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  108913. /**
  108914. * Uploads spherical polynomials information to the texture.
  108915. * @param texture defines the texture we are trying to upload the information to
  108916. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  108917. */
  108918. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  108919. /** @hidden */
  108920. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  108921. }
  108922. }
  108923. declare module BABYLON {
  108924. /**
  108925. * Implementation of the ENV Texture Loader.
  108926. * @hidden
  108927. */
  108928. export class _ENVTextureLoader implements IInternalTextureLoader {
  108929. /**
  108930. * Defines wether the loader supports cascade loading the different faces.
  108931. */
  108932. readonly supportCascades: boolean;
  108933. /**
  108934. * This returns if the loader support the current file information.
  108935. * @param extension defines the file extension of the file being loaded
  108936. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108937. * @param fallback defines the fallback internal texture if any
  108938. * @param isBase64 defines whether the texture is encoded as a base64
  108939. * @param isBuffer defines whether the texture data are stored as a buffer
  108940. * @returns true if the loader can load the specified file
  108941. */
  108942. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  108943. /**
  108944. * Transform the url before loading if required.
  108945. * @param rootUrl the url of the texture
  108946. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108947. * @returns the transformed texture
  108948. */
  108949. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  108950. /**
  108951. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  108952. * @param rootUrl the url of the texture
  108953. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108954. * @returns the fallback texture
  108955. */
  108956. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  108957. /**
  108958. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  108959. * @param data contains the texture data
  108960. * @param texture defines the BabylonJS internal texture
  108961. * @param createPolynomials will be true if polynomials have been requested
  108962. * @param onLoad defines the callback to trigger once the texture is ready
  108963. * @param onError defines the callback to trigger in case of error
  108964. */
  108965. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  108966. /**
  108967. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  108968. * @param data contains the texture data
  108969. * @param texture defines the BabylonJS internal texture
  108970. * @param callback defines the method to call once ready to upload
  108971. */
  108972. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  108973. }
  108974. }
  108975. declare module BABYLON {
  108976. /**
  108977. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  108978. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  108979. */
  108980. export class KhronosTextureContainer {
  108981. /** contents of the KTX container file */
  108982. arrayBuffer: any;
  108983. private static HEADER_LEN;
  108984. private static COMPRESSED_2D;
  108985. private static COMPRESSED_3D;
  108986. private static TEX_2D;
  108987. private static TEX_3D;
  108988. /**
  108989. * Gets the openGL type
  108990. */
  108991. glType: number;
  108992. /**
  108993. * Gets the openGL type size
  108994. */
  108995. glTypeSize: number;
  108996. /**
  108997. * Gets the openGL format
  108998. */
  108999. glFormat: number;
  109000. /**
  109001. * Gets the openGL internal format
  109002. */
  109003. glInternalFormat: number;
  109004. /**
  109005. * Gets the base internal format
  109006. */
  109007. glBaseInternalFormat: number;
  109008. /**
  109009. * Gets image width in pixel
  109010. */
  109011. pixelWidth: number;
  109012. /**
  109013. * Gets image height in pixel
  109014. */
  109015. pixelHeight: number;
  109016. /**
  109017. * Gets image depth in pixels
  109018. */
  109019. pixelDepth: number;
  109020. /**
  109021. * Gets the number of array elements
  109022. */
  109023. numberOfArrayElements: number;
  109024. /**
  109025. * Gets the number of faces
  109026. */
  109027. numberOfFaces: number;
  109028. /**
  109029. * Gets the number of mipmap levels
  109030. */
  109031. numberOfMipmapLevels: number;
  109032. /**
  109033. * Gets the bytes of key value data
  109034. */
  109035. bytesOfKeyValueData: number;
  109036. /**
  109037. * Gets the load type
  109038. */
  109039. loadType: number;
  109040. /**
  109041. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  109042. */
  109043. isInvalid: boolean;
  109044. /**
  109045. * Creates a new KhronosTextureContainer
  109046. * @param arrayBuffer contents of the KTX container file
  109047. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  109048. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  109049. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  109050. */
  109051. constructor(
  109052. /** contents of the KTX container file */
  109053. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  109054. /**
  109055. * Uploads KTX content to a Babylon Texture.
  109056. * It is assumed that the texture has already been created & is currently bound
  109057. * @hidden
  109058. */
  109059. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  109060. private _upload2DCompressedLevels;
  109061. }
  109062. }
  109063. declare module BABYLON {
  109064. /**
  109065. * Implementation of the KTX Texture Loader.
  109066. * @hidden
  109067. */
  109068. export class _KTXTextureLoader implements IInternalTextureLoader {
  109069. /**
  109070. * Defines wether the loader supports cascade loading the different faces.
  109071. */
  109072. readonly supportCascades: boolean;
  109073. /**
  109074. * This returns if the loader support the current file information.
  109075. * @param extension defines the file extension of the file being loaded
  109076. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109077. * @param fallback defines the fallback internal texture if any
  109078. * @param isBase64 defines whether the texture is encoded as a base64
  109079. * @param isBuffer defines whether the texture data are stored as a buffer
  109080. * @returns true if the loader can load the specified file
  109081. */
  109082. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109083. /**
  109084. * Transform the url before loading if required.
  109085. * @param rootUrl the url of the texture
  109086. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109087. * @returns the transformed texture
  109088. */
  109089. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109090. /**
  109091. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109092. * @param rootUrl the url of the texture
  109093. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109094. * @returns the fallback texture
  109095. */
  109096. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109097. /**
  109098. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109099. * @param data contains the texture data
  109100. * @param texture defines the BabylonJS internal texture
  109101. * @param createPolynomials will be true if polynomials have been requested
  109102. * @param onLoad defines the callback to trigger once the texture is ready
  109103. * @param onError defines the callback to trigger in case of error
  109104. */
  109105. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109106. /**
  109107. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109108. * @param data contains the texture data
  109109. * @param texture defines the BabylonJS internal texture
  109110. * @param callback defines the method to call once ready to upload
  109111. */
  109112. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  109113. }
  109114. }
  109115. declare module BABYLON {
  109116. /** @hidden */
  109117. export var _forceSceneHelpersToBundle: boolean;
  109118. interface Scene {
  109119. /**
  109120. * Creates a default light for the scene.
  109121. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  109122. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  109123. */
  109124. createDefaultLight(replace?: boolean): void;
  109125. /**
  109126. * Creates a default camera for the scene.
  109127. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  109128. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  109129. * @param replace has default false, when true replaces the active camera in the scene
  109130. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  109131. */
  109132. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  109133. /**
  109134. * Creates a default camera and a default light.
  109135. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  109136. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  109137. * @param replace has the default false, when true replaces the active camera/light in the scene
  109138. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  109139. */
  109140. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  109141. /**
  109142. * Creates a new sky box
  109143. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  109144. * @param environmentTexture defines the texture to use as environment texture
  109145. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  109146. * @param scale defines the overall scale of the skybox
  109147. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  109148. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  109149. * @returns a new mesh holding the sky box
  109150. */
  109151. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  109152. /**
  109153. * Creates a new environment
  109154. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  109155. * @param options defines the options you can use to configure the environment
  109156. * @returns the new EnvironmentHelper
  109157. */
  109158. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  109159. /**
  109160. * Creates a new VREXperienceHelper
  109161. * @see http://doc.babylonjs.com/how_to/webvr_helper
  109162. * @param webVROptions defines the options used to create the new VREXperienceHelper
  109163. * @returns a new VREXperienceHelper
  109164. */
  109165. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  109166. /**
  109167. * Creates a new XREXperienceHelper
  109168. * @see http://doc.babylonjs.com/how_to/webxr
  109169. * @returns a promise for a new XREXperienceHelper
  109170. */
  109171. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  109172. }
  109173. }
  109174. declare module BABYLON {
  109175. /**
  109176. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  109177. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  109178. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  109179. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  109180. */
  109181. export class VideoDome extends TransformNode {
  109182. /**
  109183. * Define the video source as a Monoscopic panoramic 360 video.
  109184. */
  109185. static readonly MODE_MONOSCOPIC: number;
  109186. /**
  109187. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  109188. */
  109189. static readonly MODE_TOPBOTTOM: number;
  109190. /**
  109191. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  109192. */
  109193. static readonly MODE_SIDEBYSIDE: number;
  109194. private _useDirectMapping;
  109195. /**
  109196. * The video texture being displayed on the sphere
  109197. */
  109198. protected _videoTexture: VideoTexture;
  109199. /**
  109200. * Gets the video texture being displayed on the sphere
  109201. */
  109202. readonly videoTexture: VideoTexture;
  109203. /**
  109204. * The skybox material
  109205. */
  109206. protected _material: BackgroundMaterial;
  109207. /**
  109208. * The surface used for the skybox
  109209. */
  109210. protected _mesh: Mesh;
  109211. /**
  109212. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  109213. * Also see the options.resolution property.
  109214. */
  109215. fovMultiplier: number;
  109216. private _videoMode;
  109217. /**
  109218. * Gets or set the current video mode for the video. It can be:
  109219. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  109220. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  109221. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  109222. */
  109223. videoMode: number;
  109224. /**
  109225. * Oberserver used in Stereoscopic VR Mode.
  109226. */
  109227. private _onBeforeCameraRenderObserver;
  109228. /**
  109229. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  109230. * @param name Element's name, child elements will append suffixes for their own names.
  109231. * @param urlsOrVideo defines the url(s) or the video element to use
  109232. * @param options An object containing optional or exposed sub element properties
  109233. */
  109234. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  109235. resolution?: number;
  109236. clickToPlay?: boolean;
  109237. autoPlay?: boolean;
  109238. loop?: boolean;
  109239. size?: number;
  109240. poster?: string;
  109241. faceForward?: boolean;
  109242. useDirectMapping?: boolean;
  109243. }, scene: Scene);
  109244. private _changeVideoMode;
  109245. /**
  109246. * Releases resources associated with this node.
  109247. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109248. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109249. */
  109250. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109251. }
  109252. }
  109253. declare module BABYLON {
  109254. /**
  109255. * This class can be used to get instrumentation data from a Babylon engine
  109256. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  109257. */
  109258. export class EngineInstrumentation implements IDisposable {
  109259. /**
  109260. * Define the instrumented engine.
  109261. */
  109262. engine: Engine;
  109263. private _captureGPUFrameTime;
  109264. private _gpuFrameTimeToken;
  109265. private _gpuFrameTime;
  109266. private _captureShaderCompilationTime;
  109267. private _shaderCompilationTime;
  109268. private _onBeginFrameObserver;
  109269. private _onEndFrameObserver;
  109270. private _onBeforeShaderCompilationObserver;
  109271. private _onAfterShaderCompilationObserver;
  109272. /**
  109273. * Gets the perf counter used for GPU frame time
  109274. */
  109275. readonly gpuFrameTimeCounter: PerfCounter;
  109276. /**
  109277. * Gets the GPU frame time capture status
  109278. */
  109279. /**
  109280. * Enable or disable the GPU frame time capture
  109281. */
  109282. captureGPUFrameTime: boolean;
  109283. /**
  109284. * Gets the perf counter used for shader compilation time
  109285. */
  109286. readonly shaderCompilationTimeCounter: PerfCounter;
  109287. /**
  109288. * Gets the shader compilation time capture status
  109289. */
  109290. /**
  109291. * Enable or disable the shader compilation time capture
  109292. */
  109293. captureShaderCompilationTime: boolean;
  109294. /**
  109295. * Instantiates a new engine instrumentation.
  109296. * This class can be used to get instrumentation data from a Babylon engine
  109297. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  109298. * @param engine Defines the engine to instrument
  109299. */
  109300. constructor(
  109301. /**
  109302. * Define the instrumented engine.
  109303. */
  109304. engine: Engine);
  109305. /**
  109306. * Dispose and release associated resources.
  109307. */
  109308. dispose(): void;
  109309. }
  109310. }
  109311. declare module BABYLON {
  109312. /**
  109313. * This class can be used to get instrumentation data from a Babylon engine
  109314. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  109315. */
  109316. export class SceneInstrumentation implements IDisposable {
  109317. /**
  109318. * Defines the scene to instrument
  109319. */
  109320. scene: Scene;
  109321. private _captureActiveMeshesEvaluationTime;
  109322. private _activeMeshesEvaluationTime;
  109323. private _captureRenderTargetsRenderTime;
  109324. private _renderTargetsRenderTime;
  109325. private _captureFrameTime;
  109326. private _frameTime;
  109327. private _captureRenderTime;
  109328. private _renderTime;
  109329. private _captureInterFrameTime;
  109330. private _interFrameTime;
  109331. private _captureParticlesRenderTime;
  109332. private _particlesRenderTime;
  109333. private _captureSpritesRenderTime;
  109334. private _spritesRenderTime;
  109335. private _capturePhysicsTime;
  109336. private _physicsTime;
  109337. private _captureAnimationsTime;
  109338. private _animationsTime;
  109339. private _captureCameraRenderTime;
  109340. private _cameraRenderTime;
  109341. private _onBeforeActiveMeshesEvaluationObserver;
  109342. private _onAfterActiveMeshesEvaluationObserver;
  109343. private _onBeforeRenderTargetsRenderObserver;
  109344. private _onAfterRenderTargetsRenderObserver;
  109345. private _onAfterRenderObserver;
  109346. private _onBeforeDrawPhaseObserver;
  109347. private _onAfterDrawPhaseObserver;
  109348. private _onBeforeAnimationsObserver;
  109349. private _onBeforeParticlesRenderingObserver;
  109350. private _onAfterParticlesRenderingObserver;
  109351. private _onBeforeSpritesRenderingObserver;
  109352. private _onAfterSpritesRenderingObserver;
  109353. private _onBeforePhysicsObserver;
  109354. private _onAfterPhysicsObserver;
  109355. private _onAfterAnimationsObserver;
  109356. private _onBeforeCameraRenderObserver;
  109357. private _onAfterCameraRenderObserver;
  109358. /**
  109359. * Gets the perf counter used for active meshes evaluation time
  109360. */
  109361. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  109362. /**
  109363. * Gets the active meshes evaluation time capture status
  109364. */
  109365. /**
  109366. * Enable or disable the active meshes evaluation time capture
  109367. */
  109368. captureActiveMeshesEvaluationTime: boolean;
  109369. /**
  109370. * Gets the perf counter used for render targets render time
  109371. */
  109372. readonly renderTargetsRenderTimeCounter: PerfCounter;
  109373. /**
  109374. * Gets the render targets render time capture status
  109375. */
  109376. /**
  109377. * Enable or disable the render targets render time capture
  109378. */
  109379. captureRenderTargetsRenderTime: boolean;
  109380. /**
  109381. * Gets the perf counter used for particles render time
  109382. */
  109383. readonly particlesRenderTimeCounter: PerfCounter;
  109384. /**
  109385. * Gets the particles render time capture status
  109386. */
  109387. /**
  109388. * Enable or disable the particles render time capture
  109389. */
  109390. captureParticlesRenderTime: boolean;
  109391. /**
  109392. * Gets the perf counter used for sprites render time
  109393. */
  109394. readonly spritesRenderTimeCounter: PerfCounter;
  109395. /**
  109396. * Gets the sprites render time capture status
  109397. */
  109398. /**
  109399. * Enable or disable the sprites render time capture
  109400. */
  109401. captureSpritesRenderTime: boolean;
  109402. /**
  109403. * Gets the perf counter used for physics time
  109404. */
  109405. readonly physicsTimeCounter: PerfCounter;
  109406. /**
  109407. * Gets the physics time capture status
  109408. */
  109409. /**
  109410. * Enable or disable the physics time capture
  109411. */
  109412. capturePhysicsTime: boolean;
  109413. /**
  109414. * Gets the perf counter used for animations time
  109415. */
  109416. readonly animationsTimeCounter: PerfCounter;
  109417. /**
  109418. * Gets the animations time capture status
  109419. */
  109420. /**
  109421. * Enable or disable the animations time capture
  109422. */
  109423. captureAnimationsTime: boolean;
  109424. /**
  109425. * Gets the perf counter used for frame time capture
  109426. */
  109427. readonly frameTimeCounter: PerfCounter;
  109428. /**
  109429. * Gets the frame time capture status
  109430. */
  109431. /**
  109432. * Enable or disable the frame time capture
  109433. */
  109434. captureFrameTime: boolean;
  109435. /**
  109436. * Gets the perf counter used for inter-frames time capture
  109437. */
  109438. readonly interFrameTimeCounter: PerfCounter;
  109439. /**
  109440. * Gets the inter-frames time capture status
  109441. */
  109442. /**
  109443. * Enable or disable the inter-frames time capture
  109444. */
  109445. captureInterFrameTime: boolean;
  109446. /**
  109447. * Gets the perf counter used for render time capture
  109448. */
  109449. readonly renderTimeCounter: PerfCounter;
  109450. /**
  109451. * Gets the render time capture status
  109452. */
  109453. /**
  109454. * Enable or disable the render time capture
  109455. */
  109456. captureRenderTime: boolean;
  109457. /**
  109458. * Gets the perf counter used for camera render time capture
  109459. */
  109460. readonly cameraRenderTimeCounter: PerfCounter;
  109461. /**
  109462. * Gets the camera render time capture status
  109463. */
  109464. /**
  109465. * Enable or disable the camera render time capture
  109466. */
  109467. captureCameraRenderTime: boolean;
  109468. /**
  109469. * Gets the perf counter used for draw calls
  109470. */
  109471. readonly drawCallsCounter: PerfCounter;
  109472. /**
  109473. * Instantiates a new scene instrumentation.
  109474. * This class can be used to get instrumentation data from a Babylon engine
  109475. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  109476. * @param scene Defines the scene to instrument
  109477. */
  109478. constructor(
  109479. /**
  109480. * Defines the scene to instrument
  109481. */
  109482. scene: Scene);
  109483. /**
  109484. * Dispose and release associated resources.
  109485. */
  109486. dispose(): void;
  109487. }
  109488. }
  109489. declare module BABYLON {
  109490. /** @hidden */
  109491. export var glowMapGenerationPixelShader: {
  109492. name: string;
  109493. shader: string;
  109494. };
  109495. }
  109496. declare module BABYLON {
  109497. /** @hidden */
  109498. export var glowMapGenerationVertexShader: {
  109499. name: string;
  109500. shader: string;
  109501. };
  109502. }
  109503. declare module BABYLON {
  109504. /**
  109505. * Effect layer options. This helps customizing the behaviour
  109506. * of the effect layer.
  109507. */
  109508. export interface IEffectLayerOptions {
  109509. /**
  109510. * Multiplication factor apply to the canvas size to compute the render target size
  109511. * used to generated the objects (the smaller the faster).
  109512. */
  109513. mainTextureRatio: number;
  109514. /**
  109515. * Enforces a fixed size texture to ensure effect stability across devices.
  109516. */
  109517. mainTextureFixedSize?: number;
  109518. /**
  109519. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  109520. */
  109521. alphaBlendingMode: number;
  109522. /**
  109523. * The camera attached to the layer.
  109524. */
  109525. camera: Nullable<Camera>;
  109526. /**
  109527. * The rendering group to draw the layer in.
  109528. */
  109529. renderingGroupId: number;
  109530. }
  109531. /**
  109532. * The effect layer Helps adding post process effect blended with the main pass.
  109533. *
  109534. * This can be for instance use to generate glow or higlight effects on the scene.
  109535. *
  109536. * The effect layer class can not be used directly and is intented to inherited from to be
  109537. * customized per effects.
  109538. */
  109539. export abstract class EffectLayer {
  109540. private _vertexBuffers;
  109541. private _indexBuffer;
  109542. private _cachedDefines;
  109543. private _effectLayerMapGenerationEffect;
  109544. private _effectLayerOptions;
  109545. private _mergeEffect;
  109546. protected _scene: Scene;
  109547. protected _engine: Engine;
  109548. protected _maxSize: number;
  109549. protected _mainTextureDesiredSize: ISize;
  109550. protected _mainTexture: RenderTargetTexture;
  109551. protected _shouldRender: boolean;
  109552. protected _postProcesses: PostProcess[];
  109553. protected _textures: BaseTexture[];
  109554. protected _emissiveTextureAndColor: {
  109555. texture: Nullable<BaseTexture>;
  109556. color: Color4;
  109557. };
  109558. /**
  109559. * The name of the layer
  109560. */
  109561. name: string;
  109562. /**
  109563. * The clear color of the texture used to generate the glow map.
  109564. */
  109565. neutralColor: Color4;
  109566. /**
  109567. * Specifies wether the highlight layer is enabled or not.
  109568. */
  109569. isEnabled: boolean;
  109570. /**
  109571. * Gets the camera attached to the layer.
  109572. */
  109573. readonly camera: Nullable<Camera>;
  109574. /**
  109575. * Gets the rendering group id the layer should render in.
  109576. */
  109577. readonly renderingGroupId: number;
  109578. /**
  109579. * An event triggered when the effect layer has been disposed.
  109580. */
  109581. onDisposeObservable: Observable<EffectLayer>;
  109582. /**
  109583. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  109584. */
  109585. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  109586. /**
  109587. * An event triggered when the generated texture is being merged in the scene.
  109588. */
  109589. onBeforeComposeObservable: Observable<EffectLayer>;
  109590. /**
  109591. * An event triggered when the generated texture has been merged in the scene.
  109592. */
  109593. onAfterComposeObservable: Observable<EffectLayer>;
  109594. /**
  109595. * An event triggered when the efffect layer changes its size.
  109596. */
  109597. onSizeChangedObservable: Observable<EffectLayer>;
  109598. /** @hidden */
  109599. static _SceneComponentInitialization: (scene: Scene) => void;
  109600. /**
  109601. * Instantiates a new effect Layer and references it in the scene.
  109602. * @param name The name of the layer
  109603. * @param scene The scene to use the layer in
  109604. */
  109605. constructor(
  109606. /** The Friendly of the effect in the scene */
  109607. name: string, scene: Scene);
  109608. /**
  109609. * Get the effect name of the layer.
  109610. * @return The effect name
  109611. */
  109612. abstract getEffectName(): string;
  109613. /**
  109614. * Checks for the readiness of the element composing the layer.
  109615. * @param subMesh the mesh to check for
  109616. * @param useInstances specify wether or not to use instances to render the mesh
  109617. * @return true if ready otherwise, false
  109618. */
  109619. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  109620. /**
  109621. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  109622. * @returns true if the effect requires stencil during the main canvas render pass.
  109623. */
  109624. abstract needStencil(): boolean;
  109625. /**
  109626. * Create the merge effect. This is the shader use to blit the information back
  109627. * to the main canvas at the end of the scene rendering.
  109628. * @returns The effect containing the shader used to merge the effect on the main canvas
  109629. */
  109630. protected abstract _createMergeEffect(): Effect;
  109631. /**
  109632. * Creates the render target textures and post processes used in the effect layer.
  109633. */
  109634. protected abstract _createTextureAndPostProcesses(): void;
  109635. /**
  109636. * Implementation specific of rendering the generating effect on the main canvas.
  109637. * @param effect The effect used to render through
  109638. */
  109639. protected abstract _internalRender(effect: Effect): void;
  109640. /**
  109641. * Sets the required values for both the emissive texture and and the main color.
  109642. */
  109643. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  109644. /**
  109645. * Free any resources and references associated to a mesh.
  109646. * Internal use
  109647. * @param mesh The mesh to free.
  109648. */
  109649. abstract _disposeMesh(mesh: Mesh): void;
  109650. /**
  109651. * Serializes this layer (Glow or Highlight for example)
  109652. * @returns a serialized layer object
  109653. */
  109654. abstract serialize?(): any;
  109655. /**
  109656. * Initializes the effect layer with the required options.
  109657. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  109658. */
  109659. protected _init(options: Partial<IEffectLayerOptions>): void;
  109660. /**
  109661. * Generates the index buffer of the full screen quad blending to the main canvas.
  109662. */
  109663. private _generateIndexBuffer;
  109664. /**
  109665. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  109666. */
  109667. private _generateVertexBuffer;
  109668. /**
  109669. * Sets the main texture desired size which is the closest power of two
  109670. * of the engine canvas size.
  109671. */
  109672. private _setMainTextureSize;
  109673. /**
  109674. * Creates the main texture for the effect layer.
  109675. */
  109676. protected _createMainTexture(): void;
  109677. /**
  109678. * Adds specific effects defines.
  109679. * @param defines The defines to add specifics to.
  109680. */
  109681. protected _addCustomEffectDefines(defines: string[]): void;
  109682. /**
  109683. * Checks for the readiness of the element composing the layer.
  109684. * @param subMesh the mesh to check for
  109685. * @param useInstances specify wether or not to use instances to render the mesh
  109686. * @param emissiveTexture the associated emissive texture used to generate the glow
  109687. * @return true if ready otherwise, false
  109688. */
  109689. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  109690. /**
  109691. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  109692. */
  109693. render(): void;
  109694. /**
  109695. * Determine if a given mesh will be used in the current effect.
  109696. * @param mesh mesh to test
  109697. * @returns true if the mesh will be used
  109698. */
  109699. hasMesh(mesh: AbstractMesh): boolean;
  109700. /**
  109701. * Returns true if the layer contains information to display, otherwise false.
  109702. * @returns true if the glow layer should be rendered
  109703. */
  109704. shouldRender(): boolean;
  109705. /**
  109706. * Returns true if the mesh should render, otherwise false.
  109707. * @param mesh The mesh to render
  109708. * @returns true if it should render otherwise false
  109709. */
  109710. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  109711. /**
  109712. * Returns true if the mesh can be rendered, otherwise false.
  109713. * @param mesh The mesh to render
  109714. * @param material The material used on the mesh
  109715. * @returns true if it can be rendered otherwise false
  109716. */
  109717. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  109718. /**
  109719. * Returns true if the mesh should render, otherwise false.
  109720. * @param mesh The mesh to render
  109721. * @returns true if it should render otherwise false
  109722. */
  109723. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  109724. /**
  109725. * Renders the submesh passed in parameter to the generation map.
  109726. */
  109727. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  109728. /**
  109729. * Rebuild the required buffers.
  109730. * @hidden Internal use only.
  109731. */
  109732. _rebuild(): void;
  109733. /**
  109734. * Dispose only the render target textures and post process.
  109735. */
  109736. private _disposeTextureAndPostProcesses;
  109737. /**
  109738. * Dispose the highlight layer and free resources.
  109739. */
  109740. dispose(): void;
  109741. /**
  109742. * Gets the class name of the effect layer
  109743. * @returns the string with the class name of the effect layer
  109744. */
  109745. getClassName(): string;
  109746. /**
  109747. * Creates an effect layer from parsed effect layer data
  109748. * @param parsedEffectLayer defines effect layer data
  109749. * @param scene defines the current scene
  109750. * @param rootUrl defines the root URL containing the effect layer information
  109751. * @returns a parsed effect Layer
  109752. */
  109753. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  109754. }
  109755. }
  109756. declare module BABYLON {
  109757. interface AbstractScene {
  109758. /**
  109759. * The list of effect layers (highlights/glow) added to the scene
  109760. * @see http://doc.babylonjs.com/how_to/highlight_layer
  109761. * @see http://doc.babylonjs.com/how_to/glow_layer
  109762. */
  109763. effectLayers: Array<EffectLayer>;
  109764. /**
  109765. * Removes the given effect layer from this scene.
  109766. * @param toRemove defines the effect layer to remove
  109767. * @returns the index of the removed effect layer
  109768. */
  109769. removeEffectLayer(toRemove: EffectLayer): number;
  109770. /**
  109771. * Adds the given effect layer to this scene
  109772. * @param newEffectLayer defines the effect layer to add
  109773. */
  109774. addEffectLayer(newEffectLayer: EffectLayer): void;
  109775. }
  109776. /**
  109777. * Defines the layer scene component responsible to manage any effect layers
  109778. * in a given scene.
  109779. */
  109780. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  109781. /**
  109782. * The component name helpfull to identify the component in the list of scene components.
  109783. */
  109784. readonly name: string;
  109785. /**
  109786. * The scene the component belongs to.
  109787. */
  109788. scene: Scene;
  109789. private _engine;
  109790. private _renderEffects;
  109791. private _needStencil;
  109792. private _previousStencilState;
  109793. /**
  109794. * Creates a new instance of the component for the given scene
  109795. * @param scene Defines the scene to register the component in
  109796. */
  109797. constructor(scene: Scene);
  109798. /**
  109799. * Registers the component in a given scene
  109800. */
  109801. register(): void;
  109802. /**
  109803. * Rebuilds the elements related to this component in case of
  109804. * context lost for instance.
  109805. */
  109806. rebuild(): void;
  109807. /**
  109808. * Serializes the component data to the specified json object
  109809. * @param serializationObject The object to serialize to
  109810. */
  109811. serialize(serializationObject: any): void;
  109812. /**
  109813. * Adds all the elements from the container to the scene
  109814. * @param container the container holding the elements
  109815. */
  109816. addFromContainer(container: AbstractScene): void;
  109817. /**
  109818. * Removes all the elements in the container from the scene
  109819. * @param container contains the elements to remove
  109820. * @param dispose if the removed element should be disposed (default: false)
  109821. */
  109822. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  109823. /**
  109824. * Disposes the component and the associated ressources.
  109825. */
  109826. dispose(): void;
  109827. private _isReadyForMesh;
  109828. private _renderMainTexture;
  109829. private _setStencil;
  109830. private _setStencilBack;
  109831. private _draw;
  109832. private _drawCamera;
  109833. private _drawRenderingGroup;
  109834. }
  109835. }
  109836. declare module BABYLON {
  109837. /** @hidden */
  109838. export var glowMapMergePixelShader: {
  109839. name: string;
  109840. shader: string;
  109841. };
  109842. }
  109843. declare module BABYLON {
  109844. /** @hidden */
  109845. export var glowMapMergeVertexShader: {
  109846. name: string;
  109847. shader: string;
  109848. };
  109849. }
  109850. declare module BABYLON {
  109851. interface AbstractScene {
  109852. /**
  109853. * Return a the first highlight layer of the scene with a given name.
  109854. * @param name The name of the highlight layer to look for.
  109855. * @return The highlight layer if found otherwise null.
  109856. */
  109857. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  109858. }
  109859. /**
  109860. * Glow layer options. This helps customizing the behaviour
  109861. * of the glow layer.
  109862. */
  109863. export interface IGlowLayerOptions {
  109864. /**
  109865. * Multiplication factor apply to the canvas size to compute the render target size
  109866. * used to generated the glowing objects (the smaller the faster).
  109867. */
  109868. mainTextureRatio: number;
  109869. /**
  109870. * Enforces a fixed size texture to ensure resize independant blur.
  109871. */
  109872. mainTextureFixedSize?: number;
  109873. /**
  109874. * How big is the kernel of the blur texture.
  109875. */
  109876. blurKernelSize: number;
  109877. /**
  109878. * The camera attached to the layer.
  109879. */
  109880. camera: Nullable<Camera>;
  109881. /**
  109882. * Enable MSAA by chosing the number of samples.
  109883. */
  109884. mainTextureSamples?: number;
  109885. /**
  109886. * The rendering group to draw the layer in.
  109887. */
  109888. renderingGroupId: number;
  109889. }
  109890. /**
  109891. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  109892. *
  109893. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  109894. * glowy meshes to your scene.
  109895. *
  109896. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  109897. */
  109898. export class GlowLayer extends EffectLayer {
  109899. /**
  109900. * Effect Name of the layer.
  109901. */
  109902. static readonly EffectName: string;
  109903. /**
  109904. * The default blur kernel size used for the glow.
  109905. */
  109906. static DefaultBlurKernelSize: number;
  109907. /**
  109908. * The default texture size ratio used for the glow.
  109909. */
  109910. static DefaultTextureRatio: number;
  109911. /**
  109912. * Sets the kernel size of the blur.
  109913. */
  109914. /**
  109915. * Gets the kernel size of the blur.
  109916. */
  109917. blurKernelSize: number;
  109918. /**
  109919. * Sets the glow intensity.
  109920. */
  109921. /**
  109922. * Gets the glow intensity.
  109923. */
  109924. intensity: number;
  109925. private _options;
  109926. private _intensity;
  109927. private _horizontalBlurPostprocess1;
  109928. private _verticalBlurPostprocess1;
  109929. private _horizontalBlurPostprocess2;
  109930. private _verticalBlurPostprocess2;
  109931. private _blurTexture1;
  109932. private _blurTexture2;
  109933. private _postProcesses1;
  109934. private _postProcesses2;
  109935. private _includedOnlyMeshes;
  109936. private _excludedMeshes;
  109937. /**
  109938. * Callback used to let the user override the color selection on a per mesh basis
  109939. */
  109940. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  109941. /**
  109942. * Callback used to let the user override the texture selection on a per mesh basis
  109943. */
  109944. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  109945. /**
  109946. * Instantiates a new glow Layer and references it to the scene.
  109947. * @param name The name of the layer
  109948. * @param scene The scene to use the layer in
  109949. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  109950. */
  109951. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  109952. /**
  109953. * Get the effect name of the layer.
  109954. * @return The effect name
  109955. */
  109956. getEffectName(): string;
  109957. /**
  109958. * Create the merge effect. This is the shader use to blit the information back
  109959. * to the main canvas at the end of the scene rendering.
  109960. */
  109961. protected _createMergeEffect(): Effect;
  109962. /**
  109963. * Creates the render target textures and post processes used in the glow layer.
  109964. */
  109965. protected _createTextureAndPostProcesses(): void;
  109966. /**
  109967. * Checks for the readiness of the element composing the layer.
  109968. * @param subMesh the mesh to check for
  109969. * @param useInstances specify wether or not to use instances to render the mesh
  109970. * @param emissiveTexture the associated emissive texture used to generate the glow
  109971. * @return true if ready otherwise, false
  109972. */
  109973. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  109974. /**
  109975. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  109976. */
  109977. needStencil(): boolean;
  109978. /**
  109979. * Returns true if the mesh can be rendered, otherwise false.
  109980. * @param mesh The mesh to render
  109981. * @param material The material used on the mesh
  109982. * @returns true if it can be rendered otherwise false
  109983. */
  109984. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  109985. /**
  109986. * Implementation specific of rendering the generating effect on the main canvas.
  109987. * @param effect The effect used to render through
  109988. */
  109989. protected _internalRender(effect: Effect): void;
  109990. /**
  109991. * Sets the required values for both the emissive texture and and the main color.
  109992. */
  109993. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  109994. /**
  109995. * Returns true if the mesh should render, otherwise false.
  109996. * @param mesh The mesh to render
  109997. * @returns true if it should render otherwise false
  109998. */
  109999. protected _shouldRenderMesh(mesh: Mesh): boolean;
  110000. /**
  110001. * Adds specific effects defines.
  110002. * @param defines The defines to add specifics to.
  110003. */
  110004. protected _addCustomEffectDefines(defines: string[]): void;
  110005. /**
  110006. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  110007. * @param mesh The mesh to exclude from the glow layer
  110008. */
  110009. addExcludedMesh(mesh: Mesh): void;
  110010. /**
  110011. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  110012. * @param mesh The mesh to remove
  110013. */
  110014. removeExcludedMesh(mesh: Mesh): void;
  110015. /**
  110016. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  110017. * @param mesh The mesh to include in the glow layer
  110018. */
  110019. addIncludedOnlyMesh(mesh: Mesh): void;
  110020. /**
  110021. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  110022. * @param mesh The mesh to remove
  110023. */
  110024. removeIncludedOnlyMesh(mesh: Mesh): void;
  110025. /**
  110026. * Determine if a given mesh will be used in the glow layer
  110027. * @param mesh The mesh to test
  110028. * @returns true if the mesh will be highlighted by the current glow layer
  110029. */
  110030. hasMesh(mesh: AbstractMesh): boolean;
  110031. /**
  110032. * Free any resources and references associated to a mesh.
  110033. * Internal use
  110034. * @param mesh The mesh to free.
  110035. * @hidden
  110036. */
  110037. _disposeMesh(mesh: Mesh): void;
  110038. /**
  110039. * Gets the class name of the effect layer
  110040. * @returns the string with the class name of the effect layer
  110041. */
  110042. getClassName(): string;
  110043. /**
  110044. * Serializes this glow layer
  110045. * @returns a serialized glow layer object
  110046. */
  110047. serialize(): any;
  110048. /**
  110049. * Creates a Glow Layer from parsed glow layer data
  110050. * @param parsedGlowLayer defines glow layer data
  110051. * @param scene defines the current scene
  110052. * @param rootUrl defines the root URL containing the glow layer information
  110053. * @returns a parsed Glow Layer
  110054. */
  110055. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  110056. }
  110057. }
  110058. declare module BABYLON {
  110059. /** @hidden */
  110060. export var glowBlurPostProcessPixelShader: {
  110061. name: string;
  110062. shader: string;
  110063. };
  110064. }
  110065. declare module BABYLON {
  110066. interface AbstractScene {
  110067. /**
  110068. * Return a the first highlight layer of the scene with a given name.
  110069. * @param name The name of the highlight layer to look for.
  110070. * @return The highlight layer if found otherwise null.
  110071. */
  110072. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  110073. }
  110074. /**
  110075. * Highlight layer options. This helps customizing the behaviour
  110076. * of the highlight layer.
  110077. */
  110078. export interface IHighlightLayerOptions {
  110079. /**
  110080. * Multiplication factor apply to the canvas size to compute the render target size
  110081. * used to generated the glowing objects (the smaller the faster).
  110082. */
  110083. mainTextureRatio: number;
  110084. /**
  110085. * Enforces a fixed size texture to ensure resize independant blur.
  110086. */
  110087. mainTextureFixedSize?: number;
  110088. /**
  110089. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  110090. * of the picture to blur (the smaller the faster).
  110091. */
  110092. blurTextureSizeRatio: number;
  110093. /**
  110094. * How big in texel of the blur texture is the vertical blur.
  110095. */
  110096. blurVerticalSize: number;
  110097. /**
  110098. * How big in texel of the blur texture is the horizontal blur.
  110099. */
  110100. blurHorizontalSize: number;
  110101. /**
  110102. * Alpha blending mode used to apply the blur. Default is combine.
  110103. */
  110104. alphaBlendingMode: number;
  110105. /**
  110106. * The camera attached to the layer.
  110107. */
  110108. camera: Nullable<Camera>;
  110109. /**
  110110. * Should we display highlight as a solid stroke?
  110111. */
  110112. isStroke?: boolean;
  110113. /**
  110114. * The rendering group to draw the layer in.
  110115. */
  110116. renderingGroupId: number;
  110117. }
  110118. /**
  110119. * The highlight layer Helps adding a glow effect around a mesh.
  110120. *
  110121. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  110122. * glowy meshes to your scene.
  110123. *
  110124. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  110125. */
  110126. export class HighlightLayer extends EffectLayer {
  110127. name: string;
  110128. /**
  110129. * Effect Name of the highlight layer.
  110130. */
  110131. static readonly EffectName: string;
  110132. /**
  110133. * The neutral color used during the preparation of the glow effect.
  110134. * This is black by default as the blend operation is a blend operation.
  110135. */
  110136. static NeutralColor: Color4;
  110137. /**
  110138. * Stencil value used for glowing meshes.
  110139. */
  110140. static GlowingMeshStencilReference: number;
  110141. /**
  110142. * Stencil value used for the other meshes in the scene.
  110143. */
  110144. static NormalMeshStencilReference: number;
  110145. /**
  110146. * Specifies whether or not the inner glow is ACTIVE in the layer.
  110147. */
  110148. innerGlow: boolean;
  110149. /**
  110150. * Specifies whether or not the outer glow is ACTIVE in the layer.
  110151. */
  110152. outerGlow: boolean;
  110153. /**
  110154. * Specifies the horizontal size of the blur.
  110155. */
  110156. /**
  110157. * Gets the horizontal size of the blur.
  110158. */
  110159. blurHorizontalSize: number;
  110160. /**
  110161. * Specifies the vertical size of the blur.
  110162. */
  110163. /**
  110164. * Gets the vertical size of the blur.
  110165. */
  110166. blurVerticalSize: number;
  110167. /**
  110168. * An event triggered when the highlight layer is being blurred.
  110169. */
  110170. onBeforeBlurObservable: Observable<HighlightLayer>;
  110171. /**
  110172. * An event triggered when the highlight layer has been blurred.
  110173. */
  110174. onAfterBlurObservable: Observable<HighlightLayer>;
  110175. private _instanceGlowingMeshStencilReference;
  110176. private _options;
  110177. private _downSamplePostprocess;
  110178. private _horizontalBlurPostprocess;
  110179. private _verticalBlurPostprocess;
  110180. private _blurTexture;
  110181. private _meshes;
  110182. private _excludedMeshes;
  110183. /**
  110184. * Instantiates a new highlight Layer and references it to the scene..
  110185. * @param name The name of the layer
  110186. * @param scene The scene to use the layer in
  110187. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  110188. */
  110189. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  110190. /**
  110191. * Get the effect name of the layer.
  110192. * @return The effect name
  110193. */
  110194. getEffectName(): string;
  110195. /**
  110196. * Create the merge effect. This is the shader use to blit the information back
  110197. * to the main canvas at the end of the scene rendering.
  110198. */
  110199. protected _createMergeEffect(): Effect;
  110200. /**
  110201. * Creates the render target textures and post processes used in the highlight layer.
  110202. */
  110203. protected _createTextureAndPostProcesses(): void;
  110204. /**
  110205. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  110206. */
  110207. needStencil(): boolean;
  110208. /**
  110209. * Checks for the readiness of the element composing the layer.
  110210. * @param subMesh the mesh to check for
  110211. * @param useInstances specify wether or not to use instances to render the mesh
  110212. * @param emissiveTexture the associated emissive texture used to generate the glow
  110213. * @return true if ready otherwise, false
  110214. */
  110215. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110216. /**
  110217. * Implementation specific of rendering the generating effect on the main canvas.
  110218. * @param effect The effect used to render through
  110219. */
  110220. protected _internalRender(effect: Effect): void;
  110221. /**
  110222. * Returns true if the layer contains information to display, otherwise false.
  110223. */
  110224. shouldRender(): boolean;
  110225. /**
  110226. * Returns true if the mesh should render, otherwise false.
  110227. * @param mesh The mesh to render
  110228. * @returns true if it should render otherwise false
  110229. */
  110230. protected _shouldRenderMesh(mesh: Mesh): boolean;
  110231. /**
  110232. * Sets the required values for both the emissive texture and and the main color.
  110233. */
  110234. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  110235. /**
  110236. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  110237. * @param mesh The mesh to exclude from the highlight layer
  110238. */
  110239. addExcludedMesh(mesh: Mesh): void;
  110240. /**
  110241. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  110242. * @param mesh The mesh to highlight
  110243. */
  110244. removeExcludedMesh(mesh: Mesh): void;
  110245. /**
  110246. * Determine if a given mesh will be highlighted by the current HighlightLayer
  110247. * @param mesh mesh to test
  110248. * @returns true if the mesh will be highlighted by the current HighlightLayer
  110249. */
  110250. hasMesh(mesh: AbstractMesh): boolean;
  110251. /**
  110252. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  110253. * @param mesh The mesh to highlight
  110254. * @param color The color of the highlight
  110255. * @param glowEmissiveOnly Extract the glow from the emissive texture
  110256. */
  110257. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  110258. /**
  110259. * Remove a mesh from the highlight layer in order to make it stop glowing.
  110260. * @param mesh The mesh to highlight
  110261. */
  110262. removeMesh(mesh: Mesh): void;
  110263. /**
  110264. * Force the stencil to the normal expected value for none glowing parts
  110265. */
  110266. private _defaultStencilReference;
  110267. /**
  110268. * Free any resources and references associated to a mesh.
  110269. * Internal use
  110270. * @param mesh The mesh to free.
  110271. * @hidden
  110272. */
  110273. _disposeMesh(mesh: Mesh): void;
  110274. /**
  110275. * Dispose the highlight layer and free resources.
  110276. */
  110277. dispose(): void;
  110278. /**
  110279. * Gets the class name of the effect layer
  110280. * @returns the string with the class name of the effect layer
  110281. */
  110282. getClassName(): string;
  110283. /**
  110284. * Serializes this Highlight layer
  110285. * @returns a serialized Highlight layer object
  110286. */
  110287. serialize(): any;
  110288. /**
  110289. * Creates a Highlight layer from parsed Highlight layer data
  110290. * @param parsedHightlightLayer defines the Highlight layer data
  110291. * @param scene defines the current scene
  110292. * @param rootUrl defines the root URL containing the Highlight layer information
  110293. * @returns a parsed Highlight layer
  110294. */
  110295. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  110296. }
  110297. }
  110298. declare module BABYLON {
  110299. interface AbstractScene {
  110300. /**
  110301. * The list of layers (background and foreground) of the scene
  110302. */
  110303. layers: Array<Layer>;
  110304. }
  110305. /**
  110306. * Defines the layer scene component responsible to manage any layers
  110307. * in a given scene.
  110308. */
  110309. export class LayerSceneComponent implements ISceneComponent {
  110310. /**
  110311. * The component name helpfull to identify the component in the list of scene components.
  110312. */
  110313. readonly name: string;
  110314. /**
  110315. * The scene the component belongs to.
  110316. */
  110317. scene: Scene;
  110318. private _engine;
  110319. /**
  110320. * Creates a new instance of the component for the given scene
  110321. * @param scene Defines the scene to register the component in
  110322. */
  110323. constructor(scene: Scene);
  110324. /**
  110325. * Registers the component in a given scene
  110326. */
  110327. register(): void;
  110328. /**
  110329. * Rebuilds the elements related to this component in case of
  110330. * context lost for instance.
  110331. */
  110332. rebuild(): void;
  110333. /**
  110334. * Disposes the component and the associated ressources.
  110335. */
  110336. dispose(): void;
  110337. private _draw;
  110338. private _drawCameraPredicate;
  110339. private _drawCameraBackground;
  110340. private _drawCameraForeground;
  110341. private _drawRenderTargetPredicate;
  110342. private _drawRenderTargetBackground;
  110343. private _drawRenderTargetForeground;
  110344. /**
  110345. * Adds all the elements from the container to the scene
  110346. * @param container the container holding the elements
  110347. */
  110348. addFromContainer(container: AbstractScene): void;
  110349. /**
  110350. * Removes all the elements in the container from the scene
  110351. * @param container contains the elements to remove
  110352. * @param dispose if the removed element should be disposed (default: false)
  110353. */
  110354. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110355. }
  110356. }
  110357. declare module BABYLON {
  110358. /** @hidden */
  110359. export var layerPixelShader: {
  110360. name: string;
  110361. shader: string;
  110362. };
  110363. }
  110364. declare module BABYLON {
  110365. /** @hidden */
  110366. export var layerVertexShader: {
  110367. name: string;
  110368. shader: string;
  110369. };
  110370. }
  110371. declare module BABYLON {
  110372. /**
  110373. * This represents a full screen 2d layer.
  110374. * This can be useful to display a picture in the background of your scene for instance.
  110375. * @see https://www.babylonjs-playground.com/#08A2BS#1
  110376. */
  110377. export class Layer {
  110378. /**
  110379. * Define the name of the layer.
  110380. */
  110381. name: string;
  110382. /**
  110383. * Define the texture the layer should display.
  110384. */
  110385. texture: Nullable<Texture>;
  110386. /**
  110387. * Is the layer in background or foreground.
  110388. */
  110389. isBackground: boolean;
  110390. /**
  110391. * Define the color of the layer (instead of texture).
  110392. */
  110393. color: Color4;
  110394. /**
  110395. * Define the scale of the layer in order to zoom in out of the texture.
  110396. */
  110397. scale: Vector2;
  110398. /**
  110399. * Define an offset for the layer in order to shift the texture.
  110400. */
  110401. offset: Vector2;
  110402. /**
  110403. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  110404. */
  110405. alphaBlendingMode: number;
  110406. /**
  110407. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  110408. * Alpha test will not mix with the background color in case of transparency.
  110409. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  110410. */
  110411. alphaTest: boolean;
  110412. /**
  110413. * Define a mask to restrict the layer to only some of the scene cameras.
  110414. */
  110415. layerMask: number;
  110416. /**
  110417. * Define the list of render target the layer is visible into.
  110418. */
  110419. renderTargetTextures: RenderTargetTexture[];
  110420. /**
  110421. * Define if the layer is only used in renderTarget or if it also
  110422. * renders in the main frame buffer of the canvas.
  110423. */
  110424. renderOnlyInRenderTargetTextures: boolean;
  110425. private _scene;
  110426. private _vertexBuffers;
  110427. private _indexBuffer;
  110428. private _effect;
  110429. private _alphaTestEffect;
  110430. /**
  110431. * An event triggered when the layer is disposed.
  110432. */
  110433. onDisposeObservable: Observable<Layer>;
  110434. private _onDisposeObserver;
  110435. /**
  110436. * Back compatibility with callback before the onDisposeObservable existed.
  110437. * The set callback will be triggered when the layer has been disposed.
  110438. */
  110439. onDispose: () => void;
  110440. /**
  110441. * An event triggered before rendering the scene
  110442. */
  110443. onBeforeRenderObservable: Observable<Layer>;
  110444. private _onBeforeRenderObserver;
  110445. /**
  110446. * Back compatibility with callback before the onBeforeRenderObservable existed.
  110447. * The set callback will be triggered just before rendering the layer.
  110448. */
  110449. onBeforeRender: () => void;
  110450. /**
  110451. * An event triggered after rendering the scene
  110452. */
  110453. onAfterRenderObservable: Observable<Layer>;
  110454. private _onAfterRenderObserver;
  110455. /**
  110456. * Back compatibility with callback before the onAfterRenderObservable existed.
  110457. * The set callback will be triggered just after rendering the layer.
  110458. */
  110459. onAfterRender: () => void;
  110460. /**
  110461. * Instantiates a new layer.
  110462. * This represents a full screen 2d layer.
  110463. * This can be useful to display a picture in the background of your scene for instance.
  110464. * @see https://www.babylonjs-playground.com/#08A2BS#1
  110465. * @param name Define the name of the layer in the scene
  110466. * @param imgUrl Define the url of the texture to display in the layer
  110467. * @param scene Define the scene the layer belongs to
  110468. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  110469. * @param color Defines a color for the layer
  110470. */
  110471. constructor(
  110472. /**
  110473. * Define the name of the layer.
  110474. */
  110475. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  110476. private _createIndexBuffer;
  110477. /** @hidden */
  110478. _rebuild(): void;
  110479. /**
  110480. * Renders the layer in the scene.
  110481. */
  110482. render(): void;
  110483. /**
  110484. * Disposes and releases the associated ressources.
  110485. */
  110486. dispose(): void;
  110487. }
  110488. }
  110489. declare module BABYLON {
  110490. /** @hidden */
  110491. export var lensFlarePixelShader: {
  110492. name: string;
  110493. shader: string;
  110494. };
  110495. }
  110496. declare module BABYLON {
  110497. /** @hidden */
  110498. export var lensFlareVertexShader: {
  110499. name: string;
  110500. shader: string;
  110501. };
  110502. }
  110503. declare module BABYLON {
  110504. /**
  110505. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  110506. * It is usually composed of several `lensFlare`.
  110507. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110508. */
  110509. export class LensFlareSystem {
  110510. /**
  110511. * Define the name of the lens flare system
  110512. */
  110513. name: string;
  110514. /**
  110515. * List of lens flares used in this system.
  110516. */
  110517. lensFlares: LensFlare[];
  110518. /**
  110519. * Define a limit from the border the lens flare can be visible.
  110520. */
  110521. borderLimit: number;
  110522. /**
  110523. * Define a viewport border we do not want to see the lens flare in.
  110524. */
  110525. viewportBorder: number;
  110526. /**
  110527. * Define a predicate which could limit the list of meshes able to occlude the effect.
  110528. */
  110529. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  110530. /**
  110531. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  110532. */
  110533. layerMask: number;
  110534. /**
  110535. * Define the id of the lens flare system in the scene.
  110536. * (equal to name by default)
  110537. */
  110538. id: string;
  110539. private _scene;
  110540. private _emitter;
  110541. private _vertexBuffers;
  110542. private _indexBuffer;
  110543. private _effect;
  110544. private _positionX;
  110545. private _positionY;
  110546. private _isEnabled;
  110547. /** @hidden */
  110548. static _SceneComponentInitialization: (scene: Scene) => void;
  110549. /**
  110550. * Instantiates a lens flare system.
  110551. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  110552. * It is usually composed of several `lensFlare`.
  110553. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110554. * @param name Define the name of the lens flare system in the scene
  110555. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  110556. * @param scene Define the scene the lens flare system belongs to
  110557. */
  110558. constructor(
  110559. /**
  110560. * Define the name of the lens flare system
  110561. */
  110562. name: string, emitter: any, scene: Scene);
  110563. /**
  110564. * Define if the lens flare system is enabled.
  110565. */
  110566. isEnabled: boolean;
  110567. /**
  110568. * Get the scene the effects belongs to.
  110569. * @returns the scene holding the lens flare system
  110570. */
  110571. getScene(): Scene;
  110572. /**
  110573. * Get the emitter of the lens flare system.
  110574. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  110575. * @returns the emitter of the lens flare system
  110576. */
  110577. getEmitter(): any;
  110578. /**
  110579. * Set the emitter of the lens flare system.
  110580. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  110581. * @param newEmitter Define the new emitter of the system
  110582. */
  110583. setEmitter(newEmitter: any): void;
  110584. /**
  110585. * Get the lens flare system emitter position.
  110586. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  110587. * @returns the position
  110588. */
  110589. getEmitterPosition(): Vector3;
  110590. /**
  110591. * @hidden
  110592. */
  110593. computeEffectivePosition(globalViewport: Viewport): boolean;
  110594. /** @hidden */
  110595. _isVisible(): boolean;
  110596. /**
  110597. * @hidden
  110598. */
  110599. render(): boolean;
  110600. /**
  110601. * Dispose and release the lens flare with its associated resources.
  110602. */
  110603. dispose(): void;
  110604. /**
  110605. * Parse a lens flare system from a JSON repressentation
  110606. * @param parsedLensFlareSystem Define the JSON to parse
  110607. * @param scene Define the scene the parsed system should be instantiated in
  110608. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  110609. * @returns the parsed system
  110610. */
  110611. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  110612. /**
  110613. * Serialize the current Lens Flare System into a JSON representation.
  110614. * @returns the serialized JSON
  110615. */
  110616. serialize(): any;
  110617. }
  110618. }
  110619. declare module BABYLON {
  110620. /**
  110621. * This represents one of the lens effect in a `lensFlareSystem`.
  110622. * It controls one of the indiviual texture used in the effect.
  110623. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110624. */
  110625. export class LensFlare {
  110626. /**
  110627. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  110628. */
  110629. size: number;
  110630. /**
  110631. * 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.
  110632. */
  110633. position: number;
  110634. /**
  110635. * Define the lens color.
  110636. */
  110637. color: Color3;
  110638. /**
  110639. * Define the lens texture.
  110640. */
  110641. texture: Nullable<Texture>;
  110642. /**
  110643. * Define the alpha mode to render this particular lens.
  110644. */
  110645. alphaMode: number;
  110646. private _system;
  110647. /**
  110648. * Creates a new Lens Flare.
  110649. * This represents one of the lens effect in a `lensFlareSystem`.
  110650. * It controls one of the indiviual texture used in the effect.
  110651. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110652. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  110653. * @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.
  110654. * @param color Define the lens color
  110655. * @param imgUrl Define the lens texture url
  110656. * @param system Define the `lensFlareSystem` this flare is part of
  110657. * @returns The newly created Lens Flare
  110658. */
  110659. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  110660. /**
  110661. * Instantiates a new Lens Flare.
  110662. * This represents one of the lens effect in a `lensFlareSystem`.
  110663. * It controls one of the indiviual texture used in the effect.
  110664. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110665. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  110666. * @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.
  110667. * @param color Define the lens color
  110668. * @param imgUrl Define the lens texture url
  110669. * @param system Define the `lensFlareSystem` this flare is part of
  110670. */
  110671. constructor(
  110672. /**
  110673. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  110674. */
  110675. size: number,
  110676. /**
  110677. * 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.
  110678. */
  110679. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  110680. /**
  110681. * Dispose and release the lens flare with its associated resources.
  110682. */
  110683. dispose(): void;
  110684. }
  110685. }
  110686. declare module BABYLON {
  110687. interface AbstractScene {
  110688. /**
  110689. * The list of lens flare system added to the scene
  110690. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110691. */
  110692. lensFlareSystems: Array<LensFlareSystem>;
  110693. /**
  110694. * Removes the given lens flare system from this scene.
  110695. * @param toRemove The lens flare system to remove
  110696. * @returns The index of the removed lens flare system
  110697. */
  110698. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  110699. /**
  110700. * Adds the given lens flare system to this scene
  110701. * @param newLensFlareSystem The lens flare system to add
  110702. */
  110703. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  110704. /**
  110705. * Gets a lens flare system using its name
  110706. * @param name defines the name to look for
  110707. * @returns the lens flare system or null if not found
  110708. */
  110709. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  110710. /**
  110711. * Gets a lens flare system using its id
  110712. * @param id defines the id to look for
  110713. * @returns the lens flare system or null if not found
  110714. */
  110715. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  110716. }
  110717. /**
  110718. * Defines the lens flare scene component responsible to manage any lens flares
  110719. * in a given scene.
  110720. */
  110721. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  110722. /**
  110723. * The component name helpfull to identify the component in the list of scene components.
  110724. */
  110725. readonly name: string;
  110726. /**
  110727. * The scene the component belongs to.
  110728. */
  110729. scene: Scene;
  110730. /**
  110731. * Creates a new instance of the component for the given scene
  110732. * @param scene Defines the scene to register the component in
  110733. */
  110734. constructor(scene: Scene);
  110735. /**
  110736. * Registers the component in a given scene
  110737. */
  110738. register(): void;
  110739. /**
  110740. * Rebuilds the elements related to this component in case of
  110741. * context lost for instance.
  110742. */
  110743. rebuild(): void;
  110744. /**
  110745. * Adds all the elements from the container to the scene
  110746. * @param container the container holding the elements
  110747. */
  110748. addFromContainer(container: AbstractScene): void;
  110749. /**
  110750. * Removes all the elements in the container from the scene
  110751. * @param container contains the elements to remove
  110752. * @param dispose if the removed element should be disposed (default: false)
  110753. */
  110754. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110755. /**
  110756. * Serializes the component data to the specified json object
  110757. * @param serializationObject The object to serialize to
  110758. */
  110759. serialize(serializationObject: any): void;
  110760. /**
  110761. * Disposes the component and the associated ressources.
  110762. */
  110763. dispose(): void;
  110764. private _draw;
  110765. }
  110766. }
  110767. declare module BABYLON {
  110768. /**
  110769. * Defines the shadow generator component responsible to manage any shadow generators
  110770. * in a given scene.
  110771. */
  110772. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  110773. /**
  110774. * The component name helpfull to identify the component in the list of scene components.
  110775. */
  110776. readonly name: string;
  110777. /**
  110778. * The scene the component belongs to.
  110779. */
  110780. scene: Scene;
  110781. /**
  110782. * Creates a new instance of the component for the given scene
  110783. * @param scene Defines the scene to register the component in
  110784. */
  110785. constructor(scene: Scene);
  110786. /**
  110787. * Registers the component in a given scene
  110788. */
  110789. register(): void;
  110790. /**
  110791. * Rebuilds the elements related to this component in case of
  110792. * context lost for instance.
  110793. */
  110794. rebuild(): void;
  110795. /**
  110796. * Serializes the component data to the specified json object
  110797. * @param serializationObject The object to serialize to
  110798. */
  110799. serialize(serializationObject: any): void;
  110800. /**
  110801. * Adds all the elements from the container to the scene
  110802. * @param container the container holding the elements
  110803. */
  110804. addFromContainer(container: AbstractScene): void;
  110805. /**
  110806. * Removes all the elements in the container from the scene
  110807. * @param container contains the elements to remove
  110808. * @param dispose if the removed element should be disposed (default: false)
  110809. */
  110810. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110811. /**
  110812. * Rebuilds the elements related to this component in case of
  110813. * context lost for instance.
  110814. */
  110815. dispose(): void;
  110816. private _gatherRenderTargets;
  110817. }
  110818. }
  110819. declare module BABYLON {
  110820. /**
  110821. * A point light is a light defined by an unique point in world space.
  110822. * The light is emitted in every direction from this point.
  110823. * A good example of a point light is a standard light bulb.
  110824. * Documentation: https://doc.babylonjs.com/babylon101/lights
  110825. */
  110826. export class PointLight extends ShadowLight {
  110827. private _shadowAngle;
  110828. /**
  110829. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  110830. * This specifies what angle the shadow will use to be created.
  110831. *
  110832. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  110833. */
  110834. /**
  110835. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  110836. * This specifies what angle the shadow will use to be created.
  110837. *
  110838. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  110839. */
  110840. shadowAngle: number;
  110841. /**
  110842. * Gets the direction if it has been set.
  110843. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  110844. */
  110845. /**
  110846. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  110847. */
  110848. direction: Vector3;
  110849. /**
  110850. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  110851. * A PointLight emits the light in every direction.
  110852. * It can cast shadows.
  110853. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  110854. * ```javascript
  110855. * var pointLight = new PointLight("pl", camera.position, scene);
  110856. * ```
  110857. * Documentation : https://doc.babylonjs.com/babylon101/lights
  110858. * @param name The light friendly name
  110859. * @param position The position of the point light in the scene
  110860. * @param scene The scene the lights belongs to
  110861. */
  110862. constructor(name: string, position: Vector3, scene: Scene);
  110863. /**
  110864. * Returns the string "PointLight"
  110865. * @returns the class name
  110866. */
  110867. getClassName(): string;
  110868. /**
  110869. * Returns the integer 0.
  110870. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  110871. */
  110872. getTypeID(): number;
  110873. /**
  110874. * Specifies wether or not the shadowmap should be a cube texture.
  110875. * @returns true if the shadowmap needs to be a cube texture.
  110876. */
  110877. needCube(): boolean;
  110878. /**
  110879. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  110880. * @param faceIndex The index of the face we are computed the direction to generate shadow
  110881. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  110882. */
  110883. getShadowDirection(faceIndex?: number): Vector3;
  110884. /**
  110885. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  110886. * - fov = PI / 2
  110887. * - aspect ratio : 1.0
  110888. * - z-near and far equal to the active camera minZ and maxZ.
  110889. * Returns the PointLight.
  110890. */
  110891. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  110892. protected _buildUniformLayout(): void;
  110893. /**
  110894. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  110895. * @param effect The effect to update
  110896. * @param lightIndex The index of the light in the effect to update
  110897. * @returns The point light
  110898. */
  110899. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  110900. /**
  110901. * Prepares the list of defines specific to the light type.
  110902. * @param defines the list of defines
  110903. * @param lightIndex defines the index of the light for the effect
  110904. */
  110905. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  110906. }
  110907. }
  110908. declare module BABYLON {
  110909. /**
  110910. * Header information of HDR texture files.
  110911. */
  110912. export interface HDRInfo {
  110913. /**
  110914. * The height of the texture in pixels.
  110915. */
  110916. height: number;
  110917. /**
  110918. * The width of the texture in pixels.
  110919. */
  110920. width: number;
  110921. /**
  110922. * The index of the beginning of the data in the binary file.
  110923. */
  110924. dataPosition: number;
  110925. }
  110926. /**
  110927. * This groups tools to convert HDR texture to native colors array.
  110928. */
  110929. export class HDRTools {
  110930. private static Ldexp;
  110931. private static Rgbe2float;
  110932. private static readStringLine;
  110933. /**
  110934. * Reads header information from an RGBE texture stored in a native array.
  110935. * More information on this format are available here:
  110936. * https://en.wikipedia.org/wiki/RGBE_image_format
  110937. *
  110938. * @param uint8array The binary file stored in native array.
  110939. * @return The header information.
  110940. */
  110941. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  110942. /**
  110943. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  110944. * This RGBE texture needs to store the information as a panorama.
  110945. *
  110946. * More information on this format are available here:
  110947. * https://en.wikipedia.org/wiki/RGBE_image_format
  110948. *
  110949. * @param buffer The binary file stored in an array buffer.
  110950. * @param size The expected size of the extracted cubemap.
  110951. * @return The Cube Map information.
  110952. */
  110953. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  110954. /**
  110955. * Returns the pixels data extracted from an RGBE texture.
  110956. * This pixels will be stored left to right up to down in the R G B order in one array.
  110957. *
  110958. * More information on this format are available here:
  110959. * https://en.wikipedia.org/wiki/RGBE_image_format
  110960. *
  110961. * @param uint8array The binary file stored in an array buffer.
  110962. * @param hdrInfo The header information of the file.
  110963. * @return The pixels data in RGB right to left up to down order.
  110964. */
  110965. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  110966. private static RGBE_ReadPixels_RLE;
  110967. }
  110968. }
  110969. declare module BABYLON {
  110970. /**
  110971. * This represents a texture coming from an HDR input.
  110972. *
  110973. * The only supported format is currently panorama picture stored in RGBE format.
  110974. * Example of such files can be found on HDRLib: http://hdrlib.com/
  110975. */
  110976. export class HDRCubeTexture extends BaseTexture {
  110977. private static _facesMapping;
  110978. private _generateHarmonics;
  110979. private _noMipmap;
  110980. private _textureMatrix;
  110981. private _size;
  110982. private _onLoad;
  110983. private _onError;
  110984. /**
  110985. * The texture URL.
  110986. */
  110987. url: string;
  110988. /**
  110989. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  110990. */
  110991. coordinatesMode: number;
  110992. protected _isBlocking: boolean;
  110993. /**
  110994. * Sets wether or not the texture is blocking during loading.
  110995. */
  110996. /**
  110997. * Gets wether or not the texture is blocking during loading.
  110998. */
  110999. isBlocking: boolean;
  111000. protected _rotationY: number;
  111001. /**
  111002. * Sets texture matrix rotation angle around Y axis in radians.
  111003. */
  111004. /**
  111005. * Gets texture matrix rotation angle around Y axis radians.
  111006. */
  111007. rotationY: number;
  111008. /**
  111009. * Gets or sets the center of the bounding box associated with the cube texture
  111010. * It must define where the camera used to render the texture was set
  111011. */
  111012. boundingBoxPosition: Vector3;
  111013. private _boundingBoxSize;
  111014. /**
  111015. * Gets or sets the size of the bounding box associated with the cube texture
  111016. * When defined, the cubemap will switch to local mode
  111017. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  111018. * @example https://www.babylonjs-playground.com/#RNASML
  111019. */
  111020. boundingBoxSize: Vector3;
  111021. /**
  111022. * Instantiates an HDRTexture from the following parameters.
  111023. *
  111024. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  111025. * @param scene The scene the texture will be used in
  111026. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  111027. * @param noMipmap Forces to not generate the mipmap if true
  111028. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  111029. * @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)
  111030. * @param reserved Reserved flag for internal use.
  111031. */
  111032. 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>);
  111033. /**
  111034. * Get the current class name of the texture useful for serialization or dynamic coding.
  111035. * @returns "HDRCubeTexture"
  111036. */
  111037. getClassName(): string;
  111038. /**
  111039. * Occurs when the file is raw .hdr file.
  111040. */
  111041. private loadTexture;
  111042. clone(): HDRCubeTexture;
  111043. delayLoad(): void;
  111044. /**
  111045. * Get the texture reflection matrix used to rotate/transform the reflection.
  111046. * @returns the reflection matrix
  111047. */
  111048. getReflectionTextureMatrix(): Matrix;
  111049. /**
  111050. * Set the texture reflection matrix used to rotate/transform the reflection.
  111051. * @param value Define the reflection matrix to set
  111052. */
  111053. setReflectionTextureMatrix(value: Matrix): void;
  111054. /**
  111055. * Parses a JSON representation of an HDR Texture in order to create the texture
  111056. * @param parsedTexture Define the JSON representation
  111057. * @param scene Define the scene the texture should be created in
  111058. * @param rootUrl Define the root url in case we need to load relative dependencies
  111059. * @returns the newly created texture after parsing
  111060. */
  111061. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  111062. serialize(): any;
  111063. }
  111064. }
  111065. declare module BABYLON {
  111066. /**
  111067. * Class used to control physics engine
  111068. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  111069. */
  111070. export class PhysicsEngine implements IPhysicsEngine {
  111071. private _physicsPlugin;
  111072. /**
  111073. * Global value used to control the smallest number supported by the simulation
  111074. */
  111075. static Epsilon: number;
  111076. private _impostors;
  111077. private _joints;
  111078. /**
  111079. * Gets the gravity vector used by the simulation
  111080. */
  111081. gravity: Vector3;
  111082. /**
  111083. * Factory used to create the default physics plugin.
  111084. * @returns The default physics plugin
  111085. */
  111086. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  111087. /**
  111088. * Creates a new Physics Engine
  111089. * @param gravity defines the gravity vector used by the simulation
  111090. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  111091. */
  111092. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  111093. /**
  111094. * Sets the gravity vector used by the simulation
  111095. * @param gravity defines the gravity vector to use
  111096. */
  111097. setGravity(gravity: Vector3): void;
  111098. /**
  111099. * Set the time step of the physics engine.
  111100. * Default is 1/60.
  111101. * To slow it down, enter 1/600 for example.
  111102. * To speed it up, 1/30
  111103. * @param newTimeStep defines the new timestep to apply to this world.
  111104. */
  111105. setTimeStep(newTimeStep?: number): void;
  111106. /**
  111107. * Get the time step of the physics engine.
  111108. * @returns the current time step
  111109. */
  111110. getTimeStep(): number;
  111111. /**
  111112. * Release all resources
  111113. */
  111114. dispose(): void;
  111115. /**
  111116. * Gets the name of the current physics plugin
  111117. * @returns the name of the plugin
  111118. */
  111119. getPhysicsPluginName(): string;
  111120. /**
  111121. * Adding a new impostor for the impostor tracking.
  111122. * This will be done by the impostor itself.
  111123. * @param impostor the impostor to add
  111124. */
  111125. addImpostor(impostor: PhysicsImpostor): void;
  111126. /**
  111127. * Remove an impostor from the engine.
  111128. * This impostor and its mesh will not longer be updated by the physics engine.
  111129. * @param impostor the impostor to remove
  111130. */
  111131. removeImpostor(impostor: PhysicsImpostor): void;
  111132. /**
  111133. * Add a joint to the physics engine
  111134. * @param mainImpostor defines the main impostor to which the joint is added.
  111135. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  111136. * @param joint defines the joint that will connect both impostors.
  111137. */
  111138. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  111139. /**
  111140. * Removes a joint from the simulation
  111141. * @param mainImpostor defines the impostor used with the joint
  111142. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  111143. * @param joint defines the joint to remove
  111144. */
  111145. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  111146. /**
  111147. * Called by the scene. No need to call it.
  111148. * @param delta defines the timespam between frames
  111149. */
  111150. _step(delta: number): void;
  111151. /**
  111152. * Gets the current plugin used to run the simulation
  111153. * @returns current plugin
  111154. */
  111155. getPhysicsPlugin(): IPhysicsEnginePlugin;
  111156. /**
  111157. * Gets the list of physic impostors
  111158. * @returns an array of PhysicsImpostor
  111159. */
  111160. getImpostors(): Array<PhysicsImpostor>;
  111161. /**
  111162. * Gets the impostor for a physics enabled object
  111163. * @param object defines the object impersonated by the impostor
  111164. * @returns the PhysicsImpostor or null if not found
  111165. */
  111166. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  111167. /**
  111168. * Gets the impostor for a physics body object
  111169. * @param body defines physics body used by the impostor
  111170. * @returns the PhysicsImpostor or null if not found
  111171. */
  111172. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  111173. /**
  111174. * Does a raycast in the physics world
  111175. * @param from when should the ray start?
  111176. * @param to when should the ray end?
  111177. * @returns PhysicsRaycastResult
  111178. */
  111179. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  111180. }
  111181. }
  111182. declare module BABYLON {
  111183. /** @hidden */
  111184. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  111185. private _useDeltaForWorldStep;
  111186. world: any;
  111187. name: string;
  111188. private _physicsMaterials;
  111189. private _fixedTimeStep;
  111190. private _cannonRaycastResult;
  111191. private _raycastResult;
  111192. private _removeAfterStep;
  111193. BJSCANNON: any;
  111194. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  111195. setGravity(gravity: Vector3): void;
  111196. setTimeStep(timeStep: number): void;
  111197. getTimeStep(): number;
  111198. executeStep(delta: number): void;
  111199. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111200. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111201. generatePhysicsBody(impostor: PhysicsImpostor): void;
  111202. private _processChildMeshes;
  111203. removePhysicsBody(impostor: PhysicsImpostor): void;
  111204. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  111205. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  111206. private _addMaterial;
  111207. private _checkWithEpsilon;
  111208. private _createShape;
  111209. private _createHeightmap;
  111210. private _minus90X;
  111211. private _plus90X;
  111212. private _tmpPosition;
  111213. private _tmpDeltaPosition;
  111214. private _tmpUnityRotation;
  111215. private _updatePhysicsBodyTransformation;
  111216. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  111217. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  111218. isSupported(): boolean;
  111219. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111220. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111221. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111222. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111223. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  111224. getBodyMass(impostor: PhysicsImpostor): number;
  111225. getBodyFriction(impostor: PhysicsImpostor): number;
  111226. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  111227. getBodyRestitution(impostor: PhysicsImpostor): number;
  111228. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  111229. sleepBody(impostor: PhysicsImpostor): void;
  111230. wakeUpBody(impostor: PhysicsImpostor): void;
  111231. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  111232. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  111233. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  111234. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  111235. getRadius(impostor: PhysicsImpostor): number;
  111236. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  111237. dispose(): void;
  111238. private _extendNamespace;
  111239. /**
  111240. * Does a raycast in the physics world
  111241. * @param from when should the ray start?
  111242. * @param to when should the ray end?
  111243. * @returns PhysicsRaycastResult
  111244. */
  111245. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  111246. }
  111247. }
  111248. declare module BABYLON {
  111249. /** @hidden */
  111250. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  111251. world: any;
  111252. name: string;
  111253. BJSOIMO: any;
  111254. private _raycastResult;
  111255. constructor(iterations?: number, oimoInjection?: any);
  111256. setGravity(gravity: Vector3): void;
  111257. setTimeStep(timeStep: number): void;
  111258. getTimeStep(): number;
  111259. private _tmpImpostorsArray;
  111260. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  111261. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111262. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111263. generatePhysicsBody(impostor: PhysicsImpostor): void;
  111264. private _tmpPositionVector;
  111265. removePhysicsBody(impostor: PhysicsImpostor): void;
  111266. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  111267. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  111268. isSupported(): boolean;
  111269. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  111270. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  111271. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111272. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111273. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111274. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111275. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  111276. getBodyMass(impostor: PhysicsImpostor): number;
  111277. getBodyFriction(impostor: PhysicsImpostor): number;
  111278. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  111279. getBodyRestitution(impostor: PhysicsImpostor): number;
  111280. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  111281. sleepBody(impostor: PhysicsImpostor): void;
  111282. wakeUpBody(impostor: PhysicsImpostor): void;
  111283. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  111284. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  111285. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  111286. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  111287. getRadius(impostor: PhysicsImpostor): number;
  111288. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  111289. dispose(): void;
  111290. /**
  111291. * Does a raycast in the physics world
  111292. * @param from when should the ray start?
  111293. * @param to when should the ray end?
  111294. * @returns PhysicsRaycastResult
  111295. */
  111296. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  111297. }
  111298. }
  111299. declare module BABYLON {
  111300. /**
  111301. * Class containing static functions to help procedurally build meshes
  111302. */
  111303. export class RibbonBuilder {
  111304. /**
  111305. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  111306. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  111307. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  111308. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  111309. * * 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
  111310. * * 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
  111311. * * 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
  111312. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111313. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111314. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  111315. * * 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
  111316. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  111317. * * 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
  111318. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  111319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111320. * @param name defines the name of the mesh
  111321. * @param options defines the options used to create the mesh
  111322. * @param scene defines the hosting scene
  111323. * @returns the ribbon mesh
  111324. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  111325. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  111326. */
  111327. static CreateRibbon(name: string, options: {
  111328. pathArray: Vector3[][];
  111329. closeArray?: boolean;
  111330. closePath?: boolean;
  111331. offset?: number;
  111332. updatable?: boolean;
  111333. sideOrientation?: number;
  111334. frontUVs?: Vector4;
  111335. backUVs?: Vector4;
  111336. instance?: Mesh;
  111337. invertUV?: boolean;
  111338. uvs?: Vector2[];
  111339. colors?: Color4[];
  111340. }, scene?: Nullable<Scene>): Mesh;
  111341. }
  111342. }
  111343. declare module BABYLON {
  111344. /**
  111345. * Class containing static functions to help procedurally build meshes
  111346. */
  111347. export class ShapeBuilder {
  111348. /**
  111349. * 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.
  111350. * * 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.
  111351. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  111352. * * 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.
  111353. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  111354. * * 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
  111355. * * 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
  111356. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  111357. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111358. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111359. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  111360. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  111361. * @param name defines the name of the mesh
  111362. * @param options defines the options used to create the mesh
  111363. * @param scene defines the hosting scene
  111364. * @returns the extruded shape mesh
  111365. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  111366. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  111367. */
  111368. static ExtrudeShape(name: string, options: {
  111369. shape: Vector3[];
  111370. path: Vector3[];
  111371. scale?: number;
  111372. rotation?: number;
  111373. cap?: number;
  111374. updatable?: boolean;
  111375. sideOrientation?: number;
  111376. frontUVs?: Vector4;
  111377. backUVs?: Vector4;
  111378. instance?: Mesh;
  111379. invertUV?: boolean;
  111380. }, scene?: Nullable<Scene>): Mesh;
  111381. /**
  111382. * Creates an custom extruded shape mesh.
  111383. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  111384. * * 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.
  111385. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  111386. * * 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
  111387. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  111388. * * 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
  111389. * * It must returns a float value that will be the scale value applied to the shape on each path point
  111390. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  111391. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  111392. * * 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
  111393. * * 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
  111394. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  111395. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111396. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111397. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  111398. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111399. * @param name defines the name of the mesh
  111400. * @param options defines the options used to create the mesh
  111401. * @param scene defines the hosting scene
  111402. * @returns the custom extruded shape mesh
  111403. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  111404. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  111405. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  111406. */
  111407. static ExtrudeShapeCustom(name: string, options: {
  111408. shape: Vector3[];
  111409. path: Vector3[];
  111410. scaleFunction?: any;
  111411. rotationFunction?: any;
  111412. ribbonCloseArray?: boolean;
  111413. ribbonClosePath?: boolean;
  111414. cap?: number;
  111415. updatable?: boolean;
  111416. sideOrientation?: number;
  111417. frontUVs?: Vector4;
  111418. backUVs?: Vector4;
  111419. instance?: Mesh;
  111420. invertUV?: boolean;
  111421. }, scene?: Nullable<Scene>): Mesh;
  111422. private static _ExtrudeShapeGeneric;
  111423. }
  111424. }
  111425. declare module BABYLON {
  111426. /**
  111427. * AmmoJS Physics plugin
  111428. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111429. * @see https://github.com/kripken/ammo.js/
  111430. */
  111431. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  111432. private _useDeltaForWorldStep;
  111433. /**
  111434. * Reference to the Ammo library
  111435. */
  111436. bjsAMMO: any;
  111437. /**
  111438. * Created ammoJS world which physics bodies are added to
  111439. */
  111440. world: any;
  111441. /**
  111442. * Name of the plugin
  111443. */
  111444. name: string;
  111445. private _timeStep;
  111446. private _fixedTimeStep;
  111447. private _maxSteps;
  111448. private _tmpQuaternion;
  111449. private _tmpAmmoTransform;
  111450. private _tmpAmmoQuaternion;
  111451. private _tmpAmmoConcreteContactResultCallback;
  111452. private _collisionConfiguration;
  111453. private _dispatcher;
  111454. private _overlappingPairCache;
  111455. private _solver;
  111456. private _softBodySolver;
  111457. private _tmpAmmoVectorA;
  111458. private _tmpAmmoVectorB;
  111459. private _tmpAmmoVectorC;
  111460. private _tmpAmmoVectorD;
  111461. private _tmpContactCallbackResult;
  111462. private _tmpAmmoVectorRCA;
  111463. private _tmpAmmoVectorRCB;
  111464. private _raycastResult;
  111465. private static readonly DISABLE_COLLISION_FLAG;
  111466. private static readonly KINEMATIC_FLAG;
  111467. private static readonly DISABLE_DEACTIVATION_FLAG;
  111468. /**
  111469. * Initializes the ammoJS plugin
  111470. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  111471. * @param ammoInjection can be used to inject your own ammo reference
  111472. */
  111473. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  111474. /**
  111475. * Sets the gravity of the physics world (m/(s^2))
  111476. * @param gravity Gravity to set
  111477. */
  111478. setGravity(gravity: Vector3): void;
  111479. /**
  111480. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  111481. * @param timeStep timestep to use in seconds
  111482. */
  111483. setTimeStep(timeStep: number): void;
  111484. /**
  111485. * 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)
  111486. * @param fixedTimeStep fixedTimeStep to use in seconds
  111487. */
  111488. setFixedTimeStep(fixedTimeStep: number): void;
  111489. /**
  111490. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  111491. * @param maxSteps the maximum number of steps by the physics engine per frame
  111492. */
  111493. setMaxSteps(maxSteps: number): void;
  111494. /**
  111495. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  111496. * @returns the current timestep in seconds
  111497. */
  111498. getTimeStep(): number;
  111499. private _isImpostorInContact;
  111500. private _isImpostorPairInContact;
  111501. private _stepSimulation;
  111502. /**
  111503. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  111504. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  111505. * After the step the babylon meshes are set to the position of the physics imposters
  111506. * @param delta amount of time to step forward
  111507. * @param impostors array of imposters to update before/after the step
  111508. */
  111509. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  111510. /**
  111511. * Update babylon mesh to match physics world object
  111512. * @param impostor imposter to match
  111513. */
  111514. private _afterSoftStep;
  111515. /**
  111516. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  111517. * @param impostor imposter to match
  111518. */
  111519. private _ropeStep;
  111520. /**
  111521. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  111522. * @param impostor imposter to match
  111523. */
  111524. private _softbodyOrClothStep;
  111525. private _tmpVector;
  111526. private _tmpMatrix;
  111527. /**
  111528. * Applies an impulse on the imposter
  111529. * @param impostor imposter to apply impulse to
  111530. * @param force amount of force to be applied to the imposter
  111531. * @param contactPoint the location to apply the impulse on the imposter
  111532. */
  111533. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111534. /**
  111535. * Applies a force on the imposter
  111536. * @param impostor imposter to apply force
  111537. * @param force amount of force to be applied to the imposter
  111538. * @param contactPoint the location to apply the force on the imposter
  111539. */
  111540. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111541. /**
  111542. * Creates a physics body using the plugin
  111543. * @param impostor the imposter to create the physics body on
  111544. */
  111545. generatePhysicsBody(impostor: PhysicsImpostor): void;
  111546. /**
  111547. * Removes the physics body from the imposter and disposes of the body's memory
  111548. * @param impostor imposter to remove the physics body from
  111549. */
  111550. removePhysicsBody(impostor: PhysicsImpostor): void;
  111551. /**
  111552. * Generates a joint
  111553. * @param impostorJoint the imposter joint to create the joint with
  111554. */
  111555. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  111556. /**
  111557. * Removes a joint
  111558. * @param impostorJoint the imposter joint to remove the joint from
  111559. */
  111560. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  111561. private _addMeshVerts;
  111562. /**
  111563. * Initialise the soft body vertices to match its object's (mesh) vertices
  111564. * Softbody vertices (nodes) are in world space and to match this
  111565. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  111566. * @param impostor to create the softbody for
  111567. */
  111568. private _softVertexData;
  111569. /**
  111570. * Create an impostor's soft body
  111571. * @param impostor to create the softbody for
  111572. */
  111573. private _createSoftbody;
  111574. /**
  111575. * Create cloth for an impostor
  111576. * @param impostor to create the softbody for
  111577. */
  111578. private _createCloth;
  111579. /**
  111580. * Create rope for an impostor
  111581. * @param impostor to create the softbody for
  111582. */
  111583. private _createRope;
  111584. private _addHullVerts;
  111585. private _createShape;
  111586. /**
  111587. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  111588. * @param impostor imposter containing the physics body and babylon object
  111589. */
  111590. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  111591. /**
  111592. * Sets the babylon object's position/rotation from the physics body's position/rotation
  111593. * @param impostor imposter containing the physics body and babylon object
  111594. * @param newPosition new position
  111595. * @param newRotation new rotation
  111596. */
  111597. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  111598. /**
  111599. * If this plugin is supported
  111600. * @returns true if its supported
  111601. */
  111602. isSupported(): boolean;
  111603. /**
  111604. * Sets the linear velocity of the physics body
  111605. * @param impostor imposter to set the velocity on
  111606. * @param velocity velocity to set
  111607. */
  111608. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111609. /**
  111610. * Sets the angular velocity of the physics body
  111611. * @param impostor imposter to set the velocity on
  111612. * @param velocity velocity to set
  111613. */
  111614. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111615. /**
  111616. * gets the linear velocity
  111617. * @param impostor imposter to get linear velocity from
  111618. * @returns linear velocity
  111619. */
  111620. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111621. /**
  111622. * gets the angular velocity
  111623. * @param impostor imposter to get angular velocity from
  111624. * @returns angular velocity
  111625. */
  111626. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111627. /**
  111628. * Sets the mass of physics body
  111629. * @param impostor imposter to set the mass on
  111630. * @param mass mass to set
  111631. */
  111632. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  111633. /**
  111634. * Gets the mass of the physics body
  111635. * @param impostor imposter to get the mass from
  111636. * @returns mass
  111637. */
  111638. getBodyMass(impostor: PhysicsImpostor): number;
  111639. /**
  111640. * Gets friction of the impostor
  111641. * @param impostor impostor to get friction from
  111642. * @returns friction value
  111643. */
  111644. getBodyFriction(impostor: PhysicsImpostor): number;
  111645. /**
  111646. * Sets friction of the impostor
  111647. * @param impostor impostor to set friction on
  111648. * @param friction friction value
  111649. */
  111650. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  111651. /**
  111652. * Gets restitution of the impostor
  111653. * @param impostor impostor to get restitution from
  111654. * @returns restitution value
  111655. */
  111656. getBodyRestitution(impostor: PhysicsImpostor): number;
  111657. /**
  111658. * Sets resitution of the impostor
  111659. * @param impostor impostor to set resitution on
  111660. * @param restitution resitution value
  111661. */
  111662. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  111663. /**
  111664. * Gets pressure inside the impostor
  111665. * @param impostor impostor to get pressure from
  111666. * @returns pressure value
  111667. */
  111668. getBodyPressure(impostor: PhysicsImpostor): number;
  111669. /**
  111670. * Sets pressure inside a soft body impostor
  111671. * Cloth and rope must remain 0 pressure
  111672. * @param impostor impostor to set pressure on
  111673. * @param pressure pressure value
  111674. */
  111675. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  111676. /**
  111677. * Gets stiffness of the impostor
  111678. * @param impostor impostor to get stiffness from
  111679. * @returns pressure value
  111680. */
  111681. getBodyStiffness(impostor: PhysicsImpostor): number;
  111682. /**
  111683. * Sets stiffness of the impostor
  111684. * @param impostor impostor to set stiffness on
  111685. * @param stiffness stiffness value from 0 to 1
  111686. */
  111687. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  111688. /**
  111689. * Gets velocityIterations of the impostor
  111690. * @param impostor impostor to get velocity iterations from
  111691. * @returns velocityIterations value
  111692. */
  111693. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  111694. /**
  111695. * Sets velocityIterations of the impostor
  111696. * @param impostor impostor to set velocity iterations on
  111697. * @param velocityIterations velocityIterations value
  111698. */
  111699. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  111700. /**
  111701. * Gets positionIterations of the impostor
  111702. * @param impostor impostor to get position iterations from
  111703. * @returns positionIterations value
  111704. */
  111705. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  111706. /**
  111707. * Sets positionIterations of the impostor
  111708. * @param impostor impostor to set position on
  111709. * @param positionIterations positionIterations value
  111710. */
  111711. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  111712. /**
  111713. * Append an anchor to a cloth object
  111714. * @param impostor is the cloth impostor to add anchor to
  111715. * @param otherImpostor is the rigid impostor to anchor to
  111716. * @param width ratio across width from 0 to 1
  111717. * @param height ratio up height from 0 to 1
  111718. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  111719. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  111720. */
  111721. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  111722. /**
  111723. * Append an hook to a rope object
  111724. * @param impostor is the rope impostor to add hook to
  111725. * @param otherImpostor is the rigid impostor to hook to
  111726. * @param length ratio along the rope from 0 to 1
  111727. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  111728. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  111729. */
  111730. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  111731. /**
  111732. * Sleeps the physics body and stops it from being active
  111733. * @param impostor impostor to sleep
  111734. */
  111735. sleepBody(impostor: PhysicsImpostor): void;
  111736. /**
  111737. * Activates the physics body
  111738. * @param impostor impostor to activate
  111739. */
  111740. wakeUpBody(impostor: PhysicsImpostor): void;
  111741. /**
  111742. * Updates the distance parameters of the joint
  111743. * @param joint joint to update
  111744. * @param maxDistance maximum distance of the joint
  111745. * @param minDistance minimum distance of the joint
  111746. */
  111747. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  111748. /**
  111749. * Sets a motor on the joint
  111750. * @param joint joint to set motor on
  111751. * @param speed speed of the motor
  111752. * @param maxForce maximum force of the motor
  111753. * @param motorIndex index of the motor
  111754. */
  111755. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  111756. /**
  111757. * Sets the motors limit
  111758. * @param joint joint to set limit on
  111759. * @param upperLimit upper limit
  111760. * @param lowerLimit lower limit
  111761. */
  111762. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  111763. /**
  111764. * Syncs the position and rotation of a mesh with the impostor
  111765. * @param mesh mesh to sync
  111766. * @param impostor impostor to update the mesh with
  111767. */
  111768. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  111769. /**
  111770. * Gets the radius of the impostor
  111771. * @param impostor impostor to get radius from
  111772. * @returns the radius
  111773. */
  111774. getRadius(impostor: PhysicsImpostor): number;
  111775. /**
  111776. * Gets the box size of the impostor
  111777. * @param impostor impostor to get box size from
  111778. * @param result the resulting box size
  111779. */
  111780. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  111781. /**
  111782. * Disposes of the impostor
  111783. */
  111784. dispose(): void;
  111785. /**
  111786. * Does a raycast in the physics world
  111787. * @param from when should the ray start?
  111788. * @param to when should the ray end?
  111789. * @returns PhysicsRaycastResult
  111790. */
  111791. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  111792. }
  111793. }
  111794. declare module BABYLON {
  111795. interface AbstractScene {
  111796. /**
  111797. * The list of reflection probes added to the scene
  111798. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  111799. */
  111800. reflectionProbes: Array<ReflectionProbe>;
  111801. /**
  111802. * Removes the given reflection probe from this scene.
  111803. * @param toRemove The reflection probe to remove
  111804. * @returns The index of the removed reflection probe
  111805. */
  111806. removeReflectionProbe(toRemove: ReflectionProbe): number;
  111807. /**
  111808. * Adds the given reflection probe to this scene.
  111809. * @param newReflectionProbe The reflection probe to add
  111810. */
  111811. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  111812. }
  111813. /**
  111814. * Class used to generate realtime reflection / refraction cube textures
  111815. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  111816. */
  111817. export class ReflectionProbe {
  111818. /** defines the name of the probe */
  111819. name: string;
  111820. private _scene;
  111821. private _renderTargetTexture;
  111822. private _projectionMatrix;
  111823. private _viewMatrix;
  111824. private _target;
  111825. private _add;
  111826. private _attachedMesh;
  111827. private _invertYAxis;
  111828. /** Gets or sets probe position (center of the cube map) */
  111829. position: Vector3;
  111830. /**
  111831. * Creates a new reflection probe
  111832. * @param name defines the name of the probe
  111833. * @param size defines the texture resolution (for each face)
  111834. * @param scene defines the hosting scene
  111835. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  111836. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  111837. */
  111838. constructor(
  111839. /** defines the name of the probe */
  111840. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  111841. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  111842. samples: number;
  111843. /** Gets or sets the refresh rate to use (on every frame by default) */
  111844. refreshRate: number;
  111845. /**
  111846. * Gets the hosting scene
  111847. * @returns a Scene
  111848. */
  111849. getScene(): Scene;
  111850. /** Gets the internal CubeTexture used to render to */
  111851. readonly cubeTexture: RenderTargetTexture;
  111852. /** Gets the list of meshes to render */
  111853. readonly renderList: Nullable<AbstractMesh[]>;
  111854. /**
  111855. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  111856. * @param mesh defines the mesh to attach to
  111857. */
  111858. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  111859. /**
  111860. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  111861. * @param renderingGroupId The rendering group id corresponding to its index
  111862. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  111863. */
  111864. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  111865. /**
  111866. * Clean all associated resources
  111867. */
  111868. dispose(): void;
  111869. /**
  111870. * Converts the reflection probe information to a readable string for debug purpose.
  111871. * @param fullDetails Supports for multiple levels of logging within scene loading
  111872. * @returns the human readable reflection probe info
  111873. */
  111874. toString(fullDetails?: boolean): string;
  111875. /**
  111876. * Get the class name of the relfection probe.
  111877. * @returns "ReflectionProbe"
  111878. */
  111879. getClassName(): string;
  111880. /**
  111881. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  111882. * @returns The JSON representation of the texture
  111883. */
  111884. serialize(): any;
  111885. /**
  111886. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  111887. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  111888. * @param scene Define the scene the parsed reflection probe should be instantiated in
  111889. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  111890. * @returns The parsed reflection probe if successful
  111891. */
  111892. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  111893. }
  111894. }
  111895. declare module BABYLON {
  111896. /** @hidden */
  111897. export var _BabylonLoaderRegistered: boolean;
  111898. }
  111899. declare module BABYLON {
  111900. /**
  111901. * The Physically based simple base material of BJS.
  111902. *
  111903. * This enables better naming and convention enforcements on top of the pbrMaterial.
  111904. * It is used as the base class for both the specGloss and metalRough conventions.
  111905. */
  111906. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  111907. /**
  111908. * Number of Simultaneous lights allowed on the material.
  111909. */
  111910. maxSimultaneousLights: number;
  111911. /**
  111912. * If sets to true, disables all the lights affecting the material.
  111913. */
  111914. disableLighting: boolean;
  111915. /**
  111916. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  111917. */
  111918. environmentTexture: BaseTexture;
  111919. /**
  111920. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  111921. */
  111922. invertNormalMapX: boolean;
  111923. /**
  111924. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  111925. */
  111926. invertNormalMapY: boolean;
  111927. /**
  111928. * Normal map used in the model.
  111929. */
  111930. normalTexture: BaseTexture;
  111931. /**
  111932. * Emissivie color used to self-illuminate the model.
  111933. */
  111934. emissiveColor: Color3;
  111935. /**
  111936. * Emissivie texture used to self-illuminate the model.
  111937. */
  111938. emissiveTexture: BaseTexture;
  111939. /**
  111940. * Occlusion Channel Strenght.
  111941. */
  111942. occlusionStrength: number;
  111943. /**
  111944. * Occlusion Texture of the material (adding extra occlusion effects).
  111945. */
  111946. occlusionTexture: BaseTexture;
  111947. /**
  111948. * Defines the alpha limits in alpha test mode.
  111949. */
  111950. alphaCutOff: number;
  111951. /**
  111952. * Gets the current double sided mode.
  111953. */
  111954. /**
  111955. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  111956. */
  111957. doubleSided: boolean;
  111958. /**
  111959. * Stores the pre-calculated light information of a mesh in a texture.
  111960. */
  111961. lightmapTexture: BaseTexture;
  111962. /**
  111963. * If true, the light map contains occlusion information instead of lighting info.
  111964. */
  111965. useLightmapAsShadowmap: boolean;
  111966. /**
  111967. * Instantiates a new PBRMaterial instance.
  111968. *
  111969. * @param name The material name
  111970. * @param scene The scene the material will be use in.
  111971. */
  111972. constructor(name: string, scene: Scene);
  111973. getClassName(): string;
  111974. }
  111975. }
  111976. declare module BABYLON {
  111977. /**
  111978. * The PBR material of BJS following the metal roughness convention.
  111979. *
  111980. * This fits to the PBR convention in the GLTF definition:
  111981. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  111982. */
  111983. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  111984. /**
  111985. * The base color has two different interpretations depending on the value of metalness.
  111986. * When the material is a metal, the base color is the specific measured reflectance value
  111987. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  111988. * of the material.
  111989. */
  111990. baseColor: Color3;
  111991. /**
  111992. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  111993. * well as opacity information in the alpha channel.
  111994. */
  111995. baseTexture: BaseTexture;
  111996. /**
  111997. * Specifies the metallic scalar value of the material.
  111998. * Can also be used to scale the metalness values of the metallic texture.
  111999. */
  112000. metallic: number;
  112001. /**
  112002. * Specifies the roughness scalar value of the material.
  112003. * Can also be used to scale the roughness values of the metallic texture.
  112004. */
  112005. roughness: number;
  112006. /**
  112007. * Texture containing both the metallic value in the B channel and the
  112008. * roughness value in the G channel to keep better precision.
  112009. */
  112010. metallicRoughnessTexture: BaseTexture;
  112011. /**
  112012. * Instantiates a new PBRMetalRoughnessMaterial instance.
  112013. *
  112014. * @param name The material name
  112015. * @param scene The scene the material will be use in.
  112016. */
  112017. constructor(name: string, scene: Scene);
  112018. /**
  112019. * Return the currrent class name of the material.
  112020. */
  112021. getClassName(): string;
  112022. /**
  112023. * Makes a duplicate of the current material.
  112024. * @param name - name to use for the new material.
  112025. */
  112026. clone(name: string): PBRMetallicRoughnessMaterial;
  112027. /**
  112028. * Serialize the material to a parsable JSON object.
  112029. */
  112030. serialize(): any;
  112031. /**
  112032. * Parses a JSON object correponding to the serialize function.
  112033. */
  112034. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  112035. }
  112036. }
  112037. declare module BABYLON {
  112038. /**
  112039. * The PBR material of BJS following the specular glossiness convention.
  112040. *
  112041. * This fits to the PBR convention in the GLTF definition:
  112042. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  112043. */
  112044. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  112045. /**
  112046. * Specifies the diffuse color of the material.
  112047. */
  112048. diffuseColor: Color3;
  112049. /**
  112050. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  112051. * channel.
  112052. */
  112053. diffuseTexture: BaseTexture;
  112054. /**
  112055. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  112056. */
  112057. specularColor: Color3;
  112058. /**
  112059. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  112060. */
  112061. glossiness: number;
  112062. /**
  112063. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  112064. */
  112065. specularGlossinessTexture: BaseTexture;
  112066. /**
  112067. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  112068. *
  112069. * @param name The material name
  112070. * @param scene The scene the material will be use in.
  112071. */
  112072. constructor(name: string, scene: Scene);
  112073. /**
  112074. * Return the currrent class name of the material.
  112075. */
  112076. getClassName(): string;
  112077. /**
  112078. * Makes a duplicate of the current material.
  112079. * @param name - name to use for the new material.
  112080. */
  112081. clone(name: string): PBRSpecularGlossinessMaterial;
  112082. /**
  112083. * Serialize the material to a parsable JSON object.
  112084. */
  112085. serialize(): any;
  112086. /**
  112087. * Parses a JSON object correponding to the serialize function.
  112088. */
  112089. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  112090. }
  112091. }
  112092. declare module BABYLON {
  112093. /**
  112094. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  112095. * It can help converting any input color in a desired output one. This can then be used to create effects
  112096. * from sepia, black and white to sixties or futuristic rendering...
  112097. *
  112098. * The only supported format is currently 3dl.
  112099. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  112100. */
  112101. export class ColorGradingTexture extends BaseTexture {
  112102. /**
  112103. * The current texture matrix. (will always be identity in color grading texture)
  112104. */
  112105. private _textureMatrix;
  112106. /**
  112107. * The texture URL.
  112108. */
  112109. url: string;
  112110. /**
  112111. * Empty line regex stored for GC.
  112112. */
  112113. private static _noneEmptyLineRegex;
  112114. private _engine;
  112115. /**
  112116. * Instantiates a ColorGradingTexture from the following parameters.
  112117. *
  112118. * @param url The location of the color gradind data (currently only supporting 3dl)
  112119. * @param scene The scene the texture will be used in
  112120. */
  112121. constructor(url: string, scene: Scene);
  112122. /**
  112123. * Returns the texture matrix used in most of the material.
  112124. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  112125. */
  112126. getTextureMatrix(): Matrix;
  112127. /**
  112128. * Occurs when the file being loaded is a .3dl LUT file.
  112129. */
  112130. private load3dlTexture;
  112131. /**
  112132. * Starts the loading process of the texture.
  112133. */
  112134. private loadTexture;
  112135. /**
  112136. * Clones the color gradind texture.
  112137. */
  112138. clone(): ColorGradingTexture;
  112139. /**
  112140. * Called during delayed load for textures.
  112141. */
  112142. delayLoad(): void;
  112143. /**
  112144. * Parses a color grading texture serialized by Babylon.
  112145. * @param parsedTexture The texture information being parsedTexture
  112146. * @param scene The scene to load the texture in
  112147. * @param rootUrl The root url of the data assets to load
  112148. * @return A color gradind texture
  112149. */
  112150. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  112151. /**
  112152. * Serializes the LUT texture to json format.
  112153. */
  112154. serialize(): any;
  112155. }
  112156. }
  112157. declare module BABYLON {
  112158. /**
  112159. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  112160. */
  112161. export class EquiRectangularCubeTexture extends BaseTexture {
  112162. /** The six faces of the cube. */
  112163. private static _FacesMapping;
  112164. private _noMipmap;
  112165. private _onLoad;
  112166. private _onError;
  112167. /** The size of the cubemap. */
  112168. private _size;
  112169. /** The buffer of the image. */
  112170. private _buffer;
  112171. /** The width of the input image. */
  112172. private _width;
  112173. /** The height of the input image. */
  112174. private _height;
  112175. /** The URL to the image. */
  112176. url: string;
  112177. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  112178. coordinatesMode: number;
  112179. /**
  112180. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  112181. * @param url The location of the image
  112182. * @param scene The scene the texture will be used in
  112183. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  112184. * @param noMipmap Forces to not generate the mipmap if true
  112185. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  112186. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  112187. * @param onLoad — defines a callback called when texture is loaded
  112188. * @param onError — defines a callback called if there is an error
  112189. */
  112190. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  112191. /**
  112192. * Load the image data, by putting the image on a canvas and extracting its buffer.
  112193. */
  112194. private loadImage;
  112195. /**
  112196. * Convert the image buffer into a cubemap and create a CubeTexture.
  112197. */
  112198. private loadTexture;
  112199. /**
  112200. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  112201. * @param buffer The ArrayBuffer that should be converted.
  112202. * @returns The buffer as Float32Array.
  112203. */
  112204. private getFloat32ArrayFromArrayBuffer;
  112205. /**
  112206. * Get the current class name of the texture useful for serialization or dynamic coding.
  112207. * @returns "EquiRectangularCubeTexture"
  112208. */
  112209. getClassName(): string;
  112210. /**
  112211. * Create a clone of the current EquiRectangularCubeTexture and return it.
  112212. * @returns A clone of the current EquiRectangularCubeTexture.
  112213. */
  112214. clone(): EquiRectangularCubeTexture;
  112215. }
  112216. }
  112217. declare module BABYLON {
  112218. /**
  112219. * Based on jsTGALoader - Javascript loader for TGA file
  112220. * By Vincent Thibault
  112221. * @see http://blog.robrowser.com/javascript-tga-loader.html
  112222. */
  112223. export class TGATools {
  112224. private static _TYPE_INDEXED;
  112225. private static _TYPE_RGB;
  112226. private static _TYPE_GREY;
  112227. private static _TYPE_RLE_INDEXED;
  112228. private static _TYPE_RLE_RGB;
  112229. private static _TYPE_RLE_GREY;
  112230. private static _ORIGIN_MASK;
  112231. private static _ORIGIN_SHIFT;
  112232. private static _ORIGIN_BL;
  112233. private static _ORIGIN_BR;
  112234. private static _ORIGIN_UL;
  112235. private static _ORIGIN_UR;
  112236. /**
  112237. * Gets the header of a TGA file
  112238. * @param data defines the TGA data
  112239. * @returns the header
  112240. */
  112241. static GetTGAHeader(data: Uint8Array): any;
  112242. /**
  112243. * Uploads TGA content to a Babylon Texture
  112244. * @hidden
  112245. */
  112246. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  112247. /** @hidden */
  112248. 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;
  112249. /** @hidden */
  112250. 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;
  112251. /** @hidden */
  112252. 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;
  112253. /** @hidden */
  112254. 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;
  112255. /** @hidden */
  112256. 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;
  112257. /** @hidden */
  112258. 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;
  112259. }
  112260. }
  112261. declare module BABYLON {
  112262. /**
  112263. * Implementation of the TGA Texture Loader.
  112264. * @hidden
  112265. */
  112266. export class _TGATextureLoader implements IInternalTextureLoader {
  112267. /**
  112268. * Defines wether the loader supports cascade loading the different faces.
  112269. */
  112270. readonly supportCascades: boolean;
  112271. /**
  112272. * This returns if the loader support the current file information.
  112273. * @param extension defines the file extension of the file being loaded
  112274. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112275. * @param fallback defines the fallback internal texture if any
  112276. * @param isBase64 defines whether the texture is encoded as a base64
  112277. * @param isBuffer defines whether the texture data are stored as a buffer
  112278. * @returns true if the loader can load the specified file
  112279. */
  112280. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  112281. /**
  112282. * Transform the url before loading if required.
  112283. * @param rootUrl the url of the texture
  112284. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112285. * @returns the transformed texture
  112286. */
  112287. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  112288. /**
  112289. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  112290. * @param rootUrl the url of the texture
  112291. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112292. * @returns the fallback texture
  112293. */
  112294. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  112295. /**
  112296. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  112297. * @param data contains the texture data
  112298. * @param texture defines the BabylonJS internal texture
  112299. * @param createPolynomials will be true if polynomials have been requested
  112300. * @param onLoad defines the callback to trigger once the texture is ready
  112301. * @param onError defines the callback to trigger in case of error
  112302. */
  112303. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  112304. /**
  112305. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  112306. * @param data contains the texture data
  112307. * @param texture defines the BabylonJS internal texture
  112308. * @param callback defines the method to call once ready to upload
  112309. */
  112310. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  112311. }
  112312. }
  112313. declare module BABYLON {
  112314. /**
  112315. * 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.
  112316. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  112317. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  112318. */
  112319. export class CustomProceduralTexture extends ProceduralTexture {
  112320. private _animate;
  112321. private _time;
  112322. private _config;
  112323. private _texturePath;
  112324. /**
  112325. * Instantiates a new Custom Procedural Texture.
  112326. * 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.
  112327. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  112328. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  112329. * @param name Define the name of the texture
  112330. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  112331. * @param size Define the size of the texture to create
  112332. * @param scene Define the scene the texture belongs to
  112333. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  112334. * @param generateMipMaps Define if the texture should creates mip maps or not
  112335. */
  112336. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  112337. private _loadJson;
  112338. /**
  112339. * Is the texture ready to be used ? (rendered at least once)
  112340. * @returns true if ready, otherwise, false.
  112341. */
  112342. isReady(): boolean;
  112343. /**
  112344. * Render the texture to its associated render target.
  112345. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  112346. */
  112347. render(useCameraPostProcess?: boolean): void;
  112348. /**
  112349. * Update the list of dependant textures samplers in the shader.
  112350. */
  112351. updateTextures(): void;
  112352. /**
  112353. * Update the uniform values of the procedural texture in the shader.
  112354. */
  112355. updateShaderUniforms(): void;
  112356. /**
  112357. * Define if the texture animates or not.
  112358. */
  112359. animate: boolean;
  112360. }
  112361. }
  112362. declare module BABYLON {
  112363. /** @hidden */
  112364. export var noisePixelShader: {
  112365. name: string;
  112366. shader: string;
  112367. };
  112368. }
  112369. declare module BABYLON {
  112370. /**
  112371. * Class used to generate noise procedural textures
  112372. */
  112373. export class NoiseProceduralTexture extends ProceduralTexture {
  112374. private _time;
  112375. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  112376. brightness: number;
  112377. /** Defines the number of octaves to process */
  112378. octaves: number;
  112379. /** Defines the level of persistence (0.8 by default) */
  112380. persistence: number;
  112381. /** Gets or sets animation speed factor (default is 1) */
  112382. animationSpeedFactor: number;
  112383. /**
  112384. * Creates a new NoiseProceduralTexture
  112385. * @param name defines the name fo the texture
  112386. * @param size defines the size of the texture (default is 256)
  112387. * @param scene defines the hosting scene
  112388. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  112389. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  112390. */
  112391. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  112392. private _updateShaderUniforms;
  112393. protected _getDefines(): string;
  112394. /** Generate the current state of the procedural texture */
  112395. render(useCameraPostProcess?: boolean): void;
  112396. /**
  112397. * Serializes this noise procedural texture
  112398. * @returns a serialized noise procedural texture object
  112399. */
  112400. serialize(): any;
  112401. /**
  112402. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  112403. * @param parsedTexture defines parsed texture data
  112404. * @param scene defines the current scene
  112405. * @param rootUrl defines the root URL containing noise procedural texture information
  112406. * @returns a parsed NoiseProceduralTexture
  112407. */
  112408. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  112409. }
  112410. }
  112411. declare module BABYLON {
  112412. /**
  112413. * Raw cube texture where the raw buffers are passed in
  112414. */
  112415. export class RawCubeTexture extends CubeTexture {
  112416. /**
  112417. * Creates a cube texture where the raw buffers are passed in.
  112418. * @param scene defines the scene the texture is attached to
  112419. * @param data defines the array of data to use to create each face
  112420. * @param size defines the size of the textures
  112421. * @param format defines the format of the data
  112422. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  112423. * @param generateMipMaps defines if the engine should generate the mip levels
  112424. * @param invertY defines if data must be stored with Y axis inverted
  112425. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  112426. * @param compression defines the compression used (null by default)
  112427. */
  112428. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  112429. /**
  112430. * Updates the raw cube texture.
  112431. * @param data defines the data to store
  112432. * @param format defines the data format
  112433. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  112434. * @param invertY defines if data must be stored with Y axis inverted
  112435. * @param compression defines the compression used (null by default)
  112436. * @param level defines which level of the texture to update
  112437. */
  112438. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  112439. /**
  112440. * Updates a raw cube texture with RGBD encoded data.
  112441. * @param data defines the array of data [mipmap][face] to use to create each face
  112442. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  112443. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  112444. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  112445. * @returns a promsie that resolves when the operation is complete
  112446. */
  112447. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  112448. /**
  112449. * Clones the raw cube texture.
  112450. * @return a new cube texture
  112451. */
  112452. clone(): CubeTexture;
  112453. /** @hidden */
  112454. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  112455. }
  112456. }
  112457. declare module BABYLON {
  112458. /**
  112459. * Class used to store 3D textures containing user data
  112460. */
  112461. export class RawTexture3D extends Texture {
  112462. /** Gets or sets the texture format to use */
  112463. format: number;
  112464. private _engine;
  112465. /**
  112466. * Create a new RawTexture3D
  112467. * @param data defines the data of the texture
  112468. * @param width defines the width of the texture
  112469. * @param height defines the height of the texture
  112470. * @param depth defines the depth of the texture
  112471. * @param format defines the texture format to use
  112472. * @param scene defines the hosting scene
  112473. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  112474. * @param invertY defines if texture must be stored with Y axis inverted
  112475. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  112476. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  112477. */
  112478. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  112479. /** Gets or sets the texture format to use */
  112480. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  112481. /**
  112482. * Update the texture with new data
  112483. * @param data defines the data to store in the texture
  112484. */
  112485. update(data: ArrayBufferView): void;
  112486. }
  112487. }
  112488. declare module BABYLON {
  112489. /**
  112490. * Creates a refraction texture used by refraction channel of the standard material.
  112491. * It is like a mirror but to see through a material.
  112492. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  112493. */
  112494. export class RefractionTexture extends RenderTargetTexture {
  112495. /**
  112496. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  112497. * 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.
  112498. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  112499. */
  112500. refractionPlane: Plane;
  112501. /**
  112502. * Define how deep under the surface we should see.
  112503. */
  112504. depth: number;
  112505. /**
  112506. * Creates a refraction texture used by refraction channel of the standard material.
  112507. * It is like a mirror but to see through a material.
  112508. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  112509. * @param name Define the texture name
  112510. * @param size Define the size of the underlying texture
  112511. * @param scene Define the scene the refraction belongs to
  112512. * @param generateMipMaps Define if we need to generate mips level for the refraction
  112513. */
  112514. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  112515. /**
  112516. * Clone the refraction texture.
  112517. * @returns the cloned texture
  112518. */
  112519. clone(): RefractionTexture;
  112520. /**
  112521. * Serialize the texture to a JSON representation you could use in Parse later on
  112522. * @returns the serialized JSON representation
  112523. */
  112524. serialize(): any;
  112525. }
  112526. }
  112527. declare module BABYLON {
  112528. /**
  112529. * Defines the options related to the creation of an HtmlElementTexture
  112530. */
  112531. export interface IHtmlElementTextureOptions {
  112532. /**
  112533. * Defines wether mip maps should be created or not.
  112534. */
  112535. generateMipMaps?: boolean;
  112536. /**
  112537. * Defines the sampling mode of the texture.
  112538. */
  112539. samplingMode?: number;
  112540. /**
  112541. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  112542. */
  112543. engine: Nullable<Engine>;
  112544. /**
  112545. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  112546. */
  112547. scene: Nullable<Scene>;
  112548. }
  112549. /**
  112550. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  112551. * To be as efficient as possible depending on your constraints nothing aside the first upload
  112552. * is automatically managed.
  112553. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  112554. * in your application.
  112555. *
  112556. * As the update is not automatic, you need to call them manually.
  112557. */
  112558. export class HtmlElementTexture extends BaseTexture {
  112559. /**
  112560. * The texture URL.
  112561. */
  112562. element: HTMLVideoElement | HTMLCanvasElement;
  112563. private static readonly DefaultOptions;
  112564. private _textureMatrix;
  112565. private _engine;
  112566. private _isVideo;
  112567. private _generateMipMaps;
  112568. private _samplingMode;
  112569. /**
  112570. * Instantiates a HtmlElementTexture from the following parameters.
  112571. *
  112572. * @param name Defines the name of the texture
  112573. * @param element Defines the video or canvas the texture is filled with
  112574. * @param options Defines the other none mandatory texture creation options
  112575. */
  112576. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  112577. private _createInternalTexture;
  112578. /**
  112579. * Returns the texture matrix used in most of the material.
  112580. */
  112581. getTextureMatrix(): Matrix;
  112582. /**
  112583. * Updates the content of the texture.
  112584. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  112585. */
  112586. update(invertY?: Nullable<boolean>): void;
  112587. }
  112588. }
  112589. declare module BABYLON {
  112590. /**
  112591. * Enum used to define the target of a block
  112592. */
  112593. export enum NodeMaterialBlockTargets {
  112594. /** Vertex shader */
  112595. Vertex = 1,
  112596. /** Fragment shader */
  112597. Fragment = 2,
  112598. /** Vertex and Fragment */
  112599. VertexAndFragment = 3
  112600. }
  112601. }
  112602. declare module BABYLON {
  112603. /**
  112604. * Defines the kind of connection point for node based material
  112605. */
  112606. export enum NodeMaterialBlockConnectionPointTypes {
  112607. /** Float */
  112608. Float = 1,
  112609. /** Int */
  112610. Int = 2,
  112611. /** Vector2 */
  112612. Vector2 = 4,
  112613. /** Vector3 */
  112614. Vector3 = 8,
  112615. /** Vector4 */
  112616. Vector4 = 16,
  112617. /** Color3 */
  112618. Color3 = 32,
  112619. /** Color4 */
  112620. Color4 = 64,
  112621. /** Matrix */
  112622. Matrix = 128,
  112623. /** Texture */
  112624. Texture = 256,
  112625. /** Texture3D */
  112626. Texture3D = 512,
  112627. /** Vector3 or Color3 */
  112628. Vector3OrColor3 = 40,
  112629. /** Vector3 or Vector4 */
  112630. Vector3OrVector4 = 24,
  112631. /** Vector4 or Color4 */
  112632. Vector4OrColor4 = 80,
  112633. /** Color3 or Color4 */
  112634. Color3OrColor4 = 96,
  112635. /** Vector3 or Color3 */
  112636. Vector3OrColor3OrVector4OrColor4 = 120
  112637. }
  112638. }
  112639. declare module BABYLON {
  112640. /**
  112641. * Enum used to define well known values e.g. values automatically provided by the system
  112642. */
  112643. export enum NodeMaterialWellKnownValues {
  112644. /** World */
  112645. World = 1,
  112646. /** View */
  112647. View = 2,
  112648. /** Projection */
  112649. Projection = 3,
  112650. /** ViewProjection */
  112651. ViewProjection = 4,
  112652. /** WorldView */
  112653. WorldView = 5,
  112654. /** WorldViewProjection */
  112655. WorldViewProjection = 6,
  112656. /** Will be filled by the block itself */
  112657. Automatic = 7
  112658. }
  112659. }
  112660. declare module BABYLON {
  112661. /**
  112662. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  112663. */
  112664. export enum NodeMaterialBlockConnectionPointMode {
  112665. /** Value is an uniform */
  112666. Uniform = 0,
  112667. /** Value is a mesh attribute */
  112668. Attribute = 1,
  112669. /** Value is a varying between vertex and fragment shaders */
  112670. Varying = 2,
  112671. /** Mode is undefined */
  112672. Undefined = 3
  112673. }
  112674. }
  112675. declare module BABYLON {
  112676. /**
  112677. * Class used to store shared data between 2 NodeMaterialBuildState
  112678. */
  112679. export class NodeMaterialBuildStateSharedData {
  112680. /**
  112681. * Gets the list of emitted varyings
  112682. */
  112683. varyings: string[];
  112684. /**
  112685. * Gets the varying declaration string
  112686. */
  112687. varyingDeclaration: string;
  112688. /**
  112689. * Uniform connection points
  112690. */
  112691. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  112692. /**
  112693. * Bindable blocks (Blocks that need to set data to the effect)
  112694. */
  112695. bindableBlocks: NodeMaterialBlock[];
  112696. /**
  112697. * List of blocks that can provide a compilation fallback
  112698. */
  112699. blocksWithFallbacks: NodeMaterialBlock[];
  112700. /**
  112701. * List of blocks that can provide a define update
  112702. */
  112703. blocksWithDefines: NodeMaterialBlock[];
  112704. /**
  112705. * List of blocks that can provide a repeatable content
  112706. */
  112707. repeatableContentBlocks: NodeMaterialBlock[];
  112708. /**
  112709. * List of blocks that can block the isReady function for the material
  112710. */
  112711. blockingBlocks: NodeMaterialBlock[];
  112712. /**
  112713. * Build Id used to avoid multiple recompilations
  112714. */
  112715. buildId: number;
  112716. /** List of emitted variables */
  112717. variableNames: {
  112718. [key: string]: number;
  112719. };
  112720. /** List of emitted defines */
  112721. defineNames: {
  112722. [key: string]: number;
  112723. };
  112724. /** Should emit comments? */
  112725. emitComments: boolean;
  112726. /** Emit build activity */
  112727. verbose: boolean;
  112728. /**
  112729. * Gets the compilation hints emitted at compilation time
  112730. */
  112731. hints: {
  112732. needWorldViewMatrix: boolean;
  112733. needWorldViewProjectionMatrix: boolean;
  112734. needAlphaBlending: boolean;
  112735. needAlphaTesting: boolean;
  112736. };
  112737. /**
  112738. * List of compilation checks
  112739. */
  112740. checks: {
  112741. emitVertex: boolean;
  112742. emitFragment: boolean;
  112743. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  112744. };
  112745. /** Creates a new shared data */
  112746. constructor();
  112747. /**
  112748. * Emits console errors and exceptions if there is a failing check
  112749. */
  112750. emitErrors(): void;
  112751. }
  112752. }
  112753. declare module BABYLON {
  112754. /**
  112755. * Class used to store node based material build state
  112756. */
  112757. export class NodeMaterialBuildState {
  112758. /**
  112759. * Gets the list of emitted attributes
  112760. */
  112761. attributes: string[];
  112762. /**
  112763. * Gets the list of emitted uniforms
  112764. */
  112765. uniforms: string[];
  112766. /**
  112767. * Gets the list of emitted samplers
  112768. */
  112769. samplers: string[];
  112770. /**
  112771. * Gets the list of emitted functions
  112772. */
  112773. functions: {
  112774. [key: string]: string;
  112775. };
  112776. /**
  112777. * Gets the target of the compilation state
  112778. */
  112779. target: NodeMaterialBlockTargets;
  112780. /**
  112781. * Shared data between multiple NodeMaterialBuildState instances
  112782. */
  112783. sharedData: NodeMaterialBuildStateSharedData;
  112784. /** @hidden */
  112785. _vertexState: NodeMaterialBuildState;
  112786. private _attributeDeclaration;
  112787. private _uniformDeclaration;
  112788. private _samplerDeclaration;
  112789. private _varyingTransfer;
  112790. private _repeatableContentAnchorIndex;
  112791. /** @hidden */
  112792. _builtCompilationString: string;
  112793. /**
  112794. * Gets the emitted compilation strings
  112795. */
  112796. compilationString: string;
  112797. /**
  112798. * Finalize the compilation strings
  112799. * @param state defines the current compilation state
  112800. */
  112801. finalize(state: NodeMaterialBuildState): void;
  112802. /** @hidden */
  112803. readonly _repeatableContentAnchor: string;
  112804. /** @hidden */
  112805. _getFreeVariableName(prefix: string): string;
  112806. /** @hidden */
  112807. _getFreeDefineName(prefix: string): string;
  112808. /** @hidden */
  112809. _excludeVariableName(name: string): void;
  112810. /** @hidden */
  112811. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  112812. /** @hidden */
  112813. _emitFunction(name: string, code: string, comments: string): void;
  112814. /** @hidden */
  112815. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  112816. replaceStrings?: {
  112817. search: RegExp;
  112818. replace: string;
  112819. }[];
  112820. }): string;
  112821. /** @hidden */
  112822. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  112823. repeatKey?: string;
  112824. removeAttributes?: boolean;
  112825. removeUniforms?: boolean;
  112826. removeVaryings?: boolean;
  112827. removeIfDef?: boolean;
  112828. replaceStrings?: {
  112829. search: RegExp;
  112830. replace: string;
  112831. }[];
  112832. }): void;
  112833. /** @hidden */
  112834. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string): void;
  112835. private _emitDefine;
  112836. /** @hidden */
  112837. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  112838. }
  112839. }
  112840. declare module BABYLON {
  112841. /**
  112842. * Root class for all node material optimizers
  112843. */
  112844. export class NodeMaterialOptimizer {
  112845. /**
  112846. * Function used to optimize a NodeMaterial graph
  112847. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  112848. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  112849. */
  112850. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  112851. }
  112852. }
  112853. declare module BABYLON {
  112854. /**
  112855. * Block used to transform a vector4 with a matrix
  112856. */
  112857. export class Vector4TransformBlock extends NodeMaterialBlock {
  112858. /**
  112859. * Defines the value to use to complement Vector3 to transform it to a Vector4
  112860. */
  112861. complementW: number;
  112862. /**
  112863. * Creates a new Vector4TransformBlock
  112864. * @param name defines the block name
  112865. */
  112866. constructor(name: string);
  112867. /**
  112868. * Gets the current class name
  112869. * @returns the class name
  112870. */
  112871. getClassName(): string;
  112872. /**
  112873. * Gets the vector input
  112874. */
  112875. readonly vector: NodeMaterialConnectionPoint;
  112876. /**
  112877. * Gets the matrix transform input
  112878. */
  112879. readonly transform: NodeMaterialConnectionPoint;
  112880. protected _buildBlock(state: NodeMaterialBuildState): this;
  112881. }
  112882. }
  112883. declare module BABYLON {
  112884. /**
  112885. * Block used to output the vertex position
  112886. */
  112887. export class VertexOutputBlock extends NodeMaterialBlock {
  112888. /**
  112889. * Creates a new VertexOutputBlock
  112890. * @param name defines the block name
  112891. */
  112892. constructor(name: string);
  112893. /**
  112894. * Gets the current class name
  112895. * @returns the class name
  112896. */
  112897. getClassName(): string;
  112898. /**
  112899. * Gets the vector input component
  112900. */
  112901. readonly vector: NodeMaterialConnectionPoint;
  112902. protected _buildBlock(state: NodeMaterialBuildState): this;
  112903. }
  112904. }
  112905. declare module BABYLON {
  112906. /**
  112907. * Block used to output the final color
  112908. */
  112909. export class FragmentOutputBlock extends NodeMaterialBlock {
  112910. /**
  112911. * Gets or sets a boolean indicating if this block will output an alpha value
  112912. */
  112913. alphaBlendingEnabled: boolean;
  112914. /**
  112915. * Create a new FragmentOutputBlock
  112916. * @param name defines the block name
  112917. */
  112918. constructor(name: string);
  112919. /**
  112920. * Gets the current class name
  112921. * @returns the class name
  112922. */
  112923. getClassName(): string;
  112924. /**
  112925. * Gets the color input component
  112926. */
  112927. readonly color: NodeMaterialConnectionPoint;
  112928. protected _buildBlock(state: NodeMaterialBuildState): this;
  112929. }
  112930. }
  112931. declare module BABYLON {
  112932. /**
  112933. * Interface used to configure the node material editor
  112934. */
  112935. export interface INodeMaterialEditorOptions {
  112936. /** Define the URl to load node editor script */
  112937. editorURL?: string;
  112938. }
  112939. /** @hidden */
  112940. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  112941. /** BONES */
  112942. NUM_BONE_INFLUENCERS: number;
  112943. BonesPerMesh: number;
  112944. BONETEXTURE: boolean;
  112945. /** MORPH TARGETS */
  112946. MORPHTARGETS: boolean;
  112947. MORPHTARGETS_NORMAL: boolean;
  112948. MORPHTARGETS_TANGENT: boolean;
  112949. NUM_MORPH_INFLUENCERS: number;
  112950. /** IMAGE PROCESSING */
  112951. IMAGEPROCESSING: boolean;
  112952. VIGNETTE: boolean;
  112953. VIGNETTEBLENDMODEMULTIPLY: boolean;
  112954. VIGNETTEBLENDMODEOPAQUE: boolean;
  112955. TONEMAPPING: boolean;
  112956. TONEMAPPING_ACES: boolean;
  112957. CONTRAST: boolean;
  112958. EXPOSURE: boolean;
  112959. COLORCURVES: boolean;
  112960. COLORGRADING: boolean;
  112961. COLORGRADING3D: boolean;
  112962. SAMPLER3DGREENDEPTH: boolean;
  112963. SAMPLER3DBGRMAP: boolean;
  112964. IMAGEPROCESSINGPOSTPROCESS: boolean;
  112965. constructor();
  112966. setValue(name: string, value: boolean): void;
  112967. }
  112968. /**
  112969. * Class used to configure NodeMaterial
  112970. */
  112971. export interface INodeMaterialOptions {
  112972. /**
  112973. * Defines if blocks should emit comments
  112974. */
  112975. emitComments: boolean;
  112976. }
  112977. /**
  112978. * Class used to create a node based material built by assembling shader blocks
  112979. */
  112980. export class NodeMaterial extends PushMaterial {
  112981. private _options;
  112982. private _vertexCompilationState;
  112983. private _fragmentCompilationState;
  112984. private _sharedData;
  112985. private _buildId;
  112986. private _buildWasSuccessful;
  112987. private _cachedWorldViewMatrix;
  112988. private _cachedWorldViewProjectionMatrix;
  112989. private _textureConnectionPoints;
  112990. private _optimizers;
  112991. /** Define the URl to load node editor script */
  112992. static EditorURL: string;
  112993. private BJSNODEMATERIALEDITOR;
  112994. /** Get the inspector from bundle or global */
  112995. private _getGlobalNodeMaterialEditor;
  112996. /**
  112997. * Defines the maximum number of lights that can be used in the material
  112998. */
  112999. maxSimultaneousLights: number;
  113000. /**
  113001. * Observable raised when the material is built
  113002. */
  113003. onBuildObservable: Observable<NodeMaterial>;
  113004. /**
  113005. * Gets or sets the root nodes of the material vertex shader
  113006. */
  113007. _vertexOutputNodes: NodeMaterialBlock[];
  113008. /**
  113009. * Gets or sets the root nodes of the material fragment (pixel) shader
  113010. */
  113011. _fragmentOutputNodes: NodeMaterialBlock[];
  113012. /** Gets or sets options to control the node material overall behavior */
  113013. options: INodeMaterialOptions;
  113014. /**
  113015. * Default configuration related to image processing available in the standard Material.
  113016. */
  113017. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  113018. /**
  113019. * Gets the image processing configuration used either in this material.
  113020. */
  113021. /**
  113022. * Sets the Default image processing configuration used either in the this material.
  113023. *
  113024. * If sets to null, the scene one is in use.
  113025. */
  113026. imageProcessingConfiguration: ImageProcessingConfiguration;
  113027. /**
  113028. * Create a new node based material
  113029. * @param name defines the material name
  113030. * @param scene defines the hosting scene
  113031. * @param options defines creation option
  113032. */
  113033. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  113034. /**
  113035. * Gets the current class name of the material e.g. "NodeMaterial"
  113036. * @returns the class name
  113037. */
  113038. getClassName(): string;
  113039. /**
  113040. * Keep track of the image processing observer to allow dispose and replace.
  113041. */
  113042. private _imageProcessingObserver;
  113043. /**
  113044. * Attaches a new image processing configuration to the Standard Material.
  113045. * @param configuration
  113046. */
  113047. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  113048. /**
  113049. * Adds a new optimizer to the list of optimizers
  113050. * @param optimizer defines the optimizers to add
  113051. * @returns the current material
  113052. */
  113053. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  113054. /**
  113055. * Remove an optimizer from the list of optimizers
  113056. * @param optimizer defines the optimizers to remove
  113057. * @returns the current material
  113058. */
  113059. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  113060. /**
  113061. * Add a new block to the list of output nodes
  113062. * @param node defines the node to add
  113063. * @returns the current material
  113064. */
  113065. addOutputNode(node: NodeMaterialBlock): this;
  113066. /**
  113067. * Remove a block from the list of root nodes
  113068. * @param node defines the node to remove
  113069. * @returns the current material
  113070. */
  113071. removeOutputNode(node: NodeMaterialBlock): this;
  113072. private _addVertexOutputNode;
  113073. private _removeVertexOutputNode;
  113074. private _addFragmentOutputNode;
  113075. private _removeFragmentOutputNode;
  113076. /**
  113077. * Specifies if the material will require alpha blending
  113078. * @returns a boolean specifying if alpha blending is needed
  113079. */
  113080. needAlphaBlending(): boolean;
  113081. /**
  113082. * Specifies if this material should be rendered in alpha test mode
  113083. * @returns a boolean specifying if an alpha test is needed.
  113084. */
  113085. needAlphaTesting(): boolean;
  113086. private _initializeBlock;
  113087. private _resetDualBlocks;
  113088. /**
  113089. * Build the material and generates the inner effect
  113090. * @param verbose defines if the build should log activity
  113091. */
  113092. build(verbose?: boolean): void;
  113093. /**
  113094. * Runs an otpimization phase to try to improve the shader code
  113095. */
  113096. optimize(): void;
  113097. private _prepareDefinesForAttributes;
  113098. /**
  113099. * Get if the submesh is ready to be used and all its information available.
  113100. * Child classes can use it to update shaders
  113101. * @param mesh defines the mesh to check
  113102. * @param subMesh defines which submesh to check
  113103. * @param useInstances specifies that instances should be used
  113104. * @returns a boolean indicating that the submesh is ready or not
  113105. */
  113106. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  113107. /**
  113108. * Binds the world matrix to the material
  113109. * @param world defines the world transformation matrix
  113110. */
  113111. bindOnlyWorldMatrix(world: Matrix): void;
  113112. /**
  113113. * Binds the submesh to this material by preparing the effect and shader to draw
  113114. * @param world defines the world transformation matrix
  113115. * @param mesh defines the mesh containing the submesh
  113116. * @param subMesh defines the submesh to bind the material to
  113117. */
  113118. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  113119. /**
  113120. * Gets the active textures from the material
  113121. * @returns an array of textures
  113122. */
  113123. getActiveTextures(): BaseTexture[];
  113124. /**
  113125. * Specifies if the material uses a texture
  113126. * @param texture defines the texture to check against the material
  113127. * @returns a boolean specifying if the material uses the texture
  113128. */
  113129. hasTexture(texture: BaseTexture): boolean;
  113130. /**
  113131. * Disposes the material
  113132. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  113133. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  113134. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  113135. */
  113136. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  113137. /** Creates the node editor window. */
  113138. private _createNodeEditor;
  113139. /**
  113140. * Launch the node material editor
  113141. * @param config Define the configuration of the editor
  113142. * @return a promise fulfilled when the node editor is visible
  113143. */
  113144. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  113145. /**
  113146. * Clear the current material
  113147. */
  113148. clear(): void;
  113149. /**
  113150. * Clear the current material and set it to a default state
  113151. */
  113152. setToDefault(): void;
  113153. }
  113154. }
  113155. declare module BABYLON {
  113156. /**
  113157. * Defines a block that can be used inside a node based material
  113158. */
  113159. export class NodeMaterialBlock {
  113160. private _buildId;
  113161. private _target;
  113162. private _isFinalMerger;
  113163. /** @hidden */
  113164. _inputs: NodeMaterialConnectionPoint[];
  113165. /** @hidden */
  113166. _outputs: NodeMaterialConnectionPoint[];
  113167. /**
  113168. * Gets or sets the name of the block
  113169. */
  113170. name: string;
  113171. /**
  113172. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  113173. */
  113174. readonly isFinalMerger: boolean;
  113175. /**
  113176. * Gets or sets the build Id
  113177. */
  113178. buildId: number;
  113179. /**
  113180. * Gets or sets the target of the block
  113181. */
  113182. target: NodeMaterialBlockTargets;
  113183. /**
  113184. * Gets the list of input points
  113185. */
  113186. readonly inputs: NodeMaterialConnectionPoint[];
  113187. /** Gets the list of output points */
  113188. readonly outputs: NodeMaterialConnectionPoint[];
  113189. /**
  113190. * Find an input by its name
  113191. * @param name defines the name of the input to look for
  113192. * @returns the input or null if not found
  113193. */
  113194. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  113195. /**
  113196. * Find an output by its name
  113197. * @param name defines the name of the outputto look for
  113198. * @returns the output or null if not found
  113199. */
  113200. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  113201. /**
  113202. * Creates a new NodeMaterialBlock
  113203. * @param name defines the block name
  113204. * @param target defines the target of that block (Vertex by default)
  113205. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  113206. */
  113207. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  113208. /**
  113209. * Initialize the block and prepare the context for build
  113210. * @param state defines the state that will be used for the build
  113211. */
  113212. initialize(state: NodeMaterialBuildState): void;
  113213. /**
  113214. * Bind data to effect. Will only be called for blocks with isBindable === true
  113215. * @param effect defines the effect to bind data to
  113216. * @param nodeMaterial defines the hosting NodeMaterial
  113217. * @param mesh defines the mesh that will be rendered
  113218. */
  113219. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  113220. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  113221. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  113222. protected _writeFloat(value: number): string;
  113223. /**
  113224. * Gets the current class name e.g. "NodeMaterialBlock"
  113225. * @returns the class name
  113226. */
  113227. getClassName(): string;
  113228. /**
  113229. * Register a new input. Must be called inside a block constructor
  113230. * @param name defines the connection point name
  113231. * @param type defines the connection point type
  113232. * @param isOptional defines a boolean indicating that this input can be omitted
  113233. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  113234. * @returns the current block
  113235. */
  113236. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  113237. /**
  113238. * Register a new output. Must be called inside a block constructor
  113239. * @param name defines the connection point name
  113240. * @param type defines the connection point type
  113241. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  113242. * @returns the current block
  113243. */
  113244. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  113245. /**
  113246. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  113247. * @param forOutput defines an optional connection point to check compatibility with
  113248. * @returns the first available input or null
  113249. */
  113250. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  113251. /**
  113252. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  113253. * @param forBlock defines an optional block to check compatibility with
  113254. * @returns the first available input or null
  113255. */
  113256. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  113257. /**
  113258. * Connect current block with another block
  113259. * @param other defines the block to connect with
  113260. * @param options define the various options to help pick the right connections
  113261. * @returns the current block
  113262. */
  113263. connectTo(other: NodeMaterialBlock, options?: {
  113264. input?: string;
  113265. output?: string;
  113266. outputSwizzle?: string;
  113267. }): this | undefined;
  113268. protected _buildBlock(state: NodeMaterialBuildState): void;
  113269. /**
  113270. * Add potential fallbacks if shader compilation fails
  113271. * @param mesh defines the mesh to be rendered
  113272. * @param fallbacks defines the current prioritized list of fallbacks
  113273. */
  113274. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  113275. /**
  113276. * Update defines for shader compilation
  113277. * @param mesh defines the mesh to be rendered
  113278. * @param nodeMaterial defines the node material requesting the update
  113279. * @param defines defines the material defines to update
  113280. * @param useInstances specifies that instances should be used
  113281. */
  113282. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  113283. /**
  113284. * Lets the block try to connect some inputs automatically
  113285. */
  113286. autoConfigure(): void;
  113287. /**
  113288. * Function called when a block is declared as repeatable content generator
  113289. * @param vertexShaderState defines the current compilation state for the vertex shader
  113290. * @param fragmentShaderState defines the current compilation state for the fragment shader
  113291. * @param mesh defines the mesh to be rendered
  113292. * @param defines defines the material defines to update
  113293. */
  113294. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  113295. /**
  113296. * Checks if the block is ready
  113297. * @param mesh defines the mesh to be rendered
  113298. * @param nodeMaterial defines the node material requesting the update
  113299. * @param defines defines the material defines to update
  113300. * @param useInstances specifies that instances should be used
  113301. * @returns true if the block is ready
  113302. */
  113303. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  113304. /**
  113305. * Compile the current node and generate the shader code
  113306. * @param state defines the current compilation state (uniforms, samplers, current string)
  113307. * @returns the current block
  113308. */
  113309. build(state: NodeMaterialBuildState): this | undefined;
  113310. }
  113311. }
  113312. declare module BABYLON {
  113313. /**
  113314. * Defines a connection point for a block
  113315. */
  113316. export class NodeMaterialConnectionPoint {
  113317. /** @hidden */
  113318. _ownerBlock: NodeMaterialBlock;
  113319. /** @hidden */
  113320. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  113321. private _associatedVariableName;
  113322. private _endpoints;
  113323. private _storedValue;
  113324. private _valueCallback;
  113325. private _mode;
  113326. /** @hidden */
  113327. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  113328. /** @hidden */
  113329. _needToEmitVarying: boolean;
  113330. /**
  113331. * Gets or sets the connection point type (default is float)
  113332. */
  113333. type: NodeMaterialBlockConnectionPointTypes;
  113334. /**
  113335. * Gets or sets the connection point name
  113336. */
  113337. name: string;
  113338. /**
  113339. * Gets or sets the swizzle to apply to this connection point when reading or writing
  113340. */
  113341. swizzle: string;
  113342. /**
  113343. * Gets or sets a boolean indicating that this connection point can be omitted
  113344. */
  113345. isOptional: boolean;
  113346. /**
  113347. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  113348. */
  113349. define: string;
  113350. /** Gets or sets the target of that connection point */
  113351. target: NodeMaterialBlockTargets;
  113352. /**
  113353. * Gets or sets the value of that point.
  113354. * Please note that this value will be ignored if valueCallback is defined
  113355. */
  113356. value: any;
  113357. /**
  113358. * Gets or sets a callback used to get the value of that point.
  113359. * Please note that setting this value will force the connection point to ignore the value property
  113360. */
  113361. valueCallback: () => any;
  113362. /**
  113363. * Gets or sets the associated variable name in the shader
  113364. */
  113365. associatedVariableName: string;
  113366. /**
  113367. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  113368. * In this case the connection point name must be the name of the uniform to use.
  113369. * Can only be set on inputs
  113370. */
  113371. isUniform: boolean;
  113372. /**
  113373. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  113374. * In this case the connection point name must be the name of the attribute to use
  113375. * Can only be set on inputs
  113376. */
  113377. isAttribute: boolean;
  113378. /**
  113379. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  113380. * Can only be set on exit points
  113381. */
  113382. isVarying: boolean;
  113383. /** Get the other side of the connection (if any) */
  113384. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  113385. /** Get the block that owns this connection point */
  113386. readonly ownerBlock: NodeMaterialBlock;
  113387. /** Get the block connected on the other side of this connection (if any) */
  113388. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  113389. /** Get the block connected on the endpoints of this connection (if any) */
  113390. readonly connectedBlocks: Array<NodeMaterialBlock>;
  113391. /**
  113392. * Creates a new connection point
  113393. * @param name defines the connection point name
  113394. * @param ownerBlock defines the block hosting this connection point
  113395. */
  113396. constructor(name: string, ownerBlock: NodeMaterialBlock);
  113397. /**
  113398. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  113399. * @returns the class name
  113400. */
  113401. getClassName(): string;
  113402. /**
  113403. * Set the source of this connection point to a vertex attribute
  113404. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  113405. * @returns the current connection point
  113406. */
  113407. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  113408. /**
  113409. * Set the source of this connection point to a well known value
  113410. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  113411. * @returns the current connection point
  113412. */
  113413. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  113414. /**
  113415. * Gets a boolean indicating that the current connection point is a well known value
  113416. */
  113417. readonly isWellKnownValue: boolean;
  113418. /**
  113419. * Gets or sets the current well known value or null if not defined as well know value
  113420. */
  113421. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  113422. private _getTypeLength;
  113423. /**
  113424. * Connect this point to another connection point
  113425. * @param connectionPoint defines the other connection point
  113426. * @returns the current connection point
  113427. */
  113428. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  113429. /**
  113430. * Disconnect this point from one of his endpoint
  113431. * @param endpoint defines the other connection point
  113432. * @returns the current connection point
  113433. */
  113434. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  113435. /**
  113436. * When connection point is an uniform, this function will send its value to the effect
  113437. * @param effect defines the effect to transmit value to
  113438. * @param world defines the world matrix
  113439. * @param worldView defines the worldxview matrix
  113440. * @param worldViewProjection defines the worldxviewxprojection matrix
  113441. */
  113442. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  113443. /**
  113444. * When connection point is an uniform, this function will send its value to the effect
  113445. * @param effect defines the effect to transmit value to
  113446. * @param scene defines the hosting scene
  113447. */
  113448. transmit(effect: Effect, scene: Scene): void;
  113449. }
  113450. }
  113451. declare module BABYLON {
  113452. /**
  113453. * Block used to add support for vertex skinning (bones)
  113454. */
  113455. export class BonesBlock extends NodeMaterialBlock {
  113456. /**
  113457. * Creates a new BonesBlock
  113458. * @param name defines the block name
  113459. */
  113460. constructor(name: string);
  113461. /**
  113462. * Initialize the block and prepare the context for build
  113463. * @param state defines the state that will be used for the build
  113464. */
  113465. initialize(state: NodeMaterialBuildState): void;
  113466. /**
  113467. * Gets the current class name
  113468. * @returns the class name
  113469. */
  113470. getClassName(): string;
  113471. /**
  113472. * Gets the matrix indices input component
  113473. */
  113474. readonly matricesIndices: NodeMaterialConnectionPoint;
  113475. /**
  113476. * Gets the matrix weights input component
  113477. */
  113478. readonly matricesWeights: NodeMaterialConnectionPoint;
  113479. /**
  113480. * Gets the extra matrix indices input component
  113481. */
  113482. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  113483. /**
  113484. * Gets the extra matrix weights input component
  113485. */
  113486. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  113487. /**
  113488. * Gets the world input component
  113489. */
  113490. readonly world: NodeMaterialConnectionPoint;
  113491. autoConfigure(): void;
  113492. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  113493. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  113494. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  113495. protected _buildBlock(state: NodeMaterialBuildState): this;
  113496. }
  113497. }
  113498. declare module BABYLON {
  113499. /**
  113500. * Block used to add support for instances
  113501. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  113502. */
  113503. export class InstancesBlock extends NodeMaterialBlock {
  113504. /**
  113505. * Creates a new InstancesBlock
  113506. * @param name defines the block name
  113507. */
  113508. constructor(name: string);
  113509. /**
  113510. * Gets the current class name
  113511. * @returns the class name
  113512. */
  113513. getClassName(): string;
  113514. /**
  113515. * Gets the first world row input component
  113516. */
  113517. readonly world0: NodeMaterialConnectionPoint;
  113518. /**
  113519. * Gets the second world row input component
  113520. */
  113521. readonly world1: NodeMaterialConnectionPoint;
  113522. /**
  113523. * Gets the third world row input component
  113524. */
  113525. readonly world2: NodeMaterialConnectionPoint;
  113526. /**
  113527. * Gets the forth world row input component
  113528. */
  113529. readonly world3: NodeMaterialConnectionPoint;
  113530. /**
  113531. * Gets the world input component
  113532. */
  113533. readonly world: NodeMaterialConnectionPoint;
  113534. /**
  113535. * Gets the output component
  113536. */
  113537. readonly output: NodeMaterialConnectionPoint;
  113538. autoConfigure(): void;
  113539. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  113540. protected _buildBlock(state: NodeMaterialBuildState): this;
  113541. }
  113542. }
  113543. declare module BABYLON {
  113544. /**
  113545. * Block used to add morph targets support to vertex shader
  113546. */
  113547. export class MorphTargetsBlock extends NodeMaterialBlock {
  113548. private _repeatableContentAnchor;
  113549. private _repeatebleContentGenerated;
  113550. /**
  113551. * Create a new MorphTargetsBlock
  113552. * @param name defines the block name
  113553. */
  113554. constructor(name: string);
  113555. /**
  113556. * Gets the current class name
  113557. * @returns the class name
  113558. */
  113559. getClassName(): string;
  113560. /**
  113561. * Gets the position input component
  113562. */
  113563. readonly position: NodeMaterialConnectionPoint;
  113564. /**
  113565. * Gets the normal input component
  113566. */
  113567. readonly normal: NodeMaterialConnectionPoint;
  113568. /**
  113569. * Gets the tangent input component
  113570. */
  113571. readonly tangent: NodeMaterialConnectionPoint;
  113572. /**
  113573. * Gets the position output component
  113574. */
  113575. readonly positionOutput: NodeMaterialConnectionPoint;
  113576. /**
  113577. * Gets the normal output component
  113578. */
  113579. readonly normalOutput: NodeMaterialConnectionPoint;
  113580. /**
  113581. * Gets the tangent output component
  113582. */
  113583. readonly tangentOutput: NodeMaterialConnectionPoint;
  113584. initialize(state: NodeMaterialBuildState): void;
  113585. autoConfigure(): void;
  113586. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  113587. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  113588. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  113589. protected _buildBlock(state: NodeMaterialBuildState): this;
  113590. }
  113591. }
  113592. declare module BABYLON {
  113593. /**
  113594. * Block used to add an alpha test in the fragment shader
  113595. */
  113596. export class AlphaTestBlock extends NodeMaterialBlock {
  113597. /**
  113598. * Gets or sets the alpha value where alpha testing happens
  113599. */
  113600. alphaCutOff: number;
  113601. /**
  113602. * Create a new AlphaTestBlock
  113603. * @param name defines the block name
  113604. */
  113605. constructor(name: string);
  113606. /**
  113607. * Gets the current class name
  113608. * @returns the class name
  113609. */
  113610. getClassName(): string;
  113611. /**
  113612. * Gets the color input component
  113613. */
  113614. readonly color: NodeMaterialConnectionPoint;
  113615. protected _buildBlock(state: NodeMaterialBuildState): this;
  113616. }
  113617. }
  113618. declare module BABYLON {
  113619. /**
  113620. * Block used to create a Color4 out of 4 inputs (one for each component)
  113621. */
  113622. export class RGBAMergerBlock extends NodeMaterialBlock {
  113623. /**
  113624. * Create a new RGBAMergerBlock
  113625. * @param name defines the block name
  113626. */
  113627. constructor(name: string);
  113628. /**
  113629. * Gets the current class name
  113630. * @returns the class name
  113631. */
  113632. getClassName(): string;
  113633. /**
  113634. * Gets the R input component
  113635. */
  113636. readonly r: NodeMaterialConnectionPoint;
  113637. /**
  113638. * Gets the G input component
  113639. */
  113640. readonly g: NodeMaterialConnectionPoint;
  113641. /**
  113642. * Gets the B input component
  113643. */
  113644. readonly b: NodeMaterialConnectionPoint;
  113645. /**
  113646. * Gets the RGB input component
  113647. */
  113648. readonly rgb: NodeMaterialConnectionPoint;
  113649. /**
  113650. * Gets the R input component
  113651. */
  113652. readonly a: NodeMaterialConnectionPoint;
  113653. protected _buildBlock(state: NodeMaterialBuildState): this;
  113654. }
  113655. }
  113656. declare module BABYLON {
  113657. /**
  113658. * Block used to create a Color3 out of 3 inputs (one for each component)
  113659. */
  113660. export class RGBMergerBlock extends NodeMaterialBlock {
  113661. /**
  113662. * Create a new RGBMergerBlock
  113663. * @param name defines the block name
  113664. */
  113665. constructor(name: string);
  113666. /**
  113667. * Gets the current class name
  113668. * @returns the class name
  113669. */
  113670. getClassName(): string;
  113671. /**
  113672. * Gets the R component input
  113673. */
  113674. readonly r: NodeMaterialConnectionPoint;
  113675. /**
  113676. * Gets the G component input
  113677. */
  113678. readonly g: NodeMaterialConnectionPoint;
  113679. /**
  113680. * Gets the B component input
  113681. */
  113682. readonly b: NodeMaterialConnectionPoint;
  113683. protected _buildBlock(state: NodeMaterialBuildState): this;
  113684. }
  113685. }
  113686. declare module BABYLON {
  113687. /**
  113688. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  113689. */
  113690. export class RGBASplitterBlock extends NodeMaterialBlock {
  113691. /**
  113692. * Create a new RGBASplitterBlock
  113693. * @param name defines the block name
  113694. */
  113695. constructor(name: string);
  113696. /**
  113697. * Gets the current class name
  113698. * @returns the class name
  113699. */
  113700. getClassName(): string;
  113701. /**
  113702. * Gets the input component
  113703. */
  113704. readonly input: NodeMaterialConnectionPoint;
  113705. protected _buildBlock(state: NodeMaterialBuildState): this;
  113706. }
  113707. }
  113708. declare module BABYLON {
  113709. /**
  113710. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  113711. */
  113712. export class RGBSplitterBlock extends NodeMaterialBlock {
  113713. /**
  113714. * Create a new RGBSplitterBlock
  113715. * @param name defines the block name
  113716. */
  113717. constructor(name: string);
  113718. /**
  113719. * Gets the current class name
  113720. * @returns the class name
  113721. */
  113722. getClassName(): string;
  113723. /**
  113724. * Gets the input component
  113725. */
  113726. readonly input: NodeMaterialConnectionPoint;
  113727. protected _buildBlock(state: NodeMaterialBuildState): this;
  113728. }
  113729. }
  113730. declare module BABYLON {
  113731. /**
  113732. * Block used to read a texture from a sampler
  113733. */
  113734. export class TextureBlock extends NodeMaterialBlock {
  113735. private _defineName;
  113736. /**
  113737. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  113738. */
  113739. autoConnectTextureMatrix: boolean;
  113740. /**
  113741. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  113742. */
  113743. autoSelectUV: boolean;
  113744. /**
  113745. * Create a new TextureBlock
  113746. * @param name defines the block name
  113747. */
  113748. constructor(name: string);
  113749. /**
  113750. * Gets the current class name
  113751. * @returns the class name
  113752. */
  113753. getClassName(): string;
  113754. /**
  113755. * Gets the uv input component
  113756. */
  113757. readonly uv: NodeMaterialConnectionPoint;
  113758. /**
  113759. * Gets the texture information input component
  113760. */
  113761. readonly textureInfo: NodeMaterialConnectionPoint;
  113762. /**
  113763. * Gets the transformed uv input component
  113764. */
  113765. readonly transformedUV: NodeMaterialConnectionPoint;
  113766. /**
  113767. * Gets the texture input component
  113768. */
  113769. readonly texture: NodeMaterialConnectionPoint;
  113770. /**
  113771. * Gets the texture transform input component
  113772. */
  113773. readonly textureTransform: NodeMaterialConnectionPoint;
  113774. autoConfigure(): void;
  113775. initialize(state: NodeMaterialBuildState): void;
  113776. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  113777. isReady(): boolean;
  113778. private _injectVertexCode;
  113779. protected _buildBlock(state: NodeMaterialBuildState): this;
  113780. }
  113781. }
  113782. declare module BABYLON {
  113783. /**
  113784. * Block used to add image processing support to fragment shader
  113785. */
  113786. export class ImageProcessingBlock extends NodeMaterialBlock {
  113787. /**
  113788. * Create a new ImageProcessingBlock
  113789. * @param name defines the block name
  113790. */
  113791. constructor(name: string);
  113792. /**
  113793. * Gets the current class name
  113794. * @returns the class name
  113795. */
  113796. getClassName(): string;
  113797. /**
  113798. * Gets the color input component
  113799. */
  113800. readonly color: NodeMaterialConnectionPoint;
  113801. /**
  113802. * Initialize the block and prepare the context for build
  113803. * @param state defines the state that will be used for the build
  113804. */
  113805. initialize(state: NodeMaterialBuildState): void;
  113806. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  113807. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  113808. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  113809. protected _buildBlock(state: NodeMaterialBuildState): this;
  113810. }
  113811. }
  113812. declare module BABYLON {
  113813. /**
  113814. * Block used to add support for scene fog
  113815. */
  113816. export class FogBlock extends NodeMaterialBlock {
  113817. /**
  113818. * Create a new FogBlock
  113819. * @param name defines the block name
  113820. */
  113821. constructor(name: string);
  113822. /**
  113823. * Gets the current class name
  113824. * @returns the class name
  113825. */
  113826. getClassName(): string;
  113827. /**
  113828. * Gets the world position input component
  113829. */
  113830. readonly worldPosition: NodeMaterialConnectionPoint;
  113831. /**
  113832. * Gets the view input component
  113833. */
  113834. readonly view: NodeMaterialConnectionPoint;
  113835. /**
  113836. * Gets the color input component
  113837. */
  113838. readonly color: NodeMaterialConnectionPoint;
  113839. /**
  113840. * Gets the fog color input component
  113841. */
  113842. readonly fogColor: NodeMaterialConnectionPoint;
  113843. /**
  113844. * Gets the for parameter input component
  113845. */
  113846. readonly fogParameters: NodeMaterialConnectionPoint;
  113847. autoConfigure(): void;
  113848. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  113849. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  113850. protected _buildBlock(state: NodeMaterialBuildState): this;
  113851. }
  113852. }
  113853. declare module BABYLON {
  113854. /**
  113855. * Block used to multiply 2 vector4
  113856. */
  113857. export class MultiplyBlock extends NodeMaterialBlock {
  113858. /**
  113859. * Creates a new MultiplyBlock
  113860. * @param name defines the block name
  113861. */
  113862. constructor(name: string);
  113863. /**
  113864. * Gets the current class name
  113865. * @returns the class name
  113866. */
  113867. getClassName(): string;
  113868. /**
  113869. * Gets the left operand input component
  113870. */
  113871. readonly left: NodeMaterialConnectionPoint;
  113872. /**
  113873. * Gets the right operand input component
  113874. */
  113875. readonly right: NodeMaterialConnectionPoint;
  113876. protected _buildBlock(state: NodeMaterialBuildState): this;
  113877. }
  113878. }
  113879. declare module BABYLON {
  113880. /**
  113881. * Block used to add 2 vector4
  113882. */
  113883. export class AddBlock extends NodeMaterialBlock {
  113884. /**
  113885. * Creates a new AddBlock
  113886. * @param name defines the block name
  113887. */
  113888. constructor(name: string);
  113889. /**
  113890. * Gets the current class name
  113891. * @returns the class name
  113892. */
  113893. getClassName(): string;
  113894. /**
  113895. * Gets the left operand input component
  113896. */
  113897. readonly left: NodeMaterialConnectionPoint;
  113898. /**
  113899. * Gets the right operand input component
  113900. */
  113901. readonly right: NodeMaterialConnectionPoint;
  113902. protected _buildBlock(state: NodeMaterialBuildState): this;
  113903. }
  113904. }
  113905. declare module BABYLON {
  113906. /**
  113907. * Block used to clamp a float
  113908. */
  113909. export class ClampBlock extends NodeMaterialBlock {
  113910. /** Gets or sets the minimum range */
  113911. minimum: number;
  113912. /** Gets or sets the maximum range */
  113913. maximum: number;
  113914. /**
  113915. * Creates a new ClampBlock
  113916. * @param name defines the block name
  113917. */
  113918. constructor(name: string);
  113919. /**
  113920. * Gets the current class name
  113921. * @returns the class name
  113922. */
  113923. getClassName(): string;
  113924. /**
  113925. * Gets the value input component
  113926. */
  113927. readonly value: NodeMaterialConnectionPoint;
  113928. protected _buildBlock(state: NodeMaterialBuildState): this;
  113929. }
  113930. }
  113931. declare module BABYLON {
  113932. /**
  113933. * Block used to transform a vector2 with a matrix
  113934. */
  113935. export class Vector2TransformBlock extends NodeMaterialBlock {
  113936. /**
  113937. * Defines the value to use to complement Vector2 to transform it to a Vector4
  113938. */
  113939. complementZ: number;
  113940. /**
  113941. * Defines the value to use to complement Vector2 to transform it to a Vector4
  113942. */
  113943. complementW: number;
  113944. /**
  113945. * Creates a new Vector2TransformBlock
  113946. * @param name defines the block name
  113947. */
  113948. constructor(name: string);
  113949. /**
  113950. * Gets the vector input
  113951. */
  113952. readonly vector: NodeMaterialConnectionPoint;
  113953. /**
  113954. * Gets the matrix transform input
  113955. */
  113956. readonly transform: NodeMaterialConnectionPoint;
  113957. /**
  113958. * Gets the current class name
  113959. * @returns the class name
  113960. */
  113961. getClassName(): string;
  113962. protected _buildBlock(state: NodeMaterialBuildState): this;
  113963. }
  113964. }
  113965. declare module BABYLON {
  113966. /**
  113967. * Block used to transform a vector3 with a matrix
  113968. */
  113969. export class Vector3TransformBlock extends NodeMaterialBlock {
  113970. /**
  113971. * Defines the value to use to complement Vector3 to transform it to a Vector4
  113972. */
  113973. complement: number;
  113974. /**
  113975. * Creates a new Vector3TransformBlock
  113976. * @param name defines the block name
  113977. */
  113978. constructor(name: string);
  113979. /**
  113980. * Gets the vector input
  113981. */
  113982. readonly vector: NodeMaterialConnectionPoint;
  113983. /**
  113984. * Gets the matrix transform input
  113985. */
  113986. readonly transform: NodeMaterialConnectionPoint;
  113987. /**
  113988. * Gets the current class name
  113989. * @returns the class name
  113990. */
  113991. getClassName(): string;
  113992. protected _buildBlock(state: NodeMaterialBuildState): this;
  113993. }
  113994. }
  113995. declare module BABYLON {
  113996. /**
  113997. * Block used to multiply two matrices
  113998. */
  113999. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  114000. /**
  114001. * Creates a new MatrixMultiplicationBlock
  114002. * @param name defines the block name
  114003. */
  114004. constructor(name: string);
  114005. /**
  114006. * Gets the left operand
  114007. */
  114008. readonly left: NodeMaterialConnectionPoint;
  114009. /**
  114010. * Gets the right operand
  114011. */
  114012. readonly right: NodeMaterialConnectionPoint;
  114013. /**
  114014. * Gets the current class name
  114015. * @returns the class name
  114016. */
  114017. getClassName(): string;
  114018. protected _buildBlock(state: NodeMaterialBuildState): this;
  114019. }
  114020. }
  114021. declare module BABYLON {
  114022. /**
  114023. * Helper class to push actions to a pool of workers.
  114024. */
  114025. export class WorkerPool implements IDisposable {
  114026. private _workerInfos;
  114027. private _pendingActions;
  114028. /**
  114029. * Constructor
  114030. * @param workers Array of workers to use for actions
  114031. */
  114032. constructor(workers: Array<Worker>);
  114033. /**
  114034. * Terminates all workers and clears any pending actions.
  114035. */
  114036. dispose(): void;
  114037. /**
  114038. * Pushes an action to the worker pool. If all the workers are active, the action will be
  114039. * pended until a worker has completed its action.
  114040. * @param action The action to perform. Call onComplete when the action is complete.
  114041. */
  114042. push(action: (worker: Worker, onComplete: () => void) => void): void;
  114043. private _execute;
  114044. }
  114045. }
  114046. declare module BABYLON {
  114047. /**
  114048. * Configuration for Draco compression
  114049. */
  114050. export interface IDracoCompressionConfiguration {
  114051. /**
  114052. * Configuration for the decoder.
  114053. */
  114054. decoder: {
  114055. /**
  114056. * The url to the WebAssembly module.
  114057. */
  114058. wasmUrl?: string;
  114059. /**
  114060. * The url to the WebAssembly binary.
  114061. */
  114062. wasmBinaryUrl?: string;
  114063. /**
  114064. * The url to the fallback JavaScript module.
  114065. */
  114066. fallbackUrl?: string;
  114067. };
  114068. }
  114069. /**
  114070. * Draco compression (https://google.github.io/draco/)
  114071. *
  114072. * This class wraps the Draco module.
  114073. *
  114074. * **Encoder**
  114075. *
  114076. * The encoder is not currently implemented.
  114077. *
  114078. * **Decoder**
  114079. *
  114080. * 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.
  114081. *
  114082. * To update the configuration, use the following code:
  114083. * ```javascript
  114084. * DracoCompression.Configuration = {
  114085. * decoder: {
  114086. * wasmUrl: "<url to the WebAssembly library>",
  114087. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  114088. * fallbackUrl: "<url to the fallback JavaScript library>",
  114089. * }
  114090. * };
  114091. * ```
  114092. *
  114093. * 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.
  114094. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  114095. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  114096. *
  114097. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  114098. * ```javascript
  114099. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  114100. * ```
  114101. *
  114102. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  114103. */
  114104. export class DracoCompression implements IDisposable {
  114105. private _workerPoolPromise?;
  114106. private _decoderModulePromise?;
  114107. /**
  114108. * The configuration. Defaults to the following urls:
  114109. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  114110. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  114111. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  114112. */
  114113. static Configuration: IDracoCompressionConfiguration;
  114114. /**
  114115. * Returns true if the decoder configuration is available.
  114116. */
  114117. static readonly DecoderAvailable: boolean;
  114118. /**
  114119. * Default number of workers to create when creating the draco compression object.
  114120. */
  114121. static DefaultNumWorkers: number;
  114122. private static GetDefaultNumWorkers;
  114123. private static _Default;
  114124. /**
  114125. * Default instance for the draco compression object.
  114126. */
  114127. static readonly Default: DracoCompression;
  114128. /**
  114129. * Constructor
  114130. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  114131. */
  114132. constructor(numWorkers?: number);
  114133. /**
  114134. * Stop all async operations and release resources.
  114135. */
  114136. dispose(): void;
  114137. /**
  114138. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  114139. * @returns a promise that resolves when ready
  114140. */
  114141. whenReadyAsync(): Promise<void>;
  114142. /**
  114143. * Decode Draco compressed mesh data to vertex data.
  114144. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  114145. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  114146. * @returns A promise that resolves with the decoded vertex data
  114147. */
  114148. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  114149. [kind: string]: number;
  114150. }): Promise<VertexData>;
  114151. }
  114152. }
  114153. declare module BABYLON {
  114154. /**
  114155. * Class for building Constructive Solid Geometry
  114156. */
  114157. export class CSG {
  114158. private polygons;
  114159. /**
  114160. * The world matrix
  114161. */
  114162. matrix: Matrix;
  114163. /**
  114164. * Stores the position
  114165. */
  114166. position: Vector3;
  114167. /**
  114168. * Stores the rotation
  114169. */
  114170. rotation: Vector3;
  114171. /**
  114172. * Stores the rotation quaternion
  114173. */
  114174. rotationQuaternion: Nullable<Quaternion>;
  114175. /**
  114176. * Stores the scaling vector
  114177. */
  114178. scaling: Vector3;
  114179. /**
  114180. * Convert the Mesh to CSG
  114181. * @param mesh The Mesh to convert to CSG
  114182. * @returns A new CSG from the Mesh
  114183. */
  114184. static FromMesh(mesh: Mesh): CSG;
  114185. /**
  114186. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  114187. * @param polygons Polygons used to construct a CSG solid
  114188. */
  114189. private static FromPolygons;
  114190. /**
  114191. * Clones, or makes a deep copy, of the CSG
  114192. * @returns A new CSG
  114193. */
  114194. clone(): CSG;
  114195. /**
  114196. * Unions this CSG with another CSG
  114197. * @param csg The CSG to union against this CSG
  114198. * @returns The unioned CSG
  114199. */
  114200. union(csg: CSG): CSG;
  114201. /**
  114202. * Unions this CSG with another CSG in place
  114203. * @param csg The CSG to union against this CSG
  114204. */
  114205. unionInPlace(csg: CSG): void;
  114206. /**
  114207. * Subtracts this CSG with another CSG
  114208. * @param csg The CSG to subtract against this CSG
  114209. * @returns A new CSG
  114210. */
  114211. subtract(csg: CSG): CSG;
  114212. /**
  114213. * Subtracts this CSG with another CSG in place
  114214. * @param csg The CSG to subtact against this CSG
  114215. */
  114216. subtractInPlace(csg: CSG): void;
  114217. /**
  114218. * Intersect this CSG with another CSG
  114219. * @param csg The CSG to intersect against this CSG
  114220. * @returns A new CSG
  114221. */
  114222. intersect(csg: CSG): CSG;
  114223. /**
  114224. * Intersects this CSG with another CSG in place
  114225. * @param csg The CSG to intersect against this CSG
  114226. */
  114227. intersectInPlace(csg: CSG): void;
  114228. /**
  114229. * Return a new CSG solid with solid and empty space switched. This solid is
  114230. * not modified.
  114231. * @returns A new CSG solid with solid and empty space switched
  114232. */
  114233. inverse(): CSG;
  114234. /**
  114235. * Inverses the CSG in place
  114236. */
  114237. inverseInPlace(): void;
  114238. /**
  114239. * This is used to keep meshes transformations so they can be restored
  114240. * when we build back a Babylon Mesh
  114241. * NB : All CSG operations are performed in world coordinates
  114242. * @param csg The CSG to copy the transform attributes from
  114243. * @returns This CSG
  114244. */
  114245. copyTransformAttributes(csg: CSG): CSG;
  114246. /**
  114247. * Build Raw mesh from CSG
  114248. * Coordinates here are in world space
  114249. * @param name The name of the mesh geometry
  114250. * @param scene The Scene
  114251. * @param keepSubMeshes Specifies if the submeshes should be kept
  114252. * @returns A new Mesh
  114253. */
  114254. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  114255. /**
  114256. * Build Mesh from CSG taking material and transforms into account
  114257. * @param name The name of the Mesh
  114258. * @param material The material of the Mesh
  114259. * @param scene The Scene
  114260. * @param keepSubMeshes Specifies if submeshes should be kept
  114261. * @returns The new Mesh
  114262. */
  114263. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  114264. }
  114265. }
  114266. declare module BABYLON {
  114267. /**
  114268. * Class used to create a trail following a mesh
  114269. */
  114270. export class TrailMesh extends Mesh {
  114271. private _generator;
  114272. private _autoStart;
  114273. private _running;
  114274. private _diameter;
  114275. private _length;
  114276. private _sectionPolygonPointsCount;
  114277. private _sectionVectors;
  114278. private _sectionNormalVectors;
  114279. private _beforeRenderObserver;
  114280. /**
  114281. * @constructor
  114282. * @param name The value used by scene.getMeshByName() to do a lookup.
  114283. * @param generator The mesh to generate a trail.
  114284. * @param scene The scene to add this mesh to.
  114285. * @param diameter Diameter of trailing mesh. Default is 1.
  114286. * @param length Length of trailing mesh. Default is 60.
  114287. * @param autoStart Automatically start trailing mesh. Default true.
  114288. */
  114289. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  114290. /**
  114291. * "TrailMesh"
  114292. * @returns "TrailMesh"
  114293. */
  114294. getClassName(): string;
  114295. private _createMesh;
  114296. /**
  114297. * Start trailing mesh.
  114298. */
  114299. start(): void;
  114300. /**
  114301. * Stop trailing mesh.
  114302. */
  114303. stop(): void;
  114304. /**
  114305. * Update trailing mesh geometry.
  114306. */
  114307. update(): void;
  114308. /**
  114309. * Returns a new TrailMesh object.
  114310. * @param name is a string, the name given to the new mesh
  114311. * @param newGenerator use new generator object for cloned trail mesh
  114312. * @returns a new mesh
  114313. */
  114314. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  114315. /**
  114316. * Serializes this trail mesh
  114317. * @param serializationObject object to write serialization to
  114318. */
  114319. serialize(serializationObject: any): void;
  114320. /**
  114321. * Parses a serialized trail mesh
  114322. * @param parsedMesh the serialized mesh
  114323. * @param scene the scene to create the trail mesh in
  114324. * @returns the created trail mesh
  114325. */
  114326. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  114327. }
  114328. }
  114329. declare module BABYLON {
  114330. /**
  114331. * Class containing static functions to help procedurally build meshes
  114332. */
  114333. export class TiledBoxBuilder {
  114334. /**
  114335. * Creates a box mesh
  114336. * 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)
  114337. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  114338. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114339. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114341. * @param name defines the name of the mesh
  114342. * @param options defines the options used to create the mesh
  114343. * @param scene defines the hosting scene
  114344. * @returns the box mesh
  114345. */
  114346. static CreateTiledBox(name: string, options: {
  114347. pattern?: number;
  114348. width?: number;
  114349. height?: number;
  114350. depth?: number;
  114351. tileSize?: number;
  114352. tileWidth?: number;
  114353. tileHeight?: number;
  114354. alignHorizontal?: number;
  114355. alignVertical?: number;
  114356. faceUV?: Vector4[];
  114357. faceColors?: Color4[];
  114358. sideOrientation?: number;
  114359. updatable?: boolean;
  114360. }, scene?: Nullable<Scene>): Mesh;
  114361. }
  114362. }
  114363. declare module BABYLON {
  114364. /**
  114365. * Class containing static functions to help procedurally build meshes
  114366. */
  114367. export class TorusKnotBuilder {
  114368. /**
  114369. * Creates a torus knot mesh
  114370. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  114371. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  114372. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  114373. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  114374. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114375. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114377. * @param name defines the name of the mesh
  114378. * @param options defines the options used to create the mesh
  114379. * @param scene defines the hosting scene
  114380. * @returns the torus knot mesh
  114381. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  114382. */
  114383. static CreateTorusKnot(name: string, options: {
  114384. radius?: number;
  114385. tube?: number;
  114386. radialSegments?: number;
  114387. tubularSegments?: number;
  114388. p?: number;
  114389. q?: number;
  114390. updatable?: boolean;
  114391. sideOrientation?: number;
  114392. frontUVs?: Vector4;
  114393. backUVs?: Vector4;
  114394. }, scene: any): Mesh;
  114395. }
  114396. }
  114397. declare module BABYLON {
  114398. /**
  114399. * Polygon
  114400. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  114401. */
  114402. export class Polygon {
  114403. /**
  114404. * Creates a rectangle
  114405. * @param xmin bottom X coord
  114406. * @param ymin bottom Y coord
  114407. * @param xmax top X coord
  114408. * @param ymax top Y coord
  114409. * @returns points that make the resulting rectation
  114410. */
  114411. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  114412. /**
  114413. * Creates a circle
  114414. * @param radius radius of circle
  114415. * @param cx scale in x
  114416. * @param cy scale in y
  114417. * @param numberOfSides number of sides that make up the circle
  114418. * @returns points that make the resulting circle
  114419. */
  114420. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  114421. /**
  114422. * Creates a polygon from input string
  114423. * @param input Input polygon data
  114424. * @returns the parsed points
  114425. */
  114426. static Parse(input: string): Vector2[];
  114427. /**
  114428. * Starts building a polygon from x and y coordinates
  114429. * @param x x coordinate
  114430. * @param y y coordinate
  114431. * @returns the started path2
  114432. */
  114433. static StartingAt(x: number, y: number): Path2;
  114434. }
  114435. /**
  114436. * Builds a polygon
  114437. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  114438. */
  114439. export class PolygonMeshBuilder {
  114440. private _points;
  114441. private _outlinepoints;
  114442. private _holes;
  114443. private _name;
  114444. private _scene;
  114445. private _epoints;
  114446. private _eholes;
  114447. private _addToepoint;
  114448. /**
  114449. * Babylon reference to the earcut plugin.
  114450. */
  114451. bjsEarcut: any;
  114452. /**
  114453. * Creates a PolygonMeshBuilder
  114454. * @param name name of the builder
  114455. * @param contours Path of the polygon
  114456. * @param scene scene to add to when creating the mesh
  114457. * @param earcutInjection can be used to inject your own earcut reference
  114458. */
  114459. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  114460. /**
  114461. * Adds a whole within the polygon
  114462. * @param hole Array of points defining the hole
  114463. * @returns this
  114464. */
  114465. addHole(hole: Vector2[]): PolygonMeshBuilder;
  114466. /**
  114467. * Creates the polygon
  114468. * @param updatable If the mesh should be updatable
  114469. * @param depth The depth of the mesh created
  114470. * @returns the created mesh
  114471. */
  114472. build(updatable?: boolean, depth?: number): Mesh;
  114473. /**
  114474. * Creates the polygon
  114475. * @param depth The depth of the mesh created
  114476. * @returns the created VertexData
  114477. */
  114478. buildVertexData(depth?: number): VertexData;
  114479. /**
  114480. * Adds a side to the polygon
  114481. * @param positions points that make the polygon
  114482. * @param normals normals of the polygon
  114483. * @param uvs uvs of the polygon
  114484. * @param indices indices of the polygon
  114485. * @param bounds bounds of the polygon
  114486. * @param points points of the polygon
  114487. * @param depth depth of the polygon
  114488. * @param flip flip of the polygon
  114489. */
  114490. private addSide;
  114491. }
  114492. }
  114493. declare module BABYLON {
  114494. /**
  114495. * Class containing static functions to help procedurally build meshes
  114496. */
  114497. export class PolygonBuilder {
  114498. /**
  114499. * Creates a polygon mesh
  114500. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  114501. * * 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
  114502. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114504. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  114505. * * Remember you can only change the shape positions, not their number when updating a polygon
  114506. * @param name defines the name of the mesh
  114507. * @param options defines the options used to create the mesh
  114508. * @param scene defines the hosting scene
  114509. * @param earcutInjection can be used to inject your own earcut reference
  114510. * @returns the polygon mesh
  114511. */
  114512. static CreatePolygon(name: string, options: {
  114513. shape: Vector3[];
  114514. holes?: Vector3[][];
  114515. depth?: number;
  114516. faceUV?: Vector4[];
  114517. faceColors?: Color4[];
  114518. updatable?: boolean;
  114519. sideOrientation?: number;
  114520. frontUVs?: Vector4;
  114521. backUVs?: Vector4;
  114522. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  114523. /**
  114524. * Creates an extruded polygon mesh, with depth in the Y direction.
  114525. * * 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)
  114526. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  114527. * @param name defines the name of the mesh
  114528. * @param options defines the options used to create the mesh
  114529. * @param scene defines the hosting scene
  114530. * @param earcutInjection can be used to inject your own earcut reference
  114531. * @returns the polygon mesh
  114532. */
  114533. static ExtrudePolygon(name: string, options: {
  114534. shape: Vector3[];
  114535. holes?: Vector3[][];
  114536. depth?: number;
  114537. faceUV?: Vector4[];
  114538. faceColors?: Color4[];
  114539. updatable?: boolean;
  114540. sideOrientation?: number;
  114541. frontUVs?: Vector4;
  114542. backUVs?: Vector4;
  114543. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  114544. }
  114545. }
  114546. declare module BABYLON {
  114547. /**
  114548. * Class containing static functions to help procedurally build meshes
  114549. */
  114550. export class LatheBuilder {
  114551. /**
  114552. * Creates lathe mesh.
  114553. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  114554. * * 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
  114555. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  114556. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  114557. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  114558. * * 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
  114559. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  114560. * * 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
  114561. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114562. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114563. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  114564. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114565. * @param name defines the name of the mesh
  114566. * @param options defines the options used to create the mesh
  114567. * @param scene defines the hosting scene
  114568. * @returns the lathe mesh
  114569. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  114570. */
  114571. static CreateLathe(name: string, options: {
  114572. shape: Vector3[];
  114573. radius?: number;
  114574. tessellation?: number;
  114575. clip?: number;
  114576. arc?: number;
  114577. closed?: boolean;
  114578. updatable?: boolean;
  114579. sideOrientation?: number;
  114580. frontUVs?: Vector4;
  114581. backUVs?: Vector4;
  114582. cap?: number;
  114583. invertUV?: boolean;
  114584. }, scene?: Nullable<Scene>): Mesh;
  114585. }
  114586. }
  114587. declare module BABYLON {
  114588. /**
  114589. * Class containing static functions to help procedurally build meshes
  114590. */
  114591. export class TiledPlaneBuilder {
  114592. /**
  114593. * Creates a tiled plane mesh
  114594. * * The parameter `pattern` will, depending on value, do nothing or
  114595. * * * flip (reflect about central vertical) alternate tiles across and up
  114596. * * * flip every tile on alternate rows
  114597. * * * rotate (180 degs) alternate tiles across and up
  114598. * * * rotate every tile on alternate rows
  114599. * * * flip and rotate alternate tiles across and up
  114600. * * * flip and rotate every tile on alternate rows
  114601. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  114602. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  114603. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114604. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114605. * * 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)
  114606. * * 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)
  114607. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  114608. * @param name defines the name of the mesh
  114609. * @param options defines the options used to create the mesh
  114610. * @param scene defines the hosting scene
  114611. * @returns the box mesh
  114612. */
  114613. static CreateTiledPlane(name: string, options: {
  114614. pattern?: number;
  114615. tileSize?: number;
  114616. tileWidth?: number;
  114617. tileHeight?: number;
  114618. size?: number;
  114619. width?: number;
  114620. height?: number;
  114621. alignHorizontal?: number;
  114622. alignVertical?: number;
  114623. sideOrientation?: number;
  114624. frontUVs?: Vector4;
  114625. backUVs?: Vector4;
  114626. updatable?: boolean;
  114627. }, scene?: Nullable<Scene>): Mesh;
  114628. }
  114629. }
  114630. declare module BABYLON {
  114631. /**
  114632. * Class containing static functions to help procedurally build meshes
  114633. */
  114634. export class TubeBuilder {
  114635. /**
  114636. * Creates a tube mesh.
  114637. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  114638. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  114639. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  114640. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  114641. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  114642. * * 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)
  114643. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  114644. * * 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
  114645. * * 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
  114646. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114647. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114648. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  114649. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114650. * @param name defines the name of the mesh
  114651. * @param options defines the options used to create the mesh
  114652. * @param scene defines the hosting scene
  114653. * @returns the tube mesh
  114654. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114655. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  114656. */
  114657. static CreateTube(name: string, options: {
  114658. path: Vector3[];
  114659. radius?: number;
  114660. tessellation?: number;
  114661. radiusFunction?: {
  114662. (i: number, distance: number): number;
  114663. };
  114664. cap?: number;
  114665. arc?: number;
  114666. updatable?: boolean;
  114667. sideOrientation?: number;
  114668. frontUVs?: Vector4;
  114669. backUVs?: Vector4;
  114670. instance?: Mesh;
  114671. invertUV?: boolean;
  114672. }, scene?: Nullable<Scene>): Mesh;
  114673. }
  114674. }
  114675. declare module BABYLON {
  114676. /**
  114677. * Class containing static functions to help procedurally build meshes
  114678. */
  114679. export class IcoSphereBuilder {
  114680. /**
  114681. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  114682. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  114683. * * 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`)
  114684. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  114685. * * 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
  114686. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114687. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114689. * @param name defines the name of the mesh
  114690. * @param options defines the options used to create the mesh
  114691. * @param scene defines the hosting scene
  114692. * @returns the icosahedron mesh
  114693. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  114694. */
  114695. static CreateIcoSphere(name: string, options: {
  114696. radius?: number;
  114697. radiusX?: number;
  114698. radiusY?: number;
  114699. radiusZ?: number;
  114700. flat?: boolean;
  114701. subdivisions?: number;
  114702. sideOrientation?: number;
  114703. frontUVs?: Vector4;
  114704. backUVs?: Vector4;
  114705. updatable?: boolean;
  114706. }, scene?: Nullable<Scene>): Mesh;
  114707. }
  114708. }
  114709. declare module BABYLON {
  114710. /**
  114711. * Class containing static functions to help procedurally build meshes
  114712. */
  114713. export class DecalBuilder {
  114714. /**
  114715. * Creates a decal mesh.
  114716. * 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
  114717. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  114718. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  114719. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  114720. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  114721. * @param name defines the name of the mesh
  114722. * @param sourceMesh defines the mesh where the decal must be applied
  114723. * @param options defines the options used to create the mesh
  114724. * @param scene defines the hosting scene
  114725. * @returns the decal mesh
  114726. * @see https://doc.babylonjs.com/how_to/decals
  114727. */
  114728. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  114729. position?: Vector3;
  114730. normal?: Vector3;
  114731. size?: Vector3;
  114732. angle?: number;
  114733. }): Mesh;
  114734. }
  114735. }
  114736. declare module BABYLON {
  114737. /**
  114738. * Class containing static functions to help procedurally build meshes
  114739. */
  114740. export class MeshBuilder {
  114741. /**
  114742. * Creates a box mesh
  114743. * * The parameter `size` sets the size (float) of each box side (default 1)
  114744. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  114745. * * 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)
  114746. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  114747. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114748. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114749. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114750. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  114751. * @param name defines the name of the mesh
  114752. * @param options defines the options used to create the mesh
  114753. * @param scene defines the hosting scene
  114754. * @returns the box mesh
  114755. */
  114756. static CreateBox(name: string, options: {
  114757. size?: number;
  114758. width?: number;
  114759. height?: number;
  114760. depth?: number;
  114761. faceUV?: Vector4[];
  114762. faceColors?: Color4[];
  114763. sideOrientation?: number;
  114764. frontUVs?: Vector4;
  114765. backUVs?: Vector4;
  114766. updatable?: boolean;
  114767. }, scene?: Nullable<Scene>): Mesh;
  114768. /**
  114769. * Creates a tiled box mesh
  114770. * * faceTiles sets the pattern, tile size and number of tiles for a face
  114771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114772. * @param name defines the name of the mesh
  114773. * @param options defines the options used to create the mesh
  114774. * @param scene defines the hosting scene
  114775. * @returns the tiled box mesh
  114776. */
  114777. static CreateTiledBox(name: string, options: {
  114778. pattern?: number;
  114779. size?: number;
  114780. width?: number;
  114781. height?: number;
  114782. depth: number;
  114783. tileSize?: number;
  114784. tileWidth?: number;
  114785. tileHeight?: number;
  114786. faceUV?: Vector4[];
  114787. faceColors?: Color4[];
  114788. alignHorizontal?: number;
  114789. alignVertical?: number;
  114790. sideOrientation?: number;
  114791. updatable?: boolean;
  114792. }, scene?: Nullable<Scene>): Mesh;
  114793. /**
  114794. * Creates a sphere mesh
  114795. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  114796. * * 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`)
  114797. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  114798. * * 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
  114799. * * 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)
  114800. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114801. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114802. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114803. * @param name defines the name of the mesh
  114804. * @param options defines the options used to create the mesh
  114805. * @param scene defines the hosting scene
  114806. * @returns the sphere mesh
  114807. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  114808. */
  114809. static CreateSphere(name: string, options: {
  114810. segments?: number;
  114811. diameter?: number;
  114812. diameterX?: number;
  114813. diameterY?: number;
  114814. diameterZ?: number;
  114815. arc?: number;
  114816. slice?: number;
  114817. sideOrientation?: number;
  114818. frontUVs?: Vector4;
  114819. backUVs?: Vector4;
  114820. updatable?: boolean;
  114821. }, scene?: Nullable<Scene>): Mesh;
  114822. /**
  114823. * Creates a plane polygonal mesh. By default, this is a disc
  114824. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  114825. * * 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
  114826. * * 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
  114827. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114828. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114829. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114830. * @param name defines the name of the mesh
  114831. * @param options defines the options used to create the mesh
  114832. * @param scene defines the hosting scene
  114833. * @returns the plane polygonal mesh
  114834. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  114835. */
  114836. static CreateDisc(name: string, options: {
  114837. radius?: number;
  114838. tessellation?: number;
  114839. arc?: number;
  114840. updatable?: boolean;
  114841. sideOrientation?: number;
  114842. frontUVs?: Vector4;
  114843. backUVs?: Vector4;
  114844. }, scene?: Nullable<Scene>): Mesh;
  114845. /**
  114846. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  114847. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  114848. * * 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`)
  114849. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  114850. * * 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
  114851. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114852. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114853. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114854. * @param name defines the name of the mesh
  114855. * @param options defines the options used to create the mesh
  114856. * @param scene defines the hosting scene
  114857. * @returns the icosahedron mesh
  114858. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  114859. */
  114860. static CreateIcoSphere(name: string, options: {
  114861. radius?: number;
  114862. radiusX?: number;
  114863. radiusY?: number;
  114864. radiusZ?: number;
  114865. flat?: boolean;
  114866. subdivisions?: number;
  114867. sideOrientation?: number;
  114868. frontUVs?: Vector4;
  114869. backUVs?: Vector4;
  114870. updatable?: boolean;
  114871. }, scene?: Nullable<Scene>): Mesh;
  114872. /**
  114873. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  114874. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  114875. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  114876. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  114877. * * 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
  114878. * * 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
  114879. * * 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
  114880. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114881. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114882. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  114883. * * 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
  114884. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  114885. * * 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
  114886. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  114887. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114888. * @param name defines the name of the mesh
  114889. * @param options defines the options used to create the mesh
  114890. * @param scene defines the hosting scene
  114891. * @returns the ribbon mesh
  114892. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  114893. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114894. */
  114895. static CreateRibbon(name: string, options: {
  114896. pathArray: Vector3[][];
  114897. closeArray?: boolean;
  114898. closePath?: boolean;
  114899. offset?: number;
  114900. updatable?: boolean;
  114901. sideOrientation?: number;
  114902. frontUVs?: Vector4;
  114903. backUVs?: Vector4;
  114904. instance?: Mesh;
  114905. invertUV?: boolean;
  114906. uvs?: Vector2[];
  114907. colors?: Color4[];
  114908. }, scene?: Nullable<Scene>): Mesh;
  114909. /**
  114910. * Creates a cylinder or a cone mesh
  114911. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  114912. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  114913. * * 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.
  114914. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  114915. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  114916. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  114917. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  114918. * * 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).
  114919. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  114920. * * 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).
  114921. * * 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
  114922. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  114923. * * 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
  114924. * * 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.
  114925. * * If `enclose` is false, a ring surface is one element.
  114926. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  114927. * * 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
  114928. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114929. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114931. * @param name defines the name of the mesh
  114932. * @param options defines the options used to create the mesh
  114933. * @param scene defines the hosting scene
  114934. * @returns the cylinder mesh
  114935. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  114936. */
  114937. static CreateCylinder(name: string, options: {
  114938. height?: number;
  114939. diameterTop?: number;
  114940. diameterBottom?: number;
  114941. diameter?: number;
  114942. tessellation?: number;
  114943. subdivisions?: number;
  114944. arc?: number;
  114945. faceColors?: Color4[];
  114946. faceUV?: Vector4[];
  114947. updatable?: boolean;
  114948. hasRings?: boolean;
  114949. enclose?: boolean;
  114950. cap?: number;
  114951. sideOrientation?: number;
  114952. frontUVs?: Vector4;
  114953. backUVs?: Vector4;
  114954. }, scene?: Nullable<Scene>): Mesh;
  114955. /**
  114956. * Creates a torus mesh
  114957. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  114958. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  114959. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  114960. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114961. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114962. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114963. * @param name defines the name of the mesh
  114964. * @param options defines the options used to create the mesh
  114965. * @param scene defines the hosting scene
  114966. * @returns the torus mesh
  114967. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  114968. */
  114969. static CreateTorus(name: string, options: {
  114970. diameter?: number;
  114971. thickness?: number;
  114972. tessellation?: number;
  114973. updatable?: boolean;
  114974. sideOrientation?: number;
  114975. frontUVs?: Vector4;
  114976. backUVs?: Vector4;
  114977. }, scene?: Nullable<Scene>): Mesh;
  114978. /**
  114979. * Creates a torus knot mesh
  114980. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  114981. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  114982. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  114983. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  114984. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114985. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114986. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114987. * @param name defines the name of the mesh
  114988. * @param options defines the options used to create the mesh
  114989. * @param scene defines the hosting scene
  114990. * @returns the torus knot mesh
  114991. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  114992. */
  114993. static CreateTorusKnot(name: string, options: {
  114994. radius?: number;
  114995. tube?: number;
  114996. radialSegments?: number;
  114997. tubularSegments?: number;
  114998. p?: number;
  114999. q?: number;
  115000. updatable?: boolean;
  115001. sideOrientation?: number;
  115002. frontUVs?: Vector4;
  115003. backUVs?: Vector4;
  115004. }, scene?: Nullable<Scene>): Mesh;
  115005. /**
  115006. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  115007. * * 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
  115008. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  115009. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  115010. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  115011. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  115012. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  115013. * * 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
  115014. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  115015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115016. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  115017. * @param name defines the name of the new line system
  115018. * @param options defines the options used to create the line system
  115019. * @param scene defines the hosting scene
  115020. * @returns a new line system mesh
  115021. */
  115022. static CreateLineSystem(name: string, options: {
  115023. lines: Vector3[][];
  115024. updatable?: boolean;
  115025. instance?: Nullable<LinesMesh>;
  115026. colors?: Nullable<Color4[][]>;
  115027. useVertexAlpha?: boolean;
  115028. }, scene: Nullable<Scene>): LinesMesh;
  115029. /**
  115030. * Creates a line mesh
  115031. * 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
  115032. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  115033. * * The parameter `points` is an array successive Vector3
  115034. * * 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
  115035. * * The optional parameter `colors` is an array of successive Color4, one per line point
  115036. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  115037. * * When updating an instance, remember that only point positions can change, not the number of points
  115038. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115039. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  115040. * @param name defines the name of the new line system
  115041. * @param options defines the options used to create the line system
  115042. * @param scene defines the hosting scene
  115043. * @returns a new line mesh
  115044. */
  115045. static CreateLines(name: string, options: {
  115046. points: Vector3[];
  115047. updatable?: boolean;
  115048. instance?: Nullable<LinesMesh>;
  115049. colors?: Color4[];
  115050. useVertexAlpha?: boolean;
  115051. }, scene?: Nullable<Scene>): LinesMesh;
  115052. /**
  115053. * Creates a dashed line mesh
  115054. * * 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
  115055. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  115056. * * The parameter `points` is an array successive Vector3
  115057. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  115058. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  115059. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  115060. * * 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
  115061. * * When updating an instance, remember that only point positions can change, not the number of points
  115062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115063. * @param name defines the name of the mesh
  115064. * @param options defines the options used to create the mesh
  115065. * @param scene defines the hosting scene
  115066. * @returns the dashed line mesh
  115067. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  115068. */
  115069. static CreateDashedLines(name: string, options: {
  115070. points: Vector3[];
  115071. dashSize?: number;
  115072. gapSize?: number;
  115073. dashNb?: number;
  115074. updatable?: boolean;
  115075. instance?: LinesMesh;
  115076. }, scene?: Nullable<Scene>): LinesMesh;
  115077. /**
  115078. * 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.
  115079. * * 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.
  115080. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  115081. * * 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.
  115082. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  115083. * * 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
  115084. * * 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
  115085. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  115086. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115087. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115088. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  115089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115090. * @param name defines the name of the mesh
  115091. * @param options defines the options used to create the mesh
  115092. * @param scene defines the hosting scene
  115093. * @returns the extruded shape mesh
  115094. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115095. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  115096. */
  115097. static ExtrudeShape(name: string, options: {
  115098. shape: Vector3[];
  115099. path: Vector3[];
  115100. scale?: number;
  115101. rotation?: number;
  115102. cap?: number;
  115103. updatable?: boolean;
  115104. sideOrientation?: number;
  115105. frontUVs?: Vector4;
  115106. backUVs?: Vector4;
  115107. instance?: Mesh;
  115108. invertUV?: boolean;
  115109. }, scene?: Nullable<Scene>): Mesh;
  115110. /**
  115111. * Creates an custom extruded shape mesh.
  115112. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  115113. * * 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.
  115114. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  115115. * * 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
  115116. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  115117. * * 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
  115118. * * It must returns a float value that will be the scale value applied to the shape on each path point
  115119. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  115120. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  115121. * * 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
  115122. * * 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
  115123. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  115124. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115125. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115126. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115128. * @param name defines the name of the mesh
  115129. * @param options defines the options used to create the mesh
  115130. * @param scene defines the hosting scene
  115131. * @returns the custom extruded shape mesh
  115132. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  115133. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115134. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  115135. */
  115136. static ExtrudeShapeCustom(name: string, options: {
  115137. shape: Vector3[];
  115138. path: Vector3[];
  115139. scaleFunction?: any;
  115140. rotationFunction?: any;
  115141. ribbonCloseArray?: boolean;
  115142. ribbonClosePath?: boolean;
  115143. cap?: number;
  115144. updatable?: boolean;
  115145. sideOrientation?: number;
  115146. frontUVs?: Vector4;
  115147. backUVs?: Vector4;
  115148. instance?: Mesh;
  115149. invertUV?: boolean;
  115150. }, scene?: Nullable<Scene>): Mesh;
  115151. /**
  115152. * Creates lathe mesh.
  115153. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  115154. * * 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
  115155. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  115156. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  115157. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  115158. * * 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
  115159. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  115160. * * 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
  115161. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115162. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115163. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115165. * @param name defines the name of the mesh
  115166. * @param options defines the options used to create the mesh
  115167. * @param scene defines the hosting scene
  115168. * @returns the lathe mesh
  115169. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  115170. */
  115171. static CreateLathe(name: string, options: {
  115172. shape: Vector3[];
  115173. radius?: number;
  115174. tessellation?: number;
  115175. clip?: number;
  115176. arc?: number;
  115177. closed?: boolean;
  115178. updatable?: boolean;
  115179. sideOrientation?: number;
  115180. frontUVs?: Vector4;
  115181. backUVs?: Vector4;
  115182. cap?: number;
  115183. invertUV?: boolean;
  115184. }, scene?: Nullable<Scene>): Mesh;
  115185. /**
  115186. * Creates a tiled plane mesh
  115187. * * You can set a limited pattern arrangement with the tiles
  115188. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115189. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115191. * @param name defines the name of the mesh
  115192. * @param options defines the options used to create the mesh
  115193. * @param scene defines the hosting scene
  115194. * @returns the plane mesh
  115195. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  115196. */
  115197. static CreateTiledPlane(name: string, options: {
  115198. pattern?: number;
  115199. tileSize?: number;
  115200. tileWidth?: number;
  115201. tileHeight?: number;
  115202. size?: number;
  115203. width?: number;
  115204. height?: number;
  115205. alignHorizontal?: number;
  115206. alignVertical?: number;
  115207. sideOrientation?: number;
  115208. frontUVs?: Vector4;
  115209. backUVs?: Vector4;
  115210. updatable?: boolean;
  115211. }, scene?: Nullable<Scene>): Mesh;
  115212. /**
  115213. * Creates a plane mesh
  115214. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  115215. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  115216. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  115217. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115218. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115220. * @param name defines the name of the mesh
  115221. * @param options defines the options used to create the mesh
  115222. * @param scene defines the hosting scene
  115223. * @returns the plane mesh
  115224. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  115225. */
  115226. static CreatePlane(name: string, options: {
  115227. size?: number;
  115228. width?: number;
  115229. height?: number;
  115230. sideOrientation?: number;
  115231. frontUVs?: Vector4;
  115232. backUVs?: Vector4;
  115233. updatable?: boolean;
  115234. sourcePlane?: Plane;
  115235. }, scene?: Nullable<Scene>): Mesh;
  115236. /**
  115237. * Creates a ground mesh
  115238. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  115239. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  115240. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115241. * @param name defines the name of the mesh
  115242. * @param options defines the options used to create the mesh
  115243. * @param scene defines the hosting scene
  115244. * @returns the ground mesh
  115245. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  115246. */
  115247. static CreateGround(name: string, options: {
  115248. width?: number;
  115249. height?: number;
  115250. subdivisions?: number;
  115251. subdivisionsX?: number;
  115252. subdivisionsY?: number;
  115253. updatable?: boolean;
  115254. }, scene?: Nullable<Scene>): Mesh;
  115255. /**
  115256. * Creates a tiled ground mesh
  115257. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  115258. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  115259. * * 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
  115260. * * 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
  115261. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115262. * @param name defines the name of the mesh
  115263. * @param options defines the options used to create the mesh
  115264. * @param scene defines the hosting scene
  115265. * @returns the tiled ground mesh
  115266. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  115267. */
  115268. static CreateTiledGround(name: string, options: {
  115269. xmin: number;
  115270. zmin: number;
  115271. xmax: number;
  115272. zmax: number;
  115273. subdivisions?: {
  115274. w: number;
  115275. h: number;
  115276. };
  115277. precision?: {
  115278. w: number;
  115279. h: number;
  115280. };
  115281. updatable?: boolean;
  115282. }, scene?: Nullable<Scene>): Mesh;
  115283. /**
  115284. * Creates a ground mesh from a height map
  115285. * * The parameter `url` sets the URL of the height map image resource.
  115286. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  115287. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  115288. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  115289. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  115290. * * 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.
  115291. * * 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).
  115292. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  115293. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115294. * @param name defines the name of the mesh
  115295. * @param url defines the url to the height map
  115296. * @param options defines the options used to create the mesh
  115297. * @param scene defines the hosting scene
  115298. * @returns the ground mesh
  115299. * @see https://doc.babylonjs.com/babylon101/height_map
  115300. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  115301. */
  115302. static CreateGroundFromHeightMap(name: string, url: string, options: {
  115303. width?: number;
  115304. height?: number;
  115305. subdivisions?: number;
  115306. minHeight?: number;
  115307. maxHeight?: number;
  115308. colorFilter?: Color3;
  115309. alphaFilter?: number;
  115310. updatable?: boolean;
  115311. onReady?: (mesh: GroundMesh) => void;
  115312. }, scene?: Nullable<Scene>): GroundMesh;
  115313. /**
  115314. * Creates a polygon mesh
  115315. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  115316. * * 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
  115317. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115318. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115319. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  115320. * * Remember you can only change the shape positions, not their number when updating a polygon
  115321. * @param name defines the name of the mesh
  115322. * @param options defines the options used to create the mesh
  115323. * @param scene defines the hosting scene
  115324. * @param earcutInjection can be used to inject your own earcut reference
  115325. * @returns the polygon mesh
  115326. */
  115327. static CreatePolygon(name: string, options: {
  115328. shape: Vector3[];
  115329. holes?: Vector3[][];
  115330. depth?: number;
  115331. faceUV?: Vector4[];
  115332. faceColors?: Color4[];
  115333. updatable?: boolean;
  115334. sideOrientation?: number;
  115335. frontUVs?: Vector4;
  115336. backUVs?: Vector4;
  115337. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  115338. /**
  115339. * Creates an extruded polygon mesh, with depth in the Y direction.
  115340. * * 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)
  115341. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115342. * @param name defines the name of the mesh
  115343. * @param options defines the options used to create the mesh
  115344. * @param scene defines the hosting scene
  115345. * @param earcutInjection can be used to inject your own earcut reference
  115346. * @returns the polygon mesh
  115347. */
  115348. static ExtrudePolygon(name: string, options: {
  115349. shape: Vector3[];
  115350. holes?: Vector3[][];
  115351. depth?: number;
  115352. faceUV?: Vector4[];
  115353. faceColors?: Color4[];
  115354. updatable?: boolean;
  115355. sideOrientation?: number;
  115356. frontUVs?: Vector4;
  115357. backUVs?: Vector4;
  115358. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  115359. /**
  115360. * Creates a tube mesh.
  115361. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  115362. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  115363. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  115364. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  115365. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  115366. * * 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)
  115367. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  115368. * * 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
  115369. * * 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
  115370. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115371. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115372. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115374. * @param name defines the name of the mesh
  115375. * @param options defines the options used to create the mesh
  115376. * @param scene defines the hosting scene
  115377. * @returns the tube mesh
  115378. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115379. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  115380. */
  115381. static CreateTube(name: string, options: {
  115382. path: Vector3[];
  115383. radius?: number;
  115384. tessellation?: number;
  115385. radiusFunction?: {
  115386. (i: number, distance: number): number;
  115387. };
  115388. cap?: number;
  115389. arc?: number;
  115390. updatable?: boolean;
  115391. sideOrientation?: number;
  115392. frontUVs?: Vector4;
  115393. backUVs?: Vector4;
  115394. instance?: Mesh;
  115395. invertUV?: boolean;
  115396. }, scene?: Nullable<Scene>): Mesh;
  115397. /**
  115398. * Creates a polyhedron mesh
  115399. * * 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
  115400. * * The parameter `size` (positive float, default 1) sets the polygon size
  115401. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  115402. * * 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`
  115403. * * 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
  115404. * * 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)`)
  115405. * * 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
  115406. * * 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
  115407. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115408. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115409. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115410. * @param name defines the name of the mesh
  115411. * @param options defines the options used to create the mesh
  115412. * @param scene defines the hosting scene
  115413. * @returns the polyhedron mesh
  115414. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  115415. */
  115416. static CreatePolyhedron(name: string, options: {
  115417. type?: number;
  115418. size?: number;
  115419. sizeX?: number;
  115420. sizeY?: number;
  115421. sizeZ?: number;
  115422. custom?: any;
  115423. faceUV?: Vector4[];
  115424. faceColors?: Color4[];
  115425. flat?: boolean;
  115426. updatable?: boolean;
  115427. sideOrientation?: number;
  115428. frontUVs?: Vector4;
  115429. backUVs?: Vector4;
  115430. }, scene?: Nullable<Scene>): Mesh;
  115431. /**
  115432. * Creates a decal mesh.
  115433. * 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
  115434. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  115435. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  115436. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  115437. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  115438. * @param name defines the name of the mesh
  115439. * @param sourceMesh defines the mesh where the decal must be applied
  115440. * @param options defines the options used to create the mesh
  115441. * @param scene defines the hosting scene
  115442. * @returns the decal mesh
  115443. * @see https://doc.babylonjs.com/how_to/decals
  115444. */
  115445. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  115446. position?: Vector3;
  115447. normal?: Vector3;
  115448. size?: Vector3;
  115449. angle?: number;
  115450. }): Mesh;
  115451. }
  115452. }
  115453. declare module BABYLON {
  115454. /**
  115455. * A simplifier interface for future simplification implementations
  115456. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  115457. */
  115458. export interface ISimplifier {
  115459. /**
  115460. * Simplification of a given mesh according to the given settings.
  115461. * Since this requires computation, it is assumed that the function runs async.
  115462. * @param settings The settings of the simplification, including quality and distance
  115463. * @param successCallback A callback that will be called after the mesh was simplified.
  115464. * @param errorCallback in case of an error, this callback will be called. optional.
  115465. */
  115466. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  115467. }
  115468. /**
  115469. * Expected simplification settings.
  115470. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  115471. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  115472. */
  115473. export interface ISimplificationSettings {
  115474. /**
  115475. * Gets or sets the expected quality
  115476. */
  115477. quality: number;
  115478. /**
  115479. * Gets or sets the distance when this optimized version should be used
  115480. */
  115481. distance: number;
  115482. /**
  115483. * Gets an already optimized mesh
  115484. */
  115485. optimizeMesh?: boolean;
  115486. }
  115487. /**
  115488. * Class used to specify simplification options
  115489. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  115490. */
  115491. export class SimplificationSettings implements ISimplificationSettings {
  115492. /** expected quality */
  115493. quality: number;
  115494. /** distance when this optimized version should be used */
  115495. distance: number;
  115496. /** already optimized mesh */
  115497. optimizeMesh?: boolean | undefined;
  115498. /**
  115499. * Creates a SimplificationSettings
  115500. * @param quality expected quality
  115501. * @param distance distance when this optimized version should be used
  115502. * @param optimizeMesh already optimized mesh
  115503. */
  115504. constructor(
  115505. /** expected quality */
  115506. quality: number,
  115507. /** distance when this optimized version should be used */
  115508. distance: number,
  115509. /** already optimized mesh */
  115510. optimizeMesh?: boolean | undefined);
  115511. }
  115512. /**
  115513. * Interface used to define a simplification task
  115514. */
  115515. export interface ISimplificationTask {
  115516. /**
  115517. * Array of settings
  115518. */
  115519. settings: Array<ISimplificationSettings>;
  115520. /**
  115521. * Simplification type
  115522. */
  115523. simplificationType: SimplificationType;
  115524. /**
  115525. * Mesh to simplify
  115526. */
  115527. mesh: Mesh;
  115528. /**
  115529. * Callback called on success
  115530. */
  115531. successCallback?: () => void;
  115532. /**
  115533. * Defines if parallel processing can be used
  115534. */
  115535. parallelProcessing: boolean;
  115536. }
  115537. /**
  115538. * Queue used to order the simplification tasks
  115539. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  115540. */
  115541. export class SimplificationQueue {
  115542. private _simplificationArray;
  115543. /**
  115544. * Gets a boolean indicating that the process is still running
  115545. */
  115546. running: boolean;
  115547. /**
  115548. * Creates a new queue
  115549. */
  115550. constructor();
  115551. /**
  115552. * Adds a new simplification task
  115553. * @param task defines a task to add
  115554. */
  115555. addTask(task: ISimplificationTask): void;
  115556. /**
  115557. * Execute next task
  115558. */
  115559. executeNext(): void;
  115560. /**
  115561. * Execute a simplification task
  115562. * @param task defines the task to run
  115563. */
  115564. runSimplification(task: ISimplificationTask): void;
  115565. private getSimplifier;
  115566. }
  115567. /**
  115568. * The implemented types of simplification
  115569. * At the moment only Quadratic Error Decimation is implemented
  115570. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  115571. */
  115572. export enum SimplificationType {
  115573. /** Quadratic error decimation */
  115574. QUADRATIC = 0
  115575. }
  115576. }
  115577. declare module BABYLON {
  115578. interface Scene {
  115579. /** @hidden (Backing field) */
  115580. _simplificationQueue: SimplificationQueue;
  115581. /**
  115582. * Gets or sets the simplification queue attached to the scene
  115583. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  115584. */
  115585. simplificationQueue: SimplificationQueue;
  115586. }
  115587. interface Mesh {
  115588. /**
  115589. * Simplify the mesh according to the given array of settings.
  115590. * Function will return immediately and will simplify async
  115591. * @param settings a collection of simplification settings
  115592. * @param parallelProcessing should all levels calculate parallel or one after the other
  115593. * @param simplificationType the type of simplification to run
  115594. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  115595. * @returns the current mesh
  115596. */
  115597. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  115598. }
  115599. /**
  115600. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  115601. * created in a scene
  115602. */
  115603. export class SimplicationQueueSceneComponent implements ISceneComponent {
  115604. /**
  115605. * The component name helpfull to identify the component in the list of scene components.
  115606. */
  115607. readonly name: string;
  115608. /**
  115609. * The scene the component belongs to.
  115610. */
  115611. scene: Scene;
  115612. /**
  115613. * Creates a new instance of the component for the given scene
  115614. * @param scene Defines the scene to register the component in
  115615. */
  115616. constructor(scene: Scene);
  115617. /**
  115618. * Registers the component in a given scene
  115619. */
  115620. register(): void;
  115621. /**
  115622. * Rebuilds the elements related to this component in case of
  115623. * context lost for instance.
  115624. */
  115625. rebuild(): void;
  115626. /**
  115627. * Disposes the component and the associated ressources
  115628. */
  115629. dispose(): void;
  115630. private _beforeCameraUpdate;
  115631. }
  115632. }
  115633. declare module BABYLON {
  115634. /**
  115635. * Class used to enable access to IndexedDB
  115636. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  115637. */
  115638. export class Database implements IOfflineProvider {
  115639. private _callbackManifestChecked;
  115640. private _currentSceneUrl;
  115641. private _db;
  115642. private _enableSceneOffline;
  115643. private _enableTexturesOffline;
  115644. private _manifestVersionFound;
  115645. private _mustUpdateRessources;
  115646. private _hasReachedQuota;
  115647. private _isSupported;
  115648. private _idbFactory;
  115649. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  115650. private static IsUASupportingBlobStorage;
  115651. /**
  115652. * Gets a boolean indicating if Database storate is enabled (off by default)
  115653. */
  115654. static IDBStorageEnabled: boolean;
  115655. /**
  115656. * Gets a boolean indicating if scene must be saved in the database
  115657. */
  115658. readonly enableSceneOffline: boolean;
  115659. /**
  115660. * Gets a boolean indicating if textures must be saved in the database
  115661. */
  115662. readonly enableTexturesOffline: boolean;
  115663. /**
  115664. * Creates a new Database
  115665. * @param urlToScene defines the url to load the scene
  115666. * @param callbackManifestChecked defines the callback to use when manifest is checked
  115667. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  115668. */
  115669. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  115670. private static _ParseURL;
  115671. private static _ReturnFullUrlLocation;
  115672. private _checkManifestFile;
  115673. /**
  115674. * Open the database and make it available
  115675. * @param successCallback defines the callback to call on success
  115676. * @param errorCallback defines the callback to call on error
  115677. */
  115678. open(successCallback: () => void, errorCallback: () => void): void;
  115679. /**
  115680. * Loads an image from the database
  115681. * @param url defines the url to load from
  115682. * @param image defines the target DOM image
  115683. */
  115684. loadImage(url: string, image: HTMLImageElement): void;
  115685. private _loadImageFromDBAsync;
  115686. private _saveImageIntoDBAsync;
  115687. private _checkVersionFromDB;
  115688. private _loadVersionFromDBAsync;
  115689. private _saveVersionIntoDBAsync;
  115690. /**
  115691. * Loads a file from database
  115692. * @param url defines the URL to load from
  115693. * @param sceneLoaded defines a callback to call on success
  115694. * @param progressCallBack defines a callback to call when progress changed
  115695. * @param errorCallback defines a callback to call on error
  115696. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  115697. */
  115698. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  115699. private _loadFileAsync;
  115700. private _saveFileAsync;
  115701. /**
  115702. * Validates if xhr data is correct
  115703. * @param xhr defines the request to validate
  115704. * @param dataType defines the expected data type
  115705. * @returns true if data is correct
  115706. */
  115707. private static _ValidateXHRData;
  115708. }
  115709. }
  115710. declare module BABYLON {
  115711. /** @hidden */
  115712. export var gpuUpdateParticlesPixelShader: {
  115713. name: string;
  115714. shader: string;
  115715. };
  115716. }
  115717. declare module BABYLON {
  115718. /** @hidden */
  115719. export var gpuUpdateParticlesVertexShader: {
  115720. name: string;
  115721. shader: string;
  115722. };
  115723. }
  115724. declare module BABYLON {
  115725. /** @hidden */
  115726. export var clipPlaneFragmentDeclaration2: {
  115727. name: string;
  115728. shader: string;
  115729. };
  115730. }
  115731. declare module BABYLON {
  115732. /** @hidden */
  115733. export var gpuRenderParticlesPixelShader: {
  115734. name: string;
  115735. shader: string;
  115736. };
  115737. }
  115738. declare module BABYLON {
  115739. /** @hidden */
  115740. export var clipPlaneVertexDeclaration2: {
  115741. name: string;
  115742. shader: string;
  115743. };
  115744. }
  115745. declare module BABYLON {
  115746. /** @hidden */
  115747. export var gpuRenderParticlesVertexShader: {
  115748. name: string;
  115749. shader: string;
  115750. };
  115751. }
  115752. declare module BABYLON {
  115753. /**
  115754. * This represents a GPU particle system in Babylon
  115755. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  115756. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  115757. */
  115758. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  115759. /**
  115760. * The layer mask we are rendering the particles through.
  115761. */
  115762. layerMask: number;
  115763. private _capacity;
  115764. private _activeCount;
  115765. private _currentActiveCount;
  115766. private _accumulatedCount;
  115767. private _renderEffect;
  115768. private _updateEffect;
  115769. private _buffer0;
  115770. private _buffer1;
  115771. private _spriteBuffer;
  115772. private _updateVAO;
  115773. private _renderVAO;
  115774. private _targetIndex;
  115775. private _sourceBuffer;
  115776. private _targetBuffer;
  115777. private _engine;
  115778. private _currentRenderId;
  115779. private _started;
  115780. private _stopped;
  115781. private _timeDelta;
  115782. private _randomTexture;
  115783. private _randomTexture2;
  115784. private _attributesStrideSize;
  115785. private _updateEffectOptions;
  115786. private _randomTextureSize;
  115787. private _actualFrame;
  115788. private readonly _rawTextureWidth;
  115789. /**
  115790. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  115791. */
  115792. static readonly IsSupported: boolean;
  115793. /**
  115794. * An event triggered when the system is disposed.
  115795. */
  115796. onDisposeObservable: Observable<GPUParticleSystem>;
  115797. /**
  115798. * Gets the maximum number of particles active at the same time.
  115799. * @returns The max number of active particles.
  115800. */
  115801. getCapacity(): number;
  115802. /**
  115803. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  115804. * to override the particles.
  115805. */
  115806. forceDepthWrite: boolean;
  115807. /**
  115808. * Gets or set the number of active particles
  115809. */
  115810. activeParticleCount: number;
  115811. private _preWarmDone;
  115812. /**
  115813. * Is this system ready to be used/rendered
  115814. * @return true if the system is ready
  115815. */
  115816. isReady(): boolean;
  115817. /**
  115818. * Gets if the system has been started. (Note: this will still be true after stop is called)
  115819. * @returns True if it has been started, otherwise false.
  115820. */
  115821. isStarted(): boolean;
  115822. /**
  115823. * Starts the particle system and begins to emit
  115824. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  115825. */
  115826. start(delay?: number): void;
  115827. /**
  115828. * Stops the particle system.
  115829. */
  115830. stop(): void;
  115831. /**
  115832. * Remove all active particles
  115833. */
  115834. reset(): void;
  115835. /**
  115836. * Returns the string "GPUParticleSystem"
  115837. * @returns a string containing the class name
  115838. */
  115839. getClassName(): string;
  115840. private _colorGradientsTexture;
  115841. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  115842. /**
  115843. * Adds a new color gradient
  115844. * @param gradient defines the gradient to use (between 0 and 1)
  115845. * @param color1 defines the color to affect to the specified gradient
  115846. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  115847. * @returns the current particle system
  115848. */
  115849. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  115850. /**
  115851. * Remove a specific color gradient
  115852. * @param gradient defines the gradient to remove
  115853. * @returns the current particle system
  115854. */
  115855. removeColorGradient(gradient: number): GPUParticleSystem;
  115856. private _angularSpeedGradientsTexture;
  115857. private _sizeGradientsTexture;
  115858. private _velocityGradientsTexture;
  115859. private _limitVelocityGradientsTexture;
  115860. private _dragGradientsTexture;
  115861. private _addFactorGradient;
  115862. /**
  115863. * Adds a new size gradient
  115864. * @param gradient defines the gradient to use (between 0 and 1)
  115865. * @param factor defines the size factor to affect to the specified gradient
  115866. * @returns the current particle system
  115867. */
  115868. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  115869. /**
  115870. * Remove a specific size gradient
  115871. * @param gradient defines the gradient to remove
  115872. * @returns the current particle system
  115873. */
  115874. removeSizeGradient(gradient: number): GPUParticleSystem;
  115875. /**
  115876. * Adds a new angular speed gradient
  115877. * @param gradient defines the gradient to use (between 0 and 1)
  115878. * @param factor defines the angular speed to affect to the specified gradient
  115879. * @returns the current particle system
  115880. */
  115881. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  115882. /**
  115883. * Remove a specific angular speed gradient
  115884. * @param gradient defines the gradient to remove
  115885. * @returns the current particle system
  115886. */
  115887. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  115888. /**
  115889. * Adds a new velocity gradient
  115890. * @param gradient defines the gradient to use (between 0 and 1)
  115891. * @param factor defines the velocity to affect to the specified gradient
  115892. * @returns the current particle system
  115893. */
  115894. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  115895. /**
  115896. * Remove a specific velocity gradient
  115897. * @param gradient defines the gradient to remove
  115898. * @returns the current particle system
  115899. */
  115900. removeVelocityGradient(gradient: number): GPUParticleSystem;
  115901. /**
  115902. * Adds a new limit velocity gradient
  115903. * @param gradient defines the gradient to use (between 0 and 1)
  115904. * @param factor defines the limit velocity value to affect to the specified gradient
  115905. * @returns the current particle system
  115906. */
  115907. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  115908. /**
  115909. * Remove a specific limit velocity gradient
  115910. * @param gradient defines the gradient to remove
  115911. * @returns the current particle system
  115912. */
  115913. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  115914. /**
  115915. * Adds a new drag gradient
  115916. * @param gradient defines the gradient to use (between 0 and 1)
  115917. * @param factor defines the drag value to affect to the specified gradient
  115918. * @returns the current particle system
  115919. */
  115920. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  115921. /**
  115922. * Remove a specific drag gradient
  115923. * @param gradient defines the gradient to remove
  115924. * @returns the current particle system
  115925. */
  115926. removeDragGradient(gradient: number): GPUParticleSystem;
  115927. /**
  115928. * Not supported by GPUParticleSystem
  115929. * @param gradient defines the gradient to use (between 0 and 1)
  115930. * @param factor defines the emit rate value to affect to the specified gradient
  115931. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  115932. * @returns the current particle system
  115933. */
  115934. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  115935. /**
  115936. * Not supported by GPUParticleSystem
  115937. * @param gradient defines the gradient to remove
  115938. * @returns the current particle system
  115939. */
  115940. removeEmitRateGradient(gradient: number): IParticleSystem;
  115941. /**
  115942. * Not supported by GPUParticleSystem
  115943. * @param gradient defines the gradient to use (between 0 and 1)
  115944. * @param factor defines the start size value to affect to the specified gradient
  115945. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  115946. * @returns the current particle system
  115947. */
  115948. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  115949. /**
  115950. * Not supported by GPUParticleSystem
  115951. * @param gradient defines the gradient to remove
  115952. * @returns the current particle system
  115953. */
  115954. removeStartSizeGradient(gradient: number): IParticleSystem;
  115955. /**
  115956. * Not supported by GPUParticleSystem
  115957. * @param gradient defines the gradient to use (between 0 and 1)
  115958. * @param min defines the color remap minimal range
  115959. * @param max defines the color remap maximal range
  115960. * @returns the current particle system
  115961. */
  115962. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  115963. /**
  115964. * Not supported by GPUParticleSystem
  115965. * @param gradient defines the gradient to remove
  115966. * @returns the current particle system
  115967. */
  115968. removeColorRemapGradient(): IParticleSystem;
  115969. /**
  115970. * Not supported by GPUParticleSystem
  115971. * @param gradient defines the gradient to use (between 0 and 1)
  115972. * @param min defines the alpha remap minimal range
  115973. * @param max defines the alpha remap maximal range
  115974. * @returns the current particle system
  115975. */
  115976. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  115977. /**
  115978. * Not supported by GPUParticleSystem
  115979. * @param gradient defines the gradient to remove
  115980. * @returns the current particle system
  115981. */
  115982. removeAlphaRemapGradient(): IParticleSystem;
  115983. /**
  115984. * Not supported by GPUParticleSystem
  115985. * @param gradient defines the gradient to use (between 0 and 1)
  115986. * @param color defines the color to affect to the specified gradient
  115987. * @returns the current particle system
  115988. */
  115989. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  115990. /**
  115991. * Not supported by GPUParticleSystem
  115992. * @param gradient defines the gradient to remove
  115993. * @returns the current particle system
  115994. */
  115995. removeRampGradient(): IParticleSystem;
  115996. /**
  115997. * Not supported by GPUParticleSystem
  115998. * @returns the list of ramp gradients
  115999. */
  116000. getRampGradients(): Nullable<Array<Color3Gradient>>;
  116001. /**
  116002. * Not supported by GPUParticleSystem
  116003. * Gets or sets a boolean indicating that ramp gradients must be used
  116004. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  116005. */
  116006. useRampGradients: boolean;
  116007. /**
  116008. * Not supported by GPUParticleSystem
  116009. * @param gradient defines the gradient to use (between 0 and 1)
  116010. * @param factor defines the life time factor to affect to the specified gradient
  116011. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  116012. * @returns the current particle system
  116013. */
  116014. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  116015. /**
  116016. * Not supported by GPUParticleSystem
  116017. * @param gradient defines the gradient to remove
  116018. * @returns the current particle system
  116019. */
  116020. removeLifeTimeGradient(gradient: number): IParticleSystem;
  116021. /**
  116022. * Instantiates a GPU particle system.
  116023. * 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.
  116024. * @param name The name of the particle system
  116025. * @param options The options used to create the system
  116026. * @param scene The scene the particle system belongs to
  116027. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  116028. */
  116029. constructor(name: string, options: Partial<{
  116030. capacity: number;
  116031. randomTextureSize: number;
  116032. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  116033. protected _reset(): void;
  116034. private _createUpdateVAO;
  116035. private _createRenderVAO;
  116036. private _initialize;
  116037. /** @hidden */
  116038. _recreateUpdateEffect(): void;
  116039. /** @hidden */
  116040. _recreateRenderEffect(): void;
  116041. /**
  116042. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  116043. * @param preWarm defines if we are in the pre-warmimg phase
  116044. */
  116045. animate(preWarm?: boolean): void;
  116046. private _createFactorGradientTexture;
  116047. private _createSizeGradientTexture;
  116048. private _createAngularSpeedGradientTexture;
  116049. private _createVelocityGradientTexture;
  116050. private _createLimitVelocityGradientTexture;
  116051. private _createDragGradientTexture;
  116052. private _createColorGradientTexture;
  116053. /**
  116054. * Renders the particle system in its current state
  116055. * @param preWarm defines if the system should only update the particles but not render them
  116056. * @returns the current number of particles
  116057. */
  116058. render(preWarm?: boolean): number;
  116059. /**
  116060. * Rebuilds the particle system
  116061. */
  116062. rebuild(): void;
  116063. private _releaseBuffers;
  116064. private _releaseVAOs;
  116065. /**
  116066. * Disposes the particle system and free the associated resources
  116067. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  116068. */
  116069. dispose(disposeTexture?: boolean): void;
  116070. /**
  116071. * Clones the particle system.
  116072. * @param name The name of the cloned object
  116073. * @param newEmitter The new emitter to use
  116074. * @returns the cloned particle system
  116075. */
  116076. clone(name: string, newEmitter: any): GPUParticleSystem;
  116077. /**
  116078. * Serializes the particle system to a JSON object.
  116079. * @returns the JSON object
  116080. */
  116081. serialize(): any;
  116082. /**
  116083. * Parses a JSON object to create a GPU particle system.
  116084. * @param parsedParticleSystem The JSON object to parse
  116085. * @param scene The scene to create the particle system in
  116086. * @param rootUrl The root url to use to load external dependencies like texture
  116087. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  116088. * @returns the parsed GPU particle system
  116089. */
  116090. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  116091. }
  116092. }
  116093. declare module BABYLON {
  116094. /**
  116095. * Represents a set of particle systems working together to create a specific effect
  116096. */
  116097. export class ParticleSystemSet implements IDisposable {
  116098. private _emitterCreationOptions;
  116099. private _emitterNode;
  116100. /**
  116101. * Gets the particle system list
  116102. */
  116103. systems: IParticleSystem[];
  116104. /**
  116105. * Gets the emitter node used with this set
  116106. */
  116107. readonly emitterNode: Nullable<TransformNode>;
  116108. /**
  116109. * Creates a new emitter mesh as a sphere
  116110. * @param options defines the options used to create the sphere
  116111. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  116112. * @param scene defines the hosting scene
  116113. */
  116114. setEmitterAsSphere(options: {
  116115. diameter: number;
  116116. segments: number;
  116117. color: Color3;
  116118. }, renderingGroupId: number, scene: Scene): void;
  116119. /**
  116120. * Starts all particle systems of the set
  116121. * @param emitter defines an optional mesh to use as emitter for the particle systems
  116122. */
  116123. start(emitter?: AbstractMesh): void;
  116124. /**
  116125. * Release all associated resources
  116126. */
  116127. dispose(): void;
  116128. /**
  116129. * Serialize the set into a JSON compatible object
  116130. * @returns a JSON compatible representation of the set
  116131. */
  116132. serialize(): any;
  116133. /**
  116134. * Parse a new ParticleSystemSet from a serialized source
  116135. * @param data defines a JSON compatible representation of the set
  116136. * @param scene defines the hosting scene
  116137. * @param gpu defines if we want GPU particles or CPU particles
  116138. * @returns a new ParticleSystemSet
  116139. */
  116140. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  116141. }
  116142. }
  116143. declare module BABYLON {
  116144. /**
  116145. * This class is made for on one-liner static method to help creating particle system set.
  116146. */
  116147. export class ParticleHelper {
  116148. /**
  116149. * Gets or sets base Assets URL
  116150. */
  116151. static BaseAssetsUrl: string;
  116152. /**
  116153. * Create a default particle system that you can tweak
  116154. * @param emitter defines the emitter to use
  116155. * @param capacity defines the system capacity (default is 500 particles)
  116156. * @param scene defines the hosting scene
  116157. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  116158. * @returns the new Particle system
  116159. */
  116160. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  116161. /**
  116162. * This is the main static method (one-liner) of this helper to create different particle systems
  116163. * @param type This string represents the type to the particle system to create
  116164. * @param scene The scene where the particle system should live
  116165. * @param gpu If the system will use gpu
  116166. * @returns the ParticleSystemSet created
  116167. */
  116168. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  116169. /**
  116170. * Static function used to export a particle system to a ParticleSystemSet variable.
  116171. * Please note that the emitter shape is not exported
  116172. * @param systems defines the particle systems to export
  116173. * @returns the created particle system set
  116174. */
  116175. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  116176. }
  116177. }
  116178. declare module BABYLON {
  116179. interface Engine {
  116180. /**
  116181. * Create an effect to use with particle systems.
  116182. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  116183. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  116184. * @param uniformsNames defines a list of attribute names
  116185. * @param samplers defines an array of string used to represent textures
  116186. * @param defines defines the string containing the defines to use to compile the shaders
  116187. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  116188. * @param onCompiled defines a function to call when the effect creation is successful
  116189. * @param onError defines a function to call when the effect creation has failed
  116190. * @returns the new Effect
  116191. */
  116192. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  116193. }
  116194. interface Mesh {
  116195. /**
  116196. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  116197. * @returns an array of IParticleSystem
  116198. */
  116199. getEmittedParticleSystems(): IParticleSystem[];
  116200. /**
  116201. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  116202. * @returns an array of IParticleSystem
  116203. */
  116204. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  116205. }
  116206. /**
  116207. * @hidden
  116208. */
  116209. export var _IDoNeedToBeInTheBuild: number;
  116210. }
  116211. declare module BABYLON {
  116212. interface Scene {
  116213. /** @hidden (Backing field) */
  116214. _physicsEngine: Nullable<IPhysicsEngine>;
  116215. /**
  116216. * Gets the current physics engine
  116217. * @returns a IPhysicsEngine or null if none attached
  116218. */
  116219. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  116220. /**
  116221. * Enables physics to the current scene
  116222. * @param gravity defines the scene's gravity for the physics engine
  116223. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  116224. * @return a boolean indicating if the physics engine was initialized
  116225. */
  116226. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  116227. /**
  116228. * Disables and disposes the physics engine associated with the scene
  116229. */
  116230. disablePhysicsEngine(): void;
  116231. /**
  116232. * Gets a boolean indicating if there is an active physics engine
  116233. * @returns a boolean indicating if there is an active physics engine
  116234. */
  116235. isPhysicsEnabled(): boolean;
  116236. /**
  116237. * Deletes a physics compound impostor
  116238. * @param compound defines the compound to delete
  116239. */
  116240. deleteCompoundImpostor(compound: any): void;
  116241. /**
  116242. * An event triggered when physic simulation is about to be run
  116243. */
  116244. onBeforePhysicsObservable: Observable<Scene>;
  116245. /**
  116246. * An event triggered when physic simulation has been done
  116247. */
  116248. onAfterPhysicsObservable: Observable<Scene>;
  116249. }
  116250. interface AbstractMesh {
  116251. /** @hidden */
  116252. _physicsImpostor: Nullable<PhysicsImpostor>;
  116253. /**
  116254. * Gets or sets impostor used for physic simulation
  116255. * @see http://doc.babylonjs.com/features/physics_engine
  116256. */
  116257. physicsImpostor: Nullable<PhysicsImpostor>;
  116258. /**
  116259. * Gets the current physics impostor
  116260. * @see http://doc.babylonjs.com/features/physics_engine
  116261. * @returns a physics impostor or null
  116262. */
  116263. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  116264. /** Apply a physic impulse to the mesh
  116265. * @param force defines the force to apply
  116266. * @param contactPoint defines where to apply the force
  116267. * @returns the current mesh
  116268. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  116269. */
  116270. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  116271. /**
  116272. * Creates a physic joint between two meshes
  116273. * @param otherMesh defines the other mesh to use
  116274. * @param pivot1 defines the pivot to use on this mesh
  116275. * @param pivot2 defines the pivot to use on the other mesh
  116276. * @param options defines additional options (can be plugin dependent)
  116277. * @returns the current mesh
  116278. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  116279. */
  116280. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  116281. /** @hidden */
  116282. _disposePhysicsObserver: Nullable<Observer<Node>>;
  116283. }
  116284. /**
  116285. * Defines the physics engine scene component responsible to manage a physics engine
  116286. */
  116287. export class PhysicsEngineSceneComponent implements ISceneComponent {
  116288. /**
  116289. * The component name helpful to identify the component in the list of scene components.
  116290. */
  116291. readonly name: string;
  116292. /**
  116293. * The scene the component belongs to.
  116294. */
  116295. scene: Scene;
  116296. /**
  116297. * Creates a new instance of the component for the given scene
  116298. * @param scene Defines the scene to register the component in
  116299. */
  116300. constructor(scene: Scene);
  116301. /**
  116302. * Registers the component in a given scene
  116303. */
  116304. register(): void;
  116305. /**
  116306. * Rebuilds the elements related to this component in case of
  116307. * context lost for instance.
  116308. */
  116309. rebuild(): void;
  116310. /**
  116311. * Disposes the component and the associated ressources
  116312. */
  116313. dispose(): void;
  116314. }
  116315. }
  116316. declare module BABYLON {
  116317. /**
  116318. * A helper for physics simulations
  116319. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116320. */
  116321. export class PhysicsHelper {
  116322. private _scene;
  116323. private _physicsEngine;
  116324. /**
  116325. * Initializes the Physics helper
  116326. * @param scene Babylon.js scene
  116327. */
  116328. constructor(scene: Scene);
  116329. /**
  116330. * Applies a radial explosion impulse
  116331. * @param origin the origin of the explosion
  116332. * @param radiusOrEventOptions the radius or the options of radial explosion
  116333. * @param strength the explosion strength
  116334. * @param falloff possible options: Constant & Linear. Defaults to Constant
  116335. * @returns A physics radial explosion event, or null
  116336. */
  116337. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  116338. /**
  116339. * Applies a radial explosion force
  116340. * @param origin the origin of the explosion
  116341. * @param radiusOrEventOptions the radius or the options of radial explosion
  116342. * @param strength the explosion strength
  116343. * @param falloff possible options: Constant & Linear. Defaults to Constant
  116344. * @returns A physics radial explosion event, or null
  116345. */
  116346. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  116347. /**
  116348. * Creates a gravitational field
  116349. * @param origin the origin of the explosion
  116350. * @param radiusOrEventOptions the radius or the options of radial explosion
  116351. * @param strength the explosion strength
  116352. * @param falloff possible options: Constant & Linear. Defaults to Constant
  116353. * @returns A physics gravitational field event, or null
  116354. */
  116355. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  116356. /**
  116357. * Creates a physics updraft event
  116358. * @param origin the origin of the updraft
  116359. * @param radiusOrEventOptions the radius or the options of the updraft
  116360. * @param strength the strength of the updraft
  116361. * @param height the height of the updraft
  116362. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  116363. * @returns A physics updraft event, or null
  116364. */
  116365. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  116366. /**
  116367. * Creates a physics vortex event
  116368. * @param origin the of the vortex
  116369. * @param radiusOrEventOptions the radius or the options of the vortex
  116370. * @param strength the strength of the vortex
  116371. * @param height the height of the vortex
  116372. * @returns a Physics vortex event, or null
  116373. * A physics vortex event or null
  116374. */
  116375. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  116376. }
  116377. /**
  116378. * Represents a physics radial explosion event
  116379. */
  116380. class PhysicsRadialExplosionEvent {
  116381. private _scene;
  116382. private _options;
  116383. private _sphere;
  116384. private _dataFetched;
  116385. /**
  116386. * Initializes a radial explosioin event
  116387. * @param _scene BabylonJS scene
  116388. * @param _options The options for the vortex event
  116389. */
  116390. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  116391. /**
  116392. * Returns the data related to the radial explosion event (sphere).
  116393. * @returns The radial explosion event data
  116394. */
  116395. getData(): PhysicsRadialExplosionEventData;
  116396. /**
  116397. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  116398. * @param impostor A physics imposter
  116399. * @param origin the origin of the explosion
  116400. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  116401. */
  116402. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  116403. /**
  116404. * Triggers affecterd impostors callbacks
  116405. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  116406. */
  116407. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  116408. /**
  116409. * Disposes the sphere.
  116410. * @param force Specifies if the sphere should be disposed by force
  116411. */
  116412. dispose(force?: boolean): void;
  116413. /*** Helpers ***/
  116414. private _prepareSphere;
  116415. private _intersectsWithSphere;
  116416. }
  116417. /**
  116418. * Represents a gravitational field event
  116419. */
  116420. class PhysicsGravitationalFieldEvent {
  116421. private _physicsHelper;
  116422. private _scene;
  116423. private _origin;
  116424. private _options;
  116425. private _tickCallback;
  116426. private _sphere;
  116427. private _dataFetched;
  116428. /**
  116429. * Initializes the physics gravitational field event
  116430. * @param _physicsHelper A physics helper
  116431. * @param _scene BabylonJS scene
  116432. * @param _origin The origin position of the gravitational field event
  116433. * @param _options The options for the vortex event
  116434. */
  116435. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  116436. /**
  116437. * Returns the data related to the gravitational field event (sphere).
  116438. * @returns A gravitational field event
  116439. */
  116440. getData(): PhysicsGravitationalFieldEventData;
  116441. /**
  116442. * Enables the gravitational field.
  116443. */
  116444. enable(): void;
  116445. /**
  116446. * Disables the gravitational field.
  116447. */
  116448. disable(): void;
  116449. /**
  116450. * Disposes the sphere.
  116451. * @param force The force to dispose from the gravitational field event
  116452. */
  116453. dispose(force?: boolean): void;
  116454. private _tick;
  116455. }
  116456. /**
  116457. * Represents a physics updraft event
  116458. */
  116459. class PhysicsUpdraftEvent {
  116460. private _scene;
  116461. private _origin;
  116462. private _options;
  116463. private _physicsEngine;
  116464. private _originTop;
  116465. private _originDirection;
  116466. private _tickCallback;
  116467. private _cylinder;
  116468. private _cylinderPosition;
  116469. private _dataFetched;
  116470. /**
  116471. * Initializes the physics updraft event
  116472. * @param _scene BabylonJS scene
  116473. * @param _origin The origin position of the updraft
  116474. * @param _options The options for the updraft event
  116475. */
  116476. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  116477. /**
  116478. * Returns the data related to the updraft event (cylinder).
  116479. * @returns A physics updraft event
  116480. */
  116481. getData(): PhysicsUpdraftEventData;
  116482. /**
  116483. * Enables the updraft.
  116484. */
  116485. enable(): void;
  116486. /**
  116487. * Disables the updraft.
  116488. */
  116489. disable(): void;
  116490. /**
  116491. * Disposes the cylinder.
  116492. * @param force Specifies if the updraft should be disposed by force
  116493. */
  116494. dispose(force?: boolean): void;
  116495. private getImpostorHitData;
  116496. private _tick;
  116497. /*** Helpers ***/
  116498. private _prepareCylinder;
  116499. private _intersectsWithCylinder;
  116500. }
  116501. /**
  116502. * Represents a physics vortex event
  116503. */
  116504. class PhysicsVortexEvent {
  116505. private _scene;
  116506. private _origin;
  116507. private _options;
  116508. private _physicsEngine;
  116509. private _originTop;
  116510. private _tickCallback;
  116511. private _cylinder;
  116512. private _cylinderPosition;
  116513. private _dataFetched;
  116514. /**
  116515. * Initializes the physics vortex event
  116516. * @param _scene The BabylonJS scene
  116517. * @param _origin The origin position of the vortex
  116518. * @param _options The options for the vortex event
  116519. */
  116520. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  116521. /**
  116522. * Returns the data related to the vortex event (cylinder).
  116523. * @returns The physics vortex event data
  116524. */
  116525. getData(): PhysicsVortexEventData;
  116526. /**
  116527. * Enables the vortex.
  116528. */
  116529. enable(): void;
  116530. /**
  116531. * Disables the cortex.
  116532. */
  116533. disable(): void;
  116534. /**
  116535. * Disposes the sphere.
  116536. * @param force
  116537. */
  116538. dispose(force?: boolean): void;
  116539. private getImpostorHitData;
  116540. private _tick;
  116541. /*** Helpers ***/
  116542. private _prepareCylinder;
  116543. private _intersectsWithCylinder;
  116544. }
  116545. /**
  116546. * Options fot the radial explosion event
  116547. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116548. */
  116549. export class PhysicsRadialExplosionEventOptions {
  116550. /**
  116551. * The radius of the sphere for the radial explosion.
  116552. */
  116553. radius: number;
  116554. /**
  116555. * The strenth of the explosion.
  116556. */
  116557. strength: number;
  116558. /**
  116559. * The strenght of the force in correspondence to the distance of the affected object
  116560. */
  116561. falloff: PhysicsRadialImpulseFalloff;
  116562. /**
  116563. * Sphere options for the radial explosion.
  116564. */
  116565. sphere: {
  116566. segments: number;
  116567. diameter: number;
  116568. };
  116569. /**
  116570. * Sphere options for the radial explosion.
  116571. */
  116572. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  116573. }
  116574. /**
  116575. * Options fot the updraft event
  116576. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116577. */
  116578. export class PhysicsUpdraftEventOptions {
  116579. /**
  116580. * The radius of the cylinder for the vortex
  116581. */
  116582. radius: number;
  116583. /**
  116584. * The strenth of the updraft.
  116585. */
  116586. strength: number;
  116587. /**
  116588. * The height of the cylinder for the updraft.
  116589. */
  116590. height: number;
  116591. /**
  116592. * The mode for the the updraft.
  116593. */
  116594. updraftMode: PhysicsUpdraftMode;
  116595. }
  116596. /**
  116597. * Options fot the vortex event
  116598. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116599. */
  116600. export class PhysicsVortexEventOptions {
  116601. /**
  116602. * The radius of the cylinder for the vortex
  116603. */
  116604. radius: number;
  116605. /**
  116606. * The strenth of the vortex.
  116607. */
  116608. strength: number;
  116609. /**
  116610. * The height of the cylinder for the vortex.
  116611. */
  116612. height: number;
  116613. /**
  116614. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  116615. */
  116616. centripetalForceThreshold: number;
  116617. /**
  116618. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  116619. */
  116620. centripetalForceMultiplier: number;
  116621. /**
  116622. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  116623. */
  116624. centrifugalForceMultiplier: number;
  116625. /**
  116626. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  116627. */
  116628. updraftForceMultiplier: number;
  116629. }
  116630. /**
  116631. * The strenght of the force in correspondence to the distance of the affected object
  116632. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116633. */
  116634. export enum PhysicsRadialImpulseFalloff {
  116635. /** Defines that impulse is constant in strength across it's whole radius */
  116636. Constant = 0,
  116637. /** Defines that impulse gets weaker if it's further from the origin */
  116638. Linear = 1
  116639. }
  116640. /**
  116641. * The strength of the force in correspondence to the distance of the affected object
  116642. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116643. */
  116644. export enum PhysicsUpdraftMode {
  116645. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  116646. Center = 0,
  116647. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  116648. Perpendicular = 1
  116649. }
  116650. /**
  116651. * Interface for a physics hit data
  116652. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116653. */
  116654. export interface PhysicsHitData {
  116655. /**
  116656. * The force applied at the contact point
  116657. */
  116658. force: Vector3;
  116659. /**
  116660. * The contact point
  116661. */
  116662. contactPoint: Vector3;
  116663. /**
  116664. * The distance from the origin to the contact point
  116665. */
  116666. distanceFromOrigin: number;
  116667. }
  116668. /**
  116669. * Interface for radial explosion event data
  116670. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116671. */
  116672. export interface PhysicsRadialExplosionEventData {
  116673. /**
  116674. * A sphere used for the radial explosion event
  116675. */
  116676. sphere: Mesh;
  116677. }
  116678. /**
  116679. * Interface for gravitational field event data
  116680. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116681. */
  116682. export interface PhysicsGravitationalFieldEventData {
  116683. /**
  116684. * A sphere mesh used for the gravitational field event
  116685. */
  116686. sphere: Mesh;
  116687. }
  116688. /**
  116689. * Interface for updraft event data
  116690. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116691. */
  116692. export interface PhysicsUpdraftEventData {
  116693. /**
  116694. * A cylinder used for the updraft event
  116695. */
  116696. cylinder: Mesh;
  116697. }
  116698. /**
  116699. * Interface for vortex event data
  116700. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116701. */
  116702. export interface PhysicsVortexEventData {
  116703. /**
  116704. * A cylinder used for the vortex event
  116705. */
  116706. cylinder: Mesh;
  116707. }
  116708. /**
  116709. * Interface for an affected physics impostor
  116710. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116711. */
  116712. export interface PhysicsAffectedImpostorWithData {
  116713. /**
  116714. * The impostor affected by the effect
  116715. */
  116716. impostor: PhysicsImpostor;
  116717. /**
  116718. * The data about the hit/horce from the explosion
  116719. */
  116720. hitData: PhysicsHitData;
  116721. }
  116722. }
  116723. declare module BABYLON {
  116724. /** @hidden */
  116725. export var blackAndWhitePixelShader: {
  116726. name: string;
  116727. shader: string;
  116728. };
  116729. }
  116730. declare module BABYLON {
  116731. /**
  116732. * Post process used to render in black and white
  116733. */
  116734. export class BlackAndWhitePostProcess extends PostProcess {
  116735. /**
  116736. * Linear about to convert he result to black and white (default: 1)
  116737. */
  116738. degree: number;
  116739. /**
  116740. * Creates a black and white post process
  116741. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  116742. * @param name The name of the effect.
  116743. * @param options The required width/height ratio to downsize to before computing the render pass.
  116744. * @param camera The camera to apply the render pass to.
  116745. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116746. * @param engine The engine which the post process will be applied. (default: current engine)
  116747. * @param reusable If the post process can be reused on the same frame. (default: false)
  116748. */
  116749. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  116750. }
  116751. }
  116752. declare module BABYLON {
  116753. /**
  116754. * This represents a set of one or more post processes in Babylon.
  116755. * A post process can be used to apply a shader to a texture after it is rendered.
  116756. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  116757. */
  116758. export class PostProcessRenderEffect {
  116759. private _postProcesses;
  116760. private _getPostProcesses;
  116761. private _singleInstance;
  116762. private _cameras;
  116763. private _indicesForCamera;
  116764. /**
  116765. * Name of the effect
  116766. * @hidden
  116767. */
  116768. _name: string;
  116769. /**
  116770. * Instantiates a post process render effect.
  116771. * A post process can be used to apply a shader to a texture after it is rendered.
  116772. * @param engine The engine the effect is tied to
  116773. * @param name The name of the effect
  116774. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  116775. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  116776. */
  116777. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  116778. /**
  116779. * Checks if all the post processes in the effect are supported.
  116780. */
  116781. readonly isSupported: boolean;
  116782. /**
  116783. * Updates the current state of the effect
  116784. * @hidden
  116785. */
  116786. _update(): void;
  116787. /**
  116788. * Attaches the effect on cameras
  116789. * @param cameras The camera to attach to.
  116790. * @hidden
  116791. */
  116792. _attachCameras(cameras: Camera): void;
  116793. /**
  116794. * Attaches the effect on cameras
  116795. * @param cameras The camera to attach to.
  116796. * @hidden
  116797. */
  116798. _attachCameras(cameras: Camera[]): void;
  116799. /**
  116800. * Detaches the effect on cameras
  116801. * @param cameras The camera to detatch from.
  116802. * @hidden
  116803. */
  116804. _detachCameras(cameras: Camera): void;
  116805. /**
  116806. * Detatches the effect on cameras
  116807. * @param cameras The camera to detatch from.
  116808. * @hidden
  116809. */
  116810. _detachCameras(cameras: Camera[]): void;
  116811. /**
  116812. * Enables the effect on given cameras
  116813. * @param cameras The camera to enable.
  116814. * @hidden
  116815. */
  116816. _enable(cameras: Camera): void;
  116817. /**
  116818. * Enables the effect on given cameras
  116819. * @param cameras The camera to enable.
  116820. * @hidden
  116821. */
  116822. _enable(cameras: Nullable<Camera[]>): void;
  116823. /**
  116824. * Disables the effect on the given cameras
  116825. * @param cameras The camera to disable.
  116826. * @hidden
  116827. */
  116828. _disable(cameras: Camera): void;
  116829. /**
  116830. * Disables the effect on the given cameras
  116831. * @param cameras The camera to disable.
  116832. * @hidden
  116833. */
  116834. _disable(cameras: Nullable<Camera[]>): void;
  116835. /**
  116836. * Gets a list of the post processes contained in the effect.
  116837. * @param camera The camera to get the post processes on.
  116838. * @returns The list of the post processes in the effect.
  116839. */
  116840. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  116841. }
  116842. }
  116843. declare module BABYLON {
  116844. /** @hidden */
  116845. export var extractHighlightsPixelShader: {
  116846. name: string;
  116847. shader: string;
  116848. };
  116849. }
  116850. declare module BABYLON {
  116851. /**
  116852. * 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.
  116853. */
  116854. export class ExtractHighlightsPostProcess extends PostProcess {
  116855. /**
  116856. * The luminance threshold, pixels below this value will be set to black.
  116857. */
  116858. threshold: number;
  116859. /** @hidden */
  116860. _exposure: number;
  116861. /**
  116862. * Post process which has the input texture to be used when performing highlight extraction
  116863. * @hidden
  116864. */
  116865. _inputPostProcess: Nullable<PostProcess>;
  116866. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  116867. }
  116868. }
  116869. declare module BABYLON {
  116870. /** @hidden */
  116871. export var bloomMergePixelShader: {
  116872. name: string;
  116873. shader: string;
  116874. };
  116875. }
  116876. declare module BABYLON {
  116877. /**
  116878. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  116879. */
  116880. export class BloomMergePostProcess extends PostProcess {
  116881. /** Weight of the bloom to be added to the original input. */
  116882. weight: number;
  116883. /**
  116884. * Creates a new instance of @see BloomMergePostProcess
  116885. * @param name The name of the effect.
  116886. * @param originalFromInput Post process which's input will be used for the merge.
  116887. * @param blurred Blurred highlights post process which's output will be used.
  116888. * @param weight Weight of the bloom to be added to the original input.
  116889. * @param options The required width/height ratio to downsize to before computing the render pass.
  116890. * @param camera The camera to apply the render pass to.
  116891. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116892. * @param engine The engine which the post process will be applied. (default: current engine)
  116893. * @param reusable If the post process can be reused on the same frame. (default: false)
  116894. * @param textureType Type of textures used when performing the post process. (default: 0)
  116895. * @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)
  116896. */
  116897. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  116898. /** Weight of the bloom to be added to the original input. */
  116899. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  116900. }
  116901. }
  116902. declare module BABYLON {
  116903. /**
  116904. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  116905. */
  116906. export class BloomEffect extends PostProcessRenderEffect {
  116907. private bloomScale;
  116908. /**
  116909. * @hidden Internal
  116910. */
  116911. _effects: Array<PostProcess>;
  116912. /**
  116913. * @hidden Internal
  116914. */
  116915. _downscale: ExtractHighlightsPostProcess;
  116916. private _blurX;
  116917. private _blurY;
  116918. private _merge;
  116919. /**
  116920. * The luminance threshold to find bright areas of the image to bloom.
  116921. */
  116922. threshold: number;
  116923. /**
  116924. * The strength of the bloom.
  116925. */
  116926. weight: number;
  116927. /**
  116928. * Specifies the size of the bloom blur kernel, relative to the final output size
  116929. */
  116930. kernel: number;
  116931. /**
  116932. * Creates a new instance of @see BloomEffect
  116933. * @param scene The scene the effect belongs to.
  116934. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  116935. * @param bloomKernel The size of the kernel to be used when applying the blur.
  116936. * @param bloomWeight The the strength of bloom.
  116937. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  116938. * @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)
  116939. */
  116940. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  116941. /**
  116942. * Disposes each of the internal effects for a given camera.
  116943. * @param camera The camera to dispose the effect on.
  116944. */
  116945. disposeEffects(camera: Camera): void;
  116946. /**
  116947. * @hidden Internal
  116948. */
  116949. _updateEffects(): void;
  116950. /**
  116951. * Internal
  116952. * @returns if all the contained post processes are ready.
  116953. * @hidden
  116954. */
  116955. _isReady(): boolean;
  116956. }
  116957. }
  116958. declare module BABYLON {
  116959. /** @hidden */
  116960. export var chromaticAberrationPixelShader: {
  116961. name: string;
  116962. shader: string;
  116963. };
  116964. }
  116965. declare module BABYLON {
  116966. /**
  116967. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  116968. */
  116969. export class ChromaticAberrationPostProcess extends PostProcess {
  116970. /**
  116971. * The amount of seperation of rgb channels (default: 30)
  116972. */
  116973. aberrationAmount: number;
  116974. /**
  116975. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  116976. */
  116977. radialIntensity: number;
  116978. /**
  116979. * 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))
  116980. */
  116981. direction: Vector2;
  116982. /**
  116983. * 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))
  116984. */
  116985. centerPosition: Vector2;
  116986. /**
  116987. * Creates a new instance ChromaticAberrationPostProcess
  116988. * @param name The name of the effect.
  116989. * @param screenWidth The width of the screen to apply the effect on.
  116990. * @param screenHeight The height of the screen to apply the effect on.
  116991. * @param options The required width/height ratio to downsize to before computing the render pass.
  116992. * @param camera The camera to apply the render pass to.
  116993. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116994. * @param engine The engine which the post process will be applied. (default: current engine)
  116995. * @param reusable If the post process can be reused on the same frame. (default: false)
  116996. * @param textureType Type of textures used when performing the post process. (default: 0)
  116997. * @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)
  116998. */
  116999. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117000. }
  117001. }
  117002. declare module BABYLON {
  117003. /** @hidden */
  117004. export var circleOfConfusionPixelShader: {
  117005. name: string;
  117006. shader: string;
  117007. };
  117008. }
  117009. declare module BABYLON {
  117010. /**
  117011. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  117012. */
  117013. export class CircleOfConfusionPostProcess extends PostProcess {
  117014. /**
  117015. * 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.
  117016. */
  117017. lensSize: number;
  117018. /**
  117019. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  117020. */
  117021. fStop: number;
  117022. /**
  117023. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  117024. */
  117025. focusDistance: number;
  117026. /**
  117027. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  117028. */
  117029. focalLength: number;
  117030. private _depthTexture;
  117031. /**
  117032. * Creates a new instance CircleOfConfusionPostProcess
  117033. * @param name The name of the effect.
  117034. * @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.
  117035. * @param options The required width/height ratio to downsize to before computing the render pass.
  117036. * @param camera The camera to apply the render pass to.
  117037. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117038. * @param engine The engine which the post process will be applied. (default: current engine)
  117039. * @param reusable If the post process can be reused on the same frame. (default: false)
  117040. * @param textureType Type of textures used when performing the post process. (default: 0)
  117041. * @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)
  117042. */
  117043. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117044. /**
  117045. * 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.
  117046. */
  117047. depthTexture: RenderTargetTexture;
  117048. }
  117049. }
  117050. declare module BABYLON {
  117051. /** @hidden */
  117052. export var colorCorrectionPixelShader: {
  117053. name: string;
  117054. shader: string;
  117055. };
  117056. }
  117057. declare module BABYLON {
  117058. /**
  117059. *
  117060. * This post-process allows the modification of rendered colors by using
  117061. * a 'look-up table' (LUT). This effect is also called Color Grading.
  117062. *
  117063. * The object needs to be provided an url to a texture containing the color
  117064. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  117065. * Use an image editing software to tweak the LUT to match your needs.
  117066. *
  117067. * For an example of a color LUT, see here:
  117068. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  117069. * For explanations on color grading, see here:
  117070. * @see http://udn.epicgames.com/Three/ColorGrading.html
  117071. *
  117072. */
  117073. export class ColorCorrectionPostProcess extends PostProcess {
  117074. private _colorTableTexture;
  117075. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  117076. }
  117077. }
  117078. declare module BABYLON {
  117079. /** @hidden */
  117080. export var convolutionPixelShader: {
  117081. name: string;
  117082. shader: string;
  117083. };
  117084. }
  117085. declare module BABYLON {
  117086. /**
  117087. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  117088. * input texture to perform effects such as edge detection or sharpening
  117089. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  117090. */
  117091. export class ConvolutionPostProcess extends PostProcess {
  117092. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  117093. kernel: number[];
  117094. /**
  117095. * Creates a new instance ConvolutionPostProcess
  117096. * @param name The name of the effect.
  117097. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  117098. * @param options The required width/height ratio to downsize to before computing the render pass.
  117099. * @param camera The camera to apply the render pass to.
  117100. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117101. * @param engine The engine which the post process will be applied. (default: current engine)
  117102. * @param reusable If the post process can be reused on the same frame. (default: false)
  117103. * @param textureType Type of textures used when performing the post process. (default: 0)
  117104. */
  117105. constructor(name: string,
  117106. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  117107. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  117108. /**
  117109. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117110. */
  117111. static EdgeDetect0Kernel: number[];
  117112. /**
  117113. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117114. */
  117115. static EdgeDetect1Kernel: number[];
  117116. /**
  117117. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117118. */
  117119. static EdgeDetect2Kernel: number[];
  117120. /**
  117121. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117122. */
  117123. static SharpenKernel: number[];
  117124. /**
  117125. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117126. */
  117127. static EmbossKernel: number[];
  117128. /**
  117129. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117130. */
  117131. static GaussianKernel: number[];
  117132. }
  117133. }
  117134. declare module BABYLON {
  117135. /**
  117136. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  117137. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  117138. * based on samples that have a large difference in distance than the center pixel.
  117139. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  117140. */
  117141. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  117142. direction: Vector2;
  117143. /**
  117144. * Creates a new instance CircleOfConfusionPostProcess
  117145. * @param name The name of the effect.
  117146. * @param scene The scene the effect belongs to.
  117147. * @param direction The direction the blur should be applied.
  117148. * @param kernel The size of the kernel used to blur.
  117149. * @param options The required width/height ratio to downsize to before computing the render pass.
  117150. * @param camera The camera to apply the render pass to.
  117151. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  117152. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  117153. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117154. * @param engine The engine which the post process will be applied. (default: current engine)
  117155. * @param reusable If the post process can be reused on the same frame. (default: false)
  117156. * @param textureType Type of textures used when performing the post process. (default: 0)
  117157. * @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)
  117158. */
  117159. 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);
  117160. }
  117161. }
  117162. declare module BABYLON {
  117163. /** @hidden */
  117164. export var depthOfFieldMergePixelShader: {
  117165. name: string;
  117166. shader: string;
  117167. };
  117168. }
  117169. declare module BABYLON {
  117170. /**
  117171. * Options to be set when merging outputs from the default pipeline.
  117172. */
  117173. export class DepthOfFieldMergePostProcessOptions {
  117174. /**
  117175. * The original image to merge on top of
  117176. */
  117177. originalFromInput: PostProcess;
  117178. /**
  117179. * Parameters to perform the merge of the depth of field effect
  117180. */
  117181. depthOfField?: {
  117182. circleOfConfusion: PostProcess;
  117183. blurSteps: Array<PostProcess>;
  117184. };
  117185. /**
  117186. * Parameters to perform the merge of bloom effect
  117187. */
  117188. bloom?: {
  117189. blurred: PostProcess;
  117190. weight: number;
  117191. };
  117192. }
  117193. /**
  117194. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  117195. */
  117196. export class DepthOfFieldMergePostProcess extends PostProcess {
  117197. private blurSteps;
  117198. /**
  117199. * Creates a new instance of DepthOfFieldMergePostProcess
  117200. * @param name The name of the effect.
  117201. * @param originalFromInput Post process which's input will be used for the merge.
  117202. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  117203. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  117204. * @param options The required width/height ratio to downsize to before computing the render pass.
  117205. * @param camera The camera to apply the render pass to.
  117206. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117207. * @param engine The engine which the post process will be applied. (default: current engine)
  117208. * @param reusable If the post process can be reused on the same frame. (default: false)
  117209. * @param textureType Type of textures used when performing the post process. (default: 0)
  117210. * @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)
  117211. */
  117212. 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);
  117213. /**
  117214. * Updates the effect with the current post process compile time values and recompiles the shader.
  117215. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  117216. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  117217. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  117218. * @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
  117219. * @param onCompiled Called when the shader has been compiled.
  117220. * @param onError Called if there is an error when compiling a shader.
  117221. */
  117222. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  117223. }
  117224. }
  117225. declare module BABYLON {
  117226. /**
  117227. * Specifies the level of max blur that should be applied when using the depth of field effect
  117228. */
  117229. export enum DepthOfFieldEffectBlurLevel {
  117230. /**
  117231. * Subtle blur
  117232. */
  117233. Low = 0,
  117234. /**
  117235. * Medium blur
  117236. */
  117237. Medium = 1,
  117238. /**
  117239. * Large blur
  117240. */
  117241. High = 2
  117242. }
  117243. /**
  117244. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  117245. */
  117246. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  117247. private _circleOfConfusion;
  117248. /**
  117249. * @hidden Internal, blurs from high to low
  117250. */
  117251. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  117252. private _depthOfFieldBlurY;
  117253. private _dofMerge;
  117254. /**
  117255. * @hidden Internal post processes in depth of field effect
  117256. */
  117257. _effects: Array<PostProcess>;
  117258. /**
  117259. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  117260. */
  117261. focalLength: number;
  117262. /**
  117263. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  117264. */
  117265. fStop: number;
  117266. /**
  117267. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  117268. */
  117269. focusDistance: number;
  117270. /**
  117271. * 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.
  117272. */
  117273. lensSize: number;
  117274. /**
  117275. * Creates a new instance DepthOfFieldEffect
  117276. * @param scene The scene the effect belongs to.
  117277. * @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.
  117278. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  117279. * @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)
  117280. */
  117281. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  117282. /**
  117283. * Get the current class name of the current effet
  117284. * @returns "DepthOfFieldEffect"
  117285. */
  117286. getClassName(): string;
  117287. /**
  117288. * 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.
  117289. */
  117290. depthTexture: RenderTargetTexture;
  117291. /**
  117292. * Disposes each of the internal effects for a given camera.
  117293. * @param camera The camera to dispose the effect on.
  117294. */
  117295. disposeEffects(camera: Camera): void;
  117296. /**
  117297. * @hidden Internal
  117298. */
  117299. _updateEffects(): void;
  117300. /**
  117301. * Internal
  117302. * @returns if all the contained post processes are ready.
  117303. * @hidden
  117304. */
  117305. _isReady(): boolean;
  117306. }
  117307. }
  117308. declare module BABYLON {
  117309. /** @hidden */
  117310. export var displayPassPixelShader: {
  117311. name: string;
  117312. shader: string;
  117313. };
  117314. }
  117315. declare module BABYLON {
  117316. /**
  117317. * DisplayPassPostProcess which produces an output the same as it's input
  117318. */
  117319. export class DisplayPassPostProcess extends PostProcess {
  117320. /**
  117321. * Creates the DisplayPassPostProcess
  117322. * @param name The name of the effect.
  117323. * @param options The required width/height ratio to downsize to before computing the render pass.
  117324. * @param camera The camera to apply the render pass to.
  117325. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117326. * @param engine The engine which the post process will be applied. (default: current engine)
  117327. * @param reusable If the post process can be reused on the same frame. (default: false)
  117328. */
  117329. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  117330. }
  117331. }
  117332. declare module BABYLON {
  117333. /** @hidden */
  117334. export var filterPixelShader: {
  117335. name: string;
  117336. shader: string;
  117337. };
  117338. }
  117339. declare module BABYLON {
  117340. /**
  117341. * Applies a kernel filter to the image
  117342. */
  117343. export class FilterPostProcess extends PostProcess {
  117344. /** The matrix to be applied to the image */
  117345. kernelMatrix: Matrix;
  117346. /**
  117347. *
  117348. * @param name The name of the effect.
  117349. * @param kernelMatrix The matrix to be applied to the image
  117350. * @param options The required width/height ratio to downsize to before computing the render pass.
  117351. * @param camera The camera to apply the render pass to.
  117352. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117353. * @param engine The engine which the post process will be applied. (default: current engine)
  117354. * @param reusable If the post process can be reused on the same frame. (default: false)
  117355. */
  117356. constructor(name: string,
  117357. /** The matrix to be applied to the image */
  117358. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  117359. }
  117360. }
  117361. declare module BABYLON {
  117362. /** @hidden */
  117363. export var fxaaPixelShader: {
  117364. name: string;
  117365. shader: string;
  117366. };
  117367. }
  117368. declare module BABYLON {
  117369. /** @hidden */
  117370. export var fxaaVertexShader: {
  117371. name: string;
  117372. shader: string;
  117373. };
  117374. }
  117375. declare module BABYLON {
  117376. /**
  117377. * Fxaa post process
  117378. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  117379. */
  117380. export class FxaaPostProcess extends PostProcess {
  117381. /** @hidden */
  117382. texelWidth: number;
  117383. /** @hidden */
  117384. texelHeight: number;
  117385. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  117386. private _getDefines;
  117387. }
  117388. }
  117389. declare module BABYLON {
  117390. /** @hidden */
  117391. export var grainPixelShader: {
  117392. name: string;
  117393. shader: string;
  117394. };
  117395. }
  117396. declare module BABYLON {
  117397. /**
  117398. * The GrainPostProcess adds noise to the image at mid luminance levels
  117399. */
  117400. export class GrainPostProcess extends PostProcess {
  117401. /**
  117402. * The intensity of the grain added (default: 30)
  117403. */
  117404. intensity: number;
  117405. /**
  117406. * If the grain should be randomized on every frame
  117407. */
  117408. animated: boolean;
  117409. /**
  117410. * Creates a new instance of @see GrainPostProcess
  117411. * @param name The name of the effect.
  117412. * @param options The required width/height ratio to downsize to before computing the render pass.
  117413. * @param camera The camera to apply the render pass to.
  117414. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117415. * @param engine The engine which the post process will be applied. (default: current engine)
  117416. * @param reusable If the post process can be reused on the same frame. (default: false)
  117417. * @param textureType Type of textures used when performing the post process. (default: 0)
  117418. * @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)
  117419. */
  117420. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117421. }
  117422. }
  117423. declare module BABYLON {
  117424. /** @hidden */
  117425. export var highlightsPixelShader: {
  117426. name: string;
  117427. shader: string;
  117428. };
  117429. }
  117430. declare module BABYLON {
  117431. /**
  117432. * Extracts highlights from the image
  117433. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  117434. */
  117435. export class HighlightsPostProcess extends PostProcess {
  117436. /**
  117437. * Extracts highlights from the image
  117438. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  117439. * @param name The name of the effect.
  117440. * @param options The required width/height ratio to downsize to before computing the render pass.
  117441. * @param camera The camera to apply the render pass to.
  117442. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117443. * @param engine The engine which the post process will be applied. (default: current engine)
  117444. * @param reusable If the post process can be reused on the same frame. (default: false)
  117445. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  117446. */
  117447. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  117448. }
  117449. }
  117450. declare module BABYLON {
  117451. /** @hidden */
  117452. export var mrtFragmentDeclaration: {
  117453. name: string;
  117454. shader: string;
  117455. };
  117456. }
  117457. declare module BABYLON {
  117458. /** @hidden */
  117459. export var geometryPixelShader: {
  117460. name: string;
  117461. shader: string;
  117462. };
  117463. }
  117464. declare module BABYLON {
  117465. /** @hidden */
  117466. export var geometryVertexShader: {
  117467. name: string;
  117468. shader: string;
  117469. };
  117470. }
  117471. declare module BABYLON {
  117472. /** @hidden */
  117473. interface ISavedTransformationMatrix {
  117474. world: Matrix;
  117475. viewProjection: Matrix;
  117476. }
  117477. /**
  117478. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  117479. */
  117480. export class GeometryBufferRenderer {
  117481. /**
  117482. * Constant used to retrieve the position texture index in the G-Buffer textures array
  117483. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  117484. */
  117485. static readonly POSITION_TEXTURE_TYPE: number;
  117486. /**
  117487. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  117488. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  117489. */
  117490. static readonly VELOCITY_TEXTURE_TYPE: number;
  117491. /**
  117492. * Dictionary used to store the previous transformation matrices of each rendered mesh
  117493. * in order to compute objects velocities when enableVelocity is set to "true"
  117494. * @hidden
  117495. */
  117496. _previousTransformationMatrices: {
  117497. [index: number]: ISavedTransformationMatrix;
  117498. };
  117499. /**
  117500. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  117501. * in order to compute objects velocities when enableVelocity is set to "true"
  117502. * @hidden
  117503. */
  117504. _previousBonesTransformationMatrices: {
  117505. [index: number]: Float32Array;
  117506. };
  117507. /**
  117508. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  117509. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  117510. */
  117511. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  117512. private _scene;
  117513. private _multiRenderTarget;
  117514. private _ratio;
  117515. private _enablePosition;
  117516. private _enableVelocity;
  117517. private _positionIndex;
  117518. private _velocityIndex;
  117519. protected _effect: Effect;
  117520. protected _cachedDefines: string;
  117521. /**
  117522. * Set the render list (meshes to be rendered) used in the G buffer.
  117523. */
  117524. renderList: Mesh[];
  117525. /**
  117526. * Gets wether or not G buffer are supported by the running hardware.
  117527. * This requires draw buffer supports
  117528. */
  117529. readonly isSupported: boolean;
  117530. /**
  117531. * Returns the index of the given texture type in the G-Buffer textures array
  117532. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  117533. * @returns the index of the given texture type in the G-Buffer textures array
  117534. */
  117535. getTextureIndex(textureType: number): number;
  117536. /**
  117537. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  117538. */
  117539. /**
  117540. * Sets whether or not objects positions are enabled for the G buffer.
  117541. */
  117542. enablePosition: boolean;
  117543. /**
  117544. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  117545. */
  117546. /**
  117547. * Sets wether or not objects velocities are enabled for the G buffer.
  117548. */
  117549. enableVelocity: boolean;
  117550. /**
  117551. * Gets the scene associated with the buffer.
  117552. */
  117553. readonly scene: Scene;
  117554. /**
  117555. * Gets the ratio used by the buffer during its creation.
  117556. * How big is the buffer related to the main canvas.
  117557. */
  117558. readonly ratio: number;
  117559. /** @hidden */
  117560. static _SceneComponentInitialization: (scene: Scene) => void;
  117561. /**
  117562. * Creates a new G Buffer for the scene
  117563. * @param scene The scene the buffer belongs to
  117564. * @param ratio How big is the buffer related to the main canvas.
  117565. */
  117566. constructor(scene: Scene, ratio?: number);
  117567. /**
  117568. * Checks wether everything is ready to render a submesh to the G buffer.
  117569. * @param subMesh the submesh to check readiness for
  117570. * @param useInstances is the mesh drawn using instance or not
  117571. * @returns true if ready otherwise false
  117572. */
  117573. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  117574. /**
  117575. * Gets the current underlying G Buffer.
  117576. * @returns the buffer
  117577. */
  117578. getGBuffer(): MultiRenderTarget;
  117579. /**
  117580. * Gets the number of samples used to render the buffer (anti aliasing).
  117581. */
  117582. /**
  117583. * Sets the number of samples used to render the buffer (anti aliasing).
  117584. */
  117585. samples: number;
  117586. /**
  117587. * Disposes the renderer and frees up associated resources.
  117588. */
  117589. dispose(): void;
  117590. protected _createRenderTargets(): void;
  117591. private _copyBonesTransformationMatrices;
  117592. }
  117593. }
  117594. declare module BABYLON {
  117595. interface Scene {
  117596. /** @hidden (Backing field) */
  117597. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  117598. /**
  117599. * Gets or Sets the current geometry buffer associated to the scene.
  117600. */
  117601. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  117602. /**
  117603. * Enables a GeometryBufferRender and associates it with the scene
  117604. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  117605. * @returns the GeometryBufferRenderer
  117606. */
  117607. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  117608. /**
  117609. * Disables the GeometryBufferRender associated with the scene
  117610. */
  117611. disableGeometryBufferRenderer(): void;
  117612. }
  117613. /**
  117614. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  117615. * in several rendering techniques.
  117616. */
  117617. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  117618. /**
  117619. * The component name helpful to identify the component in the list of scene components.
  117620. */
  117621. readonly name: string;
  117622. /**
  117623. * The scene the component belongs to.
  117624. */
  117625. scene: Scene;
  117626. /**
  117627. * Creates a new instance of the component for the given scene
  117628. * @param scene Defines the scene to register the component in
  117629. */
  117630. constructor(scene: Scene);
  117631. /**
  117632. * Registers the component in a given scene
  117633. */
  117634. register(): void;
  117635. /**
  117636. * Rebuilds the elements related to this component in case of
  117637. * context lost for instance.
  117638. */
  117639. rebuild(): void;
  117640. /**
  117641. * Disposes the component and the associated ressources
  117642. */
  117643. dispose(): void;
  117644. private _gatherRenderTargets;
  117645. }
  117646. }
  117647. declare module BABYLON {
  117648. /** @hidden */
  117649. export var motionBlurPixelShader: {
  117650. name: string;
  117651. shader: string;
  117652. };
  117653. }
  117654. declare module BABYLON {
  117655. /**
  117656. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  117657. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  117658. * As an example, all you have to do is to create the post-process:
  117659. * var mb = new BABYLON.MotionBlurPostProcess(
  117660. * 'mb', // The name of the effect.
  117661. * scene, // The scene containing the objects to blur according to their velocity.
  117662. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  117663. * camera // The camera to apply the render pass to.
  117664. * );
  117665. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  117666. */
  117667. export class MotionBlurPostProcess extends PostProcess {
  117668. /**
  117669. * Defines how much the image is blurred by the movement. Default value is equal to 1
  117670. */
  117671. motionStrength: number;
  117672. /**
  117673. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  117674. */
  117675. /**
  117676. * Sets the number of iterations to be used for motion blur quality
  117677. */
  117678. motionBlurSamples: number;
  117679. private _motionBlurSamples;
  117680. private _geometryBufferRenderer;
  117681. /**
  117682. * Creates a new instance MotionBlurPostProcess
  117683. * @param name The name of the effect.
  117684. * @param scene The scene containing the objects to blur according to their velocity.
  117685. * @param options The required width/height ratio to downsize to before computing the render pass.
  117686. * @param camera The camera to apply the render pass to.
  117687. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117688. * @param engine The engine which the post process will be applied. (default: current engine)
  117689. * @param reusable If the post process can be reused on the same frame. (default: false)
  117690. * @param textureType Type of textures used when performing the post process. (default: 0)
  117691. * @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)
  117692. */
  117693. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117694. /**
  117695. * Excludes the given skinned mesh from computing bones velocities.
  117696. * 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.
  117697. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  117698. */
  117699. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  117700. /**
  117701. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  117702. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  117703. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  117704. */
  117705. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  117706. /**
  117707. * Disposes the post process.
  117708. * @param camera The camera to dispose the post process on.
  117709. */
  117710. dispose(camera?: Camera): void;
  117711. }
  117712. }
  117713. declare module BABYLON {
  117714. /** @hidden */
  117715. export var refractionPixelShader: {
  117716. name: string;
  117717. shader: string;
  117718. };
  117719. }
  117720. declare module BABYLON {
  117721. /**
  117722. * Post process which applies a refractin texture
  117723. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  117724. */
  117725. export class RefractionPostProcess extends PostProcess {
  117726. /** the base color of the refraction (used to taint the rendering) */
  117727. color: Color3;
  117728. /** simulated refraction depth */
  117729. depth: number;
  117730. /** the coefficient of the base color (0 to remove base color tainting) */
  117731. colorLevel: number;
  117732. private _refTexture;
  117733. private _ownRefractionTexture;
  117734. /**
  117735. * Gets or sets the refraction texture
  117736. * Please note that you are responsible for disposing the texture if you set it manually
  117737. */
  117738. refractionTexture: Texture;
  117739. /**
  117740. * Initializes the RefractionPostProcess
  117741. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  117742. * @param name The name of the effect.
  117743. * @param refractionTextureUrl Url of the refraction texture to use
  117744. * @param color the base color of the refraction (used to taint the rendering)
  117745. * @param depth simulated refraction depth
  117746. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  117747. * @param camera The camera to apply the render pass to.
  117748. * @param options The required width/height ratio to downsize to before computing the render pass.
  117749. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117750. * @param engine The engine which the post process will be applied. (default: current engine)
  117751. * @param reusable If the post process can be reused on the same frame. (default: false)
  117752. */
  117753. constructor(name: string, refractionTextureUrl: string,
  117754. /** the base color of the refraction (used to taint the rendering) */
  117755. color: Color3,
  117756. /** simulated refraction depth */
  117757. depth: number,
  117758. /** the coefficient of the base color (0 to remove base color tainting) */
  117759. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  117760. /**
  117761. * Disposes of the post process
  117762. * @param camera Camera to dispose post process on
  117763. */
  117764. dispose(camera: Camera): void;
  117765. }
  117766. }
  117767. declare module BABYLON {
  117768. /** @hidden */
  117769. export var sharpenPixelShader: {
  117770. name: string;
  117771. shader: string;
  117772. };
  117773. }
  117774. declare module BABYLON {
  117775. /**
  117776. * The SharpenPostProcess applies a sharpen kernel to every pixel
  117777. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  117778. */
  117779. export class SharpenPostProcess extends PostProcess {
  117780. /**
  117781. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  117782. */
  117783. colorAmount: number;
  117784. /**
  117785. * How much sharpness should be applied (default: 0.3)
  117786. */
  117787. edgeAmount: number;
  117788. /**
  117789. * Creates a new instance ConvolutionPostProcess
  117790. * @param name The name of the effect.
  117791. * @param options The required width/height ratio to downsize to before computing the render pass.
  117792. * @param camera The camera to apply the render pass to.
  117793. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117794. * @param engine The engine which the post process will be applied. (default: current engine)
  117795. * @param reusable If the post process can be reused on the same frame. (default: false)
  117796. * @param textureType Type of textures used when performing the post process. (default: 0)
  117797. * @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)
  117798. */
  117799. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117800. }
  117801. }
  117802. declare module BABYLON {
  117803. /**
  117804. * PostProcessRenderPipeline
  117805. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  117806. */
  117807. export class PostProcessRenderPipeline {
  117808. private engine;
  117809. private _renderEffects;
  117810. private _renderEffectsForIsolatedPass;
  117811. /**
  117812. * List of inspectable custom properties (used by the Inspector)
  117813. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  117814. */
  117815. inspectableCustomProperties: IInspectable[];
  117816. /**
  117817. * @hidden
  117818. */
  117819. protected _cameras: Camera[];
  117820. /** @hidden */
  117821. _name: string;
  117822. /**
  117823. * Gets pipeline name
  117824. */
  117825. readonly name: string;
  117826. /**
  117827. * Initializes a PostProcessRenderPipeline
  117828. * @param engine engine to add the pipeline to
  117829. * @param name name of the pipeline
  117830. */
  117831. constructor(engine: Engine, name: string);
  117832. /**
  117833. * Gets the class name
  117834. * @returns "PostProcessRenderPipeline"
  117835. */
  117836. getClassName(): string;
  117837. /**
  117838. * If all the render effects in the pipeline are supported
  117839. */
  117840. readonly isSupported: boolean;
  117841. /**
  117842. * Adds an effect to the pipeline
  117843. * @param renderEffect the effect to add
  117844. */
  117845. addEffect(renderEffect: PostProcessRenderEffect): void;
  117846. /** @hidden */
  117847. _rebuild(): void;
  117848. /** @hidden */
  117849. _enableEffect(renderEffectName: string, cameras: Camera): void;
  117850. /** @hidden */
  117851. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  117852. /** @hidden */
  117853. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  117854. /** @hidden */
  117855. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  117856. /** @hidden */
  117857. _attachCameras(cameras: Camera, unique: boolean): void;
  117858. /** @hidden */
  117859. _attachCameras(cameras: Camera[], unique: boolean): void;
  117860. /** @hidden */
  117861. _detachCameras(cameras: Camera): void;
  117862. /** @hidden */
  117863. _detachCameras(cameras: Nullable<Camera[]>): void;
  117864. /** @hidden */
  117865. _update(): void;
  117866. /** @hidden */
  117867. _reset(): void;
  117868. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  117869. /**
  117870. * Disposes of the pipeline
  117871. */
  117872. dispose(): void;
  117873. }
  117874. }
  117875. declare module BABYLON {
  117876. /**
  117877. * PostProcessRenderPipelineManager class
  117878. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  117879. */
  117880. export class PostProcessRenderPipelineManager {
  117881. private _renderPipelines;
  117882. /**
  117883. * Initializes a PostProcessRenderPipelineManager
  117884. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  117885. */
  117886. constructor();
  117887. /**
  117888. * Gets the list of supported render pipelines
  117889. */
  117890. readonly supportedPipelines: PostProcessRenderPipeline[];
  117891. /**
  117892. * Adds a pipeline to the manager
  117893. * @param renderPipeline The pipeline to add
  117894. */
  117895. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  117896. /**
  117897. * Attaches a camera to the pipeline
  117898. * @param renderPipelineName The name of the pipeline to attach to
  117899. * @param cameras the camera to attach
  117900. * @param unique if the camera can be attached multiple times to the pipeline
  117901. */
  117902. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  117903. /**
  117904. * Detaches a camera from the pipeline
  117905. * @param renderPipelineName The name of the pipeline to detach from
  117906. * @param cameras the camera to detach
  117907. */
  117908. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  117909. /**
  117910. * Enables an effect by name on a pipeline
  117911. * @param renderPipelineName the name of the pipeline to enable the effect in
  117912. * @param renderEffectName the name of the effect to enable
  117913. * @param cameras the cameras that the effect should be enabled on
  117914. */
  117915. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  117916. /**
  117917. * Disables an effect by name on a pipeline
  117918. * @param renderPipelineName the name of the pipeline to disable the effect in
  117919. * @param renderEffectName the name of the effect to disable
  117920. * @param cameras the cameras that the effect should be disabled on
  117921. */
  117922. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  117923. /**
  117924. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  117925. */
  117926. update(): void;
  117927. /** @hidden */
  117928. _rebuild(): void;
  117929. /**
  117930. * Disposes of the manager and pipelines
  117931. */
  117932. dispose(): void;
  117933. }
  117934. }
  117935. declare module BABYLON {
  117936. interface Scene {
  117937. /** @hidden (Backing field) */
  117938. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  117939. /**
  117940. * Gets the postprocess render pipeline manager
  117941. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  117942. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  117943. */
  117944. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  117945. }
  117946. /**
  117947. * Defines the Render Pipeline scene component responsible to rendering pipelines
  117948. */
  117949. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  117950. /**
  117951. * The component name helpfull to identify the component in the list of scene components.
  117952. */
  117953. readonly name: string;
  117954. /**
  117955. * The scene the component belongs to.
  117956. */
  117957. scene: Scene;
  117958. /**
  117959. * Creates a new instance of the component for the given scene
  117960. * @param scene Defines the scene to register the component in
  117961. */
  117962. constructor(scene: Scene);
  117963. /**
  117964. * Registers the component in a given scene
  117965. */
  117966. register(): void;
  117967. /**
  117968. * Rebuilds the elements related to this component in case of
  117969. * context lost for instance.
  117970. */
  117971. rebuild(): void;
  117972. /**
  117973. * Disposes the component and the associated ressources
  117974. */
  117975. dispose(): void;
  117976. private _gatherRenderTargets;
  117977. }
  117978. }
  117979. declare module BABYLON {
  117980. /**
  117981. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  117982. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  117983. */
  117984. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  117985. private _scene;
  117986. private _camerasToBeAttached;
  117987. /**
  117988. * ID of the sharpen post process,
  117989. */
  117990. private readonly SharpenPostProcessId;
  117991. /**
  117992. * @ignore
  117993. * ID of the image processing post process;
  117994. */
  117995. readonly ImageProcessingPostProcessId: string;
  117996. /**
  117997. * @ignore
  117998. * ID of the Fast Approximate Anti-Aliasing post process;
  117999. */
  118000. readonly FxaaPostProcessId: string;
  118001. /**
  118002. * ID of the chromatic aberration post process,
  118003. */
  118004. private readonly ChromaticAberrationPostProcessId;
  118005. /**
  118006. * ID of the grain post process
  118007. */
  118008. private readonly GrainPostProcessId;
  118009. /**
  118010. * Sharpen post process which will apply a sharpen convolution to enhance edges
  118011. */
  118012. sharpen: SharpenPostProcess;
  118013. private _sharpenEffect;
  118014. private bloom;
  118015. /**
  118016. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  118017. */
  118018. depthOfField: DepthOfFieldEffect;
  118019. /**
  118020. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  118021. */
  118022. fxaa: FxaaPostProcess;
  118023. /**
  118024. * Image post processing pass used to perform operations such as tone mapping or color grading.
  118025. */
  118026. imageProcessing: ImageProcessingPostProcess;
  118027. /**
  118028. * Chromatic aberration post process which will shift rgb colors in the image
  118029. */
  118030. chromaticAberration: ChromaticAberrationPostProcess;
  118031. private _chromaticAberrationEffect;
  118032. /**
  118033. * Grain post process which add noise to the image
  118034. */
  118035. grain: GrainPostProcess;
  118036. private _grainEffect;
  118037. /**
  118038. * Glow post process which adds a glow to emissive areas of the image
  118039. */
  118040. private _glowLayer;
  118041. /**
  118042. * Animations which can be used to tweak settings over a period of time
  118043. */
  118044. animations: Animation[];
  118045. private _imageProcessingConfigurationObserver;
  118046. private _sharpenEnabled;
  118047. private _bloomEnabled;
  118048. private _depthOfFieldEnabled;
  118049. private _depthOfFieldBlurLevel;
  118050. private _fxaaEnabled;
  118051. private _imageProcessingEnabled;
  118052. private _defaultPipelineTextureType;
  118053. private _bloomScale;
  118054. private _chromaticAberrationEnabled;
  118055. private _grainEnabled;
  118056. private _buildAllowed;
  118057. /**
  118058. * Gets active scene
  118059. */
  118060. readonly scene: Scene;
  118061. /**
  118062. * Enable or disable the sharpen process from the pipeline
  118063. */
  118064. sharpenEnabled: boolean;
  118065. private _resizeObserver;
  118066. private _hardwareScaleLevel;
  118067. private _bloomKernel;
  118068. /**
  118069. * Specifies the size of the bloom blur kernel, relative to the final output size
  118070. */
  118071. bloomKernel: number;
  118072. /**
  118073. * Specifies the weight of the bloom in the final rendering
  118074. */
  118075. private _bloomWeight;
  118076. /**
  118077. * Specifies the luma threshold for the area that will be blurred by the bloom
  118078. */
  118079. private _bloomThreshold;
  118080. private _hdr;
  118081. /**
  118082. * The strength of the bloom.
  118083. */
  118084. bloomWeight: number;
  118085. /**
  118086. * The strength of the bloom.
  118087. */
  118088. bloomThreshold: number;
  118089. /**
  118090. * The scale of the bloom, lower value will provide better performance.
  118091. */
  118092. bloomScale: number;
  118093. /**
  118094. * Enable or disable the bloom from the pipeline
  118095. */
  118096. bloomEnabled: boolean;
  118097. private _rebuildBloom;
  118098. /**
  118099. * If the depth of field is enabled.
  118100. */
  118101. depthOfFieldEnabled: boolean;
  118102. /**
  118103. * Blur level of the depth of field effect. (Higher blur will effect performance)
  118104. */
  118105. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  118106. /**
  118107. * If the anti aliasing is enabled.
  118108. */
  118109. fxaaEnabled: boolean;
  118110. private _samples;
  118111. /**
  118112. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  118113. */
  118114. samples: number;
  118115. /**
  118116. * If image processing is enabled.
  118117. */
  118118. imageProcessingEnabled: boolean;
  118119. /**
  118120. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  118121. */
  118122. glowLayerEnabled: boolean;
  118123. /**
  118124. * Gets the glow layer (or null if not defined)
  118125. */
  118126. readonly glowLayer: Nullable<GlowLayer>;
  118127. /**
  118128. * Enable or disable the chromaticAberration process from the pipeline
  118129. */
  118130. chromaticAberrationEnabled: boolean;
  118131. /**
  118132. * Enable or disable the grain process from the pipeline
  118133. */
  118134. grainEnabled: boolean;
  118135. /**
  118136. * @constructor
  118137. * @param name - The rendering pipeline name (default: "")
  118138. * @param hdr - If high dynamic range textures should be used (default: true)
  118139. * @param scene - The scene linked to this pipeline (default: the last created scene)
  118140. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  118141. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  118142. */
  118143. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  118144. /**
  118145. * Get the class name
  118146. * @returns "DefaultRenderingPipeline"
  118147. */
  118148. getClassName(): string;
  118149. /**
  118150. * Force the compilation of the entire pipeline.
  118151. */
  118152. prepare(): void;
  118153. private _hasCleared;
  118154. private _prevPostProcess;
  118155. private _prevPrevPostProcess;
  118156. private _setAutoClearAndTextureSharing;
  118157. private _depthOfFieldSceneObserver;
  118158. private _buildPipeline;
  118159. private _disposePostProcesses;
  118160. /**
  118161. * Adds a camera to the pipeline
  118162. * @param camera the camera to be added
  118163. */
  118164. addCamera(camera: Camera): void;
  118165. /**
  118166. * Removes a camera from the pipeline
  118167. * @param camera the camera to remove
  118168. */
  118169. removeCamera(camera: Camera): void;
  118170. /**
  118171. * Dispose of the pipeline and stop all post processes
  118172. */
  118173. dispose(): void;
  118174. /**
  118175. * Serialize the rendering pipeline (Used when exporting)
  118176. * @returns the serialized object
  118177. */
  118178. serialize(): any;
  118179. /**
  118180. * Parse the serialized pipeline
  118181. * @param source Source pipeline.
  118182. * @param scene The scene to load the pipeline to.
  118183. * @param rootUrl The URL of the serialized pipeline.
  118184. * @returns An instantiated pipeline from the serialized object.
  118185. */
  118186. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  118187. }
  118188. }
  118189. declare module BABYLON {
  118190. /** @hidden */
  118191. export var lensHighlightsPixelShader: {
  118192. name: string;
  118193. shader: string;
  118194. };
  118195. }
  118196. declare module BABYLON {
  118197. /** @hidden */
  118198. export var depthOfFieldPixelShader: {
  118199. name: string;
  118200. shader: string;
  118201. };
  118202. }
  118203. declare module BABYLON {
  118204. /**
  118205. * BABYLON.JS Chromatic Aberration GLSL Shader
  118206. * Author: Olivier Guyot
  118207. * Separates very slightly R, G and B colors on the edges of the screen
  118208. * Inspired by Francois Tarlier & Martins Upitis
  118209. */
  118210. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  118211. /**
  118212. * @ignore
  118213. * The chromatic aberration PostProcess id in the pipeline
  118214. */
  118215. LensChromaticAberrationEffect: string;
  118216. /**
  118217. * @ignore
  118218. * The highlights enhancing PostProcess id in the pipeline
  118219. */
  118220. HighlightsEnhancingEffect: string;
  118221. /**
  118222. * @ignore
  118223. * The depth-of-field PostProcess id in the pipeline
  118224. */
  118225. LensDepthOfFieldEffect: string;
  118226. private _scene;
  118227. private _depthTexture;
  118228. private _grainTexture;
  118229. private _chromaticAberrationPostProcess;
  118230. private _highlightsPostProcess;
  118231. private _depthOfFieldPostProcess;
  118232. private _edgeBlur;
  118233. private _grainAmount;
  118234. private _chromaticAberration;
  118235. private _distortion;
  118236. private _highlightsGain;
  118237. private _highlightsThreshold;
  118238. private _dofDistance;
  118239. private _dofAperture;
  118240. private _dofDarken;
  118241. private _dofPentagon;
  118242. private _blurNoise;
  118243. /**
  118244. * @constructor
  118245. *
  118246. * Effect parameters are as follow:
  118247. * {
  118248. * chromatic_aberration: number; // from 0 to x (1 for realism)
  118249. * edge_blur: number; // from 0 to x (1 for realism)
  118250. * distortion: number; // from 0 to x (1 for realism)
  118251. * grain_amount: number; // from 0 to 1
  118252. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  118253. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  118254. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  118255. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  118256. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  118257. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  118258. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  118259. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  118260. * }
  118261. * Note: if an effect parameter is unset, effect is disabled
  118262. *
  118263. * @param name The rendering pipeline name
  118264. * @param parameters - An object containing all parameters (see above)
  118265. * @param scene The scene linked to this pipeline
  118266. * @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)
  118267. * @param cameras The array of cameras that the rendering pipeline will be attached to
  118268. */
  118269. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  118270. /**
  118271. * Get the class name
  118272. * @returns "LensRenderingPipeline"
  118273. */
  118274. getClassName(): string;
  118275. /**
  118276. * Gets associated scene
  118277. */
  118278. readonly scene: Scene;
  118279. /**
  118280. * Gets or sets the edge blur
  118281. */
  118282. edgeBlur: number;
  118283. /**
  118284. * Gets or sets the grain amount
  118285. */
  118286. grainAmount: number;
  118287. /**
  118288. * Gets or sets the chromatic aberration amount
  118289. */
  118290. chromaticAberration: number;
  118291. /**
  118292. * Gets or sets the depth of field aperture
  118293. */
  118294. dofAperture: number;
  118295. /**
  118296. * Gets or sets the edge distortion
  118297. */
  118298. edgeDistortion: number;
  118299. /**
  118300. * Gets or sets the depth of field distortion
  118301. */
  118302. dofDistortion: number;
  118303. /**
  118304. * Gets or sets the darken out of focus amount
  118305. */
  118306. darkenOutOfFocus: number;
  118307. /**
  118308. * Gets or sets a boolean indicating if blur noise is enabled
  118309. */
  118310. blurNoise: boolean;
  118311. /**
  118312. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  118313. */
  118314. pentagonBokeh: boolean;
  118315. /**
  118316. * Gets or sets the highlight grain amount
  118317. */
  118318. highlightsGain: number;
  118319. /**
  118320. * Gets or sets the highlight threshold
  118321. */
  118322. highlightsThreshold: number;
  118323. /**
  118324. * Sets the amount of blur at the edges
  118325. * @param amount blur amount
  118326. */
  118327. setEdgeBlur(amount: number): void;
  118328. /**
  118329. * Sets edge blur to 0
  118330. */
  118331. disableEdgeBlur(): void;
  118332. /**
  118333. * Sets the amout of grain
  118334. * @param amount Amount of grain
  118335. */
  118336. setGrainAmount(amount: number): void;
  118337. /**
  118338. * Set grain amount to 0
  118339. */
  118340. disableGrain(): void;
  118341. /**
  118342. * Sets the chromatic aberration amount
  118343. * @param amount amount of chromatic aberration
  118344. */
  118345. setChromaticAberration(amount: number): void;
  118346. /**
  118347. * Sets chromatic aberration amount to 0
  118348. */
  118349. disableChromaticAberration(): void;
  118350. /**
  118351. * Sets the EdgeDistortion amount
  118352. * @param amount amount of EdgeDistortion
  118353. */
  118354. setEdgeDistortion(amount: number): void;
  118355. /**
  118356. * Sets edge distortion to 0
  118357. */
  118358. disableEdgeDistortion(): void;
  118359. /**
  118360. * Sets the FocusDistance amount
  118361. * @param amount amount of FocusDistance
  118362. */
  118363. setFocusDistance(amount: number): void;
  118364. /**
  118365. * Disables depth of field
  118366. */
  118367. disableDepthOfField(): void;
  118368. /**
  118369. * Sets the Aperture amount
  118370. * @param amount amount of Aperture
  118371. */
  118372. setAperture(amount: number): void;
  118373. /**
  118374. * Sets the DarkenOutOfFocus amount
  118375. * @param amount amount of DarkenOutOfFocus
  118376. */
  118377. setDarkenOutOfFocus(amount: number): void;
  118378. private _pentagonBokehIsEnabled;
  118379. /**
  118380. * Creates a pentagon bokeh effect
  118381. */
  118382. enablePentagonBokeh(): void;
  118383. /**
  118384. * Disables the pentagon bokeh effect
  118385. */
  118386. disablePentagonBokeh(): void;
  118387. /**
  118388. * Enables noise blur
  118389. */
  118390. enableNoiseBlur(): void;
  118391. /**
  118392. * Disables noise blur
  118393. */
  118394. disableNoiseBlur(): void;
  118395. /**
  118396. * Sets the HighlightsGain amount
  118397. * @param amount amount of HighlightsGain
  118398. */
  118399. setHighlightsGain(amount: number): void;
  118400. /**
  118401. * Sets the HighlightsThreshold amount
  118402. * @param amount amount of HighlightsThreshold
  118403. */
  118404. setHighlightsThreshold(amount: number): void;
  118405. /**
  118406. * Disables highlights
  118407. */
  118408. disableHighlights(): void;
  118409. /**
  118410. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  118411. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  118412. */
  118413. dispose(disableDepthRender?: boolean): void;
  118414. private _createChromaticAberrationPostProcess;
  118415. private _createHighlightsPostProcess;
  118416. private _createDepthOfFieldPostProcess;
  118417. private _createGrainTexture;
  118418. }
  118419. }
  118420. declare module BABYLON {
  118421. /** @hidden */
  118422. export var ssao2PixelShader: {
  118423. name: string;
  118424. shader: string;
  118425. };
  118426. }
  118427. declare module BABYLON {
  118428. /** @hidden */
  118429. export var ssaoCombinePixelShader: {
  118430. name: string;
  118431. shader: string;
  118432. };
  118433. }
  118434. declare module BABYLON {
  118435. /**
  118436. * Render pipeline to produce ssao effect
  118437. */
  118438. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  118439. /**
  118440. * @ignore
  118441. * The PassPostProcess id in the pipeline that contains the original scene color
  118442. */
  118443. SSAOOriginalSceneColorEffect: string;
  118444. /**
  118445. * @ignore
  118446. * The SSAO PostProcess id in the pipeline
  118447. */
  118448. SSAORenderEffect: string;
  118449. /**
  118450. * @ignore
  118451. * The horizontal blur PostProcess id in the pipeline
  118452. */
  118453. SSAOBlurHRenderEffect: string;
  118454. /**
  118455. * @ignore
  118456. * The vertical blur PostProcess id in the pipeline
  118457. */
  118458. SSAOBlurVRenderEffect: string;
  118459. /**
  118460. * @ignore
  118461. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  118462. */
  118463. SSAOCombineRenderEffect: string;
  118464. /**
  118465. * The output strength of the SSAO post-process. Default value is 1.0.
  118466. */
  118467. totalStrength: number;
  118468. /**
  118469. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  118470. */
  118471. maxZ: number;
  118472. /**
  118473. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  118474. */
  118475. minZAspect: number;
  118476. private _samples;
  118477. /**
  118478. * Number of samples used for the SSAO calculations. Default value is 8
  118479. */
  118480. samples: number;
  118481. private _textureSamples;
  118482. /**
  118483. * Number of samples to use for antialiasing
  118484. */
  118485. textureSamples: number;
  118486. /**
  118487. * Ratio object used for SSAO ratio and blur ratio
  118488. */
  118489. private _ratio;
  118490. /**
  118491. * Dynamically generated sphere sampler.
  118492. */
  118493. private _sampleSphere;
  118494. /**
  118495. * Blur filter offsets
  118496. */
  118497. private _samplerOffsets;
  118498. private _expensiveBlur;
  118499. /**
  118500. * If bilateral blur should be used
  118501. */
  118502. expensiveBlur: boolean;
  118503. /**
  118504. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  118505. */
  118506. radius: number;
  118507. /**
  118508. * The base color of the SSAO post-process
  118509. * The final result is "base + ssao" between [0, 1]
  118510. */
  118511. base: number;
  118512. /**
  118513. * Support test.
  118514. */
  118515. static readonly IsSupported: boolean;
  118516. private _scene;
  118517. private _depthTexture;
  118518. private _normalTexture;
  118519. private _randomTexture;
  118520. private _originalColorPostProcess;
  118521. private _ssaoPostProcess;
  118522. private _blurHPostProcess;
  118523. private _blurVPostProcess;
  118524. private _ssaoCombinePostProcess;
  118525. private _firstUpdate;
  118526. /**
  118527. * Gets active scene
  118528. */
  118529. readonly scene: Scene;
  118530. /**
  118531. * @constructor
  118532. * @param name The rendering pipeline name
  118533. * @param scene The scene linked to this pipeline
  118534. * @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 }
  118535. * @param cameras The array of cameras that the rendering pipeline will be attached to
  118536. */
  118537. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  118538. /**
  118539. * Get the class name
  118540. * @returns "SSAO2RenderingPipeline"
  118541. */
  118542. getClassName(): string;
  118543. /**
  118544. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  118545. */
  118546. dispose(disableGeometryBufferRenderer?: boolean): void;
  118547. private _createBlurPostProcess;
  118548. /** @hidden */
  118549. _rebuild(): void;
  118550. private _bits;
  118551. private _radicalInverse_VdC;
  118552. private _hammersley;
  118553. private _hemisphereSample_uniform;
  118554. private _generateHemisphere;
  118555. private _createSSAOPostProcess;
  118556. private _createSSAOCombinePostProcess;
  118557. private _createRandomTexture;
  118558. /**
  118559. * Serialize the rendering pipeline (Used when exporting)
  118560. * @returns the serialized object
  118561. */
  118562. serialize(): any;
  118563. /**
  118564. * Parse the serialized pipeline
  118565. * @param source Source pipeline.
  118566. * @param scene The scene to load the pipeline to.
  118567. * @param rootUrl The URL of the serialized pipeline.
  118568. * @returns An instantiated pipeline from the serialized object.
  118569. */
  118570. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  118571. }
  118572. }
  118573. declare module BABYLON {
  118574. /** @hidden */
  118575. export var ssaoPixelShader: {
  118576. name: string;
  118577. shader: string;
  118578. };
  118579. }
  118580. declare module BABYLON {
  118581. /**
  118582. * Render pipeline to produce ssao effect
  118583. */
  118584. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  118585. /**
  118586. * @ignore
  118587. * The PassPostProcess id in the pipeline that contains the original scene color
  118588. */
  118589. SSAOOriginalSceneColorEffect: string;
  118590. /**
  118591. * @ignore
  118592. * The SSAO PostProcess id in the pipeline
  118593. */
  118594. SSAORenderEffect: string;
  118595. /**
  118596. * @ignore
  118597. * The horizontal blur PostProcess id in the pipeline
  118598. */
  118599. SSAOBlurHRenderEffect: string;
  118600. /**
  118601. * @ignore
  118602. * The vertical blur PostProcess id in the pipeline
  118603. */
  118604. SSAOBlurVRenderEffect: string;
  118605. /**
  118606. * @ignore
  118607. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  118608. */
  118609. SSAOCombineRenderEffect: string;
  118610. /**
  118611. * The output strength of the SSAO post-process. Default value is 1.0.
  118612. */
  118613. totalStrength: number;
  118614. /**
  118615. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  118616. */
  118617. radius: number;
  118618. /**
  118619. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  118620. * Must not be equal to fallOff and superior to fallOff.
  118621. * Default value is 0.0075
  118622. */
  118623. area: number;
  118624. /**
  118625. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  118626. * Must not be equal to area and inferior to area.
  118627. * Default value is 0.000001
  118628. */
  118629. fallOff: number;
  118630. /**
  118631. * The base color of the SSAO post-process
  118632. * The final result is "base + ssao" between [0, 1]
  118633. */
  118634. base: number;
  118635. private _scene;
  118636. private _depthTexture;
  118637. private _randomTexture;
  118638. private _originalColorPostProcess;
  118639. private _ssaoPostProcess;
  118640. private _blurHPostProcess;
  118641. private _blurVPostProcess;
  118642. private _ssaoCombinePostProcess;
  118643. private _firstUpdate;
  118644. /**
  118645. * Gets active scene
  118646. */
  118647. readonly scene: Scene;
  118648. /**
  118649. * @constructor
  118650. * @param name - The rendering pipeline name
  118651. * @param scene - The scene linked to this pipeline
  118652. * @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 }
  118653. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  118654. */
  118655. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  118656. /**
  118657. * Get the class name
  118658. * @returns "SSAORenderingPipeline"
  118659. */
  118660. getClassName(): string;
  118661. /**
  118662. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  118663. */
  118664. dispose(disableDepthRender?: boolean): void;
  118665. private _createBlurPostProcess;
  118666. /** @hidden */
  118667. _rebuild(): void;
  118668. private _createSSAOPostProcess;
  118669. private _createSSAOCombinePostProcess;
  118670. private _createRandomTexture;
  118671. }
  118672. }
  118673. declare module BABYLON {
  118674. /** @hidden */
  118675. export var standardPixelShader: {
  118676. name: string;
  118677. shader: string;
  118678. };
  118679. }
  118680. declare module BABYLON {
  118681. /**
  118682. * Standard rendering pipeline
  118683. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  118684. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  118685. */
  118686. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  118687. /**
  118688. * Public members
  118689. */
  118690. /**
  118691. * Post-process which contains the original scene color before the pipeline applies all the effects
  118692. */
  118693. originalPostProcess: Nullable<PostProcess>;
  118694. /**
  118695. * Post-process used to down scale an image x4
  118696. */
  118697. downSampleX4PostProcess: Nullable<PostProcess>;
  118698. /**
  118699. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  118700. */
  118701. brightPassPostProcess: Nullable<PostProcess>;
  118702. /**
  118703. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  118704. */
  118705. blurHPostProcesses: PostProcess[];
  118706. /**
  118707. * Post-process array storing all the vertical blur post-processes used by the pipeline
  118708. */
  118709. blurVPostProcesses: PostProcess[];
  118710. /**
  118711. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  118712. */
  118713. textureAdderPostProcess: Nullable<PostProcess>;
  118714. /**
  118715. * Post-process used to create volumetric lighting effect
  118716. */
  118717. volumetricLightPostProcess: Nullable<PostProcess>;
  118718. /**
  118719. * Post-process used to smooth the previous volumetric light post-process on the X axis
  118720. */
  118721. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  118722. /**
  118723. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  118724. */
  118725. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  118726. /**
  118727. * Post-process used to merge the volumetric light effect and the real scene color
  118728. */
  118729. volumetricLightMergePostProces: Nullable<PostProcess>;
  118730. /**
  118731. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  118732. */
  118733. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  118734. /**
  118735. * Base post-process used to calculate the average luminance of the final image for HDR
  118736. */
  118737. luminancePostProcess: Nullable<PostProcess>;
  118738. /**
  118739. * Post-processes used to create down sample post-processes in order to get
  118740. * the average luminance of the final image for HDR
  118741. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  118742. */
  118743. luminanceDownSamplePostProcesses: PostProcess[];
  118744. /**
  118745. * Post-process used to create a HDR effect (light adaptation)
  118746. */
  118747. hdrPostProcess: Nullable<PostProcess>;
  118748. /**
  118749. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  118750. */
  118751. textureAdderFinalPostProcess: Nullable<PostProcess>;
  118752. /**
  118753. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  118754. */
  118755. lensFlareFinalPostProcess: Nullable<PostProcess>;
  118756. /**
  118757. * Post-process used to merge the final HDR post-process and the real scene color
  118758. */
  118759. hdrFinalPostProcess: Nullable<PostProcess>;
  118760. /**
  118761. * Post-process used to create a lens flare effect
  118762. */
  118763. lensFlarePostProcess: Nullable<PostProcess>;
  118764. /**
  118765. * Post-process that merges the result of the lens flare post-process and the real scene color
  118766. */
  118767. lensFlareComposePostProcess: Nullable<PostProcess>;
  118768. /**
  118769. * Post-process used to create a motion blur effect
  118770. */
  118771. motionBlurPostProcess: Nullable<PostProcess>;
  118772. /**
  118773. * Post-process used to create a depth of field effect
  118774. */
  118775. depthOfFieldPostProcess: Nullable<PostProcess>;
  118776. /**
  118777. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  118778. */
  118779. fxaaPostProcess: Nullable<FxaaPostProcess>;
  118780. /**
  118781. * Represents the brightness threshold in order to configure the illuminated surfaces
  118782. */
  118783. brightThreshold: number;
  118784. /**
  118785. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  118786. */
  118787. blurWidth: number;
  118788. /**
  118789. * Sets if the blur for highlighted surfaces must be only horizontal
  118790. */
  118791. horizontalBlur: boolean;
  118792. /**
  118793. * Gets the overall exposure used by the pipeline
  118794. */
  118795. /**
  118796. * Sets the overall exposure used by the pipeline
  118797. */
  118798. exposure: number;
  118799. /**
  118800. * Texture used typically to simulate "dirty" on camera lens
  118801. */
  118802. lensTexture: Nullable<Texture>;
  118803. /**
  118804. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  118805. */
  118806. volumetricLightCoefficient: number;
  118807. /**
  118808. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  118809. */
  118810. volumetricLightPower: number;
  118811. /**
  118812. * Used the set the blur intensity to smooth the volumetric lights
  118813. */
  118814. volumetricLightBlurScale: number;
  118815. /**
  118816. * Light (spot or directional) used to generate the volumetric lights rays
  118817. * The source light must have a shadow generate so the pipeline can get its
  118818. * depth map
  118819. */
  118820. sourceLight: Nullable<SpotLight | DirectionalLight>;
  118821. /**
  118822. * For eye adaptation, represents the minimum luminance the eye can see
  118823. */
  118824. hdrMinimumLuminance: number;
  118825. /**
  118826. * For eye adaptation, represents the decrease luminance speed
  118827. */
  118828. hdrDecreaseRate: number;
  118829. /**
  118830. * For eye adaptation, represents the increase luminance speed
  118831. */
  118832. hdrIncreaseRate: number;
  118833. /**
  118834. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  118835. */
  118836. /**
  118837. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  118838. */
  118839. hdrAutoExposure: boolean;
  118840. /**
  118841. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  118842. */
  118843. lensColorTexture: Nullable<Texture>;
  118844. /**
  118845. * The overall strengh for the lens flare effect
  118846. */
  118847. lensFlareStrength: number;
  118848. /**
  118849. * Dispersion coefficient for lens flare ghosts
  118850. */
  118851. lensFlareGhostDispersal: number;
  118852. /**
  118853. * Main lens flare halo width
  118854. */
  118855. lensFlareHaloWidth: number;
  118856. /**
  118857. * Based on the lens distortion effect, defines how much the lens flare result
  118858. * is distorted
  118859. */
  118860. lensFlareDistortionStrength: number;
  118861. /**
  118862. * Lens star texture must be used to simulate rays on the flares and is available
  118863. * in the documentation
  118864. */
  118865. lensStarTexture: Nullable<Texture>;
  118866. /**
  118867. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  118868. * flare effect by taking account of the dirt texture
  118869. */
  118870. lensFlareDirtTexture: Nullable<Texture>;
  118871. /**
  118872. * Represents the focal length for the depth of field effect
  118873. */
  118874. depthOfFieldDistance: number;
  118875. /**
  118876. * Represents the blur intensity for the blurred part of the depth of field effect
  118877. */
  118878. depthOfFieldBlurWidth: number;
  118879. /**
  118880. * Gets how much the image is blurred by the movement while using the motion blur post-process
  118881. */
  118882. /**
  118883. * Sets how much the image is blurred by the movement while using the motion blur post-process
  118884. */
  118885. motionStrength: number;
  118886. /**
  118887. * Gets wether or not the motion blur post-process is object based or screen based.
  118888. */
  118889. /**
  118890. * Sets wether or not the motion blur post-process should be object based or screen based
  118891. */
  118892. objectBasedMotionBlur: boolean;
  118893. /**
  118894. * List of animations for the pipeline (IAnimatable implementation)
  118895. */
  118896. animations: Animation[];
  118897. /**
  118898. * Private members
  118899. */
  118900. private _scene;
  118901. private _currentDepthOfFieldSource;
  118902. private _basePostProcess;
  118903. private _fixedExposure;
  118904. private _currentExposure;
  118905. private _hdrAutoExposure;
  118906. private _hdrCurrentLuminance;
  118907. private _motionStrength;
  118908. private _isObjectBasedMotionBlur;
  118909. private _floatTextureType;
  118910. private _ratio;
  118911. private _bloomEnabled;
  118912. private _depthOfFieldEnabled;
  118913. private _vlsEnabled;
  118914. private _lensFlareEnabled;
  118915. private _hdrEnabled;
  118916. private _motionBlurEnabled;
  118917. private _fxaaEnabled;
  118918. private _motionBlurSamples;
  118919. private _volumetricLightStepsCount;
  118920. private _samples;
  118921. /**
  118922. * @ignore
  118923. * Specifies if the bloom pipeline is enabled
  118924. */
  118925. BloomEnabled: boolean;
  118926. /**
  118927. * @ignore
  118928. * Specifies if the depth of field pipeline is enabed
  118929. */
  118930. DepthOfFieldEnabled: boolean;
  118931. /**
  118932. * @ignore
  118933. * Specifies if the lens flare pipeline is enabed
  118934. */
  118935. LensFlareEnabled: boolean;
  118936. /**
  118937. * @ignore
  118938. * Specifies if the HDR pipeline is enabled
  118939. */
  118940. HDREnabled: boolean;
  118941. /**
  118942. * @ignore
  118943. * Specifies if the volumetric lights scattering effect is enabled
  118944. */
  118945. VLSEnabled: boolean;
  118946. /**
  118947. * @ignore
  118948. * Specifies if the motion blur effect is enabled
  118949. */
  118950. MotionBlurEnabled: boolean;
  118951. /**
  118952. * Specifies if anti-aliasing is enabled
  118953. */
  118954. fxaaEnabled: boolean;
  118955. /**
  118956. * Specifies the number of steps used to calculate the volumetric lights
  118957. * Typically in interval [50, 200]
  118958. */
  118959. volumetricLightStepsCount: number;
  118960. /**
  118961. * Specifies the number of samples used for the motion blur effect
  118962. * Typically in interval [16, 64]
  118963. */
  118964. motionBlurSamples: number;
  118965. /**
  118966. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  118967. */
  118968. samples: number;
  118969. /**
  118970. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  118971. * @constructor
  118972. * @param name The rendering pipeline name
  118973. * @param scene The scene linked to this pipeline
  118974. * @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)
  118975. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  118976. * @param cameras The array of cameras that the rendering pipeline will be attached to
  118977. */
  118978. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  118979. private _buildPipeline;
  118980. private _createDownSampleX4PostProcess;
  118981. private _createBrightPassPostProcess;
  118982. private _createBlurPostProcesses;
  118983. private _createTextureAdderPostProcess;
  118984. private _createVolumetricLightPostProcess;
  118985. private _createLuminancePostProcesses;
  118986. private _createHdrPostProcess;
  118987. private _createLensFlarePostProcess;
  118988. private _createDepthOfFieldPostProcess;
  118989. private _createMotionBlurPostProcess;
  118990. private _getDepthTexture;
  118991. private _disposePostProcesses;
  118992. /**
  118993. * Dispose of the pipeline and stop all post processes
  118994. */
  118995. dispose(): void;
  118996. /**
  118997. * Serialize the rendering pipeline (Used when exporting)
  118998. * @returns the serialized object
  118999. */
  119000. serialize(): any;
  119001. /**
  119002. * Parse the serialized pipeline
  119003. * @param source Source pipeline.
  119004. * @param scene The scene to load the pipeline to.
  119005. * @param rootUrl The URL of the serialized pipeline.
  119006. * @returns An instantiated pipeline from the serialized object.
  119007. */
  119008. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  119009. /**
  119010. * Luminance steps
  119011. */
  119012. static LuminanceSteps: number;
  119013. }
  119014. }
  119015. declare module BABYLON {
  119016. /** @hidden */
  119017. export var tonemapPixelShader: {
  119018. name: string;
  119019. shader: string;
  119020. };
  119021. }
  119022. declare module BABYLON {
  119023. /** Defines operator used for tonemapping */
  119024. export enum TonemappingOperator {
  119025. /** Hable */
  119026. Hable = 0,
  119027. /** Reinhard */
  119028. Reinhard = 1,
  119029. /** HejiDawson */
  119030. HejiDawson = 2,
  119031. /** Photographic */
  119032. Photographic = 3
  119033. }
  119034. /**
  119035. * Defines a post process to apply tone mapping
  119036. */
  119037. export class TonemapPostProcess extends PostProcess {
  119038. private _operator;
  119039. /** Defines the required exposure adjustement */
  119040. exposureAdjustment: number;
  119041. /**
  119042. * Creates a new TonemapPostProcess
  119043. * @param name defines the name of the postprocess
  119044. * @param _operator defines the operator to use
  119045. * @param exposureAdjustment defines the required exposure adjustement
  119046. * @param camera defines the camera to use (can be null)
  119047. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  119048. * @param engine defines the hosting engine (can be ignore if camera is set)
  119049. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  119050. */
  119051. constructor(name: string, _operator: TonemappingOperator,
  119052. /** Defines the required exposure adjustement */
  119053. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  119054. }
  119055. }
  119056. declare module BABYLON {
  119057. /** @hidden */
  119058. export var depthVertexShader: {
  119059. name: string;
  119060. shader: string;
  119061. };
  119062. }
  119063. declare module BABYLON {
  119064. /** @hidden */
  119065. export var volumetricLightScatteringPixelShader: {
  119066. name: string;
  119067. shader: string;
  119068. };
  119069. }
  119070. declare module BABYLON {
  119071. /** @hidden */
  119072. export var volumetricLightScatteringPassPixelShader: {
  119073. name: string;
  119074. shader: string;
  119075. };
  119076. }
  119077. declare module BABYLON {
  119078. /**
  119079. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  119080. */
  119081. export class VolumetricLightScatteringPostProcess extends PostProcess {
  119082. private _volumetricLightScatteringPass;
  119083. private _volumetricLightScatteringRTT;
  119084. private _viewPort;
  119085. private _screenCoordinates;
  119086. private _cachedDefines;
  119087. /**
  119088. * If not undefined, the mesh position is computed from the attached node position
  119089. */
  119090. attachedNode: {
  119091. position: Vector3;
  119092. };
  119093. /**
  119094. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  119095. */
  119096. customMeshPosition: Vector3;
  119097. /**
  119098. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  119099. */
  119100. useCustomMeshPosition: boolean;
  119101. /**
  119102. * If the post-process should inverse the light scattering direction
  119103. */
  119104. invert: boolean;
  119105. /**
  119106. * The internal mesh used by the post-process
  119107. */
  119108. mesh: Mesh;
  119109. /**
  119110. * @hidden
  119111. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  119112. */
  119113. useDiffuseColor: boolean;
  119114. /**
  119115. * Array containing the excluded meshes not rendered in the internal pass
  119116. */
  119117. excludedMeshes: AbstractMesh[];
  119118. /**
  119119. * Controls the overall intensity of the post-process
  119120. */
  119121. exposure: number;
  119122. /**
  119123. * Dissipates each sample's contribution in range [0, 1]
  119124. */
  119125. decay: number;
  119126. /**
  119127. * Controls the overall intensity of each sample
  119128. */
  119129. weight: number;
  119130. /**
  119131. * Controls the density of each sample
  119132. */
  119133. density: number;
  119134. /**
  119135. * @constructor
  119136. * @param name The post-process name
  119137. * @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)
  119138. * @param camera The camera that the post-process will be attached to
  119139. * @param mesh The mesh used to create the light scattering
  119140. * @param samples The post-process quality, default 100
  119141. * @param samplingModeThe post-process filtering mode
  119142. * @param engine The babylon engine
  119143. * @param reusable If the post-process is reusable
  119144. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  119145. */
  119146. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  119147. /**
  119148. * Returns the string "VolumetricLightScatteringPostProcess"
  119149. * @returns "VolumetricLightScatteringPostProcess"
  119150. */
  119151. getClassName(): string;
  119152. private _isReady;
  119153. /**
  119154. * Sets the new light position for light scattering effect
  119155. * @param position The new custom light position
  119156. */
  119157. setCustomMeshPosition(position: Vector3): void;
  119158. /**
  119159. * Returns the light position for light scattering effect
  119160. * @return Vector3 The custom light position
  119161. */
  119162. getCustomMeshPosition(): Vector3;
  119163. /**
  119164. * Disposes the internal assets and detaches the post-process from the camera
  119165. */
  119166. dispose(camera: Camera): void;
  119167. /**
  119168. * Returns the render target texture used by the post-process
  119169. * @return the render target texture used by the post-process
  119170. */
  119171. getPass(): RenderTargetTexture;
  119172. private _meshExcluded;
  119173. private _createPass;
  119174. private _updateMeshScreenCoordinates;
  119175. /**
  119176. * Creates a default mesh for the Volumeric Light Scattering post-process
  119177. * @param name The mesh name
  119178. * @param scene The scene where to create the mesh
  119179. * @return the default mesh
  119180. */
  119181. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  119182. }
  119183. }
  119184. declare module BABYLON {
  119185. interface Scene {
  119186. /** @hidden (Backing field) */
  119187. _boundingBoxRenderer: BoundingBoxRenderer;
  119188. /** @hidden (Backing field) */
  119189. _forceShowBoundingBoxes: boolean;
  119190. /**
  119191. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  119192. */
  119193. forceShowBoundingBoxes: boolean;
  119194. /**
  119195. * Gets the bounding box renderer associated with the scene
  119196. * @returns a BoundingBoxRenderer
  119197. */
  119198. getBoundingBoxRenderer(): BoundingBoxRenderer;
  119199. }
  119200. interface AbstractMesh {
  119201. /** @hidden (Backing field) */
  119202. _showBoundingBox: boolean;
  119203. /**
  119204. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  119205. */
  119206. showBoundingBox: boolean;
  119207. }
  119208. /**
  119209. * Component responsible of rendering the bounding box of the meshes in a scene.
  119210. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  119211. */
  119212. export class BoundingBoxRenderer implements ISceneComponent {
  119213. /**
  119214. * The component name helpfull to identify the component in the list of scene components.
  119215. */
  119216. readonly name: string;
  119217. /**
  119218. * The scene the component belongs to.
  119219. */
  119220. scene: Scene;
  119221. /**
  119222. * Color of the bounding box lines placed in front of an object
  119223. */
  119224. frontColor: Color3;
  119225. /**
  119226. * Color of the bounding box lines placed behind an object
  119227. */
  119228. backColor: Color3;
  119229. /**
  119230. * Defines if the renderer should show the back lines or not
  119231. */
  119232. showBackLines: boolean;
  119233. /**
  119234. * @hidden
  119235. */
  119236. renderList: SmartArray<BoundingBox>;
  119237. private _colorShader;
  119238. private _vertexBuffers;
  119239. private _indexBuffer;
  119240. private _fillIndexBuffer;
  119241. private _fillIndexData;
  119242. /**
  119243. * Instantiates a new bounding box renderer in a scene.
  119244. * @param scene the scene the renderer renders in
  119245. */
  119246. constructor(scene: Scene);
  119247. /**
  119248. * Registers the component in a given scene
  119249. */
  119250. register(): void;
  119251. private _evaluateSubMesh;
  119252. private _activeMesh;
  119253. private _prepareRessources;
  119254. private _createIndexBuffer;
  119255. /**
  119256. * Rebuilds the elements related to this component in case of
  119257. * context lost for instance.
  119258. */
  119259. rebuild(): void;
  119260. /**
  119261. * @hidden
  119262. */
  119263. reset(): void;
  119264. /**
  119265. * Render the bounding boxes of a specific rendering group
  119266. * @param renderingGroupId defines the rendering group to render
  119267. */
  119268. render(renderingGroupId: number): void;
  119269. /**
  119270. * In case of occlusion queries, we can render the occlusion bounding box through this method
  119271. * @param mesh Define the mesh to render the occlusion bounding box for
  119272. */
  119273. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  119274. /**
  119275. * Dispose and release the resources attached to this renderer.
  119276. */
  119277. dispose(): void;
  119278. }
  119279. }
  119280. declare module BABYLON {
  119281. /** @hidden */
  119282. export var depthPixelShader: {
  119283. name: string;
  119284. shader: string;
  119285. };
  119286. }
  119287. declare module BABYLON {
  119288. /**
  119289. * This represents a depth renderer in Babylon.
  119290. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  119291. */
  119292. export class DepthRenderer {
  119293. private _scene;
  119294. private _depthMap;
  119295. private _effect;
  119296. private _cachedDefines;
  119297. private _camera;
  119298. /**
  119299. * Specifiess that the depth renderer will only be used within
  119300. * the camera it is created for.
  119301. * This can help forcing its rendering during the camera processing.
  119302. */
  119303. useOnlyInActiveCamera: boolean;
  119304. /** @hidden */
  119305. static _SceneComponentInitialization: (scene: Scene) => void;
  119306. /**
  119307. * Instantiates a depth renderer
  119308. * @param scene The scene the renderer belongs to
  119309. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  119310. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  119311. */
  119312. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  119313. /**
  119314. * Creates the depth rendering effect and checks if the effect is ready.
  119315. * @param subMesh The submesh to be used to render the depth map of
  119316. * @param useInstances If multiple world instances should be used
  119317. * @returns if the depth renderer is ready to render the depth map
  119318. */
  119319. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  119320. /**
  119321. * Gets the texture which the depth map will be written to.
  119322. * @returns The depth map texture
  119323. */
  119324. getDepthMap(): RenderTargetTexture;
  119325. /**
  119326. * Disposes of the depth renderer.
  119327. */
  119328. dispose(): void;
  119329. }
  119330. }
  119331. declare module BABYLON {
  119332. interface Scene {
  119333. /** @hidden (Backing field) */
  119334. _depthRenderer: {
  119335. [id: string]: DepthRenderer;
  119336. };
  119337. /**
  119338. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  119339. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  119340. * @returns the created depth renderer
  119341. */
  119342. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  119343. /**
  119344. * Disables a depth renderer for a given camera
  119345. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  119346. */
  119347. disableDepthRenderer(camera?: Nullable<Camera>): void;
  119348. }
  119349. /**
  119350. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  119351. * in several rendering techniques.
  119352. */
  119353. export class DepthRendererSceneComponent implements ISceneComponent {
  119354. /**
  119355. * The component name helpfull to identify the component in the list of scene components.
  119356. */
  119357. readonly name: string;
  119358. /**
  119359. * The scene the component belongs to.
  119360. */
  119361. scene: Scene;
  119362. /**
  119363. * Creates a new instance of the component for the given scene
  119364. * @param scene Defines the scene to register the component in
  119365. */
  119366. constructor(scene: Scene);
  119367. /**
  119368. * Registers the component in a given scene
  119369. */
  119370. register(): void;
  119371. /**
  119372. * Rebuilds the elements related to this component in case of
  119373. * context lost for instance.
  119374. */
  119375. rebuild(): void;
  119376. /**
  119377. * Disposes the component and the associated ressources
  119378. */
  119379. dispose(): void;
  119380. private _gatherRenderTargets;
  119381. private _gatherActiveCameraRenderTargets;
  119382. }
  119383. }
  119384. declare module BABYLON {
  119385. /** @hidden */
  119386. export var outlinePixelShader: {
  119387. name: string;
  119388. shader: string;
  119389. };
  119390. }
  119391. declare module BABYLON {
  119392. /** @hidden */
  119393. export var outlineVertexShader: {
  119394. name: string;
  119395. shader: string;
  119396. };
  119397. }
  119398. declare module BABYLON {
  119399. interface Scene {
  119400. /** @hidden */
  119401. _outlineRenderer: OutlineRenderer;
  119402. /**
  119403. * Gets the outline renderer associated with the scene
  119404. * @returns a OutlineRenderer
  119405. */
  119406. getOutlineRenderer(): OutlineRenderer;
  119407. }
  119408. interface AbstractMesh {
  119409. /** @hidden (Backing field) */
  119410. _renderOutline: boolean;
  119411. /**
  119412. * Gets or sets a boolean indicating if the outline must be rendered as well
  119413. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  119414. */
  119415. renderOutline: boolean;
  119416. /** @hidden (Backing field) */
  119417. _renderOverlay: boolean;
  119418. /**
  119419. * Gets or sets a boolean indicating if the overlay must be rendered as well
  119420. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  119421. */
  119422. renderOverlay: boolean;
  119423. }
  119424. /**
  119425. * This class is responsible to draw bothe outline/overlay of meshes.
  119426. * It should not be used directly but through the available method on mesh.
  119427. */
  119428. export class OutlineRenderer implements ISceneComponent {
  119429. /**
  119430. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  119431. */
  119432. private static _StencilReference;
  119433. /**
  119434. * The name of the component. Each component must have a unique name.
  119435. */
  119436. name: string;
  119437. /**
  119438. * The scene the component belongs to.
  119439. */
  119440. scene: Scene;
  119441. /**
  119442. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  119443. */
  119444. zOffset: number;
  119445. private _engine;
  119446. private _effect;
  119447. private _cachedDefines;
  119448. private _savedDepthWrite;
  119449. /**
  119450. * Instantiates a new outline renderer. (There could be only one per scene).
  119451. * @param scene Defines the scene it belongs to
  119452. */
  119453. constructor(scene: Scene);
  119454. /**
  119455. * Register the component to one instance of a scene.
  119456. */
  119457. register(): void;
  119458. /**
  119459. * Rebuilds the elements related to this component in case of
  119460. * context lost for instance.
  119461. */
  119462. rebuild(): void;
  119463. /**
  119464. * Disposes the component and the associated ressources.
  119465. */
  119466. dispose(): void;
  119467. /**
  119468. * Renders the outline in the canvas.
  119469. * @param subMesh Defines the sumesh to render
  119470. * @param batch Defines the batch of meshes in case of instances
  119471. * @param useOverlay Defines if the rendering is for the overlay or the outline
  119472. */
  119473. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  119474. /**
  119475. * Returns whether or not the outline renderer is ready for a given submesh.
  119476. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  119477. * @param subMesh Defines the submesh to check readyness for
  119478. * @param useInstances Defines wheter wee are trying to render instances or not
  119479. * @returns true if ready otherwise false
  119480. */
  119481. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  119482. private _beforeRenderingMesh;
  119483. private _afterRenderingMesh;
  119484. }
  119485. }
  119486. declare module BABYLON {
  119487. /**
  119488. * Defines the list of states available for a task inside a AssetsManager
  119489. */
  119490. export enum AssetTaskState {
  119491. /**
  119492. * Initialization
  119493. */
  119494. INIT = 0,
  119495. /**
  119496. * Running
  119497. */
  119498. RUNNING = 1,
  119499. /**
  119500. * Done
  119501. */
  119502. DONE = 2,
  119503. /**
  119504. * Error
  119505. */
  119506. ERROR = 3
  119507. }
  119508. /**
  119509. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  119510. */
  119511. export abstract class AbstractAssetTask {
  119512. /**
  119513. * Task name
  119514. */ name: string;
  119515. /**
  119516. * Callback called when the task is successful
  119517. */
  119518. onSuccess: (task: any) => void;
  119519. /**
  119520. * Callback called when the task is not successful
  119521. */
  119522. onError: (task: any, message?: string, exception?: any) => void;
  119523. /**
  119524. * Creates a new AssetsManager
  119525. * @param name defines the name of the task
  119526. */
  119527. constructor(
  119528. /**
  119529. * Task name
  119530. */ name: string);
  119531. private _isCompleted;
  119532. private _taskState;
  119533. private _errorObject;
  119534. /**
  119535. * Get if the task is completed
  119536. */
  119537. readonly isCompleted: boolean;
  119538. /**
  119539. * Gets the current state of the task
  119540. */
  119541. readonly taskState: AssetTaskState;
  119542. /**
  119543. * Gets the current error object (if task is in error)
  119544. */
  119545. readonly errorObject: {
  119546. message?: string;
  119547. exception?: any;
  119548. };
  119549. /**
  119550. * Internal only
  119551. * @hidden
  119552. */
  119553. _setErrorObject(message?: string, exception?: any): void;
  119554. /**
  119555. * Execute the current task
  119556. * @param scene defines the scene where you want your assets to be loaded
  119557. * @param onSuccess is a callback called when the task is successfully executed
  119558. * @param onError is a callback called if an error occurs
  119559. */
  119560. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  119561. /**
  119562. * Execute the current task
  119563. * @param scene defines the scene where you want your assets to be loaded
  119564. * @param onSuccess is a callback called when the task is successfully executed
  119565. * @param onError is a callback called if an error occurs
  119566. */
  119567. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  119568. /**
  119569. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  119570. * This can be used with failed tasks that have the reason for failure fixed.
  119571. */
  119572. reset(): void;
  119573. private onErrorCallback;
  119574. private onDoneCallback;
  119575. }
  119576. /**
  119577. * Define the interface used by progress events raised during assets loading
  119578. */
  119579. export interface IAssetsProgressEvent {
  119580. /**
  119581. * Defines the number of remaining tasks to process
  119582. */
  119583. remainingCount: number;
  119584. /**
  119585. * Defines the total number of tasks
  119586. */
  119587. totalCount: number;
  119588. /**
  119589. * Defines the task that was just processed
  119590. */
  119591. task: AbstractAssetTask;
  119592. }
  119593. /**
  119594. * Class used to share progress information about assets loading
  119595. */
  119596. export class AssetsProgressEvent implements IAssetsProgressEvent {
  119597. /**
  119598. * Defines the number of remaining tasks to process
  119599. */
  119600. remainingCount: number;
  119601. /**
  119602. * Defines the total number of tasks
  119603. */
  119604. totalCount: number;
  119605. /**
  119606. * Defines the task that was just processed
  119607. */
  119608. task: AbstractAssetTask;
  119609. /**
  119610. * Creates a AssetsProgressEvent
  119611. * @param remainingCount defines the number of remaining tasks to process
  119612. * @param totalCount defines the total number of tasks
  119613. * @param task defines the task that was just processed
  119614. */
  119615. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  119616. }
  119617. /**
  119618. * Define a task used by AssetsManager to load meshes
  119619. */
  119620. export class MeshAssetTask extends AbstractAssetTask {
  119621. /**
  119622. * Defines the name of the task
  119623. */
  119624. name: string;
  119625. /**
  119626. * Defines the list of mesh's names you want to load
  119627. */
  119628. meshesNames: any;
  119629. /**
  119630. * Defines the root url to use as a base to load your meshes and associated resources
  119631. */
  119632. rootUrl: string;
  119633. /**
  119634. * Defines the filename of the scene to load from
  119635. */
  119636. sceneFilename: string;
  119637. /**
  119638. * Gets the list of loaded meshes
  119639. */
  119640. loadedMeshes: Array<AbstractMesh>;
  119641. /**
  119642. * Gets the list of loaded particle systems
  119643. */
  119644. loadedParticleSystems: Array<IParticleSystem>;
  119645. /**
  119646. * Gets the list of loaded skeletons
  119647. */
  119648. loadedSkeletons: Array<Skeleton>;
  119649. /**
  119650. * Gets the list of loaded animation groups
  119651. */
  119652. loadedAnimationGroups: Array<AnimationGroup>;
  119653. /**
  119654. * Callback called when the task is successful
  119655. */
  119656. onSuccess: (task: MeshAssetTask) => void;
  119657. /**
  119658. * Callback called when the task is successful
  119659. */
  119660. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  119661. /**
  119662. * Creates a new MeshAssetTask
  119663. * @param name defines the name of the task
  119664. * @param meshesNames defines the list of mesh's names you want to load
  119665. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  119666. * @param sceneFilename defines the filename of the scene to load from
  119667. */
  119668. constructor(
  119669. /**
  119670. * Defines the name of the task
  119671. */
  119672. name: string,
  119673. /**
  119674. * Defines the list of mesh's names you want to load
  119675. */
  119676. meshesNames: any,
  119677. /**
  119678. * Defines the root url to use as a base to load your meshes and associated resources
  119679. */
  119680. rootUrl: string,
  119681. /**
  119682. * Defines the filename of the scene to load from
  119683. */
  119684. sceneFilename: string);
  119685. /**
  119686. * Execute the current task
  119687. * @param scene defines the scene where you want your assets to be loaded
  119688. * @param onSuccess is a callback called when the task is successfully executed
  119689. * @param onError is a callback called if an error occurs
  119690. */
  119691. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  119692. }
  119693. /**
  119694. * Define a task used by AssetsManager to load text content
  119695. */
  119696. export class TextFileAssetTask extends AbstractAssetTask {
  119697. /**
  119698. * Defines the name of the task
  119699. */
  119700. name: string;
  119701. /**
  119702. * Defines the location of the file to load
  119703. */
  119704. url: string;
  119705. /**
  119706. * Gets the loaded text string
  119707. */
  119708. text: string;
  119709. /**
  119710. * Callback called when the task is successful
  119711. */
  119712. onSuccess: (task: TextFileAssetTask) => void;
  119713. /**
  119714. * Callback called when the task is successful
  119715. */
  119716. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  119717. /**
  119718. * Creates a new TextFileAssetTask object
  119719. * @param name defines the name of the task
  119720. * @param url defines the location of the file to load
  119721. */
  119722. constructor(
  119723. /**
  119724. * Defines the name of the task
  119725. */
  119726. name: string,
  119727. /**
  119728. * Defines the location of the file to load
  119729. */
  119730. url: string);
  119731. /**
  119732. * Execute the current task
  119733. * @param scene defines the scene where you want your assets to be loaded
  119734. * @param onSuccess is a callback called when the task is successfully executed
  119735. * @param onError is a callback called if an error occurs
  119736. */
  119737. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  119738. }
  119739. /**
  119740. * Define a task used by AssetsManager to load binary data
  119741. */
  119742. export class BinaryFileAssetTask extends AbstractAssetTask {
  119743. /**
  119744. * Defines the name of the task
  119745. */
  119746. name: string;
  119747. /**
  119748. * Defines the location of the file to load
  119749. */
  119750. url: string;
  119751. /**
  119752. * Gets the lodaded data (as an array buffer)
  119753. */
  119754. data: ArrayBuffer;
  119755. /**
  119756. * Callback called when the task is successful
  119757. */
  119758. onSuccess: (task: BinaryFileAssetTask) => void;
  119759. /**
  119760. * Callback called when the task is successful
  119761. */
  119762. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  119763. /**
  119764. * Creates a new BinaryFileAssetTask object
  119765. * @param name defines the name of the new task
  119766. * @param url defines the location of the file to load
  119767. */
  119768. constructor(
  119769. /**
  119770. * Defines the name of the task
  119771. */
  119772. name: string,
  119773. /**
  119774. * Defines the location of the file to load
  119775. */
  119776. url: string);
  119777. /**
  119778. * Execute the current task
  119779. * @param scene defines the scene where you want your assets to be loaded
  119780. * @param onSuccess is a callback called when the task is successfully executed
  119781. * @param onError is a callback called if an error occurs
  119782. */
  119783. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  119784. }
  119785. /**
  119786. * Define a task used by AssetsManager to load images
  119787. */
  119788. export class ImageAssetTask extends AbstractAssetTask {
  119789. /**
  119790. * Defines the name of the task
  119791. */
  119792. name: string;
  119793. /**
  119794. * Defines the location of the image to load
  119795. */
  119796. url: string;
  119797. /**
  119798. * Gets the loaded images
  119799. */
  119800. image: HTMLImageElement;
  119801. /**
  119802. * Callback called when the task is successful
  119803. */
  119804. onSuccess: (task: ImageAssetTask) => void;
  119805. /**
  119806. * Callback called when the task is successful
  119807. */
  119808. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  119809. /**
  119810. * Creates a new ImageAssetTask
  119811. * @param name defines the name of the task
  119812. * @param url defines the location of the image to load
  119813. */
  119814. constructor(
  119815. /**
  119816. * Defines the name of the task
  119817. */
  119818. name: string,
  119819. /**
  119820. * Defines the location of the image to load
  119821. */
  119822. url: string);
  119823. /**
  119824. * Execute the current task
  119825. * @param scene defines the scene where you want your assets to be loaded
  119826. * @param onSuccess is a callback called when the task is successfully executed
  119827. * @param onError is a callback called if an error occurs
  119828. */
  119829. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  119830. }
  119831. /**
  119832. * Defines the interface used by texture loading tasks
  119833. */
  119834. export interface ITextureAssetTask<TEX extends BaseTexture> {
  119835. /**
  119836. * Gets the loaded texture
  119837. */
  119838. texture: TEX;
  119839. }
  119840. /**
  119841. * Define a task used by AssetsManager to load 2D textures
  119842. */
  119843. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  119844. /**
  119845. * Defines the name of the task
  119846. */
  119847. name: string;
  119848. /**
  119849. * Defines the location of the file to load
  119850. */
  119851. url: string;
  119852. /**
  119853. * Defines if mipmap should not be generated (default is false)
  119854. */
  119855. noMipmap?: boolean | undefined;
  119856. /**
  119857. * Defines if texture must be inverted on Y axis (default is false)
  119858. */
  119859. invertY?: boolean | undefined;
  119860. /**
  119861. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  119862. */
  119863. samplingMode: number;
  119864. /**
  119865. * Gets the loaded texture
  119866. */
  119867. texture: Texture;
  119868. /**
  119869. * Callback called when the task is successful
  119870. */
  119871. onSuccess: (task: TextureAssetTask) => void;
  119872. /**
  119873. * Callback called when the task is successful
  119874. */
  119875. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  119876. /**
  119877. * Creates a new TextureAssetTask object
  119878. * @param name defines the name of the task
  119879. * @param url defines the location of the file to load
  119880. * @param noMipmap defines if mipmap should not be generated (default is false)
  119881. * @param invertY defines if texture must be inverted on Y axis (default is false)
  119882. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  119883. */
  119884. constructor(
  119885. /**
  119886. * Defines the name of the task
  119887. */
  119888. name: string,
  119889. /**
  119890. * Defines the location of the file to load
  119891. */
  119892. url: string,
  119893. /**
  119894. * Defines if mipmap should not be generated (default is false)
  119895. */
  119896. noMipmap?: boolean | undefined,
  119897. /**
  119898. * Defines if texture must be inverted on Y axis (default is false)
  119899. */
  119900. invertY?: boolean | undefined,
  119901. /**
  119902. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  119903. */
  119904. samplingMode?: number);
  119905. /**
  119906. * Execute the current task
  119907. * @param scene defines the scene where you want your assets to be loaded
  119908. * @param onSuccess is a callback called when the task is successfully executed
  119909. * @param onError is a callback called if an error occurs
  119910. */
  119911. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  119912. }
  119913. /**
  119914. * Define a task used by AssetsManager to load cube textures
  119915. */
  119916. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  119917. /**
  119918. * Defines the name of the task
  119919. */
  119920. name: string;
  119921. /**
  119922. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  119923. */
  119924. url: string;
  119925. /**
  119926. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  119927. */
  119928. extensions?: string[] | undefined;
  119929. /**
  119930. * Defines if mipmaps should not be generated (default is false)
  119931. */
  119932. noMipmap?: boolean | undefined;
  119933. /**
  119934. * Defines the explicit list of files (undefined by default)
  119935. */
  119936. files?: string[] | undefined;
  119937. /**
  119938. * Gets the loaded texture
  119939. */
  119940. texture: CubeTexture;
  119941. /**
  119942. * Callback called when the task is successful
  119943. */
  119944. onSuccess: (task: CubeTextureAssetTask) => void;
  119945. /**
  119946. * Callback called when the task is successful
  119947. */
  119948. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  119949. /**
  119950. * Creates a new CubeTextureAssetTask
  119951. * @param name defines the name of the task
  119952. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  119953. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  119954. * @param noMipmap defines if mipmaps should not be generated (default is false)
  119955. * @param files defines the explicit list of files (undefined by default)
  119956. */
  119957. constructor(
  119958. /**
  119959. * Defines the name of the task
  119960. */
  119961. name: string,
  119962. /**
  119963. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  119964. */
  119965. url: string,
  119966. /**
  119967. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  119968. */
  119969. extensions?: string[] | undefined,
  119970. /**
  119971. * Defines if mipmaps should not be generated (default is false)
  119972. */
  119973. noMipmap?: boolean | undefined,
  119974. /**
  119975. * Defines the explicit list of files (undefined by default)
  119976. */
  119977. files?: string[] | undefined);
  119978. /**
  119979. * Execute the current task
  119980. * @param scene defines the scene where you want your assets to be loaded
  119981. * @param onSuccess is a callback called when the task is successfully executed
  119982. * @param onError is a callback called if an error occurs
  119983. */
  119984. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  119985. }
  119986. /**
  119987. * Define a task used by AssetsManager to load HDR cube textures
  119988. */
  119989. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  119990. /**
  119991. * Defines the name of the task
  119992. */
  119993. name: string;
  119994. /**
  119995. * Defines the location of the file to load
  119996. */
  119997. url: string;
  119998. /**
  119999. * Defines the desired size (the more it increases the longer the generation will be)
  120000. */
  120001. size: number;
  120002. /**
  120003. * Defines if mipmaps should not be generated (default is false)
  120004. */
  120005. noMipmap: boolean;
  120006. /**
  120007. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  120008. */
  120009. generateHarmonics: boolean;
  120010. /**
  120011. * 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)
  120012. */
  120013. gammaSpace: boolean;
  120014. /**
  120015. * Internal Use Only
  120016. */
  120017. reserved: boolean;
  120018. /**
  120019. * Gets the loaded texture
  120020. */
  120021. texture: HDRCubeTexture;
  120022. /**
  120023. * Callback called when the task is successful
  120024. */
  120025. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  120026. /**
  120027. * Callback called when the task is successful
  120028. */
  120029. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  120030. /**
  120031. * Creates a new HDRCubeTextureAssetTask object
  120032. * @param name defines the name of the task
  120033. * @param url defines the location of the file to load
  120034. * @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.
  120035. * @param noMipmap defines if mipmaps should not be generated (default is false)
  120036. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  120037. * @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)
  120038. * @param reserved Internal use only
  120039. */
  120040. constructor(
  120041. /**
  120042. * Defines the name of the task
  120043. */
  120044. name: string,
  120045. /**
  120046. * Defines the location of the file to load
  120047. */
  120048. url: string,
  120049. /**
  120050. * Defines the desired size (the more it increases the longer the generation will be)
  120051. */
  120052. size: number,
  120053. /**
  120054. * Defines if mipmaps should not be generated (default is false)
  120055. */
  120056. noMipmap?: boolean,
  120057. /**
  120058. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  120059. */
  120060. generateHarmonics?: boolean,
  120061. /**
  120062. * 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)
  120063. */
  120064. gammaSpace?: boolean,
  120065. /**
  120066. * Internal Use Only
  120067. */
  120068. reserved?: boolean);
  120069. /**
  120070. * Execute the current task
  120071. * @param scene defines the scene where you want your assets to be loaded
  120072. * @param onSuccess is a callback called when the task is successfully executed
  120073. * @param onError is a callback called if an error occurs
  120074. */
  120075. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120076. }
  120077. /**
  120078. * Define a task used by AssetsManager to load Equirectangular cube textures
  120079. */
  120080. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  120081. /**
  120082. * Defines the name of the task
  120083. */
  120084. name: string;
  120085. /**
  120086. * Defines the location of the file to load
  120087. */
  120088. url: string;
  120089. /**
  120090. * Defines the desired size (the more it increases the longer the generation will be)
  120091. */
  120092. size: number;
  120093. /**
  120094. * Defines if mipmaps should not be generated (default is false)
  120095. */
  120096. noMipmap: boolean;
  120097. /**
  120098. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  120099. * but the standard material would require them in Gamma space) (default is true)
  120100. */
  120101. gammaSpace: boolean;
  120102. /**
  120103. * Gets the loaded texture
  120104. */
  120105. texture: EquiRectangularCubeTexture;
  120106. /**
  120107. * Callback called when the task is successful
  120108. */
  120109. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  120110. /**
  120111. * Callback called when the task is successful
  120112. */
  120113. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  120114. /**
  120115. * Creates a new EquiRectangularCubeTextureAssetTask object
  120116. * @param name defines the name of the task
  120117. * @param url defines the location of the file to load
  120118. * @param size defines the desired size (the more it increases the longer the generation will be)
  120119. * If the size is omitted this implies you are using a preprocessed cubemap.
  120120. * @param noMipmap defines if mipmaps should not be generated (default is false)
  120121. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  120122. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  120123. * (default is true)
  120124. */
  120125. constructor(
  120126. /**
  120127. * Defines the name of the task
  120128. */
  120129. name: string,
  120130. /**
  120131. * Defines the location of the file to load
  120132. */
  120133. url: string,
  120134. /**
  120135. * Defines the desired size (the more it increases the longer the generation will be)
  120136. */
  120137. size: number,
  120138. /**
  120139. * Defines if mipmaps should not be generated (default is false)
  120140. */
  120141. noMipmap?: boolean,
  120142. /**
  120143. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  120144. * but the standard material would require them in Gamma space) (default is true)
  120145. */
  120146. gammaSpace?: boolean);
  120147. /**
  120148. * Execute the current task
  120149. * @param scene defines the scene where you want your assets to be loaded
  120150. * @param onSuccess is a callback called when the task is successfully executed
  120151. * @param onError is a callback called if an error occurs
  120152. */
  120153. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120154. }
  120155. /**
  120156. * This class can be used to easily import assets into a scene
  120157. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  120158. */
  120159. export class AssetsManager {
  120160. private _scene;
  120161. private _isLoading;
  120162. protected _tasks: AbstractAssetTask[];
  120163. protected _waitingTasksCount: number;
  120164. protected _totalTasksCount: number;
  120165. /**
  120166. * Callback called when all tasks are processed
  120167. */
  120168. onFinish: (tasks: AbstractAssetTask[]) => void;
  120169. /**
  120170. * Callback called when a task is successful
  120171. */
  120172. onTaskSuccess: (task: AbstractAssetTask) => void;
  120173. /**
  120174. * Callback called when a task had an error
  120175. */
  120176. onTaskError: (task: AbstractAssetTask) => void;
  120177. /**
  120178. * Callback called when a task is done (whatever the result is)
  120179. */
  120180. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  120181. /**
  120182. * Observable called when all tasks are processed
  120183. */
  120184. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  120185. /**
  120186. * Observable called when a task had an error
  120187. */
  120188. onTaskErrorObservable: Observable<AbstractAssetTask>;
  120189. /**
  120190. * Observable called when all tasks were executed
  120191. */
  120192. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  120193. /**
  120194. * Observable called when a task is done (whatever the result is)
  120195. */
  120196. onProgressObservable: Observable<IAssetsProgressEvent>;
  120197. /**
  120198. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  120199. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  120200. */
  120201. useDefaultLoadingScreen: boolean;
  120202. /**
  120203. * Creates a new AssetsManager
  120204. * @param scene defines the scene to work on
  120205. */
  120206. constructor(scene: Scene);
  120207. /**
  120208. * Add a MeshAssetTask to the list of active tasks
  120209. * @param taskName defines the name of the new task
  120210. * @param meshesNames defines the name of meshes to load
  120211. * @param rootUrl defines the root url to use to locate files
  120212. * @param sceneFilename defines the filename of the scene file
  120213. * @returns a new MeshAssetTask object
  120214. */
  120215. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  120216. /**
  120217. * Add a TextFileAssetTask to the list of active tasks
  120218. * @param taskName defines the name of the new task
  120219. * @param url defines the url of the file to load
  120220. * @returns a new TextFileAssetTask object
  120221. */
  120222. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  120223. /**
  120224. * Add a BinaryFileAssetTask to the list of active tasks
  120225. * @param taskName defines the name of the new task
  120226. * @param url defines the url of the file to load
  120227. * @returns a new BinaryFileAssetTask object
  120228. */
  120229. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  120230. /**
  120231. * Add a ImageAssetTask to the list of active tasks
  120232. * @param taskName defines the name of the new task
  120233. * @param url defines the url of the file to load
  120234. * @returns a new ImageAssetTask object
  120235. */
  120236. addImageTask(taskName: string, url: string): ImageAssetTask;
  120237. /**
  120238. * Add a TextureAssetTask to the list of active tasks
  120239. * @param taskName defines the name of the new task
  120240. * @param url defines the url of the file to load
  120241. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  120242. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  120243. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  120244. * @returns a new TextureAssetTask object
  120245. */
  120246. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  120247. /**
  120248. * Add a CubeTextureAssetTask to the list of active tasks
  120249. * @param taskName defines the name of the new task
  120250. * @param url defines the url of the file to load
  120251. * @param extensions defines the extension to use to load the cube map (can be null)
  120252. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  120253. * @param files defines the list of files to load (can be null)
  120254. * @returns a new CubeTextureAssetTask object
  120255. */
  120256. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  120257. /**
  120258. *
  120259. * Add a HDRCubeTextureAssetTask to the list of active tasks
  120260. * @param taskName defines the name of the new task
  120261. * @param url defines the url of the file to load
  120262. * @param size defines the size you want for the cubemap (can be null)
  120263. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  120264. * @param generateHarmonics defines if you want to automatically generate (true by default)
  120265. * @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)
  120266. * @param reserved Internal use only
  120267. * @returns a new HDRCubeTextureAssetTask object
  120268. */
  120269. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  120270. /**
  120271. *
  120272. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  120273. * @param taskName defines the name of the new task
  120274. * @param url defines the url of the file to load
  120275. * @param size defines the size you want for the cubemap (can be null)
  120276. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  120277. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  120278. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  120279. * @returns a new EquiRectangularCubeTextureAssetTask object
  120280. */
  120281. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  120282. /**
  120283. * Remove a task from the assets manager.
  120284. * @param task the task to remove
  120285. */
  120286. removeTask(task: AbstractAssetTask): void;
  120287. private _decreaseWaitingTasksCount;
  120288. private _runTask;
  120289. /**
  120290. * Reset the AssetsManager and remove all tasks
  120291. * @return the current instance of the AssetsManager
  120292. */
  120293. reset(): AssetsManager;
  120294. /**
  120295. * Start the loading process
  120296. * @return the current instance of the AssetsManager
  120297. */
  120298. load(): AssetsManager;
  120299. /**
  120300. * Start the loading process as an async operation
  120301. * @return a promise returning the list of failed tasks
  120302. */
  120303. loadAsync(): Promise<void>;
  120304. }
  120305. }
  120306. declare module BABYLON {
  120307. /**
  120308. * Wrapper class for promise with external resolve and reject.
  120309. */
  120310. export class Deferred<T> {
  120311. /**
  120312. * The promise associated with this deferred object.
  120313. */
  120314. readonly promise: Promise<T>;
  120315. private _resolve;
  120316. private _reject;
  120317. /**
  120318. * The resolve method of the promise associated with this deferred object.
  120319. */
  120320. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  120321. /**
  120322. * The reject method of the promise associated with this deferred object.
  120323. */
  120324. readonly reject: (reason?: any) => void;
  120325. /**
  120326. * Constructor for this deferred object.
  120327. */
  120328. constructor();
  120329. }
  120330. }
  120331. declare module BABYLON {
  120332. /**
  120333. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  120334. */
  120335. export class MeshExploder {
  120336. private _centerMesh;
  120337. private _meshes;
  120338. private _meshesOrigins;
  120339. private _toCenterVectors;
  120340. private _scaledDirection;
  120341. private _newPosition;
  120342. private _centerPosition;
  120343. /**
  120344. * Explodes meshes from a center mesh.
  120345. * @param meshes The meshes to explode.
  120346. * @param centerMesh The mesh to be center of explosion.
  120347. */
  120348. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  120349. private _setCenterMesh;
  120350. /**
  120351. * Get class name
  120352. * @returns "MeshExploder"
  120353. */
  120354. getClassName(): string;
  120355. /**
  120356. * "Exploded meshes"
  120357. * @returns Array of meshes with the centerMesh at index 0.
  120358. */
  120359. getMeshes(): Array<Mesh>;
  120360. /**
  120361. * Explodes meshes giving a specific direction
  120362. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  120363. */
  120364. explode(direction?: number): void;
  120365. }
  120366. }
  120367. declare module BABYLON {
  120368. /**
  120369. * Class used to help managing file picking and drag'n'drop
  120370. */
  120371. export class FilesInput {
  120372. /**
  120373. * List of files ready to be loaded
  120374. */
  120375. static readonly FilesToLoad: {
  120376. [key: string]: File;
  120377. };
  120378. /**
  120379. * Callback called when a file is processed
  120380. */
  120381. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  120382. private _engine;
  120383. private _currentScene;
  120384. private _sceneLoadedCallback;
  120385. private _progressCallback;
  120386. private _additionalRenderLoopLogicCallback;
  120387. private _textureLoadingCallback;
  120388. private _startingProcessingFilesCallback;
  120389. private _onReloadCallback;
  120390. private _errorCallback;
  120391. private _elementToMonitor;
  120392. private _sceneFileToLoad;
  120393. private _filesToLoad;
  120394. /**
  120395. * Creates a new FilesInput
  120396. * @param engine defines the rendering engine
  120397. * @param scene defines the hosting scene
  120398. * @param sceneLoadedCallback callback called when scene is loaded
  120399. * @param progressCallback callback called to track progress
  120400. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  120401. * @param textureLoadingCallback callback called when a texture is loading
  120402. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  120403. * @param onReloadCallback callback called when a reload is requested
  120404. * @param errorCallback callback call if an error occurs
  120405. */
  120406. 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);
  120407. private _dragEnterHandler;
  120408. private _dragOverHandler;
  120409. private _dropHandler;
  120410. /**
  120411. * Calls this function to listen to drag'n'drop events on a specific DOM element
  120412. * @param elementToMonitor defines the DOM element to track
  120413. */
  120414. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  120415. /**
  120416. * Release all associated resources
  120417. */
  120418. dispose(): void;
  120419. private renderFunction;
  120420. private drag;
  120421. private drop;
  120422. private _traverseFolder;
  120423. private _processFiles;
  120424. /**
  120425. * Load files from a drop event
  120426. * @param event defines the drop event to use as source
  120427. */
  120428. loadFiles(event: any): void;
  120429. private _processReload;
  120430. /**
  120431. * Reload the current scene from the loaded files
  120432. */
  120433. reload(): void;
  120434. }
  120435. }
  120436. declare module BABYLON {
  120437. /**
  120438. * Defines the root class used to create scene optimization to use with SceneOptimizer
  120439. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120440. */
  120441. export class SceneOptimization {
  120442. /**
  120443. * Defines the priority of this optimization (0 by default which means first in the list)
  120444. */
  120445. priority: number;
  120446. /**
  120447. * Gets a string describing the action executed by the current optimization
  120448. * @returns description string
  120449. */
  120450. getDescription(): string;
  120451. /**
  120452. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120453. * @param scene defines the current scene where to apply this optimization
  120454. * @param optimizer defines the current optimizer
  120455. * @returns true if everything that can be done was applied
  120456. */
  120457. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120458. /**
  120459. * Creates the SceneOptimization object
  120460. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  120461. * @param desc defines the description associated with the optimization
  120462. */
  120463. constructor(
  120464. /**
  120465. * Defines the priority of this optimization (0 by default which means first in the list)
  120466. */
  120467. priority?: number);
  120468. }
  120469. /**
  120470. * Defines an optimization used to reduce the size of render target textures
  120471. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120472. */
  120473. export class TextureOptimization extends SceneOptimization {
  120474. /**
  120475. * Defines the priority of this optimization (0 by default which means first in the list)
  120476. */
  120477. priority: number;
  120478. /**
  120479. * 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
  120480. */
  120481. maximumSize: number;
  120482. /**
  120483. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  120484. */
  120485. step: number;
  120486. /**
  120487. * Gets a string describing the action executed by the current optimization
  120488. * @returns description string
  120489. */
  120490. getDescription(): string;
  120491. /**
  120492. * Creates the TextureOptimization object
  120493. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  120494. * @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
  120495. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  120496. */
  120497. constructor(
  120498. /**
  120499. * Defines the priority of this optimization (0 by default which means first in the list)
  120500. */
  120501. priority?: number,
  120502. /**
  120503. * 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
  120504. */
  120505. maximumSize?: number,
  120506. /**
  120507. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  120508. */
  120509. step?: number);
  120510. /**
  120511. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120512. * @param scene defines the current scene where to apply this optimization
  120513. * @param optimizer defines the current optimizer
  120514. * @returns true if everything that can be done was applied
  120515. */
  120516. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120517. }
  120518. /**
  120519. * Defines an optimization used to increase or decrease the rendering resolution
  120520. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120521. */
  120522. export class HardwareScalingOptimization extends SceneOptimization {
  120523. /**
  120524. * Defines the priority of this optimization (0 by default which means first in the list)
  120525. */
  120526. priority: number;
  120527. /**
  120528. * Defines the maximum scale to use (2 by default)
  120529. */
  120530. maximumScale: number;
  120531. /**
  120532. * Defines the step to use between two passes (0.5 by default)
  120533. */
  120534. step: number;
  120535. private _currentScale;
  120536. private _directionOffset;
  120537. /**
  120538. * Gets a string describing the action executed by the current optimization
  120539. * @return description string
  120540. */
  120541. getDescription(): string;
  120542. /**
  120543. * Creates the HardwareScalingOptimization object
  120544. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  120545. * @param maximumScale defines the maximum scale to use (2 by default)
  120546. * @param step defines the step to use between two passes (0.5 by default)
  120547. */
  120548. constructor(
  120549. /**
  120550. * Defines the priority of this optimization (0 by default which means first in the list)
  120551. */
  120552. priority?: number,
  120553. /**
  120554. * Defines the maximum scale to use (2 by default)
  120555. */
  120556. maximumScale?: number,
  120557. /**
  120558. * Defines the step to use between two passes (0.5 by default)
  120559. */
  120560. step?: number);
  120561. /**
  120562. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120563. * @param scene defines the current scene where to apply this optimization
  120564. * @param optimizer defines the current optimizer
  120565. * @returns true if everything that can be done was applied
  120566. */
  120567. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120568. }
  120569. /**
  120570. * Defines an optimization used to remove shadows
  120571. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120572. */
  120573. export class ShadowsOptimization extends SceneOptimization {
  120574. /**
  120575. * Gets a string describing the action executed by the current optimization
  120576. * @return description string
  120577. */
  120578. getDescription(): string;
  120579. /**
  120580. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120581. * @param scene defines the current scene where to apply this optimization
  120582. * @param optimizer defines the current optimizer
  120583. * @returns true if everything that can be done was applied
  120584. */
  120585. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120586. }
  120587. /**
  120588. * Defines an optimization used to turn post-processes off
  120589. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120590. */
  120591. export class PostProcessesOptimization extends SceneOptimization {
  120592. /**
  120593. * Gets a string describing the action executed by the current optimization
  120594. * @return description string
  120595. */
  120596. getDescription(): string;
  120597. /**
  120598. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120599. * @param scene defines the current scene where to apply this optimization
  120600. * @param optimizer defines the current optimizer
  120601. * @returns true if everything that can be done was applied
  120602. */
  120603. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120604. }
  120605. /**
  120606. * Defines an optimization used to turn lens flares off
  120607. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120608. */
  120609. export class LensFlaresOptimization extends SceneOptimization {
  120610. /**
  120611. * Gets a string describing the action executed by the current optimization
  120612. * @return description string
  120613. */
  120614. getDescription(): string;
  120615. /**
  120616. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120617. * @param scene defines the current scene where to apply this optimization
  120618. * @param optimizer defines the current optimizer
  120619. * @returns true if everything that can be done was applied
  120620. */
  120621. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120622. }
  120623. /**
  120624. * Defines an optimization based on user defined callback.
  120625. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120626. */
  120627. export class CustomOptimization extends SceneOptimization {
  120628. /**
  120629. * Callback called to apply the custom optimization.
  120630. */
  120631. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  120632. /**
  120633. * Callback called to get custom description
  120634. */
  120635. onGetDescription: () => string;
  120636. /**
  120637. * Gets a string describing the action executed by the current optimization
  120638. * @returns description string
  120639. */
  120640. getDescription(): string;
  120641. /**
  120642. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120643. * @param scene defines the current scene where to apply this optimization
  120644. * @param optimizer defines the current optimizer
  120645. * @returns true if everything that can be done was applied
  120646. */
  120647. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120648. }
  120649. /**
  120650. * Defines an optimization used to turn particles off
  120651. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120652. */
  120653. export class ParticlesOptimization extends SceneOptimization {
  120654. /**
  120655. * Gets a string describing the action executed by the current optimization
  120656. * @return description string
  120657. */
  120658. getDescription(): string;
  120659. /**
  120660. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120661. * @param scene defines the current scene where to apply this optimization
  120662. * @param optimizer defines the current optimizer
  120663. * @returns true if everything that can be done was applied
  120664. */
  120665. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120666. }
  120667. /**
  120668. * Defines an optimization used to turn render targets off
  120669. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120670. */
  120671. export class RenderTargetsOptimization extends SceneOptimization {
  120672. /**
  120673. * Gets a string describing the action executed by the current optimization
  120674. * @return description string
  120675. */
  120676. getDescription(): string;
  120677. /**
  120678. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120679. * @param scene defines the current scene where to apply this optimization
  120680. * @param optimizer defines the current optimizer
  120681. * @returns true if everything that can be done was applied
  120682. */
  120683. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120684. }
  120685. /**
  120686. * Defines an optimization used to merge meshes with compatible materials
  120687. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120688. */
  120689. export class MergeMeshesOptimization extends SceneOptimization {
  120690. private static _UpdateSelectionTree;
  120691. /**
  120692. * Gets or sets a boolean which defines if optimization octree has to be updated
  120693. */
  120694. /**
  120695. * Gets or sets a boolean which defines if optimization octree has to be updated
  120696. */
  120697. static UpdateSelectionTree: boolean;
  120698. /**
  120699. * Gets a string describing the action executed by the current optimization
  120700. * @return description string
  120701. */
  120702. getDescription(): string;
  120703. private _canBeMerged;
  120704. /**
  120705. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120706. * @param scene defines the current scene where to apply this optimization
  120707. * @param optimizer defines the current optimizer
  120708. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  120709. * @returns true if everything that can be done was applied
  120710. */
  120711. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  120712. }
  120713. /**
  120714. * Defines a list of options used by SceneOptimizer
  120715. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120716. */
  120717. export class SceneOptimizerOptions {
  120718. /**
  120719. * Defines the target frame rate to reach (60 by default)
  120720. */
  120721. targetFrameRate: number;
  120722. /**
  120723. * Defines the interval between two checkes (2000ms by default)
  120724. */
  120725. trackerDuration: number;
  120726. /**
  120727. * Gets the list of optimizations to apply
  120728. */
  120729. optimizations: SceneOptimization[];
  120730. /**
  120731. * Creates a new list of options used by SceneOptimizer
  120732. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  120733. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  120734. */
  120735. constructor(
  120736. /**
  120737. * Defines the target frame rate to reach (60 by default)
  120738. */
  120739. targetFrameRate?: number,
  120740. /**
  120741. * Defines the interval between two checkes (2000ms by default)
  120742. */
  120743. trackerDuration?: number);
  120744. /**
  120745. * Add a new optimization
  120746. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  120747. * @returns the current SceneOptimizerOptions
  120748. */
  120749. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  120750. /**
  120751. * Add a new custom optimization
  120752. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  120753. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  120754. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  120755. * @returns the current SceneOptimizerOptions
  120756. */
  120757. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  120758. /**
  120759. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  120760. * @param targetFrameRate defines the target frame rate (60 by default)
  120761. * @returns a SceneOptimizerOptions object
  120762. */
  120763. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  120764. /**
  120765. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  120766. * @param targetFrameRate defines the target frame rate (60 by default)
  120767. * @returns a SceneOptimizerOptions object
  120768. */
  120769. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  120770. /**
  120771. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  120772. * @param targetFrameRate defines the target frame rate (60 by default)
  120773. * @returns a SceneOptimizerOptions object
  120774. */
  120775. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  120776. }
  120777. /**
  120778. * Class used to run optimizations in order to reach a target frame rate
  120779. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120780. */
  120781. export class SceneOptimizer implements IDisposable {
  120782. private _isRunning;
  120783. private _options;
  120784. private _scene;
  120785. private _currentPriorityLevel;
  120786. private _targetFrameRate;
  120787. private _trackerDuration;
  120788. private _currentFrameRate;
  120789. private _sceneDisposeObserver;
  120790. private _improvementMode;
  120791. /**
  120792. * Defines an observable called when the optimizer reaches the target frame rate
  120793. */
  120794. onSuccessObservable: Observable<SceneOptimizer>;
  120795. /**
  120796. * Defines an observable called when the optimizer enables an optimization
  120797. */
  120798. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  120799. /**
  120800. * Defines an observable called when the optimizer is not able to reach the target frame rate
  120801. */
  120802. onFailureObservable: Observable<SceneOptimizer>;
  120803. /**
  120804. * Gets a boolean indicating if the optimizer is in improvement mode
  120805. */
  120806. readonly isInImprovementMode: boolean;
  120807. /**
  120808. * Gets the current priority level (0 at start)
  120809. */
  120810. readonly currentPriorityLevel: number;
  120811. /**
  120812. * Gets the current frame rate checked by the SceneOptimizer
  120813. */
  120814. readonly currentFrameRate: number;
  120815. /**
  120816. * Gets or sets the current target frame rate (60 by default)
  120817. */
  120818. /**
  120819. * Gets or sets the current target frame rate (60 by default)
  120820. */
  120821. targetFrameRate: number;
  120822. /**
  120823. * Gets or sets the current interval between two checks (every 2000ms by default)
  120824. */
  120825. /**
  120826. * Gets or sets the current interval between two checks (every 2000ms by default)
  120827. */
  120828. trackerDuration: number;
  120829. /**
  120830. * Gets the list of active optimizations
  120831. */
  120832. readonly optimizations: SceneOptimization[];
  120833. /**
  120834. * Creates a new SceneOptimizer
  120835. * @param scene defines the scene to work on
  120836. * @param options defines the options to use with the SceneOptimizer
  120837. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  120838. * @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)
  120839. */
  120840. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  120841. /**
  120842. * Stops the current optimizer
  120843. */
  120844. stop(): void;
  120845. /**
  120846. * Reset the optimizer to initial step (current priority level = 0)
  120847. */
  120848. reset(): void;
  120849. /**
  120850. * Start the optimizer. By default it will try to reach a specific framerate
  120851. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  120852. */
  120853. start(): void;
  120854. private _checkCurrentState;
  120855. /**
  120856. * Release all resources
  120857. */
  120858. dispose(): void;
  120859. /**
  120860. * Helper function to create a SceneOptimizer with one single line of code
  120861. * @param scene defines the scene to work on
  120862. * @param options defines the options to use with the SceneOptimizer
  120863. * @param onSuccess defines a callback to call on success
  120864. * @param onFailure defines a callback to call on failure
  120865. * @returns the new SceneOptimizer object
  120866. */
  120867. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  120868. }
  120869. }
  120870. declare module BABYLON {
  120871. /**
  120872. * Class used to serialize a scene into a string
  120873. */
  120874. export class SceneSerializer {
  120875. /**
  120876. * Clear cache used by a previous serialization
  120877. */
  120878. static ClearCache(): void;
  120879. /**
  120880. * Serialize a scene into a JSON compatible object
  120881. * @param scene defines the scene to serialize
  120882. * @returns a JSON compatible object
  120883. */
  120884. static Serialize(scene: Scene): any;
  120885. /**
  120886. * Serialize a mesh into a JSON compatible object
  120887. * @param toSerialize defines the mesh to serialize
  120888. * @param withParents defines if parents must be serialized as well
  120889. * @param withChildren defines if children must be serialized as well
  120890. * @returns a JSON compatible object
  120891. */
  120892. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  120893. }
  120894. }
  120895. declare module BABYLON {
  120896. /**
  120897. * Class used to host texture specific utilities
  120898. */
  120899. export class TextureTools {
  120900. /**
  120901. * Uses the GPU to create a copy texture rescaled at a given size
  120902. * @param texture Texture to copy from
  120903. * @param width defines the desired width
  120904. * @param height defines the desired height
  120905. * @param useBilinearMode defines if bilinear mode has to be used
  120906. * @return the generated texture
  120907. */
  120908. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  120909. }
  120910. }
  120911. declare module BABYLON {
  120912. /**
  120913. * This represents the different options avilable for the video capture.
  120914. */
  120915. export interface VideoRecorderOptions {
  120916. /** Defines the mime type of the video */
  120917. mimeType: string;
  120918. /** Defines the video the video should be recorded at */
  120919. fps: number;
  120920. /** Defines the chunk size for the recording data */
  120921. recordChunckSize: number;
  120922. /** The audio tracks to attach to the record */
  120923. audioTracks?: MediaStreamTrack[];
  120924. }
  120925. /**
  120926. * This can helps recording videos from BabylonJS.
  120927. * This is based on the available WebRTC functionalities of the browser.
  120928. *
  120929. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  120930. */
  120931. export class VideoRecorder {
  120932. private static readonly _defaultOptions;
  120933. /**
  120934. * Returns wehther or not the VideoRecorder is available in your browser.
  120935. * @param engine Defines the Babylon Engine to check the support for
  120936. * @returns true if supported otherwise false
  120937. */
  120938. static IsSupported(engine: Engine): boolean;
  120939. private readonly _options;
  120940. private _canvas;
  120941. private _mediaRecorder;
  120942. private _recordedChunks;
  120943. private _fileName;
  120944. private _resolve;
  120945. private _reject;
  120946. /**
  120947. * True wether a recording is already in progress.
  120948. */
  120949. readonly isRecording: boolean;
  120950. /**
  120951. * Create a new VideoCapture object which can help converting what you see in Babylon to
  120952. * a video file.
  120953. * @param engine Defines the BabylonJS Engine you wish to record
  120954. * @param options Defines options that can be used to customized the capture
  120955. */
  120956. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  120957. /**
  120958. * Stops the current recording before the default capture timeout passed in the startRecording
  120959. * functions.
  120960. */
  120961. stopRecording(): void;
  120962. /**
  120963. * Starts recording the canvas for a max duration specified in parameters.
  120964. * @param fileName Defines the name of the file to be downloaded when the recording stop. If null no automatic download will start and you can rely on the promise to get the data back.
  120965. * @param maxDuration Defines the maximum recording time in seconds.
  120966. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  120967. * @return a promise callback at the end of the recording with the video data in Blob.
  120968. */
  120969. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  120970. /**
  120971. * Releases internal resources used during the recording.
  120972. */
  120973. dispose(): void;
  120974. private _handleDataAvailable;
  120975. private _handleError;
  120976. private _handleStop;
  120977. }
  120978. }
  120979. declare module BABYLON {
  120980. /**
  120981. * Class containing a set of static utilities functions for screenshots
  120982. */
  120983. export class ScreenshotTools {
  120984. /**
  120985. * Captures a screenshot of the current rendering
  120986. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  120987. * @param engine defines the rendering engine
  120988. * @param camera defines the source camera
  120989. * @param size This parameter can be set to a single number or to an object with the
  120990. * following (optional) properties: precision, width, height. If a single number is passed,
  120991. * it will be used for both width and height. If an object is passed, the screenshot size
  120992. * will be derived from the parameters. The precision property is a multiplier allowing
  120993. * rendering at a higher or lower resolution
  120994. * @param successCallback defines the callback receives a single parameter which contains the
  120995. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  120996. * src parameter of an <img> to display it
  120997. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  120998. * Check your browser for supported MIME types
  120999. */
  121000. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  121001. /**
  121002. * Generates an image screenshot from the specified camera.
  121003. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  121004. * @param engine The engine to use for rendering
  121005. * @param camera The camera to use for rendering
  121006. * @param size This parameter can be set to a single number or to an object with the
  121007. * following (optional) properties: precision, width, height. If a single number is passed,
  121008. * it will be used for both width and height. If an object is passed, the screenshot size
  121009. * will be derived from the parameters. The precision property is a multiplier allowing
  121010. * rendering at a higher or lower resolution
  121011. * @param successCallback The callback receives a single parameter which contains the
  121012. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  121013. * src parameter of an <img> to display it
  121014. * @param mimeType The MIME type of the screenshot image (default: image/png).
  121015. * Check your browser for supported MIME types
  121016. * @param samples Texture samples (default: 1)
  121017. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  121018. * @param fileName A name for for the downloaded file.
  121019. */
  121020. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  121021. }
  121022. }
  121023. declare module BABYLON {
  121024. /**
  121025. * A cursor which tracks a point on a path
  121026. */
  121027. export class PathCursor {
  121028. private path;
  121029. /**
  121030. * Stores path cursor callbacks for when an onchange event is triggered
  121031. */
  121032. private _onchange;
  121033. /**
  121034. * The value of the path cursor
  121035. */
  121036. value: number;
  121037. /**
  121038. * The animation array of the path cursor
  121039. */
  121040. animations: Animation[];
  121041. /**
  121042. * Initializes the path cursor
  121043. * @param path The path to track
  121044. */
  121045. constructor(path: Path2);
  121046. /**
  121047. * Gets the cursor point on the path
  121048. * @returns A point on the path cursor at the cursor location
  121049. */
  121050. getPoint(): Vector3;
  121051. /**
  121052. * Moves the cursor ahead by the step amount
  121053. * @param step The amount to move the cursor forward
  121054. * @returns This path cursor
  121055. */
  121056. moveAhead(step?: number): PathCursor;
  121057. /**
  121058. * Moves the cursor behind by the step amount
  121059. * @param step The amount to move the cursor back
  121060. * @returns This path cursor
  121061. */
  121062. moveBack(step?: number): PathCursor;
  121063. /**
  121064. * Moves the cursor by the step amount
  121065. * If the step amount is greater than one, an exception is thrown
  121066. * @param step The amount to move the cursor
  121067. * @returns This path cursor
  121068. */
  121069. move(step: number): PathCursor;
  121070. /**
  121071. * Ensures that the value is limited between zero and one
  121072. * @returns This path cursor
  121073. */
  121074. private ensureLimits;
  121075. /**
  121076. * Runs onchange callbacks on change (used by the animation engine)
  121077. * @returns This path cursor
  121078. */
  121079. private raiseOnChange;
  121080. /**
  121081. * Executes a function on change
  121082. * @param f A path cursor onchange callback
  121083. * @returns This path cursor
  121084. */
  121085. onchange(f: (cursor: PathCursor) => void): PathCursor;
  121086. }
  121087. }
  121088. declare module BABYLON {
  121089. /** @hidden */
  121090. export var blurPixelShader: {
  121091. name: string;
  121092. shader: string;
  121093. };
  121094. }
  121095. declare module BABYLON {
  121096. /** @hidden */
  121097. export var bones300Declaration: {
  121098. name: string;
  121099. shader: string;
  121100. };
  121101. }
  121102. declare module BABYLON {
  121103. /** @hidden */
  121104. export var instances300Declaration: {
  121105. name: string;
  121106. shader: string;
  121107. };
  121108. }
  121109. declare module BABYLON {
  121110. /** @hidden */
  121111. export var pointCloudVertexDeclaration: {
  121112. name: string;
  121113. shader: string;
  121114. };
  121115. }
  121116. // Mixins
  121117. interface Window {
  121118. mozIndexedDB: IDBFactory;
  121119. webkitIndexedDB: IDBFactory;
  121120. msIndexedDB: IDBFactory;
  121121. webkitURL: typeof URL;
  121122. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  121123. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  121124. WebGLRenderingContext: WebGLRenderingContext;
  121125. MSGesture: MSGesture;
  121126. CANNON: any;
  121127. AudioContext: AudioContext;
  121128. webkitAudioContext: AudioContext;
  121129. PointerEvent: any;
  121130. Math: Math;
  121131. Uint8Array: Uint8ArrayConstructor;
  121132. Float32Array: Float32ArrayConstructor;
  121133. mozURL: typeof URL;
  121134. msURL: typeof URL;
  121135. VRFrameData: any; // WebVR, from specs 1.1
  121136. DracoDecoderModule: any;
  121137. setImmediate(handler: (...args: any[]) => void): number;
  121138. }
  121139. interface HTMLCanvasElement {
  121140. requestPointerLock(): void;
  121141. msRequestPointerLock?(): void;
  121142. mozRequestPointerLock?(): void;
  121143. webkitRequestPointerLock?(): void;
  121144. /** Track wether a record is in progress */
  121145. isRecording: boolean;
  121146. /** Capture Stream method defined by some browsers */
  121147. captureStream(fps?: number): MediaStream;
  121148. }
  121149. interface CanvasRenderingContext2D {
  121150. msImageSmoothingEnabled: boolean;
  121151. }
  121152. interface MouseEvent {
  121153. mozMovementX: number;
  121154. mozMovementY: number;
  121155. webkitMovementX: number;
  121156. webkitMovementY: number;
  121157. msMovementX: number;
  121158. msMovementY: number;
  121159. }
  121160. interface Navigator {
  121161. mozGetVRDevices: (any: any) => any;
  121162. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  121163. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  121164. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  121165. webkitGetGamepads(): Gamepad[];
  121166. msGetGamepads(): Gamepad[];
  121167. webkitGamepads(): Gamepad[];
  121168. }
  121169. interface HTMLVideoElement {
  121170. mozSrcObject: any;
  121171. }
  121172. interface Math {
  121173. fround(x: number): number;
  121174. imul(a: number, b: number): number;
  121175. }
  121176. interface WebGLRenderingContext {
  121177. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  121178. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  121179. vertexAttribDivisor(index: number, divisor: number): void;
  121180. createVertexArray(): any;
  121181. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  121182. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  121183. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  121184. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  121185. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  121186. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  121187. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  121188. // Queries
  121189. createQuery(): WebGLQuery;
  121190. deleteQuery(query: WebGLQuery): void;
  121191. beginQuery(target: number, query: WebGLQuery): void;
  121192. endQuery(target: number): void;
  121193. getQueryParameter(query: WebGLQuery, pname: number): any;
  121194. getQuery(target: number, pname: number): any;
  121195. MAX_SAMPLES: number;
  121196. RGBA8: number;
  121197. READ_FRAMEBUFFER: number;
  121198. DRAW_FRAMEBUFFER: number;
  121199. UNIFORM_BUFFER: number;
  121200. HALF_FLOAT_OES: number;
  121201. RGBA16F: number;
  121202. RGBA32F: number;
  121203. R32F: number;
  121204. RG32F: number;
  121205. RGB32F: number;
  121206. R16F: number;
  121207. RG16F: number;
  121208. RGB16F: number;
  121209. RED: number;
  121210. RG: number;
  121211. R8: number;
  121212. RG8: number;
  121213. UNSIGNED_INT_24_8: number;
  121214. DEPTH24_STENCIL8: number;
  121215. /* Multiple Render Targets */
  121216. drawBuffers(buffers: number[]): void;
  121217. readBuffer(src: number): void;
  121218. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  121219. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  121220. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  121221. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  121222. // Occlusion Query
  121223. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  121224. ANY_SAMPLES_PASSED: number;
  121225. QUERY_RESULT_AVAILABLE: number;
  121226. QUERY_RESULT: number;
  121227. }
  121228. interface WebGLProgram {
  121229. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  121230. }
  121231. interface EXT_disjoint_timer_query {
  121232. QUERY_COUNTER_BITS_EXT: number;
  121233. TIME_ELAPSED_EXT: number;
  121234. TIMESTAMP_EXT: number;
  121235. GPU_DISJOINT_EXT: number;
  121236. QUERY_RESULT_EXT: number;
  121237. QUERY_RESULT_AVAILABLE_EXT: number;
  121238. queryCounterEXT(query: WebGLQuery, target: number): void;
  121239. createQueryEXT(): WebGLQuery;
  121240. beginQueryEXT(target: number, query: WebGLQuery): void;
  121241. endQueryEXT(target: number): void;
  121242. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  121243. deleteQueryEXT(query: WebGLQuery): void;
  121244. }
  121245. interface WebGLUniformLocation {
  121246. _currentState: any;
  121247. }
  121248. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  121249. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  121250. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  121251. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  121252. interface WebGLRenderingContext {
  121253. readonly RASTERIZER_DISCARD: number;
  121254. readonly DEPTH_COMPONENT24: number;
  121255. readonly TEXTURE_3D: number;
  121256. readonly TEXTURE_2D_ARRAY: number;
  121257. readonly TEXTURE_COMPARE_FUNC: number;
  121258. readonly TEXTURE_COMPARE_MODE: number;
  121259. readonly COMPARE_REF_TO_TEXTURE: number;
  121260. readonly TEXTURE_WRAP_R: number;
  121261. readonly HALF_FLOAT: number;
  121262. readonly RGB8: number;
  121263. readonly RED_INTEGER: number;
  121264. readonly RG_INTEGER: number;
  121265. readonly RGB_INTEGER: number;
  121266. readonly RGBA_INTEGER: number;
  121267. readonly R8_SNORM: number;
  121268. readonly RG8_SNORM: number;
  121269. readonly RGB8_SNORM: number;
  121270. readonly RGBA8_SNORM: number;
  121271. readonly R8I: number;
  121272. readonly RG8I: number;
  121273. readonly RGB8I: number;
  121274. readonly RGBA8I: number;
  121275. readonly R8UI: number;
  121276. readonly RG8UI: number;
  121277. readonly RGB8UI: number;
  121278. readonly RGBA8UI: number;
  121279. readonly R16I: number;
  121280. readonly RG16I: number;
  121281. readonly RGB16I: number;
  121282. readonly RGBA16I: number;
  121283. readonly R16UI: number;
  121284. readonly RG16UI: number;
  121285. readonly RGB16UI: number;
  121286. readonly RGBA16UI: number;
  121287. readonly R32I: number;
  121288. readonly RG32I: number;
  121289. readonly RGB32I: number;
  121290. readonly RGBA32I: number;
  121291. readonly R32UI: number;
  121292. readonly RG32UI: number;
  121293. readonly RGB32UI: number;
  121294. readonly RGBA32UI: number;
  121295. readonly RGB10_A2UI: number;
  121296. readonly R11F_G11F_B10F: number;
  121297. readonly RGB9_E5: number;
  121298. readonly RGB10_A2: number;
  121299. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  121300. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  121301. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  121302. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  121303. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  121304. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  121305. 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;
  121306. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  121307. readonly TRANSFORM_FEEDBACK: number;
  121308. readonly INTERLEAVED_ATTRIBS: number;
  121309. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  121310. createTransformFeedback(): WebGLTransformFeedback;
  121311. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  121312. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  121313. beginTransformFeedback(primitiveMode: number): void;
  121314. endTransformFeedback(): void;
  121315. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  121316. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  121317. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  121318. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  121319. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  121320. }
  121321. interface ImageBitmap {
  121322. readonly width: number;
  121323. readonly height: number;
  121324. close(): void;
  121325. }
  121326. interface WebGLQuery extends WebGLObject {
  121327. }
  121328. declare var WebGLQuery: {
  121329. prototype: WebGLQuery;
  121330. new(): WebGLQuery;
  121331. };
  121332. interface WebGLSampler extends WebGLObject {
  121333. }
  121334. declare var WebGLSampler: {
  121335. prototype: WebGLSampler;
  121336. new(): WebGLSampler;
  121337. };
  121338. interface WebGLSync extends WebGLObject {
  121339. }
  121340. declare var WebGLSync: {
  121341. prototype: WebGLSync;
  121342. new(): WebGLSync;
  121343. };
  121344. interface WebGLTransformFeedback extends WebGLObject {
  121345. }
  121346. declare var WebGLTransformFeedback: {
  121347. prototype: WebGLTransformFeedback;
  121348. new(): WebGLTransformFeedback;
  121349. };
  121350. interface WebGLVertexArrayObject extends WebGLObject {
  121351. }
  121352. declare var WebGLVertexArrayObject: {
  121353. prototype: WebGLVertexArrayObject;
  121354. new(): WebGLVertexArrayObject;
  121355. };
  121356. // Type definitions for WebVR API
  121357. // Project: https://w3c.github.io/webvr/
  121358. // Definitions by: six a <https://github.com/lostfictions>
  121359. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  121360. interface VRDisplay extends EventTarget {
  121361. /**
  121362. * Dictionary of capabilities describing the VRDisplay.
  121363. */
  121364. readonly capabilities: VRDisplayCapabilities;
  121365. /**
  121366. * z-depth defining the far plane of the eye view frustum
  121367. * enables mapping of values in the render target depth
  121368. * attachment to scene coordinates. Initially set to 10000.0.
  121369. */
  121370. depthFar: number;
  121371. /**
  121372. * z-depth defining the near plane of the eye view frustum
  121373. * enables mapping of values in the render target depth
  121374. * attachment to scene coordinates. Initially set to 0.01.
  121375. */
  121376. depthNear: number;
  121377. /**
  121378. * An identifier for this distinct VRDisplay. Used as an
  121379. * association point in the Gamepad API.
  121380. */
  121381. readonly displayId: number;
  121382. /**
  121383. * A display name, a user-readable name identifying it.
  121384. */
  121385. readonly displayName: string;
  121386. readonly isConnected: boolean;
  121387. readonly isPresenting: boolean;
  121388. /**
  121389. * If this VRDisplay supports room-scale experiences, the optional
  121390. * stage attribute contains details on the room-scale parameters.
  121391. */
  121392. readonly stageParameters: VRStageParameters | null;
  121393. /**
  121394. * Passing the value returned by `requestAnimationFrame` to
  121395. * `cancelAnimationFrame` will unregister the callback.
  121396. * @param handle Define the hanle of the request to cancel
  121397. */
  121398. cancelAnimationFrame(handle: number): void;
  121399. /**
  121400. * Stops presenting to the VRDisplay.
  121401. * @returns a promise to know when it stopped
  121402. */
  121403. exitPresent(): Promise<void>;
  121404. /**
  121405. * Return the current VREyeParameters for the given eye.
  121406. * @param whichEye Define the eye we want the parameter for
  121407. * @returns the eye parameters
  121408. */
  121409. getEyeParameters(whichEye: string): VREyeParameters;
  121410. /**
  121411. * Populates the passed VRFrameData with the information required to render
  121412. * the current frame.
  121413. * @param frameData Define the data structure to populate
  121414. * @returns true if ok otherwise false
  121415. */
  121416. getFrameData(frameData: VRFrameData): boolean;
  121417. /**
  121418. * Get the layers currently being presented.
  121419. * @returns the list of VR layers
  121420. */
  121421. getLayers(): VRLayer[];
  121422. /**
  121423. * Return a VRPose containing the future predicted pose of the VRDisplay
  121424. * when the current frame will be presented. The value returned will not
  121425. * change until JavaScript has returned control to the browser.
  121426. *
  121427. * The VRPose will contain the position, orientation, velocity,
  121428. * and acceleration of each of these properties.
  121429. * @returns the pose object
  121430. */
  121431. getPose(): VRPose;
  121432. /**
  121433. * Return the current instantaneous pose of the VRDisplay, with no
  121434. * prediction applied.
  121435. * @returns the current instantaneous pose
  121436. */
  121437. getImmediatePose(): VRPose;
  121438. /**
  121439. * The callback passed to `requestAnimationFrame` will be called
  121440. * any time a new frame should be rendered. When the VRDisplay is
  121441. * presenting the callback will be called at the native refresh
  121442. * rate of the HMD. When not presenting this function acts
  121443. * identically to how window.requestAnimationFrame acts. Content should
  121444. * make no assumptions of frame rate or vsync behavior as the HMD runs
  121445. * asynchronously from other displays and at differing refresh rates.
  121446. * @param callback Define the eaction to run next frame
  121447. * @returns the request handle it
  121448. */
  121449. requestAnimationFrame(callback: FrameRequestCallback): number;
  121450. /**
  121451. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  121452. * Repeat calls while already presenting will update the VRLayers being displayed.
  121453. * @param layers Define the list of layer to present
  121454. * @returns a promise to know when the request has been fulfilled
  121455. */
  121456. requestPresent(layers: VRLayer[]): Promise<void>;
  121457. /**
  121458. * Reset the pose for this display, treating its current position and
  121459. * orientation as the "origin/zero" values. VRPose.position,
  121460. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  121461. * updated when calling resetPose(). This should be called in only
  121462. * sitting-space experiences.
  121463. */
  121464. resetPose(): void;
  121465. /**
  121466. * The VRLayer provided to the VRDisplay will be captured and presented
  121467. * in the HMD. Calling this function has the same effect on the source
  121468. * canvas as any other operation that uses its source image, and canvases
  121469. * created without preserveDrawingBuffer set to true will be cleared.
  121470. * @param pose Define the pose to submit
  121471. */
  121472. submitFrame(pose?: VRPose): void;
  121473. }
  121474. declare var VRDisplay: {
  121475. prototype: VRDisplay;
  121476. new(): VRDisplay;
  121477. };
  121478. interface VRLayer {
  121479. leftBounds?: number[] | Float32Array | null;
  121480. rightBounds?: number[] | Float32Array | null;
  121481. source?: HTMLCanvasElement | null;
  121482. }
  121483. interface VRDisplayCapabilities {
  121484. readonly canPresent: boolean;
  121485. readonly hasExternalDisplay: boolean;
  121486. readonly hasOrientation: boolean;
  121487. readonly hasPosition: boolean;
  121488. readonly maxLayers: number;
  121489. }
  121490. interface VREyeParameters {
  121491. /** @deprecated */
  121492. readonly fieldOfView: VRFieldOfView;
  121493. readonly offset: Float32Array;
  121494. readonly renderHeight: number;
  121495. readonly renderWidth: number;
  121496. }
  121497. interface VRFieldOfView {
  121498. readonly downDegrees: number;
  121499. readonly leftDegrees: number;
  121500. readonly rightDegrees: number;
  121501. readonly upDegrees: number;
  121502. }
  121503. interface VRFrameData {
  121504. readonly leftProjectionMatrix: Float32Array;
  121505. readonly leftViewMatrix: Float32Array;
  121506. readonly pose: VRPose;
  121507. readonly rightProjectionMatrix: Float32Array;
  121508. readonly rightViewMatrix: Float32Array;
  121509. readonly timestamp: number;
  121510. }
  121511. interface VRPose {
  121512. readonly angularAcceleration: Float32Array | null;
  121513. readonly angularVelocity: Float32Array | null;
  121514. readonly linearAcceleration: Float32Array | null;
  121515. readonly linearVelocity: Float32Array | null;
  121516. readonly orientation: Float32Array | null;
  121517. readonly position: Float32Array | null;
  121518. readonly timestamp: number;
  121519. }
  121520. interface VRStageParameters {
  121521. sittingToStandingTransform?: Float32Array;
  121522. sizeX?: number;
  121523. sizeY?: number;
  121524. }
  121525. interface Navigator {
  121526. getVRDisplays(): Promise<VRDisplay[]>;
  121527. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  121528. }
  121529. interface Window {
  121530. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  121531. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  121532. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  121533. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  121534. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  121535. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  121536. }
  121537. interface Gamepad {
  121538. readonly displayId: number;
  121539. }
  121540. interface XRDevice {
  121541. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  121542. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  121543. }
  121544. interface XRSession {
  121545. getInputSources(): Array<any>;
  121546. baseLayer: XRWebGLLayer;
  121547. requestFrameOfReference(type: string): Promise<void>;
  121548. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  121549. end(): Promise<void>;
  121550. requestAnimationFrame: Function;
  121551. addEventListener: Function;
  121552. }
  121553. interface XRSessionCreationOptions {
  121554. outputContext?: WebGLRenderingContext | null;
  121555. immersive?: boolean;
  121556. environmentIntegration?: boolean;
  121557. }
  121558. interface XRLayer {
  121559. getViewport: Function;
  121560. framebufferWidth: number;
  121561. framebufferHeight: number;
  121562. }
  121563. interface XRView {
  121564. projectionMatrix: Float32Array;
  121565. }
  121566. interface XRFrame {
  121567. getDevicePose: Function;
  121568. getInputPose: Function;
  121569. views: Array<XRView>;
  121570. baseLayer: XRLayer;
  121571. }
  121572. interface XRFrameOfReference {
  121573. }
  121574. interface XRWebGLLayer extends XRLayer {
  121575. framebuffer: WebGLFramebuffer;
  121576. }
  121577. declare var XRWebGLLayer: {
  121578. prototype: XRWebGLLayer;
  121579. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  121580. };